cc2fd60f4e4274304338253717e49d2466ca505e
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / text-view / text-processor.h
1 #ifndef __DALI_TOOLKIT_TEXT_PROCESSOR_H__
2 #define __DALI_TOOLKIT_TEXT_PROCESSOR_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/markup-processor/markup-processor.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal
31 {
32
33 namespace TextProcessor
34 {
35
36 /**
37  * Splits the given text in lines.
38  *
39  * @note Assumes the StyledTextArray has 1 Character per Text element. (which is the case for text in TextInput, but
40  * not necessarily the case for text in TextView)
41  *
42  * @param [in] text The given text.
43  * @param [out] lines The text split in lines.
44  */
45 void SplitInLines( const MarkupProcessor::StyledTextArray& text,
46                    std::vector<MarkupProcessor::StyledTextArray>& lines );
47
48 /**
49  * Splits the given line in words.
50  *
51  * @note Assumes the StyledTextArray has 1 Character per Text element. (which is the case for text in TextInput, but
52  * not necessarily the case for text in TextView)
53  *
54  * @param [in] line The given line.
55  * @param [out] words The line split in words.
56  */
57 void SplitInWords( const MarkupProcessor::StyledTextArray& line,
58                    std::vector<MarkupProcessor::StyledTextArray>& words );
59
60 /**
61  * Whether the text begins with right-to-left (bidirectional) character.
62  * @param [in] text The given text.
63  * @return \e true if the text begins right-to-left character.
64  */
65 bool BeginsRightToLeftCharacter( const Text& text );
66
67 /**
68  * @copydoc BeginsRightToLeftCharacter( const Text& text )
69  */
70 bool BeginsRightToLeftCharacter( const MarkupProcessor::StyledTextArray& text );
71
72 /**
73  * Whether the text contains any right-to-left (bidirectional) character.
74  * @param [in] text The given text.
75  * @return \e true if the text contains right-to-left character.
76  */
77 bool ContainsRightToLeftCharacter( const Text& text );
78
79 /**
80  * @copydoc ContainsRightToLeftCharacter( const Text& text )
81  */
82 bool ContainsRightToLeftCharacter( const MarkupProcessor::StyledTextArray& text );
83
84 /**
85  * Convert the text as specified by the Unicode Bidirectional Algorithm.
86  * The text is converted only if it is bidirectional.
87  * @param[in] line The line of text to be converted.
88  * @param[out] convertedText The text converted. Text is grouped in chunks which only have one direction.
89  * @param[out] logicalToVisualMap The character position map from the logical input text to the visual output text.
90  * @param[out] visualToLogicalMap The character position map from the visual output text to the logical input text.
91  */
92  void ConvertBidirectionalText( const MarkupProcessor::StyledTextArray& line,
93                                 std::vector<MarkupProcessor::StyledTextArray>& convertedText,
94                                 std::vector<int>& logicalToVisualMap,
95                                 std::vector<int>& visualToLogicalMap );
96
97 /**
98  * Finds the nearest word in a string to a specified
99  * offset (in Characters).
100  *
101  * @note Assumes the StyledTextArray has 1 Character per Text element. (which is the case for text in TextInput, but
102  * not necessarily the case for text in TextView)
103  *
104  * @param[in] text The text to search through.
105  * @param[in] offset The current offset position to begin search from.
106  * @param[out] start The start position of nearest word
107  * @param[out] end The end position of nearest word
108  */
109 void FindNearestWord( const MarkupProcessor::StyledTextArray& text, size_t offset, size_t& start, size_t& end);
110
111 } // namespace TextProcessor
112
113 } // namespace Internal
114
115 } // namespace DaliToolkit
116
117 } // namespace Dali
118
119 #endif // __DALI_TOOLKIT_TEXT_PROCESSOR_H__