| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef CORE_SRC_FXCRT_FX_ARABIC_H_ | 7 #ifndef CORE_INCLUDE_FXCRT_FX_BIDI_H_ |
| 8 #define CORE_SRC_FXCRT_FX_ARABIC_H_ | 8 #define CORE_INCLUDE_FXCRT_FX_BIDI_H_ |
| 9 | 9 |
| 10 #include "../../include/fxcrt/fx_arb.h" | 10 #include "fx_system.h" |
| 11 | 11 |
| 12 class CFX_BidiChar final : public IFX_BidiChar { | 12 // Processes characters and group them into segments based on text direction. |
| 13 class CFX_BidiChar { |
| 13 public: | 14 public: |
| 15 enum Direction { NEUTRAL, LEFT, RIGHT }; |
| 16 |
| 14 CFX_BidiChar(); | 17 CFX_BidiChar(); |
| 15 ~CFX_BidiChar() override {} | 18 ~CFX_BidiChar(); |
| 16 | 19 |
| 17 void SetPolicy(FX_BOOL bSeparateNeutral = TRUE) override; | 20 // Append a character and classify it as left, right, or neutral. |
| 18 FX_BOOL AppendChar(FX_WCHAR wch) override; | 21 // Returns true if the character has a different direction than the |
| 19 FX_BOOL EndChar() override; | 22 // existing direction to indicate there is a segment to process. |
| 20 int32_t GetBidiInfo(int32_t& iStart, int32_t& iCount) override; | 23 bool AppendChar(FX_WCHAR wch); |
| 21 void Reset() override; | 24 |
| 25 // Call this after the last character has been appended. AppendChar() |
| 26 // must not be called after this. |
| 27 // Returns true if there is still a segment to process. |
| 28 bool EndChar(); |
| 29 |
| 30 // Get information about the segment to process. |
| 31 // The segment's start position and character count is returned in |iStart| |
| 32 // and |iCount|, respectively. Pass in null pointers if the information is |
| 33 // not needed. |
| 34 // Returns the segment direction. |
| 35 Direction GetBidiInfo(int32_t* iStart, int32_t* iCount) const; |
| 22 | 36 |
| 23 private: | 37 private: |
| 24 FX_BOOL m_bSeparateNeutral; | 38 void SaveCurrentStateToLastState(); |
| 39 |
| 40 // Position of the current segment. |
| 25 int32_t m_iCurStart; | 41 int32_t m_iCurStart; |
| 42 |
| 43 // Number of characters in the current segment. |
| 26 int32_t m_iCurCount; | 44 int32_t m_iCurCount; |
| 27 int32_t m_iCurBidi; | 45 |
| 28 int32_t m_iLastBidi; | 46 // Direction of the current segment. |
| 47 Direction m_CurBidi; |
| 48 |
| 49 // Number of characters in the last segment. |
| 29 int32_t m_iLastStart; | 50 int32_t m_iLastStart; |
| 51 |
| 52 // Number of characters in the last segment. |
| 30 int32_t m_iLastCount; | 53 int32_t m_iLastCount; |
| 54 |
| 55 // Direction of the last segment. |
| 56 Direction m_LastBidi; |
| 31 }; | 57 }; |
| 32 | 58 |
| 33 #endif // CORE_SRC_FXCRT_FX_ARABIC_H_ | 59 #endif // CORE_INCLUDE_FXCRT_FX_BIDI_H_ |
| OLD | NEW |