Merge "Multi-line layout." into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / bidirectional-support.cpp
index cf9ec63..fd85439 100644 (file)
@@ -215,11 +215,14 @@ void ReorderLines( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInf
       // The memory is freed after the visual to logical to visual conversion tables are built in the logical model.
       lineInfoRun.visualToLogicalMap = reinterpret_cast<CharacterIndex*>( malloc( line.characterRun.numberOfCharacters * sizeof( CharacterIndex ) ) );
 
-      // Reorders the line.
-      bidirectionalSupport.Reorder( paragraphInfo.bidirectionalInfoIndex,
-                                    line.characterRun.characterIndex - paragraphInfo.characterRun.characterIndex,
-                                    line.characterRun.numberOfCharacters,
-                                    lineInfoRun.visualToLogicalMap );
+      if( NULL != lineInfoRun.visualToLogicalMap )
+      {
+        // Reorders the line.
+        bidirectionalSupport.Reorder( paragraphInfo.bidirectionalInfoIndex,
+                                      line.characterRun.characterIndex - paragraphInfo.characterRun.characterIndex,
+                                      line.characterRun.numberOfCharacters,
+                                      lineInfoRun.visualToLogicalMap );
+      }
 
       // Push the run into the vector.
       lineInfoRuns.PushBack( lineInfoRun );
@@ -228,15 +231,33 @@ void ReorderLines( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInf
 }
 
 bool GetMirroredText( const Vector<Character>& text,
-                      Vector<Character>& mirroredText )
+                      Vector<Character>& mirroredText,
+                      const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo )
 {
+  bool hasTextMirrored = false;
+
   // Handle to the bidirectional info module in text-abstraction.
   TextAbstraction::BidirectionalSupport bidirectionalSupport = TextAbstraction::BidirectionalSupport::Get();
 
   mirroredText = text;
 
-  return bidirectionalSupport.GetMirroredText( mirroredText.Begin(),
-                                               mirroredText.Count() );
+  Character* mirroredTextBuffer = mirroredText.Begin();
+
+  // Traverse the paragraphs and mirror the right to left ones.
+  for( Vector<BidirectionalParagraphInfoRun>::ConstIterator it = bidirectionalInfo.Begin(),
+         endIt = bidirectionalInfo.End();
+       it != endIt;
+       ++it )
+  {
+    const BidirectionalParagraphInfoRun& run = *it;
+
+    const bool tmpMirrored = bidirectionalSupport.GetMirroredText( mirroredTextBuffer + run.characterRun.characterIndex,
+                                                                   run.characterRun.numberOfCharacters );
+
+    hasTextMirrored = hasTextMirrored || tmpMirrored;
+  }
+
+  return hasTextMirrored;
 }
 
 void GetCharactersDirection( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,