Retrieves character's directions. 33/37133/3
authorVictor Cebollada <v.cebollada@samsung.com>
Thu, 19 Mar 2015 08:17:02 +0000 (08:17 +0000)
committerVictor Cebollada <v.cebollada@samsung.com>
Fri, 20 Mar 2015 07:24:04 +0000 (07:24 +0000)
Change-Id: I0a37c5c3d5ed459359fce987e391284ba16c21a7
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
dali-toolkit/internal/text/bidirectional-support.cpp
dali-toolkit/internal/text/bidirectional-support.h
dali-toolkit/internal/text/logical-model-impl.cpp
dali-toolkit/internal/text/logical-model-impl.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-definitions.h

index 6f74f19..c982018 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali-toolkit/internal/text/bidirectional-support.h>
 
 // EXTERNAL INCLUDES
 #include <dali-toolkit/internal/text/bidirectional-support.h>
 
 // EXTERNAL INCLUDES
+#include <memory.h>
 #include <dali/public-api/text-abstraction/bidirectional-support.h>
 
 namespace Dali
 #include <dali/public-api/text-abstraction/bidirectional-support.h>
 
 namespace Dali
@@ -250,6 +251,34 @@ bool GetMirroredText( const Vector<Character>& text,
                                                mirroredText.Count() );
 }
 
                                                mirroredText.Count() );
 }
 
+void GetCharactersDirection( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
+                             Vector<CharacterDirection>& directions )
+{
+  // Handle to the bidirectional info module in text-abstraction.
+  TextAbstraction::BidirectionalSupport bidirectionalSupport = TextAbstraction::BidirectionalSupport::Get();
+
+  CharacterIndex index = 0u;
+  CharacterDirection* directionsBuffer = directions.Begin();
+  for( Vector<BidirectionalParagraphInfoRun>::ConstIterator it = bidirectionalInfo.Begin(),
+         endIt = bidirectionalInfo.End();
+       it != endIt;
+       ++it )
+  {
+    const BidirectionalParagraphInfoRun& paragraph = *it;
+
+    // Fills with left to right those paragraphs without right to left characters.
+    memset( directionsBuffer + index, false, ( paragraph.characterRun.characterIndex - index ) * sizeof( bool ) );
+    index += paragraph.characterRun.numberOfCharacters;
+
+    bidirectionalSupport.GetCharactersDirection( paragraph.bidirectionalInfoIndex,
+                                                 directionsBuffer + paragraph.characterRun.characterIndex,
+                                                 paragraph.characterRun.numberOfCharacters );
+  }
+
+  // Fills with left to right those paragraphs without right to left characters.
+  memset( directionsBuffer + index, false, ( directions.Count() - index ) * sizeof( bool ) );
+}
+
 } // namespace Text
 
 } // namespace Toolkit
 } // namespace Text
 
 } // namespace Toolkit
index 227133e..95f438a 100644 (file)
@@ -72,7 +72,7 @@ void ReplaceBidirectionalInfo( LogicalModel& model,
                                Length numberOfCharactersToInsert );
 
 /**
                                Length numberOfCharactersToInsert );
 
 /**
- * Sets the visual to logical and logical to visual map tables.
+ * Sets the visual to logical map tables.
  *
  * Any map tables previously set are removed.
  *
  *
  * Any map tables previously set are removed.
  *
@@ -82,7 +82,7 @@ void ReplaceBidirectionalInfo( LogicalModel& model,
  *
  * @param[in] bidirectionalInfo Vector with the bidirectional infor for each paragraph.
  * @param[in] lineRuns The line runs converted to characters.
  *
  * @param[in] bidirectionalInfo Vector with the bidirectional infor for each paragraph.
  * @param[in] lineRuns The line runs converted to characters.
- * @param[out] lineInfoRuns line runs with the visual to logical and logical to visual conversion maps.
+ * @param[out] lineInfoRuns line runs with the visual to logical conversion maps.
  */
 void ReorderLines( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
                    const Vector<LineRun>& lineRuns,
  */
 void ReorderLines( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
                    const Vector<LineRun>& lineRuns,
@@ -120,6 +120,19 @@ void ReorderLines( LogicalModel& logicalModel,
  */
 bool GetMirroredText( const Vector<Character>& text,
                       Vector<Character>& mirroredText );
  */
 bool GetMirroredText( const Vector<Character>& text,
                       Vector<Character>& mirroredText );
+
+/**
+ * @brief Retrieves the character's directions.
+ *
+ * @pre The @p logicalModel needs to have a text set.
+ * @pre The @p logicalModel needs to have the bidirectional info indices for each paragraph set.
+ *
+ * @param[in] bidirectionalInfo Vector with the bidirectional infor for each paragraph.
+ * @param[out] directions The direction, @e false is left to right and @e true is right to left, of each character of the paragraph.
+ */
+void GetCharactersDirection( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
+                             Vector<CharacterDirection>& directions );
+
 } // namespace Text
 
 } // namespace Toolkit
 } // namespace Text
 
 } // namespace Toolkit
