summaryrefslogtreecommitdiff
path: root/core/include/fxcrt
diff options
context:
space:
mode:
Diffstat (limited to 'core/include/fxcrt')
-rw-r--r--core/include/fxcrt/fx_arb.h42
-rw-r--r--core/include/fxcrt/fx_bidi.h59
-rw-r--r--core/include/fxcrt/fx_ucd.h18
3 files changed, 74 insertions, 45 deletions
diff --git a/core/include/fxcrt/fx_arb.h b/core/include/fxcrt/fx_arb.h
index d3612db4e7..6760ef3d79 100644
--- a/core/include/fxcrt/fx_arb.h
+++ b/core/include/fxcrt/fx_arb.h
@@ -11,39 +11,35 @@
#include "fx_ucd.h"
class IFX_ArabicChar;
-class IFX_BidiChar;
-#ifdef __cplusplus
-extern "C" {
-#endif
-typedef struct _FX_ARBFORMTABLE {
+
+struct FX_ARBFORMTABLE {
FX_WCHAR wIsolated;
FX_WCHAR wFinal;
FX_WCHAR wInitial;
FX_WCHAR wMedial;
-} FX_ARBFORMTABLE, *FX_LPARBFORMTABLE;
-typedef FX_ARBFORMTABLE const* FX_LPCARBFORMTABLE;
-typedef struct _FX_ARAALEF {
+};
+
+struct FX_ARAALEF {
FX_WCHAR wAlef;
FX_WCHAR wIsolated;
-} FX_ARAALEF, *FX_LPARAALEF;
-typedef FX_ARAALEF const* FX_LPCARAALEF;
-typedef struct _FX_ARASHADDA {
+};
+
+struct FX_ARASHADDA {
FX_WCHAR wShadda;
FX_WCHAR wIsolated;
-} FX_ARASHADDA, *FX_LPARASHADDA;
-typedef FX_ARASHADDA const* FX_LPCARASHADDA;
-FX_LPCARBFORMTABLE FX_GetArabicFormTable(FX_WCHAR unicode);
+};
+
+const FX_ARBFORMTABLE* FX_GetArabicFormTable(FX_WCHAR unicode);
FX_WCHAR FX_GetArabicFromAlefTable(FX_WCHAR alef);
FX_WCHAR FX_GetArabicFromShaddaTable(FX_WCHAR shadda);
-#ifdef __cplusplus
-};
-#endif
+
enum FX_ARBPOSITION {
FX_ARBPOSITION_Isolated = 0,
FX_ARBPOSITION_Final,
FX_ARBPOSITION_Initial,
FX_ARBPOSITION_Medial,
};
+
class IFX_ArabicChar {
public:
static IFX_ArabicChar* Create();
@@ -58,6 +54,7 @@ class IFX_ArabicChar {
const CFX_Char* prev,
const CFX_Char* next) const = 0;
};
+
void FX_BidiLine(CFX_WideString& wsText, int32_t iBaseLevel = 0);
void FX_BidiLine(CFX_TxtCharArray& chars,
int32_t iCount,
@@ -65,16 +62,5 @@ void FX_BidiLine(CFX_TxtCharArray& chars,
void FX_BidiLine(CFX_RTFCharArray& chars,
int32_t iCount,
int32_t iBaseLevel = 0);
-class IFX_BidiChar {
- public:
- static IFX_BidiChar* Create();
- virtual ~IFX_BidiChar() {}
-
- virtual void SetPolicy(FX_BOOL bSeparateNeutral = TRUE) = 0;
- virtual FX_BOOL AppendChar(FX_WCHAR wch) = 0;
- virtual FX_BOOL EndChar() = 0;
- virtual int32_t GetBidiInfo(int32_t& iStart, int32_t& iCount) = 0;
- virtual void Reset() = 0;
-};
#endif // CORE_INCLUDE_FXCRT_FX_ARB_H_
diff --git a/core/include/fxcrt/fx_bidi.h b/core/include/fxcrt/fx_bidi.h
new file mode 100644
index 0000000000..a55ce6cfd2
--- /dev/null
+++ b/core/include/fxcrt/fx_bidi.h
@@ -0,0 +1,59 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_INCLUDE_FXCRT_FX_BIDI_H_
+#define CORE_INCLUDE_FXCRT_FX_BIDI_H_
+
+#include "fx_system.h"
+
+// Processes characters and group them into segments based on text direction.
+class CFX_BidiChar {
+ public:
+ enum Direction { NEUTRAL, LEFT, RIGHT };
+
+ CFX_BidiChar();
+ ~CFX_BidiChar();
+
+ // Append a character and classify it as left, right, or neutral.
+ // Returns true if the character has a different direction than the
+ // existing direction to indicate there is a segment to process.
+ bool AppendChar(FX_WCHAR wch);
+
+ // Call this after the last character has been appended. AppendChar()
+ // must not be called after this.
+ // Returns true if there is still a segment to process.
+ bool EndChar();
+
+ // Get information about the segment to process.
+ // The segment's start position and character count is returned in |iStart|
+ // and |iCount|, respectively. Pass in null pointers if the information is
+ // not needed.
+ // Returns the segment direction.
+ Direction GetBidiInfo(int32_t* iStart, int32_t* iCount) const;
+
+ private:
+ void SaveCurrentStateToLastState();
+
+ // Position of the current segment.
+ int32_t m_iCurStart;
+
+ // Number of characters in the current segment.
+ int32_t m_iCurCount;
+
+ // Direction of the current segment.
+ Direction m_CurBidi;
+
+ // Number of characters in the last segment.
+ int32_t m_iLastStart;
+
+ // Number of characters in the last segment.
+ int32_t m_iLastCount;
+
+ // Direction of the last segment.
+ Direction m_LastBidi;
+};
+
+#endif // CORE_INCLUDE_FXCRT_FX_BIDI_H_
diff --git a/core/include/fxcrt/fx_ucd.h b/core/include/fxcrt/fx_ucd.h
index 823b80700a..d4a43bd096 100644
--- a/core/include/fxcrt/fx_ucd.h
+++ b/core/include/fxcrt/fx_ucd.h
@@ -101,25 +101,9 @@ enum FX_CHARTYPE {
FX_CHARTYPE_ArabicForm = (11 << FX_CHARTYPEBITS),
FX_CHARTYPE_Arabic = (12 << FX_CHARTYPEBITS),
};
-typedef struct _FX_CHARPROPERTIES {
- union FX_CHARPROPERTIES_UNION {
- struct FX_CHARPROPERTIES_BIT {
- FX_DWORD dwBreakType : 6;
- FX_DWORD dwBidiClass : 5;
- FX_DWORD dwCharType : 4;
- FX_DWORD dwRotation : 1;
- FX_DWORD dwCJKSpecial : 1;
- FX_DWORD dwVertIndex : 6;
- FX_DWORD dwBidiIndex : 9;
- };
- FX_DWORD dwCharProps;
- };
-} FX_CHARPROPERTIES;
+
FX_DWORD FX_GetUnicodeProperties(FX_WCHAR wch);
FX_BOOL FX_IsCtrlCode(FX_WCHAR ch);
-FX_BOOL FX_IsRotationCode(FX_WCHAR ch);
-FX_BOOL FX_IsCombinationChar(FX_WCHAR wch);
-FX_BOOL FX_IsBidiChar(FX_WCHAR wch);
FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_BOOL bRTL, FX_BOOL bVertical);
FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch,
FX_DWORD dwProps,