2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/text/markup-processor-color.h>
22 #include <dali/public-api/common/dali-vector.h>
25 #include <dali-toolkit/internal/text/color-run.h>
26 #include <dali-toolkit/internal/text/font-description-run.h>
27 #include <dali-toolkit/internal/text/markup-processor-character-spacing.h>
28 #include <dali-toolkit/internal/text/markup-processor-font.h>
29 #include <dali-toolkit/internal/text/markup-processor-helper-functions.h>
30 #include <dali-toolkit/internal/text/markup-processor-strikethrough.h>
31 #include <dali-toolkit/internal/text/markup-processor-underline.h>
32 #include <dali-toolkit/internal/text/markup-tags-and-attributes.h>
40 void ProcessSpanTag(const Tag& tag,
42 FontDescriptionRun& fontRun,
43 UnderlinedCharacterRun& underlinedCharacterRun,
44 ColorRun& backgroundColorRun,
45 StrikethroughCharacterRun& strikethroughRun,
46 CharacterSpacingCharacterRun& characterSpacingCharacterRun,
49 bool& isUnderlinedCharacterDefined,
50 bool& isBackgroundColorDefined,
51 bool& isStrikethroughDefined,
52 bool& isCharacterSpacingDefined)
54 for(Vector<Attribute>::ConstIterator it = tag.attributes.Begin(),
55 endIt = tag.attributes.End();
59 const Attribute& attribute(*it);
61 if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::TEXT_COLOR, attribute.nameBuffer, attribute.nameLength))
63 isColorDefined = true;
64 ProcessColor(attribute, colorRun);
66 else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::BACKGROUND_COLOR, attribute.nameBuffer, attribute.nameLength))
68 isBackgroundColorDefined = true;
69 ProcessColor(attribute, backgroundColorRun);
71 else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::FONT_FAMILY, attribute.nameBuffer, attribute.nameLength))
74 ProcessFontFamily(attribute, fontRun);
76 else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::FONT_SIZE, attribute.nameBuffer, attribute.nameLength))
79 ProcessFontSize(attribute, fontRun);
81 else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::FONT_WEIGHT, attribute.nameBuffer, attribute.nameLength))
84 ProcessFontWeight(attribute, fontRun);
86 else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::FONT_WIDTH, attribute.nameBuffer, attribute.nameLength))
89 ProcessFontWidth(attribute, fontRun);
91 else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::FONT_SLANT, attribute.nameBuffer, attribute.nameLength))
94 ProcessFontSlant(attribute, fontRun);
96 else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::UNDERLINE_COLOR, attribute.nameBuffer, attribute.nameLength))
98 isUnderlinedCharacterDefined = true;
99 ProcessColorAttribute(attribute, underlinedCharacterRun);
101 else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::UNDERLINE_HEIGHT, attribute.nameBuffer, attribute.nameLength))
103 isUnderlinedCharacterDefined = true;
104 ProcessHeightAttribute(attribute, underlinedCharacterRun);
106 else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::UNDERLINE_TYPE, attribute.nameBuffer, attribute.nameLength))
108 isUnderlinedCharacterDefined = true;
109 ProcessTypeAttribute(attribute, underlinedCharacterRun);
111 else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::UNDERLINE_DASH_GAP, attribute.nameBuffer, attribute.nameLength))
113 isUnderlinedCharacterDefined = true;
114 ProcessDashGapAttribute(attribute, underlinedCharacterRun);
116 else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::UNDERLINE_DASH_WIDTH, attribute.nameBuffer, attribute.nameLength))
118 isUnderlinedCharacterDefined = true;
119 ProcessDashWidthAttribute(attribute, underlinedCharacterRun);
121 else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::STRIKETHROUGH_COLOR, attribute.nameBuffer, attribute.nameLength))
123 isStrikethroughDefined = true;
124 ProcessColorAttribute(attribute, strikethroughRun);
126 else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::STRIKETHROUGH_HEIGHT, attribute.nameBuffer, attribute.nameLength))
128 isStrikethroughDefined = true;
129 ProcessHeightAttribute(attribute, strikethroughRun);
131 else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::CHARACTER_SPACING_VALUE, attribute.nameBuffer, attribute.nameLength))
133 isCharacterSpacingDefined = true;
134 ProcessValueAttribute(attribute, characterSpacingCharacterRun);
141 } // namespace Toolkit