OLD | NEW |
(Empty) | |
| 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_INCLUDE_FXCRT_FX_BIDI_H_ |
| 8 #define CORE_INCLUDE_FXCRT_FX_BIDI_H_ |
| 9 |
| 10 #include "fx_system.h" |
| 11 |
| 12 // Processes characters and group them into segments based on text direction. |
| 13 class CFX_BidiChar { |
| 14 public: |
| 15 enum Direction { NEUTRAL, LEFT, RIGHT }; |
| 16 |
| 17 CFX_BidiChar(); |
| 18 ~CFX_BidiChar(); |
| 19 |
| 20 // Append a character and classify it as left, right, or neutral. |
| 21 // Returns true if the character has a different direction than the |
| 22 // existing direction to indicate there is a segment to process. |
| 23 bool AppendChar(FX_WCHAR wch); |
| 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; |
| 36 |
| 37 private: |
| 38 void SaveCurrentStateToLastState(); |
| 39 |
| 40 // Position of the current segment. |
| 41 int32_t m_iCurStart; |
| 42 |
| 43 // Number of characters in the current segment. |
| 44 int32_t m_iCurCount; |
| 45 |
| 46 // Direction of the current segment. |
| 47 Direction m_CurBidi; |
| 48 |
| 49 // Number of characters in the last segment. |
| 50 int32_t m_iLastStart; |
| 51 |
| 52 // Number of characters in the last segment. |
| 53 int32_t m_iLastCount; |
| 54 |
| 55 // Direction of the last segment. |
| 56 Direction m_LastBidi; |
| 57 }; |
| 58 |
| 59 #endif // CORE_INCLUDE_FXCRT_FX_BIDI_H_ |
OLD | NEW |