index 807f7fb..80d6595 100644 (file)
@@ -391,15 +391,42 @@ void ReplaceBidirectionalInfo( CharacterIndex characterIndex,
 {
 }
 
 {
 }
 
+void LogicalModel::SetCharacterDirections( const CharacterDirection* const directions,
+                                           Length numberOfCharacters )
+{
+  if( 0u == numberOfCharacters )
+  {
+    mCharacterDirections.Clear();
+  }
+  else
+  {
+    mCharacterDirections.Resize( numberOfCharacters );
+    memcpy( mCharacterDirections.Begin(), directions, numberOfCharacters * sizeof( CharacterDirection ) );
+  }
+}
+
 void LogicalModel::GetCharacterDirections( CharacterDirection* directions,
                                            CharacterIndex characterIndex,
                                            Length numberOfCharacters ) const
 {
 void LogicalModel::GetCharacterDirections( CharacterDirection* directions,
                                            CharacterIndex characterIndex,
                                            Length numberOfCharacters ) const
 {
+  if( 0u == mCharacterDirections.Count() )
+  {
+    // Nothing to retrieve if the model has no right to left characters.
+    return;
+  }
+
+  memcpy( directions, mCharacterDirections.Begin() + characterIndex, numberOfCharacters * sizeof( CharacterDirection ) );
 }
 
 CharacterDirection LogicalModel::GetCharacterDirection( CharacterIndex characterIndex ) const
 {
 }
 
 CharacterDirection LogicalModel::GetCharacterDirection( CharacterIndex characterIndex ) const
 {
-  return false;
+  if( characterIndex >= mCharacterDirections.Count() )
+  {
+    // The model has no right to left characters, so the vector of directions is void.
+    return false;
+  }
+
+  return *( mCharacterDirections.Begin() + characterIndex );
 }
 
 void LogicalModel::SetVisualToLogicalMap( const BidirectionalLineInfoRun* const bidirectionalInfo,
 }
 
 void LogicalModel::SetVisualToLogicalMap( const BidirectionalLineInfoRun* const bidirectionalInfo,
index c73190e..6baf44e 100644 (file)
@@ -95,7 +95,7 @@ public:
                 Length numberOfCharacters ) const;
 
   /**
                 Length numberOfCharacters ) const;
 
   /**
-   * Retrieves a character.
+   * @brief Retrieves a character.
    *
    * @param[in] characterIndex Index to a character.
    *
    *
    * @param[in] characterIndex Index to a character.
    *
@@ -104,7 +104,7 @@ public:
   Character GetCharacter( CharacterIndex characterIndex ) const;
 
   /**
   Character GetCharacter( CharacterIndex characterIndex ) const;
 
   /**
-   * Replaces characters from the text.
+   * @brief Replaces characters from the text.
    *
    * If the @p numberOfCharactersToRemove is zero, this operation is like an insert.
    * If the @p numberOfCharactersToInsert is zero, this operation is like a remove.
    *
    * If the @p numberOfCharactersToRemove is zero, this operation is like an insert.
    * If the @p numberOfCharactersToInsert is zero, this operation is like a remove.
@@ -122,7 +122,7 @@ public:
   // Language support interface.
 
   /**
   // Language support interface.
 
   /**
-   * Sets the script runs.
+   * @brief Sets the script runs.
    *
    * Replaces any scripts previously set.
    *
    *
    * Replaces any scripts previously set.
    *
@@ -137,7 +137,7 @@ public:
                    Length numberOfRuns );
 
   /**
                    Length numberOfRuns );
 
   /**
-   * Retrieves the number of script runs and the index to the first one for the given range of characters.
+   * @brief Retrieves the number of script runs and the index to the first one for the given range of characters.
    *
    * A run is a group of consecutive characters. A script run contains the script for a run.
    *
    *
    * A run is a group of consecutive characters. A script run contains the script for a run.
    *
@@ -152,7 +152,7 @@ public:
                               Length& numberOfScriptRuns ) const;
 
   /**
                               Length& numberOfScriptRuns ) const;
 
   /**
-   * Retrieves the script runs for the given range of characters.
+   * @brief Retrieves the script runs for the given range of characters.
    *
    * The @p scriptRuns buffer needs to be big enough to copy the number of script runs.
    * Call GetNumberOfScriptRuns() to retrieve the number of script runs.
    *
    * The @p scriptRuns buffer needs to be big enough to copy the number of script runs.
    * Call GetNumberOfScriptRuns() to retrieve the number of script runs.
@@ -166,7 +166,7 @@ public:
                       Length numberOfCharacters ) const;
 
   /**
                       Length numberOfCharacters ) const;
 
   /**
-   * Retrieves the script for the given character index.
+   * @brief Retrieves the script for the given character index.
    *
    * @param[in] characterIndex Index to the character.
    *
    *
    * @param[in] characterIndex Index to the character.
    *
@@ -175,7 +175,7 @@ public:
   Script GetScript( CharacterIndex characterIndex ) const;
 
   /**
   Script GetScript( CharacterIndex characterIndex ) const;
 
   /**
-   * Replaces script runs for the given range of characters.
+   * @brief Replaces script runs for the given range of characters.
    *
    * If the @p numberOfCharactersToRemove is zero, this operation is like an insert.
    * If the @p numberOfCharactersToInsert is zero, this operation is like a remove.
    *
    * If the @p numberOfCharactersToRemove is zero, this operation is like an insert.
    * If the @p numberOfCharactersToInsert is zero, this operation is like a remove.
@@ -191,7 +191,7 @@ public:
                        Length numberOfCharactersToInsert );
 
   /**
                        Length numberOfCharactersToInsert );
 
   /**
-   * Sets the font runs.
+   * @brief Sets the font runs.
    *
    * Replaces any fonts previously set.
    *
    *
    * Replaces any fonts previously set.
    *
@@ -206,7 +206,7 @@ public:
                  Length numberOfRuns );
 
   /**
                  Length numberOfRuns );
 
   /**
-   * Retrieves the number of font runs and the index of the first one for the given range of characters.
+   * @brief Retrieves the number of font runs and the index of the first one for the given range of characters.
    *
    * A run is a group of consecutive characters. A font run contains the font id for a run.
    *
    *
    * A run is a group of consecutive characters. A font run contains the font id for a run.
    *
@@ -221,7 +221,7 @@ public:
                             Length& numberOfFontRuns ) const;
 
   /**
                             Length& numberOfFontRuns ) const;
 
   /**
-   * Retrieves the font runs for the given range of characters.
+   * @brief Retrieves the font runs for the given range of characters.
    *
    * The @p fontRuns buffer needs to be big enough to copy the number of font runs.
    * Call GetNumberOfFontRuns() to retrieve the number of font runs.
    *
    * The @p fontRuns buffer needs to be big enough to copy the number of font runs.
    * Call GetNumberOfFontRuns() to retrieve the number of font runs.
@@ -235,7 +235,7 @@ public:
                     Length numberOfCharacters ) const;
 
   /**
                     Length numberOfCharacters ) const;
 
   /**
-   * Retrieves the font id for the given character index.
+   * @brief Retrieves the font id for the given character index.
    *
    * @param[in] characterIndex Index to the first character.
    *
    *
    * @param[in] characterIndex Index to the first character.
    *
@@ -244,7 +244,7 @@ public:
   FontId GetFont( CharacterIndex characterIndex ) const;
 
   /**
   FontId GetFont( CharacterIndex characterIndex ) const;
 
   /**
-   * Replaces font runs for the given range of characters.
+   * @brief Replaces font runs for the given range of characters.
    *
    * If the @p numberOfCharactersToRemove is zero, this operation is like an insert.
    * If the @p numberOfCharactersToInsert is zero, this operation is like a remove.
    *
    * If the @p numberOfCharactersToRemove is zero, this operation is like an insert.
    * If the @p numberOfCharactersToInsert is zero, this operation is like a remove.
@@ -262,7 +262,7 @@ public:
   // Break info interface.
 
   /**
   // Break info interface.
 
   /**
-   * Sets the line break info.
+   * @brief Sets the line break info.
    *
    * See GetLineBreakInfo() to get how the line break info is encoded.
    *
    *
    * See GetLineBreakInfo() to get how the line break info is encoded.
    *
@@ -277,7 +277,7 @@ public:
                          Length length );
 
   /**
                          Length length );
 
   /**
-   * Retrieves the line break info in the given buffer.
+   * @brief Retrieves the line break info in the given buffer.
    *
    * The size of the @p lineBreakInfo buffer needs to be big enough to copy the @p numberOfItems.
    *
    *
    * The size of the @p lineBreakInfo buffer needs to be big enough to copy the @p numberOfItems.
    *
@@ -301,14 +301,14 @@ public:
                          Length numberOfItems ) const;
 
   /**
                          Length numberOfItems ) const;
 
   /**
-   * Retrieves the line break info for the given item index.
+   * @brief Retrieves the line break info for the given item index.
    *
    * @param[in] characterIndex Index to the line break info item.
    */
   LineBreakInfo GetLineBreakInfo( CharacterIndex characterIndex ) const;
 
   /**
    *
    * @param[in] characterIndex Index to the line break info item.
    */
   LineBreakInfo GetLineBreakInfo( CharacterIndex characterIndex ) const;
 
   /**
-   * Replaces line break info.
+   * @brief Replaces line break info.
    *
    * See GetLineBreakInfo() to get how the line break info is encoded.
    *
    *
    * See GetLineBreakInfo() to get how the line break info is encoded.
    *
@@ -326,7 +326,7 @@ public:
                              Length numberOfItemsToInsert );
 
   /**
                              Length numberOfItemsToInsert );
 
   /**
-   * Sets the word break info.
+   * @brief Sets the word break info.
    *
    * See GetWordBreakInfo() to get how the word break info is encoded.
    *
    *
    * See GetWordBreakInfo() to get how the word break info is encoded.
    *
@@ -341,7 +341,7 @@ public:
                          Length length );
 
   /**
                          Length length );
 
   /**
-   * Retrieves the word break info in the given buffer.
+   * @brief Retrieves the word break info in the given buffer.
    *
    * The size of the @p wordBreakInfo buffer needs to be big enough to copy the @p numberOfItems.
    *
    *
    * The size of the @p wordBreakInfo buffer needs to be big enough to copy the @p numberOfItems.
    *
@@ -367,14 +367,14 @@ public:
                          Length numberOfItems ) const;
 
   /**
                          Length numberOfItems ) const;
 
   /**
-   * Retrieves the word break info for the given item index.
+   * @brief Retrieves the word break info for the given item index.
    *
    * @param[in] characterIndex Index to the word break info item.
    */
   WordBreakInfo GetWordBreakInfo( CharacterIndex characterIndex ) const;
 
   /**
    *
    * @param[in] characterIndex Index to the word break info item.
    */
   WordBreakInfo GetWordBreakInfo( CharacterIndex characterIndex ) const;
 
   /**
-   * Replaces word break info.
+   * @brief Replaces word break info.
    *
    * See GetWordBreakInfo() to get how the word break info is encoded.
    *
    *
    * See GetWordBreakInfo() to get how the word break info is encoded.
    *
@@ -394,7 +394,7 @@ public:
   // Bidirectional support interface.
 
   /**
   // Bidirectional support interface.
 
   /**
-   * Sets the bidirectional info runs.
+   * @brief Sets the bidirectional info runs.
    *
    * Replaces any bidirectional info previously set.
    *
    *
    * Replaces any bidirectional info previously set.
    *
@@ -412,7 +412,7 @@ public:
                              Length numberOfRuns );
 
   /**
                              Length numberOfRuns );
 
   /**
-   * Retrieves the number of bidirectional info runs and the index to the first one for the given range of characters.
+   * @brief Retrieves the number of bidirectional info runs and the index to the first one for the given range of characters.
    *
    * It may be zero if there is no right to left scripts.
    *
    *
    * It may be zero if there is no right to left scripts.
    *
@@ -427,7 +427,7 @@ public:
                                          Length& numberOfFontRuns ) const;
 
   /**
                                          Length& numberOfFontRuns ) const;
 
   /**
-   * Retrieves the bidirectional paragraph info runs for the given range of characters.
+   * @brief Retrieves the bidirectional paragraph info runs for the given range of characters.
    *
    * The @p bidirectionalInfo buffer needs to be big enough to copy the number of bidirectional
    * paragraph info runs.
    *
    * The @p bidirectionalInfo buffer needs to be big enough to copy the number of bidirectional
    * paragraph info runs.
@@ -442,7 +442,7 @@ public:
                              Length numberOfCharacters ) const;
 
   /**
                              Length numberOfCharacters ) const;
 
   /**
-   * Replaces bidirectional info runs for the given range of characters.
+   * @brief Replaces bidirectional info runs for the given range of characters.
    *
    * If the @p numberOfCharactersToRemove is zero, this operation is like an insert.
    * If the @p numberOfCharactersToInsert is zero, this operation is like a remove.
    *
    * If the @p numberOfCharactersToRemove is zero, this operation is like an insert.
    * If the @p numberOfCharactersToInsert is zero, this operation is like a remove.
@@ -458,15 +458,29 @@ public:
                                  Length numberOfCharactersToInsert );
 
   /**
                                  Length numberOfCharactersToInsert );
 
   /**
-   * Retrieves the direction of the characters.
+   * @brief Replaces the direction of the characters.
    *
    *
-   * It sets @c true for right to left characters and @c false for left to right.
+   * @note If the number of characters is zero the directions buffer is cleared.
+   *
+   * @param[in] directions The directions of the characters.
+   * @param[in] numberOfCharacters The number of characters.
+   */
+  void SetCharacterDirections( const CharacterDirection* const directions,
+                               Length numberOfCharacters );
+
+  /**
+   * @brief Retrieves the direction of the characters.
+   *
+   * It sets @e true for right to left characters and @e false for left to right.
    * For neutral characters it check's the next and previous character's directions:
    * - If they are equals set that direction. If they are not, sets the paragraph's direction.
    * - If there is no next, sets the paragraph's direction.
    *
    * See SetBidirectionalInfo() to get an explanation of the 'paragraph' meaning in the bidirectional algorithm.
    *
    * For neutral characters it check's the next and previous character's directions:
    * - If they are equals set that direction. If they are not, sets the paragraph's direction.
    * - If there is no next, sets the paragraph's direction.
    *
    * See SetBidirectionalInfo() to get an explanation of the 'paragraph' meaning in the bidirectional algorithm.
    *
+   * @pre the @p directions vector should be initialized to @e false (left to right) as this method is not going
+   *      to update it if there is no right to left characters.
+   *
    * @param[out] directions Whether the characters are right to left or left to right.
    * @param[in] characterIndex Index to the first character.
    * @param[in] numberOfCharacters The number of characters.
    * @param[out] directions Whether the characters are right to left or left to right.
    * @param[in] characterIndex Index to the first character.
    * @param[in] numberOfCharacters The number of characters.
@@ -476,7 +490,7 @@ public:
                                Length numberOfCharacters ) const;
 
   /**
                                Length numberOfCharacters ) const;
 
   /**
-   * Retrieves the direction of a characters.
+   * @brief Retrieves the direction of a characters.
    *
    * See GetCharacterDirections().
    *
    *
    * See GetCharacterDirections().
    *
@@ -489,7 +503,7 @@ public:
   // Visual <--> Logical conversion tables.
 
   /**
   // Visual <--> Logical conversion tables.
 
   /**
-   * Sets the visual to logical and the logical to visual map tables.
+   * @brief Sets the visual to logical and the logical to visual map tables.
    *
    * Replaces any map tables previously set.
    *
    *
    * Replaces any map tables previously set.
    *
@@ -502,7 +516,7 @@ public:
                               Length numberOfRuns );
 
   /**
                               Length numberOfRuns );
 
   /**
-   * Replaces the visual to logical and logical to visual map tables for the given range of characters.
+   * @brief Replaces the visual to logical and logical to visual map tables for the given range of characters.
    *
    * If the @p numberOfCharactersToRemove is zero, this operation is like an insert.
    * If the @p numberOfCharactersToInsert is zero, this operation is like a remove.
    *
    * If the @p numberOfCharactersToRemove is zero, this operation is like an insert.
    * If the @p numberOfCharactersToInsert is zero, this operation is like a remove.
@@ -518,7 +532,7 @@ public:
                                   Length numberOfCharactersToInsert );
 
   /**
                                   Length numberOfCharactersToInsert );
 
   /**
-   * Retrieves the visual character index for the given logical character index.
+   * @brief Retrieves the visual character index for the given logical character index.
    *
    * @param[in] logicalCharacterIndex The logical character index.
    *
    *
    * @param[in] logicalCharacterIndex The logical character index.
    *
@@ -527,7 +541,7 @@ public:
   CharacterIndex GetVisualCharacterIndex( CharacterIndex logicalCharacterIndex ) const;
 
   /**
   CharacterIndex GetVisualCharacterIndex( CharacterIndex logicalCharacterIndex ) const;
 
   /**
-   * Retrieves the logical character index for the given visual character index.
+   * @brief Retrieves the logical character index for the given visual character index.
    *
    * @param[in] visualCharacterIndex The visual character index.
    *
    *
    * @param[in] visualCharacterIndex The visual character index.
    *
@@ -536,7 +550,7 @@ public:
   CharacterIndex GetLogicalCharacterIndex( CharacterIndex visualCharacterIndex ) const;
 
   /**
   CharacterIndex GetLogicalCharacterIndex( CharacterIndex visualCharacterIndex ) const;
 
   /**
-   * Retrieves the whole or part of the logical to visual conversion map.
+   * @brief Retrieves the whole or part of the logical to visual conversion map.
    *
    * The size of the buffer needs to be big enough to copy the @p numberOfCharacters.
    *
    *
    * The size of the buffer needs to be big enough to copy the @p numberOfCharacters.
    *
@@ -549,7 +563,7 @@ public:
                               Length numberOfCharacters ) const;
 
   /**
                               Length numberOfCharacters ) const;
 
   /**
-   * Retrieves the whole or part of the visual to logical conversion map.
+   * @brief Retrieves the whole or part of the visual to logical conversion map.
    *
    * The size of the buffer needs to be big enough to copy the @p numberOfCharacters.
    *
    *
    * The size of the buffer needs to be big enough to copy the @p numberOfCharacters.
    *
@@ -589,10 +603,10 @@ public:
   Vector<LineBreakInfo>                 mLineBreakInfo;
   Vector<WordBreakInfo>                 mWordBreakInfo;
   Vector<BidirectionalParagraphInfoRun> mBidirectionalParagraphInfo;
   Vector<LineBreakInfo>                 mLineBreakInfo;
   Vector<WordBreakInfo>                 mWordBreakInfo;
   Vector<BidirectionalParagraphInfoRun> mBidirectionalParagraphInfo;
-
+  Vector<CharacterDirection>            mCharacterDirections;        ///< For each character, whether is right to left. ( @e flase is left to right, @e true right to left ).
   Vector<BidirectionalLineInfoRun>      mBidirectionalLineInfo;
   Vector<BidirectionalLineInfoRun>      mBidirectionalLineInfo;
-  Vector<CharacterIndex>                mLogicalToVisualMap; ///< Bidirectional logical to visual conversion table.
-  Vector<CharacterIndex>                mVisualToLogicalMap; ///< Bidirectional visual to logical conversion table.
+  Vector<CharacterIndex>                mLogicalToVisualMap;         ///< Bidirectional logical to visual conversion table.
+  Vector<CharacterIndex>                mVisualToLogicalMap;         ///< Bidirectional visual to logical conversion table.
 };
 
 } // namespace Text
 };
 
 } // namespace Text
index 47b0115..f6bc916 100644 (file)
@@ -951,6 +951,7 @@ void Controller::ReplaceTextEvent( const std::string& text )
   mImpl->mLogicalModel->mLineBreakInfo.Clear();
   mImpl->mLogicalModel->mWordBreakInfo.Clear();
   mImpl->mLogicalModel->mBidirectionalParagraphInfo.Clear();
   mImpl->mLogicalModel->mLineBreakInfo.Clear();
   mImpl->mLogicalModel->mWordBreakInfo.Clear();
   mImpl->mLogicalModel->mBidirectionalParagraphInfo.Clear();
+  mImpl->mLogicalModel->mCharacterDirections.Clear();
   mImpl->mLogicalModel->mBidirectionalLineInfo.Clear();
   mImpl->mLogicalModel->mLogicalToVisualMap.Clear();
   mImpl->mLogicalModel->mVisualToLogicalMap.Clear();
   mImpl->mLogicalModel->mBidirectionalLineInfo.Clear();
   mImpl->mLogicalModel->mLogicalToVisualMap.Clear();
   mImpl->mLogicalModel->mVisualToLogicalMap.Clear();
@@ -1003,6 +1004,7 @@ void Controller::InsertTextEvent( const std::string& text )
   mImpl->mLogicalModel->mLineBreakInfo.Clear();
   mImpl->mLogicalModel->mWordBreakInfo.Clear();
   mImpl->mLogicalModel->mBidirectionalParagraphInfo.Clear();
   mImpl->mLogicalModel->mLineBreakInfo.Clear();
   mImpl->mLogicalModel->mWordBreakInfo.Clear();
   mImpl->mLogicalModel->mBidirectionalParagraphInfo.Clear();
+  mImpl->mLogicalModel->mCharacterDirections.Clear();
   mImpl->mLogicalModel->mBidirectionalLineInfo.Clear();
   mImpl->mLogicalModel->mLogicalToVisualMap.Clear();
   mImpl->mLogicalModel->mVisualToLogicalMap.Clear();
   mImpl->mLogicalModel->mBidirectionalLineInfo.Clear();
   mImpl->mLogicalModel->mLogicalToVisualMap.Clear();
   mImpl->mLogicalModel->mVisualToLogicalMap.Clear();
@@ -1067,6 +1069,7 @@ void Controller::DeleteTextEvent()
   mImpl->mLogicalModel->mLineBreakInfo.Clear();
   mImpl->mLogicalModel->mWordBreakInfo.Clear();
   mImpl->mLogicalModel->mBidirectionalParagraphInfo.Clear();
   mImpl->mLogicalModel->mLineBreakInfo.Clear();
   mImpl->mLogicalModel->mWordBreakInfo.Clear();
   mImpl->mLogicalModel->mBidirectionalParagraphInfo.Clear();
+  mImpl->mLogicalModel->mCharacterDirections.Clear();
   mImpl->mLogicalModel->mBidirectionalLineInfo.Clear();
   mImpl->mLogicalModel->mLogicalToVisualMap.Clear();
   mImpl->mLogicalModel->mVisualToLogicalMap.Clear();
   mImpl->mLogicalModel->mBidirectionalLineInfo.Clear();
   mImpl->mLogicalModel->mLogicalToVisualMap.Clear();
   mImpl->mLogicalModel->mVisualToLogicalMap.Clear();
@@ -1208,8 +1211,21 @@ void Controller::UpdateModel( OperationsMask operationsRequired )
       // TODO: consider if the mirrored string can be stored as well.
 
       textMirrored = GetMirroredText( utf32Characters, mirroredUtf32Characters );
       // TODO: consider if the mirrored string can be stored as well.
 
       textMirrored = GetMirroredText( utf32Characters, mirroredUtf32Characters );
+
+      // Only set the character directions if there is right to left characters.
+      Vector<CharacterDirection>& directions = mImpl->mLogicalModel->mCharacterDirections;
+      directions.Resize( numberOfCharacters );
+
+      GetCharactersDirection( bidirectionalInfo,
+                              directions );
     }
     }
-  }
+    else
+    {
+      // There is no right to left characters. Clear the directions vector.
+      mImpl->mLogicalModel->mCharacterDirections.Clear();
+    }
+
+   }
 
   Vector<GlyphInfo>& glyphs = mImpl->mVisualModel->mGlyphs;
   Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mVisualModel->mGlyphsToCharacters;
 
   Vector<GlyphInfo>& glyphs = mImpl->mVisualModel->mGlyphs;
   Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mVisualModel->mGlyphsToCharacters;
index 6f00b7b..17bca2d 100644 (file)
@@ -33,22 +33,22 @@ namespace Toolkit
 namespace Text
 {
 
 namespace Text
 {
 
-typedef TextAbstraction::FontId          FontId;                ///< The unique identifier for a font face (generated by FontClient).
-typedef TextAbstraction::FontMetrics     FontMetrics;           ///< The metrics for a Font expressed in 26.6 fractional pixel format.
-typedef TextAbstraction::PointSize26Dot6 PointSize26Dot6;       ///< The point size in 26.6 fractional points.
-typedef TextAbstraction::FaceIndex       FaceIndex;             ///< Used with fonts which allow several font faces.
-typedef TextAbstraction::GlyphIndex      GlyphIndex;            ///< Uniquely identifies a glyph within a particular font.
-typedef TextAbstraction::Character       Character;             ///< A UTF-32 representation of a character.
-typedef TextAbstraction::GlyphInfo       GlyphInfo;             ///< The information describing a glyph (font ID, index, metrics).
-typedef TextAbstraction::CharacterIndex  CharacterIndex;        ///< An index into an array of characters.
-typedef TextAbstraction::Length          Length;                ///< The length of an array.
-typedef TextAbstraction::BidiInfoIndex   BidiInfoIndex;         ///< Index to the bidirectional info for a paragraph.
-typedef TextAbstraction::Script          Script;                ///< The character's script.
-typedef TextAbstraction::LineBreakInfo   LineBreakInfo;         ///< Line break info (must break, allow break, no break). Possible values are: @e LINE_MUST_BREAK, @e LINE_ALLOW_BREAK and @e LINE_NO_BREAK (in the TextAbstraction namespace).
-typedef TextAbstraction::WordBreakInfo   WordBreakInfo;         ///< Word break info (break, no break). Possible values are: @e WORD_BREAK and @e WORD_NO_BREAK (in the TextAbstraction namespace).
+typedef TextAbstraction::FontId             FontId;             ///< The unique identifier for a font face (generated by FontClient).
+typedef TextAbstraction::FontMetrics        FontMetrics;        ///< The metrics for a Font expressed in 26.6 fractional pixel format.
+typedef TextAbstraction::PointSize26Dot6    PointSize26Dot6;    ///< The point size in 26.6 fractional points.
+typedef TextAbstraction::FaceIndex          FaceIndex;          ///< Used with fonts which allow several font faces.
+typedef TextAbstraction::GlyphIndex         GlyphIndex;         ///< Uniquely identifies a glyph within a particular font.
+typedef TextAbstraction::Character          Character;          ///< A UTF-32 representation of a character.
+typedef TextAbstraction::GlyphInfo          GlyphInfo;          ///< The information describing a glyph (font ID, index, metrics).
+typedef TextAbstraction::CharacterIndex     CharacterIndex;     ///< An index into an array of characters.
+typedef TextAbstraction::Length             Length;             ///< The length of an array.
+typedef TextAbstraction::BidiInfoIndex      BidiInfoIndex;      ///< Index to the bidirectional info for a paragraph.
+typedef TextAbstraction::Script             Script;             ///< The character's script.
+typedef TextAbstraction::LineBreakInfo      LineBreakInfo;      ///< Line break info (must break, allow break, no break). Possible values are: @e LINE_MUST_BREAK, @e LINE_ALLOW_BREAK and @e LINE_NO_BREAK (in the TextAbstraction namespace).
+typedef TextAbstraction::WordBreakInfo      WordBreakInfo;      ///< Word break info (break, no break). Possible values are: @e WORD_BREAK and @e WORD_NO_BREAK (in the TextAbstraction namespace).
+typedef TextAbstraction::CharacterDirection CharacterDirection; ///< The character's direction: @e false is left to right, @e true is right to left.
 
 typedef uint32_t                         GlyphIndex;            ///< An index into an array of glyphs.
 
 typedef uint32_t                         GlyphIndex;            ///< An index into an array of glyphs.
-typedef bool                             CharacterDirection;    ///< The character's direction: @e false is left to right, @e true is right to left.
 typedef uint32_t                         ScriptRunIndex;        ///< An index into an array of script runs.
 typedef uint32_t                         FontRunIndex;          ///< An index into an array of font runs.
 typedef uint32_t                         BidirectionalRunIndex; ///< An index into an array of font runs.
 typedef uint32_t                         ScriptRunIndex;        ///< An index into an array of script runs.
 typedef uint32_t                         FontRunIndex;          ///< An index into an array of font runs.
 typedef uint32_t                         BidirectionalRunIndex; ///< An index into an array of font runs.