+ }
+
+ return logicalCursorIndex;
+}
+
+CharacterIndex LogicalModel::GetLogicalCharacterIndex( CharacterIndex visualCharacterIndex )
+{
+ // The bidirectional line info.
+ const BidirectionalLineInfoRun* const bidirectionalLineInfo = mBidirectionalLineInfo.Begin() + mBidirectionalLineIndex;
+
+ return *( bidirectionalLineInfo->visualToLogicalMap + visualCharacterIndex - bidirectionalLineInfo->characterRun.characterIndex ) + bidirectionalLineInfo->characterRun.characterIndex;
+}
+
+bool LogicalModel::FetchBidirectionalLineInfo( CharacterIndex characterIndex )
+{
+ // The number of bidirectional lines.
+ const Length numberOfBidirectionalLines = mBidirectionalLineInfo.Count();
+
+ if( 0u == numberOfBidirectionalLines )
+ {
+ // If there is no bidirectional info.
+ return false;
+ }
+
+ // Find the bidi line where the character is laid-out.
+
+ const BidirectionalLineInfoRun* const bidirectionalLineInfoBuffer = mBidirectionalLineInfo.Begin();
+
+ // Check first if the character is in the previously fetched line.
+
+ BidirectionalLineRunIndex bidiLineIndex = 0u;
+ CharacterIndex lastCharacterOfRightToLeftRun = 0u;
+ if( mBidirectionalLineIndex < numberOfBidirectionalLines )
+ {
+ const BidirectionalLineInfoRun& bidiLineRun = *( bidirectionalLineInfoBuffer + mBidirectionalLineIndex );