summaryrefslogtreecommitdiff
path: root/xfa/fgas/layout
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-04-12 16:55:56 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-12 16:55:56 -0700
commit17f382a50a7c4e5b6f14f76027a15de4ac17bc4c (patch)
tree337f45c03f9a6f40d30dc0820f29575fd55034b0 /xfa/fgas/layout
parentf1accf62715942e3f833fa57d0e6e1b70f51bae6 (diff)
downloadpdfium-17f382a50a7c4e5b6f14f76027a15de4ac17bc4c.tar.xz
Cleanup various IFX_ text interfaces.
This CL removes IFX_ArabicChar, IFX_RTFBreak, IFX_TxtBreak, IFX_WordBreak, IFX_FormatString, and IFX_GSUBTable. References were updated to be the concrete classes. The CFX_GSUBTable was also removed as it is unused. BUG=pdfium:468 Review URL: https://codereview.chromium.org/1882213002
Diffstat (limited to 'xfa/fgas/layout')
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.cpp172
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.h200
-rw-r--r--xfa/fgas/layout/fgas_textbreak.cpp169
-rw-r--r--xfa/fgas/layout/fgas_textbreak.h200
4 files changed, 321 insertions, 420 deletions
diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp
index 38a2d212af..3adb251254 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.cpp
+++ b/xfa/fgas/layout/fgas_rtfbreak.cpp
@@ -8,179 +8,11 @@
#include <algorithm>
+#include "core/fxcrt/include/fx_arabic.h"
#include "core/fxcrt/include/fx_arb.h"
#include "xfa/fgas/layout/fgas_linebreak.h"
#include "xfa/fgas/layout/fgas_unicode.h"
-namespace {
-
-class CFX_RTFLine {
- public:
- CFX_RTFLine()
- : m_LinePieces(16),
- m_iStart(0),
- m_iWidth(0),
- m_iArabicChars(0),
- m_iMBCSChars(0) {}
- ~CFX_RTFLine() { RemoveAll(); }
- int32_t CountChars() const { return m_LineChars.GetSize(); }
- CFX_RTFChar& GetChar(int32_t index) {
- FXSYS_assert(index > -1 && index < m_LineChars.GetSize());
- return *m_LineChars.GetDataPtr(index);
- }
- CFX_RTFChar* GetCharPtr(int32_t index) {
- FXSYS_assert(index > -1 && index < m_LineChars.GetSize());
- return m_LineChars.GetDataPtr(index);
- }
- int32_t CountPieces() const { return m_LinePieces.GetSize(); }
- CFX_RTFPiece& GetPiece(int32_t index) const {
- FXSYS_assert(index > -1 && index < m_LinePieces.GetSize());
- return m_LinePieces.GetAt(index);
- }
- CFX_RTFPiece* GetPiecePtr(int32_t index) const {
- FXSYS_assert(index > -1 && index < m_LinePieces.GetSize());
- return m_LinePieces.GetPtrAt(index);
- }
- int32_t GetLineEnd() const { return m_iStart + m_iWidth; }
- void RemoveAll(FX_BOOL bLeaveMemory = FALSE) {
- CFX_RTFChar* pChar;
- IFX_Unknown* pUnknown;
- int32_t iCount = m_LineChars.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- pChar = m_LineChars.GetDataPtr(i);
- if ((pUnknown = pChar->m_pUserData) != NULL) {
- pUnknown->Release();
- }
- }
- m_LineChars.RemoveAll();
- m_LinePieces.RemoveAll(bLeaveMemory);
- m_iWidth = 0;
- m_iArabicChars = 0;
- m_iMBCSChars = 0;
- }
- CFX_RTFCharArray m_LineChars;
- CFX_RTFPieceArray m_LinePieces;
- int32_t m_iStart;
- int32_t m_iWidth;
- int32_t m_iArabicChars;
- int32_t m_iMBCSChars;
-};
-
-class CFX_RTFBreak : public IFX_RTFBreak {
- public:
- CFX_RTFBreak(uint32_t dwPolicies);
- ~CFX_RTFBreak();
- void Release() override { delete this; }
- void SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) override;
- void SetLineStartPos(FX_FLOAT fLinePos) override;
- uint32_t GetLayoutStyles() const override { return m_dwLayoutStyles; }
- void SetLayoutStyles(uint32_t dwLayoutStyles) override;
- void SetFont(IFX_Font* pFont) override;
- void SetFontSize(FX_FLOAT fFontSize) override;
- void SetTabWidth(FX_FLOAT fTabWidth) override;
- void AddPositionedTab(FX_FLOAT fTabPos) override;
- void SetPositionedTabs(const CFX_FloatArray& tabs) override;
- void ClearPositionedTabs() override;
- void SetDefaultChar(FX_WCHAR wch) override;
- void SetLineBreakChar(FX_WCHAR wch) override;
- void SetLineBreakTolerance(FX_FLOAT fTolerance) override;
- void SetHorizontalScale(int32_t iScale) override;
- void SetVerticalScale(int32_t iScale) override;
- void SetCharRotation(int32_t iCharRotation) override;
- void SetCharSpace(FX_FLOAT fCharSpace) override;
- void SetWordSpace(FX_BOOL bDefault, FX_FLOAT fWordSpace) override;
- void SetReadingOrder(FX_BOOL bRTL = FALSE) override;
- void SetAlignment(int32_t iAlignment = FX_RTFLINEALIGNMENT_Left) override;
- void SetUserData(IFX_Unknown* pUserData) override;
- uint32_t AppendChar(FX_WCHAR wch) override;
- uint32_t EndBreak(uint32_t dwStatus = FX_RTFBREAK_PieceBreak) override;
- int32_t CountBreakPieces() const override;
- const CFX_RTFPiece* GetBreakPiece(int32_t index) const override;
- void GetLineRect(CFX_RectF& rect) const override;
- void ClearBreakPieces() override;
- void Reset() override;
- int32_t GetDisplayPos(
- const FX_RTFTEXTOBJ* pText,
- FXTEXT_CHARPOS* pCharPos,
- FX_BOOL bCharCode = FALSE,
- CFX_WideString* pWSForms = NULL,
- FX_AdjustCharDisplayPos pAdjustPos = NULL) const override;
- int32_t GetCharRects(const FX_RTFTEXTOBJ* pText,
- CFX_RectFArray& rtArray,
- FX_BOOL bCharBBox = FALSE) const override;
- uint32_t AppendChar_CharCode(FX_WCHAR wch);
- uint32_t AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation);
- uint32_t AppendChar_Tab(CFX_RTFChar* pCurChar, int32_t iRotation);
- uint32_t AppendChar_Control(CFX_RTFChar* pCurChar, int32_t iRotation);
- uint32_t AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation);
- uint32_t AppendChar_Others(CFX_RTFChar* pCurChar, int32_t iRotation);
-
- protected:
- uint32_t m_dwPolicies;
- IFX_ArabicChar* m_pArabicChar;
- int32_t m_iBoundaryStart;
- int32_t m_iBoundaryEnd;
- uint32_t m_dwLayoutStyles;
- FX_BOOL m_bPagination;
- FX_BOOL m_bVertical;
- FX_BOOL m_bSingleLine;
- FX_BOOL m_bCharCode;
- IFX_Font* m_pFont;
- int32_t m_iFontHeight;
- int32_t m_iFontSize;
- int32_t m_iTabWidth;
- CFX_Int32Array m_PositionedTabs;
- FX_BOOL m_bOrphanLine;
- FX_WCHAR m_wDefChar;
- int32_t m_iDefChar;
- FX_WCHAR m_wLineBreakChar;
- int32_t m_iHorizontalScale;
- int32_t m_iVerticalScale;
- int32_t m_iLineRotation;
- int32_t m_iCharRotation;
- int32_t m_iRotation;
- int32_t m_iCharSpace;
- FX_BOOL m_bWordSpace;
- int32_t m_iWordSpace;
- FX_BOOL m_bRTL;
- int32_t m_iAlignment;
- IFX_Unknown* m_pUserData;
- uint32_t m_dwCharType;
- uint32_t m_dwIdentity;
- CFX_RTFLine m_RTFLine1;
- CFX_RTFLine m_RTFLine2;
- CFX_RTFLine* m_pCurLine;
- int32_t m_iReady;
- int32_t m_iTolerance;
- int32_t GetLineRotation(uint32_t dwStyles) const;
- void SetBreakStatus();
- CFX_RTFChar* GetLastChar(int32_t index) const;
- CFX_RTFLine* GetRTFLine(FX_BOOL bReady) const;
- CFX_RTFPieceArray* GetRTFPieces(FX_BOOL bReady) const;
- uint32_t GetUnifiedCharType(uint32_t dwType) const;
- int32_t GetLastPositionedTab() const;
- FX_BOOL GetPositionedTab(int32_t& iTabPos) const;
- int32_t GetBreakPos(CFX_RTFCharArray& tca,
- int32_t& iEndPos,
- FX_BOOL bAllChars = FALSE,
- FX_BOOL bOnlyBrk = FALSE);
- void SplitTextLine(CFX_RTFLine* pCurLine,
- CFX_RTFLine* pNextLine,
- FX_BOOL bAllChars = FALSE);
- FX_BOOL EndBreak_SplitLine(CFX_RTFLine* pNextLine,
- FX_BOOL bAllChars,
- uint32_t dwStatus);
- void EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus);
- void EndBreak_Alignment(CFX_TPOArray& tpos,
- FX_BOOL bAllChars,
- uint32_t dwStatus);
-};
-
-} // namespace
-
-IFX_RTFBreak* IFX_RTFBreak::Create(uint32_t dwPolicies) {
- return new CFX_RTFBreak(dwPolicies);
-}
CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies)
: m_dwPolicies(dwPolicies),
m_pArabicChar(NULL),
@@ -218,7 +50,7 @@ CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies)
m_pCurLine(NULL),
m_iReady(0),
m_iTolerance(0) {
- m_pArabicChar = IFX_ArabicChar::Create();
+ m_pArabicChar = new CFX_ArabicChar;
m_pCurLine = &m_RTFLine1;
}
CFX_RTFBreak::~CFX_RTFBreak() {
diff --git a/xfa/fgas/layout/fgas_rtfbreak.h b/xfa/fgas/layout/fgas_rtfbreak.h
index 83310e9d82..8a66dd9e93 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.h
+++ b/xfa/fgas/layout/fgas_rtfbreak.h
@@ -14,6 +14,7 @@
#include "xfa/fgas/layout/fgas_textbreak.h"
#include "xfa/fgas/layout/fgas_unicode.h"
+class CFX_ArabicChar;
class IFX_Unknown;
class IFX_Font;
@@ -190,48 +191,165 @@ class CFX_RTFPiece : public CFX_Target {
};
typedef CFX_BaseArrayTemplate<CFX_RTFPiece> CFX_RTFPieceArray;
-class IFX_RTFBreak {
+class CFX_RTFLine {
public:
- static IFX_RTFBreak* Create(uint32_t dwPolicies);
- virtual ~IFX_RTFBreak() {}
- virtual void Release() = 0;
- virtual void SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) = 0;
- virtual void SetLineStartPos(FX_FLOAT fLinePos) = 0;
- virtual uint32_t GetLayoutStyles() const = 0;
- virtual void SetLayoutStyles(uint32_t dwLayoutStyles) = 0;
- virtual void SetFont(IFX_Font* pFont) = 0;
- virtual void SetFontSize(FX_FLOAT fFontSize) = 0;
- virtual void SetTabWidth(FX_FLOAT fTabWidth) = 0;
- virtual void AddPositionedTab(FX_FLOAT fTabPos) = 0;
- virtual void SetPositionedTabs(const CFX_FloatArray& tabs) = 0;
- virtual void ClearPositionedTabs() = 0;
- virtual void SetDefaultChar(FX_WCHAR wch) = 0;
- virtual void SetLineBreakChar(FX_WCHAR wch) = 0;
- virtual void SetLineBreakTolerance(FX_FLOAT fTolerance) = 0;
- virtual void SetHorizontalScale(int32_t iScale) = 0;
- virtual void SetVerticalScale(int32_t iScale) = 0;
- virtual void SetCharRotation(int32_t iCharRotation) = 0;
- virtual void SetCharSpace(FX_FLOAT fCharSpace) = 0;
- virtual void SetWordSpace(FX_BOOL bDefault, FX_FLOAT fWordSpace) = 0;
- virtual void SetReadingOrder(FX_BOOL bRTL = FALSE) = 0;
- virtual void SetAlignment(int32_t iAlignment = FX_RTFLINEALIGNMENT_Left) = 0;
- virtual void SetUserData(IFX_Unknown* pUserData) = 0;
- virtual uint32_t AppendChar(FX_WCHAR wch) = 0;
- virtual uint32_t EndBreak(uint32_t dwStatus = FX_RTFBREAK_PieceBreak) = 0;
- virtual int32_t CountBreakPieces() const = 0;
- virtual const CFX_RTFPiece* GetBreakPiece(int32_t index) const = 0;
- virtual void GetLineRect(CFX_RectF& rect) const = 0;
- virtual void ClearBreakPieces() = 0;
- virtual void Reset() = 0;
- virtual int32_t GetDisplayPos(
- const FX_RTFTEXTOBJ* pText,
- FXTEXT_CHARPOS* pCharPos,
- FX_BOOL bCharCode = FALSE,
- CFX_WideString* pWSForms = NULL,
- FX_AdjustCharDisplayPos pAdjustPos = NULL) const = 0;
- virtual int32_t GetCharRects(const FX_RTFTEXTOBJ* pText,
- CFX_RectFArray& rtArray,
- FX_BOOL bCharBBox = FALSE) const = 0;
+ CFX_RTFLine()
+ : m_LinePieces(16),
+ m_iStart(0),
+ m_iWidth(0),
+ m_iArabicChars(0),
+ m_iMBCSChars(0) {}
+ ~CFX_RTFLine() { RemoveAll(); }
+ int32_t CountChars() const { return m_LineChars.GetSize(); }
+ CFX_RTFChar& GetChar(int32_t index) {
+ FXSYS_assert(index > -1 && index < m_LineChars.GetSize());
+ return *m_LineChars.GetDataPtr(index);
+ }
+ CFX_RTFChar* GetCharPtr(int32_t index) {
+ FXSYS_assert(index > -1 && index < m_LineChars.GetSize());
+ return m_LineChars.GetDataPtr(index);
+ }
+ int32_t CountPieces() const { return m_LinePieces.GetSize(); }
+ CFX_RTFPiece& GetPiece(int32_t index) const {
+ FXSYS_assert(index > -1 && index < m_LinePieces.GetSize());
+ return m_LinePieces.GetAt(index);
+ }
+ CFX_RTFPiece* GetPiecePtr(int32_t index) const {
+ FXSYS_assert(index > -1 && index < m_LinePieces.GetSize());
+ return m_LinePieces.GetPtrAt(index);
+ }
+ int32_t GetLineEnd() const { return m_iStart + m_iWidth; }
+ void RemoveAll(FX_BOOL bLeaveMemory = FALSE) {
+ CFX_RTFChar* pChar;
+ IFX_Unknown* pUnknown;
+ int32_t iCount = m_LineChars.GetSize();
+ for (int32_t i = 0; i < iCount; i++) {
+ pChar = m_LineChars.GetDataPtr(i);
+ if ((pUnknown = pChar->m_pUserData) != NULL) {
+ pUnknown->Release();
+ }
+ }
+ m_LineChars.RemoveAll();
+ m_LinePieces.RemoveAll(bLeaveMemory);
+ m_iWidth = 0;
+ m_iArabicChars = 0;
+ m_iMBCSChars = 0;
+ }
+ CFX_RTFCharArray m_LineChars;
+ CFX_RTFPieceArray m_LinePieces;
+ int32_t m_iStart;
+ int32_t m_iWidth;
+ int32_t m_iArabicChars;
+ int32_t m_iMBCSChars;
+};
+
+class CFX_RTFBreak {
+ public:
+ CFX_RTFBreak(uint32_t dwPolicies);
+ ~CFX_RTFBreak();
+ void Release() { delete this; }
+ void SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd);
+ void SetLineStartPos(FX_FLOAT fLinePos);
+ uint32_t GetLayoutStyles() const { return m_dwLayoutStyles; }
+ void SetLayoutStyles(uint32_t dwLayoutStyles);
+ void SetFont(IFX_Font* pFont);
+ void SetFontSize(FX_FLOAT fFontSize);
+ void SetTabWidth(FX_FLOAT fTabWidth);
+ void AddPositionedTab(FX_FLOAT fTabPos);
+ void SetPositionedTabs(const CFX_FloatArray& tabs);
+ void ClearPositionedTabs();
+ void SetDefaultChar(FX_WCHAR wch);
+ void SetLineBreakChar(FX_WCHAR wch);
+ void SetLineBreakTolerance(FX_FLOAT fTolerance);
+ void SetHorizontalScale(int32_t iScale);
+ void SetVerticalScale(int32_t iScale);
+ void SetCharRotation(int32_t iCharRotation);
+ void SetCharSpace(FX_FLOAT fCharSpace);
+ void SetWordSpace(FX_BOOL bDefault, FX_FLOAT fWordSpace);
+ void SetReadingOrder(FX_BOOL bRTL = FALSE);
+ void SetAlignment(int32_t iAlignment = FX_RTFLINEALIGNMENT_Left);
+ void SetUserData(IFX_Unknown* pUserData);
+ uint32_t AppendChar(FX_WCHAR wch);
+ uint32_t EndBreak(uint32_t dwStatus = FX_RTFBREAK_PieceBreak);
+ int32_t CountBreakPieces() const;
+ const CFX_RTFPiece* GetBreakPiece(int32_t index) const;
+ void GetLineRect(CFX_RectF& rect) const;
+ void ClearBreakPieces();
+ void Reset();
+ int32_t GetDisplayPos(const FX_RTFTEXTOBJ* pText,
+ FXTEXT_CHARPOS* pCharPos,
+ FX_BOOL bCharCode = FALSE,
+ CFX_WideString* pWSForms = NULL,
+ FX_AdjustCharDisplayPos pAdjustPos = NULL) const;
+ int32_t GetCharRects(const FX_RTFTEXTOBJ* pText,
+ CFX_RectFArray& rtArray,
+ FX_BOOL bCharBBox = FALSE) const;
+ uint32_t AppendChar_CharCode(FX_WCHAR wch);
+ uint32_t AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation);
+ uint32_t AppendChar_Tab(CFX_RTFChar* pCurChar, int32_t iRotation);
+ uint32_t AppendChar_Control(CFX_RTFChar* pCurChar, int32_t iRotation);
+ uint32_t AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation);
+ uint32_t AppendChar_Others(CFX_RTFChar* pCurChar, int32_t iRotation);
+
+ protected:
+ uint32_t m_dwPolicies;
+ CFX_ArabicChar* m_pArabicChar;
+ int32_t m_iBoundaryStart;
+ int32_t m_iBoundaryEnd;
+ uint32_t m_dwLayoutStyles;
+ FX_BOOL m_bPagination;
+ FX_BOOL m_bVertical;
+ FX_BOOL m_bSingleLine;
+ FX_BOOL m_bCharCode;
+ IFX_Font* m_pFont;
+ int32_t m_iFontHeight;
+ int32_t m_iFontSize;
+ int32_t m_iTabWidth;
+ CFX_Int32Array m_PositionedTabs;
+ FX_BOOL m_bOrphanLine;
+ FX_WCHAR m_wDefChar;
+ int32_t m_iDefChar;
+ FX_WCHAR m_wLineBreakChar;
+ int32_t m_iHorizontalScale;
+ int32_t m_iVerticalScale;
+ int32_t m_iLineRotation;
+ int32_t m_iCharRotation;
+ int32_t m_iRotation;
+ int32_t m_iCharSpace;
+ FX_BOOL m_bWordSpace;
+ int32_t m_iWordSpace;
+ FX_BOOL m_bRTL;
+ int32_t m_iAlignment;
+ IFX_Unknown* m_pUserData;
+ uint32_t m_dwCharType;
+ uint32_t m_dwIdentity;
+ CFX_RTFLine m_RTFLine1;
+ CFX_RTFLine m_RTFLine2;
+ CFX_RTFLine* m_pCurLine;
+ int32_t m_iReady;
+ int32_t m_iTolerance;
+ int32_t GetLineRotation(uint32_t dwStyles) const;
+ void SetBreakStatus();
+ CFX_RTFChar* GetLastChar(int32_t index) const;
+ CFX_RTFLine* GetRTFLine(FX_BOOL bReady) const;
+ CFX_RTFPieceArray* GetRTFPieces(FX_BOOL bReady) const;
+ uint32_t GetUnifiedCharType(uint32_t dwType) const;
+ int32_t GetLastPositionedTab() const;
+ FX_BOOL GetPositionedTab(int32_t& iTabPos) const;
+ int32_t GetBreakPos(CFX_RTFCharArray& tca,
+ int32_t& iEndPos,
+ FX_BOOL bAllChars = FALSE,
+ FX_BOOL bOnlyBrk = FALSE);
+ void SplitTextLine(CFX_RTFLine* pCurLine,
+ CFX_RTFLine* pNextLine,
+ FX_BOOL bAllChars = FALSE);
+ FX_BOOL EndBreak_SplitLine(CFX_RTFLine* pNextLine,
+ FX_BOOL bAllChars,
+ uint32_t dwStatus);
+ void EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus);
+ void EndBreak_Alignment(CFX_TPOArray& tpos,
+ FX_BOOL bAllChars,
+ uint32_t dwStatus);
};
#endif // XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_
diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp
index d33d02c6f2..0face90abd 100644
--- a/xfa/fgas/layout/fgas_textbreak.cpp
+++ b/xfa/fgas/layout/fgas_textbreak.cpp
@@ -8,177 +8,12 @@
#include <algorithm>
+#include "core/fxcrt/include/fx_arabic.h"
#include "core/fxcrt/include/fx_arb.h"
#include "core/fxcrt/include/fx_memory.h"
#include "xfa/fgas/layout/fgas_linebreak.h"
#include "xfa/fgas/layout/fgas_unicode.h"
-namespace {
-
-class CFX_TxtLine {
- public:
- CFX_TxtLine(int32_t iBlockSize)
- : m_iStart(0), m_iWidth(0), m_iArabicChars(0) {
- m_pLineChars = new CFX_TxtCharArray;
- m_pLinePieces = new CFX_TxtPieceArray(16);
- }
- ~CFX_TxtLine() {
- RemoveAll();
- delete m_pLineChars;
- delete m_pLinePieces;
- }
- int32_t CountChars() const { return m_pLineChars->GetSize(); }
- CFX_TxtChar* GetCharPtr(int32_t index) const {
- FXSYS_assert(index > -1 && index < m_pLineChars->GetSize());
- return m_pLineChars->GetDataPtr(index);
- }
- int32_t CountPieces() const { return m_pLinePieces->GetSize(); }
- CFX_TxtPiece* GetPiecePtr(int32_t index) const {
- FXSYS_assert(index > -1 && index < m_pLinePieces->GetSize());
- return m_pLinePieces->GetPtrAt(index);
- }
- void GetString(CFX_WideString& wsStr) const {
- int32_t iCount = m_pLineChars->GetSize();
- FX_WCHAR* pBuf = wsStr.GetBuffer(iCount);
- CFX_Char* pChar;
- for (int32_t i = 0; i < iCount; i++) {
- pChar = m_pLineChars->GetDataPtr(i);
- *pBuf++ = (FX_WCHAR)pChar->m_wCharCode;
- }
- wsStr.ReleaseBuffer(iCount);
- }
- void RemoveAll(FX_BOOL bLeaveMemory = FALSE) {
- m_pLineChars->RemoveAll();
- m_pLinePieces->RemoveAll(bLeaveMemory);
- m_iWidth = 0;
- m_iArabicChars = 0;
- }
- CFX_TxtCharArray* m_pLineChars;
- CFX_TxtPieceArray* m_pLinePieces;
- int32_t m_iStart;
- int32_t m_iWidth;
- int32_t m_iArabicChars;
-};
-
-class CFX_TxtBreak : public IFX_TxtBreak {
- public:
- CFX_TxtBreak(uint32_t dwPolicies);
- ~CFX_TxtBreak();
- virtual void Release() { delete this; }
- virtual void SetLineWidth(FX_FLOAT fLineWidth);
- virtual void SetLinePos(FX_FLOAT fLinePos);
- virtual uint32_t GetLayoutStyles() const { return m_dwLayoutStyles; }
- virtual void SetLayoutStyles(uint32_t dwLayoutStyles);
- virtual void SetFont(IFX_Font* pFont);
- virtual void SetFontSize(FX_FLOAT fFontSize);
- virtual void SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);
- virtual void SetDefaultChar(FX_WCHAR wch);
- virtual void SetParagraphBreakChar(FX_WCHAR wch);
- virtual void SetLineBreakTolerance(FX_FLOAT fTolerance);
- virtual void SetHorizontalScale(int32_t iScale);
- virtual void SetVerticalScale(int32_t iScale);
- virtual void SetCharRotation(int32_t iCharRotation);
- virtual void SetCharSpace(FX_FLOAT fCharSpace);
- virtual void SetAlignment(int32_t iAlignment);
- virtual uint32_t GetContextCharStyles() const;
- virtual void SetContextCharStyles(uint32_t dwCharStyles);
- virtual void SetCombWidth(FX_FLOAT fCombWidth);
- virtual void SetUserData(void* pUserData);
- virtual uint32_t AppendChar(FX_WCHAR wch);
- virtual uint32_t EndBreak(uint32_t dwStatus = FX_TXTBREAK_PieceBreak);
- virtual int32_t CountBreakChars() const;
- virtual int32_t CountBreakPieces() const;
- virtual const CFX_TxtPiece* GetBreakPiece(int32_t index) const;
- virtual void ClearBreakPieces();
- virtual void Reset();
- virtual int32_t GetDisplayPos(
- const FX_TXTRUN* pTxtRun,
- FXTEXT_CHARPOS* pCharPos,
- FX_BOOL bCharCode = FALSE,
- CFX_WideString* pWSForms = NULL,
- FX_AdjustCharDisplayPos pAdjustPos = NULL) const;
- virtual int32_t GetCharRects(const FX_TXTRUN* pTxtRun,
- CFX_RectFArray& rtArray,
- FX_BOOL bCharBBox = FALSE) const;
- void AppendChar_PageLoad(CFX_Char* pCurChar, uint32_t dwProps);
- uint32_t AppendChar_Combination(CFX_Char* pCurChar, int32_t iRotation);
- uint32_t AppendChar_Tab(CFX_Char* pCurChar, int32_t iRotation);
- uint32_t AppendChar_Control(CFX_Char* pCurChar, int32_t iRotation);
- uint32_t AppendChar_Arabic(CFX_Char* pCurChar, int32_t iRotation);
- uint32_t AppendChar_Others(CFX_Char* pCurChar, int32_t iRotation);
-
- protected:
- uint32_t m_dwPolicies;
- FX_BOOL m_bPagination;
- IFX_ArabicChar* m_pArabicChar;
- int32_t m_iLineWidth;
- uint32_t m_dwLayoutStyles;
- FX_BOOL m_bVertical;
- FX_BOOL m_bArabicContext;
- FX_BOOL m_bArabicShapes;
- FX_BOOL m_bRTL;
- FX_BOOL m_bSingleLine;
- FX_BOOL m_bCombText;
- int32_t m_iArabicContext;
- int32_t m_iCurArabicContext;
- IFX_Font* m_pFont;
- int32_t m_iFontSize;
- FX_BOOL m_bEquidistant;
- int32_t m_iTabWidth;
- FX_WCHAR m_wDefChar;
- FX_WCHAR m_wParagBreakChar;
- int32_t m_iDefChar;
- int32_t m_iLineRotation;
- int32_t m_iCharRotation;
- int32_t m_iRotation;
- int32_t m_iAlignment;
- uint32_t m_dwContextCharStyles;
- int32_t m_iCombWidth;
- void* m_pUserData;
- uint32_t m_dwCharType;
- FX_BOOL m_bCurRTL;
- int32_t m_iCurAlignment;
- FX_BOOL m_bArabicNumber;
- FX_BOOL m_bArabicComma;
- CFX_TxtLine* m_pTxtLine1;
- CFX_TxtLine* m_pTxtLine2;
- CFX_TxtLine* m_pCurLine;
- int32_t m_iReady;
- int32_t m_iTolerance;
- int32_t m_iHorScale;
- int32_t m_iVerScale;
- int32_t m_iCharSpace;
- void SetBreakStatus();
- int32_t GetLineRotation(uint32_t dwStyles) const;
- CFX_TxtChar* GetLastChar(int32_t index, FX_BOOL bOmitChar = TRUE) const;
- CFX_TxtLine* GetTxtLine(FX_BOOL bReady) const;
- CFX_TxtPieceArray* GetTxtPieces(FX_BOOL bReady) const;
- uint32_t GetUnifiedCharType(uint32_t dwType) const;
- void ResetArabicContext();
- void ResetContextCharStyles();
- void EndBreak_UpdateArabicShapes();
- FX_BOOL EndBreak_SplitLine(CFX_TxtLine* pNextLine,
- FX_BOOL bAllChars,
- uint32_t dwStatus);
- void EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus);
- void EndBreak_Alignment(CFX_TPOArray& tpos,
- FX_BOOL bAllChars,
- uint32_t dwStatus);
- int32_t GetBreakPos(CFX_TxtCharArray& ca,
- int32_t& iEndPos,
- FX_BOOL bAllChars = FALSE,
- FX_BOOL bOnlyBrk = FALSE);
- void SplitTextLine(CFX_TxtLine* pCurLine,
- CFX_TxtLine* pNextLine,
- FX_BOOL bAllChars = FALSE);
-};
-
-} // namespace
-
-extern const FX_LINEBREAKTYPE gs_FX_LineBreak_PairTable[64][32];
-IFX_TxtBreak* IFX_TxtBreak::Create(uint32_t dwPolicies) {
- return new CFX_TxtBreak(dwPolicies);
-}
CFX_TxtBreak::CFX_TxtBreak(uint32_t dwPolicies)
: m_dwPolicies(dwPolicies),
m_pArabicChar(NULL),
@@ -216,7 +51,7 @@ CFX_TxtBreak::CFX_TxtBreak(uint32_t dwPolicies)
m_iVerScale(100),
m_iCharSpace(0) {
m_bPagination = (m_dwPolicies & FX_TXTBREAKPOLICY_Pagination) != 0;
- m_pArabicChar = IFX_ArabicChar::Create();
+ m_pArabicChar = new CFX_ArabicChar;
if (m_bPagination) {
m_pTxtLine1 = new CFX_TxtLine(sizeof(CFX_Char));
m_pTxtLine2 = new CFX_TxtLine(sizeof(CFX_Char));
diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h
index af817547d3..b83f2604c8 100644
--- a/xfa/fgas/layout/fgas_textbreak.h
+++ b/xfa/fgas/layout/fgas_textbreak.h
@@ -12,12 +12,12 @@
#include "xfa/fgas/crt/fgas_utils.h"
#include "xfa/fgas/layout/fgas_unicode.h"
-class IFX_Font;
+class CFX_ArabicChar;
class CFX_Char;
-class IFX_TxtAccess;
class CFX_TxtChar;
class CFX_TxtPiece;
-class IFX_TxtBreak;
+class IFX_Font;
+class IFX_TxtAccess;
#define FX_TXTBREAKPOLICY_None 0x00
#define FX_TXTBREAKPOLICY_Pagination 0x01
@@ -177,46 +177,162 @@ class CFX_TxtPiece : public CFX_Target {
};
typedef CFX_BaseArrayTemplate<CFX_TxtPiece> CFX_TxtPieceArray;
-class IFX_TxtBreak {
+class CFX_TxtLine {
+ public:
+ CFX_TxtLine(int32_t iBlockSize)
+ : m_iStart(0), m_iWidth(0), m_iArabicChars(0) {
+ m_pLineChars = new CFX_TxtCharArray;
+ m_pLinePieces = new CFX_TxtPieceArray(16);
+ }
+ ~CFX_TxtLine() {
+ RemoveAll();
+ delete m_pLineChars;
+ delete m_pLinePieces;
+ }
+ int32_t CountChars() const { return m_pLineChars->GetSize(); }
+ CFX_TxtChar* GetCharPtr(int32_t index) const {
+ FXSYS_assert(index > -1 && index < m_pLineChars->GetSize());
+ return m_pLineChars->GetDataPtr(index);
+ }
+ int32_t CountPieces() const { return m_pLinePieces->GetSize(); }
+ CFX_TxtPiece* GetPiecePtr(int32_t index) const {
+ FXSYS_assert(index > -1 && index < m_pLinePieces->GetSize());
+ return m_pLinePieces->GetPtrAt(index);
+ }
+ void GetString(CFX_WideString& wsStr) const {
+ int32_t iCount = m_pLineChars->GetSize();
+ FX_WCHAR* pBuf = wsStr.GetBuffer(iCount);
+ CFX_Char* pChar;
+ for (int32_t i = 0; i < iCount; i++) {
+ pChar = m_pLineChars->GetDataPtr(i);
+ *pBuf++ = (FX_WCHAR)pChar->m_wCharCode;
+ }
+ wsStr.ReleaseBuffer(iCount);
+ }
+ void RemoveAll(FX_BOOL bLeaveMemory = FALSE) {
+ m_pLineChars->RemoveAll();
+ m_pLinePieces->RemoveAll(bLeaveMemory);
+ m_iWidth = 0;
+ m_iArabicChars = 0;
+ }
+ CFX_TxtCharArray* m_pLineChars;
+ CFX_TxtPieceArray* m_pLinePieces;
+ int32_t m_iStart;
+ int32_t m_iWidth;
+ int32_t m_iArabicChars;
+};
+
+class CFX_TxtBreak {
public:
- static IFX_TxtBreak* Create(uint32_t dwPolicies);
- virtual ~IFX_TxtBreak() {}
- virtual void Release() = 0;
- virtual void SetLineWidth(FX_FLOAT fLineWidth) = 0;
- virtual void SetLinePos(FX_FLOAT fLinePos) = 0;
- virtual uint32_t GetLayoutStyles() const = 0;
- virtual void SetLayoutStyles(uint32_t dwLayoutStyles) = 0;
- virtual void SetFont(IFX_Font* pFont) = 0;
- virtual void SetFontSize(FX_FLOAT fFontSize) = 0;
- virtual void SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) = 0;
- virtual void SetDefaultChar(FX_WCHAR wch) = 0;
- virtual void SetParagraphBreakChar(FX_WCHAR wch) = 0;
- virtual void SetLineBreakTolerance(FX_FLOAT fTolerance) = 0;
- virtual void SetHorizontalScale(int32_t iScale) = 0;
- virtual void SetVerticalScale(int32_t iScale) = 0;
- virtual void SetCharRotation(int32_t iCharRotation) = 0;
- virtual void SetCharSpace(FX_FLOAT fCharSpace) = 0;
- virtual void SetAlignment(int32_t iAlignment) = 0;
- virtual uint32_t GetContextCharStyles() const = 0;
- virtual void SetContextCharStyles(uint32_t dwCharStyles) = 0;
- virtual void SetCombWidth(FX_FLOAT fCombWidth) = 0;
- virtual void SetUserData(void* pUserData) = 0;
- virtual uint32_t AppendChar(FX_WCHAR wch) = 0;
- virtual uint32_t EndBreak(uint32_t dwStatus = FX_TXTBREAK_PieceBreak) = 0;
- virtual int32_t CountBreakChars() const = 0;
- virtual int32_t CountBreakPieces() const = 0;
- virtual const CFX_TxtPiece* GetBreakPiece(int32_t index) const = 0;
- virtual void ClearBreakPieces() = 0;
- virtual void Reset() = 0;
- virtual int32_t GetDisplayPos(
- const FX_TXTRUN* pTxtRun,
- FXTEXT_CHARPOS* pCharPos,
- FX_BOOL bCharCode = FALSE,
- CFX_WideString* pWSForms = NULL,
- FX_AdjustCharDisplayPos pAdjustPos = NULL) const = 0;
- virtual int32_t GetCharRects(const FX_TXTRUN* pTxtRun,
- CFX_RectFArray& rtArray,
- FX_BOOL bCharBBox = FALSE) const = 0;
+ CFX_TxtBreak(uint32_t dwPolicies);
+ ~CFX_TxtBreak();
+
+ void Release() { delete this; }
+ void SetLineWidth(FX_FLOAT fLineWidth);
+ void SetLinePos(FX_FLOAT fLinePos);
+ uint32_t GetLayoutStyles() const { return m_dwLayoutStyles; }
+ void SetLayoutStyles(uint32_t dwLayoutStyles);
+ void SetFont(IFX_Font* pFont);
+ void SetFontSize(FX_FLOAT fFontSize);
+ void SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);
+ void SetDefaultChar(FX_WCHAR wch);
+ void SetParagraphBreakChar(FX_WCHAR wch);
+ void SetLineBreakTolerance(FX_FLOAT fTolerance);
+ void SetHorizontalScale(int32_t iScale);
+ void SetVerticalScale(int32_t iScale);
+ void SetCharRotation(int32_t iCharRotation);
+ void SetCharSpace(FX_FLOAT fCharSpace);
+ void SetAlignment(int32_t iAlignment);
+ uint32_t GetContextCharStyles() const;
+ void SetContextCharStyles(uint32_t dwCharStyles);
+ void SetCombWidth(FX_FLOAT fCombWidth);
+ void SetUserData(void* pUserData);
+ uint32_t AppendChar(FX_WCHAR wch);
+ uint32_t EndBreak(uint32_t dwStatus = FX_TXTBREAK_PieceBreak);
+ int32_t CountBreakChars() const;
+ int32_t CountBreakPieces() const;
+ const CFX_TxtPiece* GetBreakPiece(int32_t index) const;
+ void ClearBreakPieces();
+ void Reset();
+ int32_t GetDisplayPos(const FX_TXTRUN* pTxtRun,
+ FXTEXT_CHARPOS* pCharPos,
+ FX_BOOL bCharCode = FALSE,
+ CFX_WideString* pWSForms = NULL,
+ FX_AdjustCharDisplayPos pAdjustPos = NULL) const;
+ int32_t GetCharRects(const FX_TXTRUN* pTxtRun,
+ CFX_RectFArray& rtArray,
+ FX_BOOL bCharBBox = FALSE) const;
+ void AppendChar_PageLoad(CFX_Char* pCurChar, uint32_t dwProps);
+ uint32_t AppendChar_Combination(CFX_Char* pCurChar, int32_t iRotation);
+ uint32_t AppendChar_Tab(CFX_Char* pCurChar, int32_t iRotation);
+ uint32_t AppendChar_Control(CFX_Char* pCurChar, int32_t iRotation);
+ uint32_t AppendChar_Arabic(CFX_Char* pCurChar, int32_t iRotation);
+ uint32_t AppendChar_Others(CFX_Char* pCurChar, int32_t iRotation);
+
+ protected:
+ uint32_t m_dwPolicies;
+ FX_BOOL m_bPagination;
+ CFX_ArabicChar* m_pArabicChar;
+ int32_t m_iLineWidth;
+ uint32_t m_dwLayoutStyles;
+ FX_BOOL m_bVertical;
+ FX_BOOL m_bArabicContext;
+ FX_BOOL m_bArabicShapes;
+ FX_BOOL m_bRTL;
+ FX_BOOL m_bSingleLine;
+ FX_BOOL m_bCombText;
+ int32_t m_iArabicContext;
+ int32_t m_iCurArabicContext;
+ IFX_Font* m_pFont;
+ int32_t m_iFontSize;
+ FX_BOOL m_bEquidistant;
+ int32_t m_iTabWidth;
+ FX_WCHAR m_wDefChar;
+ FX_WCHAR m_wParagBreakChar;
+ int32_t m_iDefChar;
+ int32_t m_iLineRotation;
+ int32_t m_iCharRotation;
+ int32_t m_iRotation;
+ int32_t m_iAlignment;
+ uint32_t m_dwContextCharStyles;
+ int32_t m_iCombWidth;
+ void* m_pUserData;
+ uint32_t m_dwCharType;
+ FX_BOOL m_bCurRTL;
+ int32_t m_iCurAlignment;
+ FX_BOOL m_bArabicNumber;
+ FX_BOOL m_bArabicComma;
+ CFX_TxtLine* m_pTxtLine1;
+ CFX_TxtLine* m_pTxtLine2;
+ CFX_TxtLine* m_pCurLine;
+ int32_t m_iReady;
+ int32_t m_iTolerance;
+ int32_t m_iHorScale;
+ int32_t m_iVerScale;
+ int32_t m_iCharSpace;
+ void SetBreakStatus();
+ int32_t GetLineRotation(uint32_t dwStyles) const;
+ CFX_TxtChar* GetLastChar(int32_t index, FX_BOOL bOmitChar = TRUE) const;
+ CFX_TxtLine* GetTxtLine(FX_BOOL bReady) const;
+ CFX_TxtPieceArray* GetTxtPieces(FX_BOOL bReady) const;
+ uint32_t GetUnifiedCharType(uint32_t dwType) const;
+ void ResetArabicContext();
+ void ResetContextCharStyles();
+ void EndBreak_UpdateArabicShapes();
+ FX_BOOL EndBreak_SplitLine(CFX_TxtLine* pNextLine,
+ FX_BOOL bAllChars,
+ uint32_t dwStatus);
+ void EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus);
+ void EndBreak_Alignment(CFX_TPOArray& tpos,
+ FX_BOOL bAllChars,
+ uint32_t dwStatus);
+ int32_t GetBreakPos(CFX_TxtCharArray& ca,
+ int32_t& iEndPos,
+ FX_BOOL bAllChars = FALSE,
+ FX_BOOL bOnlyBrk = FALSE);
+ void SplitTextLine(CFX_TxtLine* pCurLine,
+ CFX_TxtLine* pNextLine,
+ FX_BOOL bAllChars = FALSE);
};
#endif // XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_