diff options
author | Lei Zhang <thestig@chromium.org> | 2015-10-29 15:01:55 -0700 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-10-29 15:01:55 -0700 |
commit | ee02ea37e8f85920885600d56df706d690e648ff (patch) | |
tree | 055bbc66a5c95a8bc75ccc491f73505bb8eb6676 /core/include/fxcrt/fx_bidi.h | |
parent | 5a88b1131c450dee0500a02f80f0838385e4c4d2 (diff) | |
download | pdfium-ee02ea37e8f85920885600d56df706d690e648ff.tar.xz |
XFA: Manual merge of Clean up IFX_BidiChar
- Replace IFX_BidiChar with just CFX_BidiChar
- Document implementation
- Change out parameters to pointers
- Remove dead code
- Add an enum for bidi directions
- Move several externs to a header
- Add unit tests
Original CL: https://codereview.chromium.org/1197643002
This version does not remove fx_arb.h and fx_arabic.h, as there is code
on the XFA branch that still uses parts of it.
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1423103002 .
Diffstat (limited to 'core/include/fxcrt/fx_bidi.h')
-rw-r--r-- | core/include/fxcrt/fx_bidi.h | 59 |
1 files changed, 59 insertions, 0 deletions
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_ |