• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_SRC_FXCRT_FX_ARABIC_H_
8 #define CORE_SRC_FXCRT_FX_ARABIC_H_
9 
10 #include "core/include/fxcrt/fx_arb.h"
11 
12 class CFX_ArabicChar : public IFX_ArabicChar {
13  public:
Release()14   virtual void Release() { delete this; }
15   virtual FX_BOOL IsArabicChar(FX_WCHAR wch) const;
16   virtual FX_BOOL IsArabicFormChar(FX_WCHAR wch) const;
17 
18   virtual FX_WCHAR GetFormChar(FX_WCHAR wch,
19                                FX_WCHAR prev = 0,
20                                FX_WCHAR next = 0) const;
21   virtual FX_WCHAR GetFormChar(const CFX_Char* cur,
22                                const CFX_Char* prev,
23                                const CFX_Char* next) const;
24 
25  protected:
26   const FX_ARBFORMTABLE* ParseChar(const CFX_Char* pTC,
27                                    FX_WCHAR& wChar,
28                                    FX_CHARTYPE& eType) const;
29 };
30 void FX_BidiReverseString(CFX_WideString& wsText,
31                           int32_t iStart,
32                           int32_t iCount);
33 void FX_BidiSetDeferredRun(CFX_Int32Array& values,
34                            int32_t iStart,
35                            int32_t iCount,
36                            int32_t iValue);
37 #define FX_BCON FX_BIDICLASS_ON
38 #define FX_BCL FX_BIDICLASS_L
39 #define FX_BCR FX_BIDICLASS_R
40 #define FX_BCAN FX_BIDICLASS_AN
41 #define FX_BCEN FX_BIDICLASS_EN
42 #define FX_BCAL FX_BIDICLASS_AL
43 #define FX_BCNSM FX_BIDICLASS_NSM
44 #define FX_BCCS FX_BIDICLASS_CS
45 #define FX_BCES FX_BIDICLASS_ES
46 #define FX_BCET FX_BIDICLASS_ET
47 #define FX_BCBN FX_BIDICLASS_BN
48 #define FX_BCS FX_BIDICLASS_S
49 #define FX_BCWS FX_BIDICLASS_WS
50 #define FX_BCB FX_BIDICLASS_B
51 #define FX_BCRLO FX_BIDICLASS_RLO
52 #define FX_BCRLE FX_BIDICLASS_RLE
53 #define FX_BCLRO FX_BIDICLASS_LRO
54 #define FX_BCLRE FX_BIDICLASS_LRE
55 #define FX_BCPDF FX_BIDICLASS_PDF
56 #define FX_BCN FX_BIDICLASS_N
57 void FX_BidiClassify(const CFX_WideString& wsText,
58                      CFX_Int32Array& classes,
59                      FX_BOOL bWS = FALSE);
60 #define FX_BIDIMAXLEVEL 61
61 #define FX_BidiGreaterEven(a) (FX_IsOdd(a) ? ((a) + 1) : ((a) + 2))
62 #define FX_BidiGreaterOdd(a) (FX_IsOdd(a) ? ((a) + 2) : ((a) + 1))
63 int32_t FX_BidiResolveExplicit(int32_t iBaseLevel,
64                                int32_t iDirection,
65                                CFX_Int32Array& classes,
66                                CFX_Int32Array& levels,
67                                int32_t iStart,
68                                int32_t iCount,
69                                int32_t iNest = 0);
70 #define FX_BidiDirection(a) (FX_IsOdd(a) ? FX_BIDICLASS_R : FX_BIDICLASS_L)
71 enum FX_BIDIWEAKSTATE {
72   FX_BIDIWEAKSTATE_xa = 0,
73   FX_BIDIWEAKSTATE_xr,
74   FX_BIDIWEAKSTATE_xl,
75   FX_BIDIWEAKSTATE_ao,
76   FX_BIDIWEAKSTATE_ro,
77   FX_BIDIWEAKSTATE_lo,
78   FX_BIDIWEAKSTATE_rt,
79   FX_BIDIWEAKSTATE_lt,
80   FX_BIDIWEAKSTATE_cn,
81   FX_BIDIWEAKSTATE_ra,
82   FX_BIDIWEAKSTATE_re,
83   FX_BIDIWEAKSTATE_la,
84   FX_BIDIWEAKSTATE_le,
85   FX_BIDIWEAKSTATE_ac,
86   FX_BIDIWEAKSTATE_rc,
87   FX_BIDIWEAKSTATE_rs,
88   FX_BIDIWEAKSTATE_lc,
89   FX_BIDIWEAKSTATE_ls,
90   FX_BIDIWEAKSTATE_ret,
91   FX_BIDIWEAKSTATE_let,
92 };
93 #define FX_BWSxa FX_BIDIWEAKSTATE_xa
94 #define FX_BWSxr FX_BIDIWEAKSTATE_xr
95 #define FX_BWSxl FX_BIDIWEAKSTATE_xl
96 #define FX_BWSao FX_BIDIWEAKSTATE_ao
97 #define FX_BWSro FX_BIDIWEAKSTATE_ro
98 #define FX_BWSlo FX_BIDIWEAKSTATE_lo
99 #define FX_BWSrt FX_BIDIWEAKSTATE_rt
100 #define FX_BWSlt FX_BIDIWEAKSTATE_lt
101 #define FX_BWScn FX_BIDIWEAKSTATE_cn
102 #define FX_BWSra FX_BIDIWEAKSTATE_ra
103 #define FX_BWSre FX_BIDIWEAKSTATE_re
104 #define FX_BWSla FX_BIDIWEAKSTATE_la
105 #define FX_BWSle FX_BIDIWEAKSTATE_le
106 #define FX_BWSac FX_BIDIWEAKSTATE_ac
107 #define FX_BWSrc FX_BIDIWEAKSTATE_rc
108 #define FX_BWSrs FX_BIDIWEAKSTATE_rs
109 #define FX_BWSlc FX_BIDIWEAKSTATE_lc
110 #define FX_BWSls FX_BIDIWEAKSTATE_ls
111 #define FX_BWSret FX_BIDIWEAKSTATE_ret
112 #define FX_BWSlet FX_BIDIWEAKSTATE_let
113 enum FX_BIDIWEAKACTION {
114   FX_BIDIWEAKACTION_IX = 0x100,
115   FX_BIDIWEAKACTION_XX = 0x0F,
116   FX_BIDIWEAKACTION_xxx = (0x0F << 4) + 0x0F,
117   FX_BIDIWEAKACTION_xIx = 0x100 + FX_BIDIWEAKACTION_xxx,
118   FX_BIDIWEAKACTION_xxN = (0x0F << 4) + FX_BIDICLASS_ON,
119   FX_BIDIWEAKACTION_xxE = (0x0F << 4) + FX_BIDICLASS_EN,
120   FX_BIDIWEAKACTION_xxA = (0x0F << 4) + FX_BIDICLASS_AN,
121   FX_BIDIWEAKACTION_xxR = (0x0F << 4) + FX_BIDICLASS_R,
122   FX_BIDIWEAKACTION_xxL = (0x0F << 4) + FX_BIDICLASS_L,
123   FX_BIDIWEAKACTION_Nxx = (FX_BIDICLASS_ON << 4) + 0x0F,
124   FX_BIDIWEAKACTION_Axx = (FX_BIDICLASS_AN << 4) + 0x0F,
125   FX_BIDIWEAKACTION_ExE = (FX_BIDICLASS_EN << 4) + FX_BIDICLASS_EN,
126   FX_BIDIWEAKACTION_NIx = (FX_BIDICLASS_ON << 4) + 0x0F + 0x100,
127   FX_BIDIWEAKACTION_NxN = (FX_BIDICLASS_ON << 4) + FX_BIDICLASS_ON,
128   FX_BIDIWEAKACTION_NxR = (FX_BIDICLASS_ON << 4) + FX_BIDICLASS_R,
129   FX_BIDIWEAKACTION_NxE = (FX_BIDICLASS_ON << 4) + FX_BIDICLASS_EN,
130   FX_BIDIWEAKACTION_AxA = (FX_BIDICLASS_AN << 4) + FX_BIDICLASS_AN,
131   FX_BIDIWEAKACTION_NxL = (FX_BIDICLASS_ON << 4) + FX_BIDICLASS_L,
132   FX_BIDIWEAKACTION_LxL = (FX_BIDICLASS_L << 4) + FX_BIDICLASS_L,
133   FX_BIDIWEAKACTION_xIL = (0x0F << 4) + FX_BIDICLASS_L + 0x100,
134   FX_BIDIWEAKACTION_AxR = (FX_BIDICLASS_AN << 4) + FX_BIDICLASS_R,
135   FX_BIDIWEAKACTION_Lxx = (FX_BIDICLASS_L << 4) + 0x0F,
136 };
137 #define FX_BWAIX FX_BIDIWEAKACTION_IX
138 #define FX_BWAXX FX_BIDIWEAKACTION_XX
139 #define FX_BWAxxx FX_BIDIWEAKACTION_xxx
140 #define FX_BWAxIx FX_BIDIWEAKACTION_xIx
141 #define FX_BWAxxN FX_BIDIWEAKACTION_xxN
142 #define FX_BWAxxE FX_BIDIWEAKACTION_xxE
143 #define FX_BWAxxA FX_BIDIWEAKACTION_xxA
144 #define FX_BWAxxR FX_BIDIWEAKACTION_xxR
145 #define FX_BWAxxL FX_BIDIWEAKACTION_xxL
146 #define FX_BWANxx FX_BIDIWEAKACTION_Nxx
147 #define FX_BWAAxx FX_BIDIWEAKACTION_Axx
148 #define FX_BWAExE FX_BIDIWEAKACTION_ExE
149 #define FX_BWANIx FX_BIDIWEAKACTION_NIx
150 #define FX_BWANxN FX_BIDIWEAKACTION_NxN
151 #define FX_BWANxR FX_BIDIWEAKACTION_NxR
152 #define FX_BWANxE FX_BIDIWEAKACTION_NxE
153 #define FX_BWAAxA FX_BIDIWEAKACTION_AxA
154 #define FX_BWANxL FX_BIDIWEAKACTION_NxL
155 #define FX_BWALxL FX_BIDIWEAKACTION_LxL
156 #define FX_BWAxIL FX_BIDIWEAKACTION_xIL
157 #define FX_BWAAxR FX_BIDIWEAKACTION_AxR
158 #define FX_BWALxx FX_BIDIWEAKACTION_Lxx
159 #define FX_BidiGetDeferredType(a) (((a) >> 4) & 0x0F)
160 #define FX_BidiGetResolvedType(a) ((a)&0x0F)
161 void FX_BidiResolveWeak(int32_t iBaseLevel,
162                         CFX_Int32Array& classes,
163                         CFX_Int32Array& levels);
164 enum FX_BIDINEUTRALSTATE {
165   FX_BIDINEUTRALSTATE_r = 0,
166   FX_BIDINEUTRALSTATE_l,
167   FX_BIDINEUTRALSTATE_rn,
168   FX_BIDINEUTRALSTATE_ln,
169   FX_BIDINEUTRALSTATE_a,
170   FX_BIDINEUTRALSTATE_na,
171 };
172 #define FX_BNSr FX_BIDINEUTRALSTATE_r
173 #define FX_BNSl FX_BIDINEUTRALSTATE_l
174 #define FX_BNSrn FX_BIDINEUTRALSTATE_rn
175 #define FX_BNSln FX_BIDINEUTRALSTATE_ln
176 #define FX_BNSa FX_BIDINEUTRALSTATE_a
177 #define FX_BNSna FX_BIDINEUTRALSTATE_na
178 enum FX_BIDINEUTRALACTION {
179   FX_BIDINEUTRALACTION_nL = FX_BIDICLASS_L,
180   FX_BIDINEUTRALACTION_En = (FX_BIDICLASS_AN << 4),
181   FX_BIDINEUTRALACTION_Rn = (FX_BIDICLASS_R << 4),
182   FX_BIDINEUTRALACTION_Ln = (FX_BIDICLASS_L << 4),
183   FX_BIDINEUTRALACTION_In = FX_BIDIWEAKACTION_IX,
184   FX_BIDINEUTRALACTION_LnL = (FX_BIDICLASS_L << 4) + FX_BIDICLASS_L,
185 };
186 #define FX_BNAnL FX_BIDINEUTRALACTION_nL
187 #define FX_BNAEn FX_BIDINEUTRALACTION_En
188 #define FX_BNARn FX_BIDINEUTRALACTION_Rn
189 #define FX_BNALn FX_BIDINEUTRALACTION_Ln
190 #define FX_BNAIn FX_BIDINEUTRALACTION_In
191 #define FX_BNALnL FX_BIDINEUTRALACTION_LnL
192 int32_t FX_BidiGetDeferredNeutrals(int32_t iAction, int32_t iLevel);
193 int32_t FX_BidiGetResolvedNeutrals(int32_t iAction);
194 void FX_BidiResolveNeutrals(int32_t iBaseLevel,
195                             CFX_Int32Array& classes,
196                             const CFX_Int32Array& levels);
197 void FX_BidiResolveImplicit(const CFX_Int32Array& classes,
198                             CFX_Int32Array& levels);
199 void FX_BidiResolveWhitespace(int32_t iBaseLevel,
200                               const CFX_Int32Array& classes,
201                               CFX_Int32Array& levels);
202 int32_t FX_BidiReorderLevel(int32_t iBaseLevel,
203                             CFX_WideString& wsText,
204                             const CFX_Int32Array& levels,
205                             int32_t iStart,
206                             FX_BOOL bReverse = FALSE);
207 void FX_BidiReorder(int32_t iBaseLevel,
208                     CFX_WideString& wsText,
209                     const CFX_Int32Array& levels);
210 
211 #endif  // CORE_SRC_FXCRT_FX_ARABIC_H_
212