Moved Text Controller & Markup Processor to sub-folders
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / markup-processor / markup-processor-span.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // FILE HEADER
19 #include <dali-toolkit/internal/text/markup-processor/markup-processor-color.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/dali-vector.h>
23
24 // INTERNAL INCLUDES
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/markup-processor-character-spacing.h>
28 #include <dali-toolkit/internal/text/markup-processor/markup-processor-font.h>
29 #include <dali-toolkit/internal/text/markup-processor/markup-processor-helper-functions.h>
30 #include <dali-toolkit/internal/text/markup-processor/markup-processor-strikethrough.h>
31 #include <dali-toolkit/internal/text/markup-processor/markup-processor-underline.h>
32 #include <dali-toolkit/internal/text/markup-tags-and-attributes.h>
33
34 namespace Dali
35 {
36 namespace Toolkit
37 {
38 namespace Text
39 {
40 void ProcessSpanTag(const Tag&                    tag,
41                     ColorRun&                     colorRun,
42                     FontDescriptionRun&           fontRun,
43                     UnderlinedCharacterRun&       underlinedCharacterRun,
44                     ColorRun&                     backgroundColorRun,
45                     StrikethroughCharacterRun&    strikethroughRun,
46                     CharacterSpacingCharacterRun& characterSpacingCharacterRun,
47                     bool&                         isColorDefined,
48                     bool&                         isFontDefined,
49                     bool&                         isUnderlinedCharacterDefined,
50                     bool&                         isBackgroundColorDefined,
51                     bool&                         isStrikethroughDefined,
52                     bool&                         isCharacterSpacingDefined)
53 {
54   for(Vector<Attribute>::ConstIterator it    = tag.attributes.Begin(),
55                                        endIt = tag.attributes.End();
56       it != endIt;
57       ++it)
58   {
59     const Attribute& attribute(*it);
60
61     if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::TEXT_COLOR, attribute.nameBuffer, attribute.nameLength))
62     {
63       isColorDefined = true;
64       ProcessColor(attribute, colorRun);
65     }
66     else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::BACKGROUND_COLOR, attribute.nameBuffer, attribute.nameLength))
67     {
68       isBackgroundColorDefined = true;
69       ProcessColor(attribute, backgroundColorRun);
70     }
71     else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::FONT_FAMILY, attribute.nameBuffer, attribute.nameLength))
72     {
73       isFontDefined = true;
74       ProcessFontFamily(attribute, fontRun);
75     }
76     else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::FONT_SIZE, attribute.nameBuffer, attribute.nameLength))
77     {
78       isFontDefined = true;
79       ProcessFontSize(attribute, fontRun);
80     }
81     else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::FONT_WEIGHT, attribute.nameBuffer, attribute.nameLength))
82     {
83       isFontDefined = true;
84       ProcessFontWeight(attribute, fontRun);
85     }
86     else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::FONT_WIDTH, attribute.nameBuffer, attribute.nameLength))
87     {
88       isFontDefined = true;
89       ProcessFontWidth(attribute, fontRun);
90     }
91     else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::FONT_SLANT, attribute.nameBuffer, attribute.nameLength))
92     {
93       isFontDefined = true;
94       ProcessFontSlant(attribute, fontRun);
95     }
96     else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::UNDERLINE_COLOR, attribute.nameBuffer, attribute.nameLength))
97     {
98       isUnderlinedCharacterDefined = true;
99       ProcessColorAttribute(attribute, underlinedCharacterRun);
100     }
101     else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::UNDERLINE_HEIGHT, attribute.nameBuffer, attribute.nameLength))
102     {
103       isUnderlinedCharacterDefined = true;
104       ProcessHeightAttribute(attribute, underlinedCharacterRun);
105     }
106     else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::UNDERLINE_TYPE, attribute.nameBuffer, attribute.nameLength))
107     {
108       isUnderlinedCharacterDefined = true;
109       ProcessTypeAttribute(attribute, underlinedCharacterRun);
110     }
111     else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::UNDERLINE_DASH_GAP, attribute.nameBuffer, attribute.nameLength))
112     {
113       isUnderlinedCharacterDefined = true;
114       ProcessDashGapAttribute(attribute, underlinedCharacterRun);
115     }
116     else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::UNDERLINE_DASH_WIDTH, attribute.nameBuffer, attribute.nameLength))
117     {
118       isUnderlinedCharacterDefined = true;
119       ProcessDashWidthAttribute(attribute, underlinedCharacterRun);
120     }
121     else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::STRIKETHROUGH_COLOR, attribute.nameBuffer, attribute.nameLength))
122     {
123       isStrikethroughDefined = true;
124       ProcessColorAttribute(attribute, strikethroughRun);
125     }
126     else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::STRIKETHROUGH_HEIGHT, attribute.nameBuffer, attribute.nameLength))
127     {
128       isStrikethroughDefined = true;
129       ProcessHeightAttribute(attribute, strikethroughRun);
130     }
131     else if(TokenComparison(MARKUP::SPAN_ATTRIBUTES::CHARACTER_SPACING_VALUE, attribute.nameBuffer, attribute.nameLength))
132     {
133       isCharacterSpacingDefined = true;
134       ProcessValueAttribute(attribute, characterSpacingCharacterRun);
135     }
136   }
137 }
138
139 } // namespace Text
140
141 } // namespace Toolkit
142
143 } // namespace Dali