Updated all cpp files to new format
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / logical-model-impl.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 3d9440e..8ecab1f
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 namespace Dali
 {
-
 namespace Toolkit
 {
-
 namespace Text
 {
-
-void FreeFontFamilyNames( Vector<FontDescriptionRun>& fontDescriptionRuns )
+void FreeFontFamilyNames(Vector<FontDescriptionRun>& fontDescriptionRuns)
 {
-  for( Vector<FontDescriptionRun>::Iterator it = fontDescriptionRuns.Begin(),
-         endIt = fontDescriptionRuns.End();
-       it != endIt;
-       ++it )
+  for(Vector<FontDescriptionRun>::Iterator it    = fontDescriptionRuns.Begin(),
+                                           endIt = fontDescriptionRuns.End();
+      it != endIt;
+      ++it)
   {
-    delete[] (*it).familyName;
+    delete[](*it).familyName;
   }
 
   fontDescriptionRuns.Clear();
 }
 
-void FreeEmbeddedItems( Vector<EmbeddedItem>& embeddedItem )
+void FreeEmbeddedItems(Vector<EmbeddedItem>& embeddedItem)
 {
-  for( Vector<EmbeddedItem>::Iterator it = embeddedItem.Begin(),
-         endIt = embeddedItem.End();
-       it != endIt;
-       ++it )
+  for(Vector<EmbeddedItem>::Iterator it    = embeddedItem.Begin(),
+                                     endIt = embeddedItem.End();
+      it != endIt;
+      ++it)
   {
     EmbeddedItem& item = *it;
     delete[] item.url;
@@ -60,20 +57,20 @@ void FreeEmbeddedItems( Vector<EmbeddedItem>& embeddedItem )
 
 LogicalModelPtr LogicalModel::New()
 {
-  return LogicalModelPtr( new LogicalModel() );
+  return LogicalModelPtr(new LogicalModel());
 }
 
-Script LogicalModel::GetScript( CharacterIndex characterIndex ) const
+Script LogicalModel::GetScript(CharacterIndex characterIndex) const
 {
   // If this operation is too slow, consider a binary search.
 
   const ScriptRun* const scriptRunBuffer = mScriptRuns.Begin();
-  for( Length index = 0u, length = mScriptRuns.Count(); index < length; ++index )
+  for(Length index = 0u, length = mScriptRuns.Count(); index < length; ++index)
   {
     const ScriptRun* const scriptRun = scriptRunBuffer + index;
 
-    if( ( scriptRun->characterRun.characterIndex <= characterIndex ) &&
-        ( characterIndex < scriptRun->characterRun.characterIndex + scriptRun->characterRun.numberOfCharacters ) )
+    if((scriptRun->characterRun.characterIndex <= characterIndex) &&
+       (characterIndex < scriptRun->characterRun.characterIndex + scriptRun->characterRun.numberOfCharacters))
     {
       return scriptRun->script;
     }
@@ -82,18 +79,18 @@ Script LogicalModel::GetScript( CharacterIndex characterIndex ) const
   return TextAbstraction::UNKNOWN;
 }
 
-CharacterDirection LogicalModel::GetCharacterDirection( CharacterIndex characterIndex ) const
+CharacterDirection LogicalModel::GetCharacterDirection(CharacterIndex characterIndex) const
 {
-  if( characterIndex >= mCharacterDirections.Count() )
+  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 );
+  return *(mCharacterDirections.Begin() + characterIndex);
 }
 
-CharacterIndex LogicalModel::GetLogicalCursorIndex( CharacterIndex visualCursorIndex )
+CharacterIndex LogicalModel::GetLogicalCursorIndex(CharacterIndex visualCursorIndex)
 {
   // The character's directions buffer.
   const CharacterDirection* const modelCharacterDirections = mCharacterDirections.Begin();
@@ -109,9 +106,9 @@ CharacterIndex LogicalModel::GetLogicalCursorIndex( CharacterIndex visualCursorI
 
   CharacterIndex logicalCursorIndex = 0u;
 
-  if( bidirectionalLineInfo->characterRun.characterIndex == visualCursorIndex )
+  if(bidirectionalLineInfo->characterRun.characterIndex == visualCursorIndex)
   {
-    if( isRightToLeftParagraph )
+    if(isRightToLeftParagraph)
     {
       logicalCursorIndex = lastCharacterIndex;
     }
@@ -120,9 +117,9 @@ CharacterIndex LogicalModel::GetLogicalCursorIndex( CharacterIndex visualCursorI
       logicalCursorIndex = bidirectionalLineInfo->characterRun.characterIndex;
     }
   }
-  else if( lastCharacterIndex == visualCursorIndex )
+  else if(lastCharacterIndex == visualCursorIndex)
   {
-    if( isRightToLeftParagraph )
+    if(isRightToLeftParagraph)
     {
       logicalCursorIndex = bidirectionalLineInfo->characterRun.characterIndex;
     }
@@ -137,17 +134,17 @@ CharacterIndex LogicalModel::GetLogicalCursorIndex( CharacterIndex visualCursorI
     // and calculate the logical position according the directions of
     // both characters and the direction of the paragraph.
 
-    const CharacterIndex previousVisualCursorIndex = visualCursorIndex - 1u;
-    const CharacterIndex previousLogicalCursorIndex = *( bidirectionalLineInfo->visualToLogicalMap + previousVisualCursorIndex - bidirectionalLineInfo->characterRun.characterIndex ) + bidirectionalLineInfo->characterRun.characterIndex;
-    const CharacterIndex currentLogicalCursorIndex = *( bidirectionalLineInfo->visualToLogicalMap + visualCursorIndex - bidirectionalLineInfo->characterRun.characterIndex ) + bidirectionalLineInfo->characterRun.characterIndex;
+    const CharacterIndex previousVisualCursorIndex  = visualCursorIndex - 1u;
+    const CharacterIndex previousLogicalCursorIndex = *(bidirectionalLineInfo->visualToLogicalMap + previousVisualCursorIndex - bidirectionalLineInfo->characterRun.characterIndex) + bidirectionalLineInfo->characterRun.characterIndex;
+    const CharacterIndex currentLogicalCursorIndex  = *(bidirectionalLineInfo->visualToLogicalMap + visualCursorIndex - bidirectionalLineInfo->characterRun.characterIndex) + bidirectionalLineInfo->characterRun.characterIndex;
 
-    const CharacterDirection previousCharacterDirection = *( modelCharacterDirections + previousLogicalCursorIndex );
-    const CharacterDirection currentCharacterDirection = *( modelCharacterDirections + currentLogicalCursorIndex );
+    const CharacterDirection previousCharacterDirection = *(modelCharacterDirections + previousLogicalCursorIndex);
+    const CharacterDirection currentCharacterDirection  = *(modelCharacterDirections + currentLogicalCursorIndex);
 
-    if( previousCharacterDirection == currentCharacterDirection )
+    if(previousCharacterDirection == currentCharacterDirection)
     {
       // Both glyphs have the same direction.
-      if( previousCharacterDirection )
+      if(previousCharacterDirection)
       {
         logicalCursorIndex = previousLogicalCursorIndex;
       }
@@ -158,9 +155,9 @@ CharacterIndex LogicalModel::GetLogicalCursorIndex( CharacterIndex visualCursorI
     }
     else
     {
-      if( isRightToLeftParagraph )
+      if(isRightToLeftParagraph)
       {
-        if( currentCharacterDirection )
+        if(currentCharacterDirection)
         {
           logicalCursorIndex = currentLogicalCursorIndex + 1u;
         }
@@ -171,7 +168,7 @@ CharacterIndex LogicalModel::GetLogicalCursorIndex( CharacterIndex visualCursorI
       }
       else
       {
-        if( previousCharacterDirection )
+        if(previousCharacterDirection)
         {
           logicalCursorIndex = currentLogicalCursorIndex;
         }
@@ -186,20 +183,20 @@ CharacterIndex LogicalModel::GetLogicalCursorIndex( CharacterIndex visualCursorI
   return logicalCursorIndex;
 }
 
-CharacterIndex LogicalModel::GetLogicalCharacterIndex( CharacterIndex visualCharacterIndex )
+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;
+  return *(bidirectionalLineInfo->visualToLogicalMap + visualCharacterIndex - bidirectionalLineInfo->characterRun.characterIndex) + bidirectionalLineInfo->characterRun.characterIndex;
 }
 
-bool LogicalModel::FetchBidirectionalLineInfo( CharacterIndex characterIndex )
+bool LogicalModel::FetchBidirectionalLineInfo(CharacterIndex characterIndex)
 {
   // The number of bidirectional lines.
   const Length numberOfBidirectionalLines = mBidirectionalLineInfo.Count();
 
-  if( 0u == numberOfBidirectionalLines )
+  if(0u == numberOfBidirectionalLines)
   {
     // If there is no bidirectional info.
     return false;
@@ -211,15 +208,15 @@ bool LogicalModel::FetchBidirectionalLineInfo( CharacterIndex characterIndex )
 
   // Check first if the character is in the previously fetched line.
 
-  BidirectionalLineRunIndex bidiLineIndex = 0u;
-  CharacterIndex lastCharacterOfRightToLeftRun = 0u;
-  if( mBidirectionalLineIndex < numberOfBidirectionalLines )
+  BidirectionalLineRunIndex bidiLineIndex                 = 0u;
+  CharacterIndex            lastCharacterOfRightToLeftRun = 0u;
+  if(mBidirectionalLineIndex < numberOfBidirectionalLines)
   {
-    const BidirectionalLineInfoRun& bidiLineRun = *( bidirectionalLineInfoBuffer + mBidirectionalLineIndex );
+    const BidirectionalLineInfoRun& bidiLineRun = *(bidirectionalLineInfoBuffer + mBidirectionalLineIndex);
 
     const CharacterIndex lastCharacterOfRunPlusOne = bidiLineRun.characterRun.characterIndex + bidiLineRun.characterRun.numberOfCharacters;
-    if( ( bidiLineRun.characterRun.characterIndex <= characterIndex ) &&
-        ( characterIndex < lastCharacterOfRunPlusOne ) )
+    if((bidiLineRun.characterRun.characterIndex <= characterIndex) &&
+       (characterIndex < lastCharacterOfRunPlusOne))
     {
       // The character is in the previously fetched bidi line.
       return true;
@@ -229,7 +226,7 @@ bool LogicalModel::FetchBidirectionalLineInfo( CharacterIndex characterIndex )
       // The character is not in the previously fetched line.
       // Set the bidi line index from where to start the fetch.
 
-      if( characterIndex < bidiLineRun.characterRun.characterIndex )
+      if(characterIndex < bidiLineRun.characterRun.characterIndex)
       {
         // Start the fetch from the beginning.
         bidiLineIndex = 0u;
@@ -237,31 +234,31 @@ bool LogicalModel::FetchBidirectionalLineInfo( CharacterIndex characterIndex )
       else
       {
         // Start the fetch from the next line.
-        bidiLineIndex = mBidirectionalLineIndex + 1u;
+        bidiLineIndex                 = mBidirectionalLineIndex + 1u;
         lastCharacterOfRightToLeftRun = lastCharacterOfRunPlusOne - 1u;
       }
     }
   }
 
   // The character has not been found in the previously fetched bidi line.
-  for( Vector<BidirectionalLineInfoRun>::ConstIterator it = bidirectionalLineInfoBuffer + bidiLineIndex,
-         endIt = mBidirectionalLineInfo.End();
-       it != endIt;
-       ++it, ++bidiLineIndex )
+  for(Vector<BidirectionalLineInfoRun>::ConstIterator it    = bidirectionalLineInfoBuffer + bidiLineIndex,
+                                                      endIt = mBidirectionalLineInfo.End();
+      it != endIt;
+      ++it, ++bidiLineIndex)
   {
     const BidirectionalLineInfoRun& bidiLineRun = *it;
 
-    if( ( lastCharacterOfRightToLeftRun < characterIndex ) &&
-        ( characterIndex < bidiLineRun.characterRun.characterIndex ) )
+    if((lastCharacterOfRightToLeftRun < characterIndex) &&
+       (characterIndex < bidiLineRun.characterRun.characterIndex))
     {
       // The character is not inside a bidi line.
       return false;
     }
 
     const CharacterIndex lastCharacterOfRunPlusOne = bidiLineRun.characterRun.characterIndex + bidiLineRun.characterRun.numberOfCharacters;
-    lastCharacterOfRightToLeftRun = lastCharacterOfRunPlusOne - 1u;
-    if( ( bidiLineRun.characterRun.characterIndex <= characterIndex ) &&
-        ( characterIndex < lastCharacterOfRunPlusOne ) )
+    lastCharacterOfRightToLeftRun                  = lastCharacterOfRunPlusOne - 1u;
+    if((bidiLineRun.characterRun.characterIndex <= characterIndex) &&
+       (characterIndex < lastCharacterOfRunPlusOne))
     {
       // Bidi line found. Fetch the line.
       mBidirectionalLineIndex = bidiLineIndex;
@@ -277,65 +274,65 @@ BidirectionalLineRunIndex LogicalModel::GetBidirectionalLineInfo() const
   return mBidirectionalLineIndex;
 }
 
-void LogicalModel::UpdateTextStyleRuns( CharacterIndex index, int numberOfCharacters )
+void LogicalModel::UpdateTextStyleRuns(CharacterIndex index, int numberOfCharacters)
 {
   const Length totalNumberOfCharacters = mText.Count();
 
   // Process the color runs.
   Vector<ColorRun> removedColorRuns;
-  UpdateCharacterRuns<ColorRun>( index,
-                                 numberOfCharacters,
-                                 totalNumberOfCharacters,
-                                 mColorRuns,
-                                 removedColorRuns );
+  UpdateCharacterRuns<ColorRun>(index,
+                                numberOfCharacters,
+                                totalNumberOfCharacters,
+                                mColorRuns,
+                                removedColorRuns);
 
   // Process the background color runs.
   Vector<ColorRun> removedBackgroundColorRuns;
-  UpdateCharacterRuns<ColorRun>( index,
-                                 numberOfCharacters,
-                                 totalNumberOfCharacters,
-                                 mBackgroundColorRuns,
-                                 removedBackgroundColorRuns );
+  UpdateCharacterRuns<ColorRun>(index,
+                                numberOfCharacters,
+                                totalNumberOfCharacters,
+                                mBackgroundColorRuns,
+                                removedBackgroundColorRuns);
 
   // Process the font description runs.
   Vector<FontDescriptionRun> removedFontDescriptionRuns;
-  UpdateCharacterRuns<FontDescriptionRun>( index,
-                                           numberOfCharacters,
-                                           totalNumberOfCharacters,
-                                           mFontDescriptionRuns,
-                                           removedFontDescriptionRuns );
+  UpdateCharacterRuns<FontDescriptionRun>(index,
+                                          numberOfCharacters,
+                                          totalNumberOfCharacters,
+                                          mFontDescriptionRuns,
+                                          removedFontDescriptionRuns);
 
   // Free memory allocated for the font family name.
-  FreeFontFamilyNames( removedFontDescriptionRuns );
+  FreeFontFamilyNames(removedFontDescriptionRuns);
 }
 
-void LogicalModel::RetrieveStyle( CharacterIndex index, InputStyle& style )
+void LogicalModel::RetrieveStyle(CharacterIndex index, InputStyle& style)
 {
   unsigned int runIndex = 0u;
 
   // Set the text color.
-  bool colorOverriden = false;
-  unsigned int colorIndex = 0u;
+  bool                  colorOverriden  = false;
+  unsigned int          colorIndex      = 0u;
   const ColorRun* const colorRunsBuffer = mColorRuns.Begin();
-  for( Vector<ColorRun>::ConstIterator it = colorRunsBuffer,
-         endIt = mColorRuns.End();
-       it != endIt;
-       ++it, ++runIndex )
+  for(Vector<ColorRun>::ConstIterator it    = colorRunsBuffer,
+                                      endIt = mColorRuns.End();
+      it != endIt;
+      ++it, ++runIndex)
   {
     const ColorRun& colorRun = *it;
 
-    if( ( colorRun.characterRun.characterIndex <= index ) &&
-        ( index < colorRun.characterRun.characterIndex + colorRun.characterRun.numberOfCharacters ) )
+    if((colorRun.characterRun.characterIndex <= index) &&
+       (index < colorRun.characterRun.characterIndex + colorRun.characterRun.numberOfCharacters))
     {
-      colorIndex = runIndex;
+      colorIndex     = runIndex;
       colorOverriden = true;
     }
   }
 
   // Set the text's color if it's overriden.
-  if( colorOverriden )
+  if(colorOverriden)
   {
-    style.textColor = ( *( colorRunsBuffer + colorIndex ) ).color;
+    style.textColor      = (*(colorRunsBuffer + colorIndex)).color;
     style.isDefaultColor = false;
   }
 
@@ -343,125 +340,125 @@ void LogicalModel::RetrieveStyle( CharacterIndex index, InputStyle& style )
   runIndex = 0u;
 
   // Set the font's parameters.
-  bool nameOverriden = false;
-  bool weightOverriden = false;
-  bool widthOverriden = false;
-  bool slantOverriden = false;
-  bool sizeOverriden = false;
-  unsigned int nameIndex = 0u;
-  unsigned int weightIndex = 0u;
-  unsigned int widthIndex = 0u;
-  unsigned int slantIndex = 0u;
-  unsigned int sizeIndex = 0u;
+  bool                            nameOverriden             = false;
+  bool                            weightOverriden           = false;
+  bool                            widthOverriden            = false;
+  bool                            slantOverriden            = false;
+  bool                            sizeOverriden             = false;
+  unsigned int                    nameIndex                 = 0u;
+  unsigned int                    weightIndex               = 0u;
+  unsigned int                    widthIndex                = 0u;
+  unsigned int                    slantIndex                = 0u;
+  unsigned int                    sizeIndex                 = 0u;
   const FontDescriptionRun* const fontDescriptionRunsBuffer = mFontDescriptionRuns.Begin();
-  for( Vector<FontDescriptionRun>::ConstIterator it = fontDescriptionRunsBuffer,
-         endIt = mFontDescriptionRuns.End();
-       it != endIt;
-       ++it, ++runIndex )
+  for(Vector<FontDescriptionRun>::ConstIterator it    = fontDescriptionRunsBuffer,
+                                                endIt = mFontDescriptionRuns.End();
+      it != endIt;
+      ++it, ++runIndex)
   {
     const FontDescriptionRun& fontDescriptionRun = *it;
 
-    if( ( fontDescriptionRun.characterRun.characterIndex <= index ) &&
-        ( index < fontDescriptionRun.characterRun.characterIndex + fontDescriptionRun.characterRun.numberOfCharacters ) )
+    if((fontDescriptionRun.characterRun.characterIndex <= index) &&
+       (index < fontDescriptionRun.characterRun.characterIndex + fontDescriptionRun.characterRun.numberOfCharacters))
     {
-      if( fontDescriptionRun.familyDefined )
+      if(fontDescriptionRun.familyDefined)
       {
-        nameIndex = runIndex;
+        nameIndex     = runIndex;
         nameOverriden = true;
       }
 
-      if( fontDescriptionRun.weightDefined )
+      if(fontDescriptionRun.weightDefined)
       {
-        weightIndex = runIndex;
+        weightIndex     = runIndex;
         weightOverriden = true;
       }
 
-      if( fontDescriptionRun.widthDefined )
+      if(fontDescriptionRun.widthDefined)
       {
-        widthIndex = runIndex;
+        widthIndex     = runIndex;
         widthOverriden = true;
       }
 
-      if( fontDescriptionRun.slantDefined )
+      if(fontDescriptionRun.slantDefined)
       {
-        slantIndex = runIndex;
+        slantIndex     = runIndex;
         slantOverriden = true;
       }
 
-      if( fontDescriptionRun.sizeDefined )
+      if(fontDescriptionRun.sizeDefined)
       {
-        sizeIndex = runIndex;
+        sizeIndex     = runIndex;
         sizeOverriden = true;
       }
     }
   }
 
   // Set the font's family name if it's overriden.
-  if( nameOverriden )
+  if(nameOverriden)
   {
-    const FontDescriptionRun& fontDescriptionRun = *( fontDescriptionRunsBuffer + nameIndex );
+    const FontDescriptionRun& fontDescriptionRun = *(fontDescriptionRunsBuffer + nameIndex);
 
-    style.familyName = std::string( fontDescriptionRun.familyName, fontDescriptionRun.familyLength );
+    style.familyName      = std::string(fontDescriptionRun.familyName, fontDescriptionRun.familyLength);
     style.isFamilyDefined = true;
   }
 
   // Set the font's weight if it's overriden.
-  if( weightOverriden )
+  if(weightOverriden)
   {
-    const FontDescriptionRun& fontDescriptionRun = *( fontDescriptionRunsBuffer + weightIndex );
+    const FontDescriptionRun& fontDescriptionRun = *(fontDescriptionRunsBuffer + weightIndex);
 
-    style.weight = fontDescriptionRun.weight;
+    style.weight          = fontDescriptionRun.weight;
     style.isWeightDefined = true;
   }
 
   // Set the font's width if it's overriden.
-  if( widthOverriden )
+  if(widthOverriden)
   {
-    const FontDescriptionRun& fontDescriptionRun = *( fontDescriptionRunsBuffer + widthIndex );
+    const FontDescriptionRun& fontDescriptionRun = *(fontDescriptionRunsBuffer + widthIndex);
 
-    style.width = fontDescriptionRun.width;
+    style.width          = fontDescriptionRun.width;
     style.isWidthDefined = true;
   }
 
   // Set the font's slant if it's overriden.
-  if( slantOverriden )
+  if(slantOverriden)
   {
-    const FontDescriptionRun& fontDescriptionRun = *( fontDescriptionRunsBuffer + slantIndex );
+    const FontDescriptionRun& fontDescriptionRun = *(fontDescriptionRunsBuffer + slantIndex);
 
-    style.slant = fontDescriptionRun.slant;
+    style.slant          = fontDescriptionRun.slant;
     style.isSlantDefined = true;
   }
 
   // Set the font's size if it's overriden.
-  if( sizeOverriden )
+  if(sizeOverriden)
   {
-    const FontDescriptionRun& fontDescriptionRun = *( fontDescriptionRunsBuffer + sizeIndex );
+    const FontDescriptionRun& fontDescriptionRun = *(fontDescriptionRunsBuffer + sizeIndex);
 
-    style.size = static_cast<float>( fontDescriptionRun.size ) / 64.f;
+    style.size          = static_cast<float>(fontDescriptionRun.size) / 64.f;
     style.isSizeDefined = true;
   }
 }
 
 void LogicalModel::ClearFontDescriptionRuns()
 {
-  FreeFontFamilyNames( mFontDescriptionRuns );
+  FreeFontFamilyNames(mFontDescriptionRuns);
 }
 
-void LogicalModel::CreateParagraphInfo( CharacterIndex startIndex,
-                                        Length numberOfCharacters )
+void LogicalModel::CreateParagraphInfo(CharacterIndex startIndex,
+                                       Length         numberOfCharacters)
 {
   const Length totalNumberOfCharacters = mLineBreakInfo.Count();
 
   // Count the number of LINE_MUST_BREAK to reserve some space for the vector of paragraph's info.
   Vector<CharacterIndex> paragraphs;
-  paragraphs.Reserve( numberOfCharacters );
-  const TextAbstraction::LineBreakInfo* lineBreakInfoBuffer = mLineBreakInfo.Begin();
-  const CharacterIndex lastCharacterIndexPlusOne = startIndex + numberOfCharacters;
-  for( Length index = startIndex; index < lastCharacterIndexPlusOne; ++index )
+  paragraphs.Reserve(numberOfCharacters);
+  const TextAbstraction::LineBreakInfo* lineBreakInfoBuffer       = mLineBreakInfo.Begin();
+  const CharacterIndex                  lastCharacterIndexPlusOne = startIndex + numberOfCharacters;
+  for(Length index = startIndex; index < lastCharacterIndexPlusOne; ++index)
   {
-    if( TextAbstraction::LINE_MUST_BREAK == *( lineBreakInfoBuffer + index ) )
+    if(TextAbstraction::LINE_MUST_BREAK == *(lineBreakInfoBuffer + index))
     {
-      paragraphs.PushBack( index );
+      paragraphs.PushBack(index);
     }
   }
 
@@ -469,16 +466,16 @@ void LogicalModel::CreateParagraphInfo( CharacterIndex startIndex,
   const bool updateCurrentParagraphs = numberOfCharacters < totalNumberOfCharacters;
 
   // Reserve space for current paragraphs plus new ones.
-  const Length numberOfNewParagraphs = paragraphs.Count();
+  const Length numberOfNewParagraphs   = paragraphs.Count();
   const Length totalNumberOfParagraphs = mParagraphInfo.Count() + numberOfNewParagraphs;
-  mParagraphInfo.Resize( totalNumberOfParagraphs );
+  mParagraphInfo.Resize(totalNumberOfParagraphs);
 
-  ParagraphRun* paragraphInfoBuffer = NULL;
+  ParagraphRun*        paragraphInfoBuffer = NULL;
   Vector<ParagraphRun> newParagraphs;
 
-  if( updateCurrentParagraphs )
+  if(updateCurrentParagraphs)
   {
-    newParagraphs.Resize( numberOfNewParagraphs );
+    newParagraphs.Resize(numberOfNewParagraphs);
     paragraphInfoBuffer = newParagraphs.Begin();
   }
   else
@@ -488,18 +485,18 @@ void LogicalModel::CreateParagraphInfo( CharacterIndex startIndex,
 
   // Find where to insert the new paragraphs.
   ParagraphRunIndex paragraphIndex = 0u;
-  CharacterIndex firstIndex = startIndex;
+  CharacterIndex    firstIndex     = startIndex;
 
-  if( updateCurrentParagraphs )
+  if(updateCurrentParagraphs)
   {
-    for( Vector<ParagraphRun>::ConstIterator it = mParagraphInfo.Begin(),
-           endIt = mParagraphInfo.Begin() + totalNumberOfParagraphs - numberOfNewParagraphs;
-         it != endIt;
-         ++it )
+    for(Vector<ParagraphRun>::ConstIterator it    = mParagraphInfo.Begin(),
+                                            endIt = mParagraphInfo.Begin() + totalNumberOfParagraphs - numberOfNewParagraphs;
+        it != endIt;
+        ++it)
     {
-      const ParagraphRun& paragraph( *it );
+      const ParagraphRun& paragraph(*it);
 
-      if( startIndex < paragraph.characterRun.characterIndex + paragraph.characterRun.numberOfCharacters )
+      if(startIndex < paragraph.characterRun.characterIndex + paragraph.characterRun.numberOfCharacters)
       {
         firstIndex = paragraph.characterRun.characterIndex;
         break;
@@ -511,70 +508,69 @@ void LogicalModel::CreateParagraphInfo( CharacterIndex startIndex,
 
   // Create the paragraph info.
   ParagraphRunIndex newParagraphIndex = 0u;
-  for( Vector<CharacterIndex>::ConstIterator it = paragraphs.Begin(),
-         endIt = paragraphs.End();
-       it != endIt;
-       ++it, ++newParagraphIndex )
+  for(Vector<CharacterIndex>::ConstIterator it    = paragraphs.Begin(),
+                                            endIt = paragraphs.End();
+      it != endIt;
+      ++it, ++newParagraphIndex)
   {
     const CharacterIndex index = *it;
 
-    ParagraphRun& paragraph = *( paragraphInfoBuffer + newParagraphIndex );
-    paragraph.characterRun.characterIndex = firstIndex;
+    ParagraphRun& paragraph                   = *(paragraphInfoBuffer + newParagraphIndex);
+    paragraph.characterRun.characterIndex     = firstIndex;
     paragraph.characterRun.numberOfCharacters = 1u + index - firstIndex;
 
     firstIndex += paragraph.characterRun.numberOfCharacters;
   }
 
-
   // Insert the new paragraphs.
-  if( updateCurrentParagraphs )
+  if(updateCurrentParagraphs)
   {
-    mParagraphInfo.Insert( mParagraphInfo.Begin() + paragraphIndex,
-                           newParagraphs.Begin(),
-                           newParagraphs.End() );
+    mParagraphInfo.Insert(mParagraphInfo.Begin() + paragraphIndex,
+                          newParagraphs.Begin(),
+                          newParagraphs.End());
 
-    mParagraphInfo.Resize( totalNumberOfParagraphs );
+    mParagraphInfo.Resize(totalNumberOfParagraphs);
 
     // Update the next paragraph indices.
-    for( Vector<ParagraphRun>::Iterator it = mParagraphInfo.Begin() + paragraphIndex + newParagraphs.Count(),
-           endIt = mParagraphInfo.End();
-         it != endIt;
-         ++it )
+    for(Vector<ParagraphRun>::Iterator it    = mParagraphInfo.Begin() + paragraphIndex + newParagraphs.Count(),
+                                       endIt = mParagraphInfo.End();
+        it != endIt;
+        ++it)
     {
-      ParagraphRun& paragraph( *it );
+      ParagraphRun& paragraph(*it);
 
       paragraph.characterRun.characterIndex += numberOfCharacters;
     }
   }
 }
 
-void LogicalModel::FindParagraphs( CharacterIndex index,
-                                   Length numberOfCharacters,
-                                   Vector<ParagraphRunIndex>& paragraphs )
+void LogicalModel::FindParagraphs(CharacterIndex             index,
+                                  Length                     numberOfCharacters,
+                                  Vector<ParagraphRunIndex>& paragraphs)
 {
   // Reserve som space for the paragraph indices.
-  paragraphs.Reserve( mParagraphInfo.Count() );
+  paragraphs.Reserve(mParagraphInfo.Count());
 
   // Traverse the paragraphs to find which ones contain the given characters.
   ParagraphRunIndex paragraphIndex = 0u;
-  for( Vector<ParagraphRun>::ConstIterator it = mParagraphInfo.Begin(),
-         endIt = mParagraphInfo.End();
-       it != endIt;
-       ++it, ++paragraphIndex )
+  for(Vector<ParagraphRun>::ConstIterator it    = mParagraphInfo.Begin(),
+                                          endIt = mParagraphInfo.End();
+      it != endIt;
+      ++it, ++paragraphIndex)
   {
-    const ParagraphRun& paragraph( *it );
+    const ParagraphRun& paragraph(*it);
 
-    if( ( paragraph.characterRun.characterIndex + paragraph.characterRun.numberOfCharacters > index ) &&
-        ( paragraph.characterRun.characterIndex < index + numberOfCharacters ) )
+    if((paragraph.characterRun.characterIndex + paragraph.characterRun.numberOfCharacters > index) &&
+       (paragraph.characterRun.characterIndex < index + numberOfCharacters))
     {
-      paragraphs.PushBack( paragraphIndex );
+      paragraphs.PushBack(paragraphIndex);
     }
   }
 }
 
 void LogicalModel::ClearEmbeddedImages()
 {
-  FreeEmbeddedItems( mEmbeddedItems );
+  FreeEmbeddedItems(mEmbeddedItems);
 }
 
 LogicalModel::~LogicalModel()
@@ -584,7 +580,7 @@ LogicalModel::~LogicalModel()
 }
 
 LogicalModel::LogicalModel()
-: mBidirectionalLineIndex( 0u )
+: mBidirectionalLineIndex(0u)
 {
 }