+ * @param[in] tag The current tag
+ * @param[in/out] characterIndex The current character index
+ */
+void ProcessAnchorTag(
+ MarkupProcessData& markupProcessData,
+ const Tag tag,
+ CharacterIndex& characterIndex)
+{
+ if(!tag.isEndTag)
+ {
+ // Create an anchor instance.
+ Anchor anchor;
+ anchor.startIndex = characterIndex;
+ anchor.endIndex = 0u;
+ ProcessAnchor(tag, anchor);
+ markupProcessData.anchors.PushBack(anchor);
+ }
+ else
+ {
+ // Update end index.
+ unsigned int count = markupProcessData.anchors.Count();
+ if(count > 0)
+ {
+ markupProcessData.anchors[count - 1].endIndex = characterIndex;
+ }
+ }
+}
+
+/**
+ * @brief Processes span tag for the color-run & font-run.
+ *
+ * @param[in] spanTag The tag we are currently processing
+ * @param[inout] spanStack The spans stack
+ * @param[inout] colorRuns The container containing all the color runs
+ * @param[inout] fontRuns The container containing all the font description runs
+ * @param[inout] underlinedCharacterRuns The container containing all the underlined character runs
+ * @param[inout] strikethroughCharacterRuns The container containing all the strikethroughed character runs
+ * @param[inout] colorRunIndex The color run index
+ * @param[inout] fontRunIndex The font run index
+ * @param[inout] underlinedCharacterRunIndex The underlined character run index
+ * @param[inout] strikethroughCharacterRunIndex The strikethroughed character run index
+ * @param[in] characterIndex The current character index
+ * @param[in] tagReference The tagReference we should increment/decrement
+ */
+void ProcessSpanForRun(
+ const Tag& spanTag,
+ StyleStack<Span>& spanStack,
+ Vector<ColorRun>& colorRuns,
+ Vector<FontDescriptionRun>& fontRuns,
+ Vector<UnderlinedCharacterRun>& underlinedCharacterRuns,
+ Vector<ColorRun>& backgroundColorRuns,
+ Vector<StrikethroughCharacterRun>& strikethroughCharacterRuns,
+ Vector<CharacterSpacingCharacterRun>& characterSpacingCharacterRuns,
+ RunIndex& colorRunIndex,
+ RunIndex& fontRunIndex,
+ RunIndex& underlinedCharacterRunIndex,
+ RunIndex& backgroundColorRunIndex,
+ RunIndex& strikethroughCharacterRunIndex,
+ RunIndex& characterSpacingCharacterRunIndex,
+ const CharacterIndex characterIndex,
+ int& tagReference)
+{
+ if(!spanTag.isEndTag)
+ {
+ // Create a new run.
+ ColorRun colorRun;
+ Initialize(colorRun);
+
+ FontDescriptionRun fontRun;
+ Initialize(fontRun);
+
+ UnderlinedCharacterRun underlinedCharacterRun;
+ Initialize(underlinedCharacterRun);
+
+ ColorRun backgroundColorRun;
+ Initialize(backgroundColorRun);
+
+ StrikethroughCharacterRun strikethroughCharacterRun;
+ Initialize(strikethroughCharacterRun);
+
+ CharacterSpacingCharacterRun characterSpacingCharacterRun;
+ Initialize(characterSpacingCharacterRun);
+
+ Span span;
+ Initialize(span);
+
+ // Fill the run with the parameters.
+ colorRun.characterRun.characterIndex = characterIndex;
+ fontRun.characterRun.characterIndex = characterIndex;
+ underlinedCharacterRun.characterRun.characterIndex = characterIndex;
+ backgroundColorRun.characterRun.characterIndex = characterIndex;
+ strikethroughCharacterRun.characterRun.characterIndex = characterIndex;
+ characterSpacingCharacterRun.characterRun.characterIndex = characterIndex;
+
+ span.colorRunIndex = colorRunIndex;
+ span.fontRunIndex = fontRunIndex;
+ span.underlinedCharacterRunIndex = underlinedCharacterRunIndex;
+ span.backgroundColorRunIndex = backgroundColorRunIndex;
+ span.strikethroughCharacterRunIndex = strikethroughCharacterRunIndex;
+ span.characterSpacingCharacterRunIndex = characterSpacingCharacterRunIndex;
+
+ ProcessSpanTag(spanTag,
+ colorRun,
+ fontRun,
+ underlinedCharacterRun,
+ backgroundColorRun,
+ strikethroughCharacterRun,
+ characterSpacingCharacterRun,
+ span.isColorDefined,
+ span.isFontDefined,
+ span.isUnderlinedCharacterDefined,
+ span.isBackgroundColorDefined,
+ span.isStrikethroughDefined,
+ span.isCharacterSpacingDefined);
+
+ // Push the span into the stack.
+ spanStack.Push(span);
+
+ // Point the next free run.
+ if(span.isColorDefined)
+ {
+ // Push the run in the logical model.
+ colorRuns.PushBack(colorRun);
+ ++colorRunIndex;
+ }
+
+ if(span.isFontDefined)
+ {
+ // Push the run in the logical model.
+ fontRuns.PushBack(fontRun);
+ ++fontRunIndex;
+ }
+
+ if(span.isUnderlinedCharacterDefined)
+ {
+ // Push the run in the logical model.
+ underlinedCharacterRuns.PushBack(underlinedCharacterRun);
+ ++underlinedCharacterRunIndex;
+ }
+
+ if(span.isBackgroundColorDefined)
+ {
+ // Push the run in the logical model.
+ backgroundColorRuns.PushBack(backgroundColorRun);
+ ++backgroundColorRunIndex;
+ }
+
+ if(span.isStrikethroughDefined)
+ {
+ // Push the run in the logical model.
+ strikethroughCharacterRuns.PushBack(strikethroughCharacterRun);
+ ++strikethroughCharacterRunIndex;
+ }
+
+ if(span.isCharacterSpacingDefined)
+ {
+ // Push the run in the logical model.
+ characterSpacingCharacterRuns.PushBack(characterSpacingCharacterRun);
+ ++characterSpacingCharacterRunIndex;
+ }
+
+ // Increase reference
+ ++tagReference;
+ }
+ else
+ {
+ if(tagReference > 0)
+ {
+ // Pop the top of the stack and set the number of characters of the run.
+ Span span = spanStack.Pop();
+
+ if(span.isColorDefined)
+ {
+ ColorRun& colorRun = *(colorRuns.Begin() + span.colorRunIndex);
+ colorRun.characterRun.numberOfCharacters = characterIndex - colorRun.characterRun.characterIndex;
+ }
+
+ if(span.isFontDefined)
+ {
+ FontDescriptionRun& fontRun = *(fontRuns.Begin() + span.fontRunIndex);
+ fontRun.characterRun.numberOfCharacters = characterIndex - fontRun.characterRun.characterIndex;
+ }
+
+ if(span.isUnderlinedCharacterDefined)
+ {
+ UnderlinedCharacterRun& underlinedCharacterRun = *(underlinedCharacterRuns.Begin() + span.underlinedCharacterRunIndex);
+ underlinedCharacterRun.characterRun.numberOfCharacters = characterIndex - underlinedCharacterRun.characterRun.characterIndex;
+ }
+
+ if(span.isBackgroundColorDefined)
+ {
+ ColorRun& backgroundColorRun = *(backgroundColorRuns.Begin() + span.backgroundColorRunIndex);
+ backgroundColorRun.characterRun.numberOfCharacters = characterIndex - backgroundColorRun.characterRun.characterIndex;
+ }
+
+ if(span.isStrikethroughDefined)
+ {
+ StrikethroughCharacterRun& strikethroughCharacterRun = *(strikethroughCharacterRuns.Begin() + span.strikethroughCharacterRunIndex);
+ strikethroughCharacterRun.characterRun.numberOfCharacters = characterIndex - strikethroughCharacterRun.characterRun.characterIndex;
+ }
+
+ if(span.isCharacterSpacingDefined)
+ {
+ CharacterSpacingCharacterRun& characterSpacingCharacterRun = *(characterSpacingCharacterRuns.Begin() + span.characterSpacingCharacterRunIndex);
+ characterSpacingCharacterRun.characterRun.numberOfCharacters = characterIndex - characterSpacingCharacterRun.characterRun.characterIndex;
+ }
+
+ --tagReference;
+ }
+ }
+}
+
+/**
+ * @brief Resizes the model's vectors
+ *
+ * @param[inout] markupProcessData The markup process data