Method added to mirror bidirectional text's characters. 83/36983/1
authorVictor Cebollada <v.cebollada@samsung.com>
Tue, 17 Mar 2015 16:35:27 +0000 (16:35 +0000)
committerVictor Cebollada <v.cebollada@samsung.com>
Tue, 17 Mar 2015 18:08:00 +0000 (18:08 +0000)
Change-Id: I2ac67c3f9e9e35e9275ba82f16c3e4f1a8494063
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
text/dali/internal/text-abstraction/bidirectional-support-impl.cpp
text/dali/internal/text-abstraction/bidirectional-support-impl.h
text/dali/public-api/text-abstraction/bidirectional-support.cpp
text/dali/public-api/text-abstraction/bidirectional-support.h

index 1274c00..041476b 100644 (file)
@@ -167,6 +167,28 @@ struct BidirectionalSupport::Plugin
     free( embeddedLevels );
   }
 
+  bool GetMirroredText( Character* text,
+                        Length numberOfCharacters ) const
+  {
+    bool updated = false;
+
+    for( CharacterIndex index = 0u; index < numberOfCharacters; ++index )
+    {
+      // Get a reference to the character inside the text.
+      Character& character = *( text + index );
+
+      // Retrieve the mirrored character.
+      FriBidiChar mirroredCharacter = character;
+      const bool mirrored = fribidi_get_mirror_char( character, &mirroredCharacter );
+      updated = updated || mirrored;
+
+      // Update the character inside the text.
+      character = mirroredCharacter;
+    }
+
+    return updated;
+  }
+
   Vector<BidirectionalInfo*> mParagraphBidirectionalInfo; ///< Stores the bidirectional info per paragraph.
   Vector<BidiInfoIndex>      mFreeIndices;                ///< Stores indices of free positions in the bidirectional info vector.
 };
@@ -235,6 +257,14 @@ void BidirectionalSupport::Reorder( BidiInfoIndex bidiInfoIndex,
                     visualToLogicalMap );
 }
 
+bool BidirectionalSupport::GetMirroredText( Character* text,
+                                            Length numberOfCharacters )
+{
+  CreatePlugin();
+
+  return mPlugin->GetMirroredText( text, numberOfCharacters );
+}
+
 void BidirectionalSupport::CreatePlugin()
 {
   if( !mPlugin )
index 33b1984..4fc0e4c 100644 (file)
@@ -75,6 +75,12 @@ public:
                 Length numberOfCharacters,
                 CharacterIndex* visualToLogicalMap );
 
+  /**
+   * @copydoc Dali::BidirectionalSupport::GetMirroredText()
+   */
+  bool GetMirroredText( Character* text,
+                        Length numberOfCharacters );
+
 private:
 
   /**
index 40a7d78..46f1104 100644 (file)
@@ -68,6 +68,13 @@ void BidirectionalSupport::Reorder( BidiInfoIndex bidiInfoIndex,
                                       visualToLogicalMap );
 }
 
+bool BidirectionalSupport::GetMirroredText( Character* text,
+                                            Length numberOfCharacters )
+{
+  return GetImplementation( *this ).GetMirroredText( text,
+                                                     numberOfCharacters );
+}
+
 } // namespace TextAbstraction
 
 } // namespace Dali
index f18a9c7..84a1f81 100644 (file)
@@ -105,6 +105,17 @@ public:
                 CharacterIndex firstCharacterIndex,
                 Length numberOfCharacters,
                 CharacterIndex* visualToLogicalMap );
+
+  /**
+   * @brief Replaces any character which could be mirrored.
+   *
+   * @param[in,out] text The text.
+   * @param[in] numberOfCharacters The number of characters.
+   *
+   * @return @e true if a character has been replaced.
+   */
+  bool GetMirroredText( Character* text,
+                        Length numberOfCharacters );
 };
 
 } // namespace TextAbstraction