Support paragraph tag <p> in markup
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / logical-model-impl.cpp
index 0de63d5..9ad00bc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -19,6 +19,7 @@
 #include <dali-toolkit/internal/text/logical-model-impl.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/bounded-paragraph-helper-functions.h>
 #include <dali-toolkit/internal/text/input-style.h>
 #include <dali-toolkit/internal/text/text-run-container.h>
 
@@ -300,10 +301,18 @@ void LogicalModel::UpdateTextStyleRuns(CharacterIndex index, int numberOfCharact
   // Process the underlined runs.
   Vector<UnderlinedCharacterRun> removedUnderlinedCharacterRuns;
   UpdateCharacterRuns<UnderlinedCharacterRun>(index,
-                                numberOfCharacters,
-                                totalNumberOfCharacters,
-                                mUnderlinedCharacterRuns,
-                                removedUnderlinedCharacterRuns);
+                                              numberOfCharacters,
+                                              totalNumberOfCharacters,
+                                              mUnderlinedCharacterRuns,
+                                              removedUnderlinedCharacterRuns);
+
+  // Process the strikethrough runs.
+  Vector<StrikethroughCharacterRun> removedStrikethroughCharacterRuns;
+  UpdateCharacterRuns<StrikethroughCharacterRun>(index,
+                                                 numberOfCharacters,
+                                                 totalNumberOfCharacters,
+                                                 mStrikethroughCharacterRuns,
+                                                 removedStrikethroughCharacterRuns);
 
   // Process the background color runs.
   Vector<ColorRun> removedBackgroundColorRuns;
@@ -323,6 +332,19 @@ void LogicalModel::UpdateTextStyleRuns(CharacterIndex index, int numberOfCharact
 
   // Free memory allocated for the font family name.
   FreeFontFamilyNames(removedFontDescriptionRuns);
+
+  // Process the bounded paragraph runs
+  MergeBoundedParagraphRunsWhenRemoveCharacters(mText,
+                                                index,
+                                                numberOfCharacters,
+                                                mBoundedParagraphRuns);
+
+  Vector<BoundedParagraphRun> removedBoundedParagraphRuns;
+  UpdateCharacterRuns<BoundedParagraphRun>(index,
+                                           numberOfCharacters,
+                                           totalNumberOfCharacters,
+                                           mBoundedParagraphRuns,
+                                           removedBoundedParagraphRuns);
 }
 
 void LogicalModel::RetrieveStyle(CharacterIndex index, InputStyle& style)
@@ -463,6 +485,11 @@ void LogicalModel::ClearFontDescriptionRuns()
   FreeFontFamilyNames(mFontDescriptionRuns);
 }
 
+void LogicalModel::ClearStrikethroughRuns()
+{
+  mStrikethroughCharacterRuns.Clear();
+}
+
 void LogicalModel::CreateParagraphInfo(CharacterIndex startIndex,
                                        Length         numberOfCharacters)
 {
@@ -587,6 +614,16 @@ void LogicalModel::FindParagraphs(CharacterIndex             index,
   }
 }
 
+Length LogicalModel::GetNumberOfBoundedParagraphRuns() const
+{
+  return mBoundedParagraphRuns.Count();
+}
+
+const Vector<BoundedParagraphRun>& LogicalModel::GetBoundedParagraphRuns() const
+{
+  return mBoundedParagraphRuns;
+}
+
 void LogicalModel::ClearEmbeddedImages()
 {
   FreeEmbeddedItems(mEmbeddedItems);