Index: core/include/fxcrt/fx_bidi.h |
diff --git a/core/src/fxcrt/fx_arabic.h b/core/include/fxcrt/fx_bidi.h |
similarity index 21% |
rename from core/src/fxcrt/fx_arabic.h |
rename to core/include/fxcrt/fx_bidi.h |
index 0230d4057978168cb4940dbfe6d245b8529a3af5..a55ce6cfd2035db3ac08e3e1751c4b7d02c6d878 100644 |
--- a/core/src/fxcrt/fx_arabic.h |
+++ b/core/include/fxcrt/fx_bidi.h |
@@ -4,30 +4,56 @@ |
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
-#ifndef CORE_SRC_FXCRT_FX_ARABIC_H_ |
-#define CORE_SRC_FXCRT_FX_ARABIC_H_ |
+#ifndef CORE_INCLUDE_FXCRT_FX_BIDI_H_ |
+#define CORE_INCLUDE_FXCRT_FX_BIDI_H_ |
-#include "../../include/fxcrt/fx_arb.h" |
+#include "fx_system.h" |
-class CFX_BidiChar final : public IFX_BidiChar { |
+// Processes characters and group them into segments based on text direction. |
+class CFX_BidiChar { |
public: |
+ enum Direction { NEUTRAL, LEFT, RIGHT }; |
+ |
CFX_BidiChar(); |
- ~CFX_BidiChar() override {} |
+ ~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(); |
- void SetPolicy(FX_BOOL bSeparateNeutral = TRUE) override; |
- FX_BOOL AppendChar(FX_WCHAR wch) override; |
- FX_BOOL EndChar() override; |
- int32_t GetBidiInfo(int32_t& iStart, int32_t& iCount) override; |
- void Reset() override; |
+ // 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: |
- FX_BOOL m_bSeparateNeutral; |
+ void SaveCurrentStateToLastState(); |
+ |
+ // Position of the current segment. |
int32_t m_iCurStart; |
+ |
+ // Number of characters in the current segment. |
int32_t m_iCurCount; |
- int32_t m_iCurBidi; |
- int32_t m_iLastBidi; |
+ |
+ // 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_SRC_FXCRT_FX_ARABIC_H_ |
+#endif // CORE_INCLUDE_FXCRT_FX_BIDI_H_ |