fix issue when strikethrough used without ending tag
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / logical-model-impl.cpp
index 8ecab1f..4516662 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.
@@ -55,6 +55,16 @@ void FreeEmbeddedItems(Vector<EmbeddedItem>& embeddedItem)
   embeddedItem.Clear();
 }
 
+void FreeAnchors(Vector<Anchor>& anchors)
+{
+  for(auto&& anchor : anchors)
+  {
+    delete[] anchor.href;
+  }
+
+  anchors.Clear();
+}
+
 LogicalModelPtr LogicalModel::New()
 {
   return LogicalModelPtr(new LogicalModel());
@@ -286,6 +296,23 @@ void LogicalModel::UpdateTextStyleRuns(CharacterIndex index, int numberOfCharact
                                 mColorRuns,
                                 removedColorRuns);
 
+  // This is needed until now for underline tag in mark-up processor
+  // Process the underlined runs.
+  Vector<UnderlinedCharacterRun> removedUnderlinedCharacterRuns;
+  UpdateCharacterRuns<UnderlinedCharacterRun>(index,
+                                              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;
   UpdateCharacterRuns<ColorRun>(index,
@@ -444,6 +471,11 @@ void LogicalModel::ClearFontDescriptionRuns()
   FreeFontFamilyNames(mFontDescriptionRuns);
 }
 
+void LogicalModel::ClearStrikethroughRuns()
+{
+  mStrikethroughCharacterRuns.Clear();
+}
+
 void LogicalModel::CreateParagraphInfo(CharacterIndex startIndex,
                                        Length         numberOfCharacters)
 {
@@ -573,6 +605,11 @@ void LogicalModel::ClearEmbeddedImages()
   FreeEmbeddedItems(mEmbeddedItems);
 }
 
+void LogicalModel::ClearAnchors()
+{
+  FreeAnchors(mAnchors);
+}
+
 LogicalModel::~LogicalModel()
 {
   ClearFontDescriptionRuns();