Text improvement
[platform/core/uifw/dali-adaptor.git] / dali / internal / text / text-abstraction / bidirectional-support-impl.h
1 #ifndef __DALI_INTERNAL_TEXT_ABSTRACTION_BIDIRECTIONAL_SUPPORT_IMPL_H__
2 #define __DALI_INTERNAL_TEXT_ABSTRACTION_BIDIRECTIONAL_SUPPORT_IMPL_H__
3
4 /*
5  * Copyright (c) 2015 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 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/dali-vector.h>
23 #include <dali/public-api/object/base-object.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/devel-api/text-abstraction/bidirectional-support.h>
27
28 namespace Dali
29 {
30
31 namespace TextAbstraction
32 {
33
34 namespace Internal
35 {
36
37 /**
38  * Implementation of the BidirectionalSupport
39  */
40 class BidirectionalSupport : public BaseObject
41 {
42 public:
43
44   /**
45    * Constructor
46    */
47   BidirectionalSupport();
48
49   /**
50    * Destructor
51    */
52   ~BidirectionalSupport();
53
54   /**
55    * @copydoc Dali::BidirectionalSupport::Get()
56    */
57   static TextAbstraction::BidirectionalSupport Get();
58
59   /**
60    * @copydoc Dali::BidirectionalSupport::CreateInfo()
61    */
62   BidiInfoIndex CreateInfo( const Character* const paragraph,
63                             Length numberOfCharacters,
64                             bool matchSystemLanguageDirection,
65                             LayoutDirection::Type layoutDirection );
66
67   /**
68    * @copydoc Dali::BidirectionalSupport::DestroyInfo()
69    */
70   void DestroyInfo( BidiInfoIndex bidiInfoIndex );
71
72   /**
73    * @copydoc Dali::BidirectionalSupport::Reorder()
74    */
75   void Reorder( BidiInfoIndex bidiInfoIndex,
76                 CharacterIndex firstCharacterIndex,
77                 Length numberOfCharacters,
78                 CharacterIndex* visualToLogicalMap );
79
80   /**
81    * @copydoc Dali::BidirectionalSupport::GetMirroredText()
82    */
83   bool GetMirroredText( Character* text,
84                         CharacterDirection* directions,
85                         Length numberOfCharacters );
86
87   /**
88    * @copydoc Dali::BidirectionalSupport::GetParagraphDirection()
89    */
90   bool GetParagraphDirection( BidiInfoIndex bidiInfoIndex ) const;
91
92   /**
93    * @copydoc Dali::BidirectionalSupport::GetCharactersDirection()
94    */
95   void GetCharactersDirection( BidiInfoIndex bidiInfoIndex,
96                                CharacterDirection* directions,
97                                Length numberOfCharacters );
98
99 private:
100
101   /**
102    * Helper for lazy initialization.
103    */
104   void CreatePlugin();
105
106 private:
107
108   // Undefined copy constructor.
109   BidirectionalSupport( const BidirectionalSupport& );
110
111   // Undefined assignment constructor.
112   BidirectionalSupport& operator=( const BidirectionalSupport& );
113
114 private:
115
116   struct Plugin;
117   Plugin* mPlugin;
118
119 }; // class BidirectionalSupport
120
121 } // namespace Internal
122
123 } // namespace TextAbstraction
124
125 inline static TextAbstraction::Internal::BidirectionalSupport& GetImplementation( TextAbstraction::BidirectionalSupport& bidirectionalSupport )
126 {
127   DALI_ASSERT_ALWAYS( bidirectionalSupport && "bidirectional support handle is empty" );
128   BaseObject& handle = bidirectionalSupport.GetBaseObject();
129   return static_cast<TextAbstraction::Internal::BidirectionalSupport&>(handle);
130 }
131
132 inline static const TextAbstraction::Internal::BidirectionalSupport& GetImplementation( const TextAbstraction::BidirectionalSupport& bidirectionalSupport )
133 {
134   DALI_ASSERT_ALWAYS( bidirectionalSupport && "bidirectional support handle is empty" );
135   const BaseObject& handle = bidirectionalSupport.GetBaseObject();
136   return static_cast<const TextAbstraction::Internal::BidirectionalSupport&>(handle);
137 }
138
139 } // namespace Dali
140
141 #endif // __DALI_INTERNAL_TEXT_ABSTRACTION_BIDIRECTIONAL_SUPPORT_IMPL_H__