diff options
-rw-r--r-- | BUILD.gn | 6 | ||||
-rw-r--r-- | core/fxcrt/cfx_char.cpp | 50 | ||||
-rw-r--r-- | core/fxcrt/cfx_char.h | 43 | ||||
-rw-r--r-- | core/fxcrt/fx_arabic.cpp | 39 | ||||
-rw-r--r-- | core/fxcrt/fx_arabic.h | 7 | ||||
-rw-r--r-- | core/fxcrt/fx_ucd.h | 76 | ||||
-rw-r--r-- | xfa/fde/cfde_txtedtpage.cpp | 4 | ||||
-rw-r--r-- | xfa/fde/cfde_txtedtparag.cpp | 2 | ||||
-rw-r--r-- | xfa/fde/tto/fde_textout.cpp | 13 | ||||
-rw-r--r-- | xfa/fde/tto/fde_textout.h | 2 | ||||
-rw-r--r-- | xfa/fgas/layout/cfx_breakline.cpp | 55 | ||||
-rw-r--r-- | xfa/fgas/layout/cfx_breakline.h | 39 | ||||
-rw-r--r-- | xfa/fgas/layout/cfx_breakpiece.cpp | 53 | ||||
-rw-r--r-- | xfa/fgas/layout/cfx_breakpiece.h | 46 | ||||
-rw-r--r-- | xfa/fgas/layout/fgas_rtfbreak.cpp | 118 | ||||
-rw-r--r-- | xfa/fgas/layout/fgas_rtfbreak.h | 104 | ||||
-rw-r--r-- | xfa/fgas/layout/fgas_textbreak.cpp | 105 | ||||
-rw-r--r-- | xfa/fgas/layout/fgas_textbreak.h | 121 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textlayout.cpp | 4 |
19 files changed, 442 insertions, 445 deletions
@@ -799,6 +799,8 @@ static_library("fxcrt") { if (pdf_enable_xfa) { sources += [ + "core/fxcrt/cfx_char.cpp", + "core/fxcrt/cfx_char.h", "core/fxcrt/fx_arabic.cpp", "core/fxcrt/fx_arabic.h", ] @@ -1234,6 +1236,10 @@ if (pdf_enable_xfa) { "xfa/fgas/font/cfgas_gefont.h", "xfa/fgas/font/fgas_fontutils.cpp", "xfa/fgas/font/fgas_fontutils.h", + "xfa/fgas/layout/cfx_breakline.cpp", + "xfa/fgas/layout/cfx_breakline.h", + "xfa/fgas/layout/cfx_breakpiece.cpp", + "xfa/fgas/layout/cfx_breakpiece.h", "xfa/fgas/layout/fgas_linebreak.cpp", "xfa/fgas/layout/fgas_linebreak.h", "xfa/fgas/layout/fgas_rtfbreak.cpp", diff --git a/core/fxcrt/cfx_char.cpp b/core/fxcrt/cfx_char.cpp new file mode 100644 index 0000000000..ab7abd9884 --- /dev/null +++ b/core/fxcrt/cfx_char.cpp @@ -0,0 +1,50 @@ +// Copyright 2017 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 + +#include "core/fxcrt/cfx_char.h" + +CFX_Char::CFX_Char() + : m_dwStatus(CFX_BreakType::None), + m_nBreakType(0), + m_dwCharStyles(0), + m_dwCharProps(0), + m_iCharWidth(0), + m_iHorizontalScale(100), + m_iVerticalScale(100), + m_iBidiClass(0), + m_iBidiLevel(0), + m_iBidiPos(0), + m_iBidiOrder(0), + m_wCharCode(0), + m_iFontSize(0), + m_iFontHeight(0), + m_dwIdentity(0), + m_pUserData(nullptr) {} + +CFX_Char::CFX_Char(uint16_t wCharCode, uint32_t dwCharProps) + : m_nBreakType(0), + m_dwCharStyles(0), + m_dwCharProps(dwCharProps), + m_iCharWidth(0), + m_iHorizontalScale(100), + m_iVerticalScale(100), + m_iBidiClass(0), + m_iBidiLevel(0), + m_iBidiPos(0), + m_iBidiOrder(0), + m_wCharCode(wCharCode), + m_iFontSize(0), + m_iFontHeight(0), + m_dwIdentity(0), + m_pUserData(nullptr) {} + +CFX_Char::CFX_Char(const CFX_Char& other) = default; + +CFX_Char::~CFX_Char() = default; + +FX_CHARTYPE CFX_Char::GetCharType() const { + return GetCharTypeFromProp(m_dwCharProps); +} diff --git a/core/fxcrt/cfx_char.h b/core/fxcrt/cfx_char.h new file mode 100644 index 0000000000..bc91c91386 --- /dev/null +++ b/core/fxcrt/cfx_char.h @@ -0,0 +1,43 @@ +// Copyright 2017 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_FXCRT_CFX_CHAR_H_ +#define CORE_FXCRT_CFX_CHAR_H_ + +#include <stdint.h> + +#include "core/fxcrt/fx_ucd.h" + +enum class CFX_BreakType { None = 0, Piece, Line, Paragraph, Page }; + +class CFX_Char { + public: + CFX_Char(); + CFX_Char(uint16_t wCharCode, uint32_t dwCharProps); + CFX_Char(const CFX_Char& other); + ~CFX_Char(); + + FX_CHARTYPE GetCharType() const; + + CFX_BreakType m_dwStatus; + uint8_t m_nBreakType; + uint32_t m_dwCharStyles; + uint32_t m_dwCharProps; + int32_t m_iCharWidth; + int32_t m_iHorizontalScale; + int32_t m_iVerticalScale; + int16_t m_iBidiClass; + int16_t m_iBidiLevel; + int16_t m_iBidiPos; + int16_t m_iBidiOrder; + uint16_t m_wCharCode; + int32_t m_iFontSize; + int32_t m_iFontHeight; + uint32_t m_dwIdentity; + CFX_RetainPtr<CFX_Retainable> m_pUserData; +}; + +#endif // CORE_FXCRT_CFX_CHAR_H_ diff --git a/core/fxcrt/fx_arabic.cpp b/core/fxcrt/fx_arabic.cpp index 29e6e437e8..11743e41ad 100644 --- a/core/fxcrt/fx_arabic.cpp +++ b/core/fxcrt/fx_arabic.cpp @@ -410,10 +410,9 @@ void FX_BidiReorder(int32_t iBaseLevel, } } -template <class baseType> class CFX_BidiLineTemplate { public: - void FX_BidiReverseString(std::vector<baseType>& chars, + void FX_BidiReverseString(std::vector<CFX_Char>& chars, int32_t iStart, int32_t iCount) { ASSERT(iStart >= 0 && iStart < pdfium::CollectionSize<int32_t>(chars)); @@ -422,7 +421,7 @@ class CFX_BidiLineTemplate { std::reverse(chars.begin() + iStart, chars.begin() + iStart + iCount); } - void FX_BidiSetDeferredRun(std::vector<baseType>& chars, + void FX_BidiSetDeferredRun(std::vector<CFX_Char>& chars, bool bClass, int32_t iStart, int32_t iCount, @@ -439,7 +438,7 @@ class CFX_BidiLineTemplate { } } - void FX_BidiClassify(std::vector<baseType>& chars, int32_t iCount, bool bWS) { + void FX_BidiClassify(std::vector<CFX_Char>& chars, int32_t iCount, bool bWS) { ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars)); if (bWS) { for (int32_t i = 0; i < iCount; i++) { @@ -456,7 +455,7 @@ class CFX_BidiLineTemplate { } } - void FX_BidiResolveExplicit(std::vector<baseType>& chars, + void FX_BidiResolveExplicit(std::vector<CFX_Char>& chars, int32_t iCount, int32_t iBaseLevel) { ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars)); @@ -465,7 +464,7 @@ class CFX_BidiLineTemplate { chars[i].m_iBidiLevel = static_cast<int16_t>(iBaseLevel); } - void FX_BidiResolveWeak(std::vector<baseType>& chars, + void FX_BidiResolveWeak(std::vector<CFX_Char>& chars, int32_t iCount, int32_t iBaseLevel) { ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars)); @@ -473,7 +472,7 @@ class CFX_BidiLineTemplate { if (iCount < 1) { return; } - baseType *pTC, *pTCNext; + CFX_Char *pTC, *pTCNext; int32_t iLevelCur = iBaseLevel; int32_t iState = FX_IsOdd(iBaseLevel) ? FX_BWSxr : FX_BWSxl; int32_t i = 0, iNum = 0, iClsCur, iClsRun, iClsNew, iAction; @@ -537,7 +536,7 @@ class CFX_BidiLineTemplate { } } - void FX_BidiResolveNeutrals(std::vector<baseType>& chars, + void FX_BidiResolveNeutrals(std::vector<CFX_Char>& chars, int32_t iCount, int32_t iBaseLevel) { ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars)); @@ -546,7 +545,7 @@ class CFX_BidiLineTemplate { if (iCount < 1) { return; } - baseType* pTC; + CFX_Char* pTC; int32_t iLevel = iBaseLevel; int32_t iState = FX_IsOdd(iBaseLevel) ? FX_BNSr : FX_BNSl; int32_t i = 0, iNum = 0, iClsCur, iClsRun, iClsNew, iAction; @@ -586,7 +585,7 @@ class CFX_BidiLineTemplate { } } - void FX_BidiResolveImplicit(std::vector<baseType>& chars, int32_t iCount) { + void FX_BidiResolveImplicit(std::vector<CFX_Char>& chars, int32_t iCount) { ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars)); for (int32_t i = 0; i < iCount; i++) { int32_t iCls = chars[i].m_iBidiClass; @@ -600,7 +599,7 @@ class CFX_BidiLineTemplate { } } - void FX_BidiResolveWhitespace(std::vector<baseType>& chars, + void FX_BidiResolveWhitespace(std::vector<CFX_Char>& chars, int32_t iCount, int32_t iBaseLevel) { ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars)); @@ -644,7 +643,7 @@ class CFX_BidiLineTemplate { } } - int32_t FX_BidiReorderLevel(std::vector<baseType>& chars, + int32_t FX_BidiReorderLevel(std::vector<CFX_Char>& chars, int32_t iCount, int32_t iBaseLevel, int32_t iStart, @@ -672,7 +671,7 @@ class CFX_BidiLineTemplate { return iNum; } - void FX_BidiReorder(std::vector<baseType>& chars, + void FX_BidiReorder(std::vector<CFX_Char>& chars, int32_t iCount, int32_t iBaseLevel) { ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars)); @@ -683,13 +682,13 @@ class CFX_BidiLineTemplate { } } - void FX_BidiPosition(std::vector<baseType>& chars, int32_t iCount) { + void FX_BidiPosition(std::vector<CFX_Char>& chars, int32_t iCount) { ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars)); for (int32_t i = 0; i < iCount; ++i) chars[chars[i].m_iBidiPos].m_iBidiOrder = i; } - void FX_BidiLine(std::vector<baseType>& chars, + void FX_BidiLine(std::vector<CFX_Char>& chars, int32_t iCount, int32_t iBaseLevel) { ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(chars)); @@ -708,15 +707,9 @@ class CFX_BidiLineTemplate { } }; -void FX_BidiLine(std::vector<CFX_TxtChar>& chars, +void FX_BidiLine(std::vector<CFX_Char>& chars, int32_t iCount, int32_t iBaseLevel) { - CFX_BidiLineTemplate<CFX_TxtChar> blt; - blt.FX_BidiLine(chars, iCount, iBaseLevel); -} -void FX_BidiLine(std::vector<CFX_RTFChar>& chars, - int32_t iCount, - int32_t iBaseLevel) { - CFX_BidiLineTemplate<CFX_RTFChar> blt; + CFX_BidiLineTemplate blt; blt.FX_BidiLine(chars, iCount, iBaseLevel); } diff --git a/core/fxcrt/fx_arabic.h b/core/fxcrt/fx_arabic.h index 9f6ec50ef6..1856f106c2 100644 --- a/core/fxcrt/fx_arabic.h +++ b/core/fxcrt/fx_arabic.h @@ -9,8 +9,8 @@ #include <vector> +#include "core/fxcrt/cfx_char.h" #include "core/fxcrt/fx_system.h" -#include "core/fxcrt/fx_ucd.h" #define FX_BIDIMAXLEVEL 61 #define FX_BidiDirection(a) (FX_IsOdd(a) ? FX_BIDICLASS_R : FX_BIDICLASS_L) @@ -164,10 +164,7 @@ const FX_ARBFORMTABLE* FX_GetArabicFormTable(FX_WCHAR unicode); FX_WCHAR FX_GetArabicFromAlefTable(FX_WCHAR alef); FX_WCHAR FX_GetArabicFromShaddaTable(FX_WCHAR shadda); -void FX_BidiLine(std::vector<CFX_TxtChar>& chars, - int32_t iCount, - int32_t iBaseLevel = 0); -void FX_BidiLine(std::vector<CFX_RTFChar>& chars, +void FX_BidiLine(std::vector<CFX_Char>& chars, int32_t iCount, int32_t iBaseLevel = 0); diff --git a/core/fxcrt/fx_ucd.h b/core/fxcrt/fx_ucd.h index f8a92a18f2..488c275808 100644 --- a/core/fxcrt/fx_ucd.h +++ b/core/fxcrt/fx_ucd.h @@ -119,82 +119,6 @@ FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, bool bRTL, bool bVertical); -enum class CFX_BreakType { None = 0, Piece, Line, Paragraph, Page }; - -class CFX_Char { - public: - CFX_Char() - : m_dwStatus(CFX_BreakType::None), - m_wCharCode(0), - m_nBreakType(0), - m_dwCharProps(0), - m_iCharWidth(0), - m_iHorizontalScale(100), - m_iVerticalScale(100) {} - - CFX_Char(uint16_t wCharCode, uint32_t dwCharProps) - : m_wCharCode(wCharCode), - m_nBreakType(0), - m_dwCharProps(dwCharProps), - m_iCharWidth(0), - m_iHorizontalScale(100), - m_iVerticalScale(100) {} - - FX_CHARTYPE GetCharType() const { return GetCharTypeFromProp(m_dwCharProps); } - - CFX_BreakType m_dwStatus; - uint16_t m_wCharCode; - uint8_t m_nBreakType; - uint32_t m_dwCharProps; - int32_t m_iCharWidth; - int32_t m_iHorizontalScale; - int32_t m_iVerticalScale; -}; - -class CFX_TxtChar : public CFX_Char { - public: - CFX_TxtChar() - : m_dwCharStyles(0), - m_iBidiClass(0), - m_iBidiLevel(0), - m_iBidiPos(0), - m_iBidiOrder(0) {} - - uint32_t m_dwCharStyles; - int16_t m_iBidiClass; - int16_t m_iBidiLevel; - int16_t m_iBidiPos; - int16_t m_iBidiOrder; -}; - -class CFX_RTFChar : public CFX_Char { - public: - CFX_RTFChar(); - CFX_RTFChar(const CFX_RTFChar& other); - ~CFX_RTFChar(); - - int32_t m_iFontSize; - int32_t m_iFontHeight; - int16_t m_iBidiClass; - int16_t m_iBidiLevel; - int16_t m_iBidiPos; - int16_t m_iBidiOrder; - uint32_t m_dwIdentity; - CFX_RetainPtr<CFX_Retainable> m_pUserData; -}; - -inline CFX_RTFChar::CFX_RTFChar() - : m_iFontSize(0), - m_iFontHeight(0), - m_iBidiClass(0), - m_iBidiLevel(0), - m_iBidiPos(0), - m_dwIdentity(0), - m_pUserData(nullptr) {} - -inline CFX_RTFChar::CFX_RTFChar(const CFX_RTFChar& other) = default; -inline CFX_RTFChar::~CFX_RTFChar() = default; - #endif // PDF_ENABLE_XFA #endif // CORE_FXCRT_FX_UCD_H_ diff --git a/xfa/fde/cfde_txtedtpage.cpp b/xfa/fde/cfde_txtedtpage.cpp index fd44b28ef2..f0a33d0516 100644 --- a/xfa/fde/cfde_txtedtpage.cpp +++ b/xfa/fde/cfde_txtedtpage.cpp @@ -296,7 +296,7 @@ int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox, if (!CFX_BreakTypeNoneOrPiece(dwBreakStatus)) { int32_t nPieceCount = pBreak->CountBreakPieces(); for (int32_t j = 0; j < nPieceCount; j++) { - const CFX_TxtPiece* pPiece = pBreak->GetBreakPiece(j); + const CFX_BreakPiece* pPiece = pBreak->GetBreakPiece(j); FDE_TEXTEDITPIECE TxtEdtPiece; FXSYS_memset(&TxtEdtPiece, 0, sizeof(FDE_TEXTEDITPIECE)); TxtEdtPiece.nBidiLevel = pPiece->m_iBidiLevel; @@ -345,7 +345,7 @@ int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox, m_Pieces.push_back(TxtEdtPiece); for (int32_t k = 0; k < TxtEdtPiece.nCount; k++) { m_CharWidths[TxtEdtPiece.nStart + k] = - pPiece->GetChar(k).m_iCharWidth; + pPiece->GetChar(k)->m_iCharWidth; } } fLinePos += fLineStep; diff --git a/xfa/fde/cfde_txtedtparag.cpp b/xfa/fde/cfde_txtedtparag.cpp index f7ba6d9631..79dcc2fbac 100644 --- a/xfa/fde/cfde_txtedtparag.cpp +++ b/xfa/fde/cfde_txtedtparag.cpp @@ -63,7 +63,7 @@ void CFDE_TxtEdtParag::LoadParag() { int32_t nCount = pTxtBreak->CountBreakPieces(); int32_t nTotal = 0; for (int32_t j = 0; j < nCount; j++) { - const CFX_TxtPiece* Piece = pTxtBreak->GetBreakPiece(j); + const CFX_BreakPiece* Piece = pTxtBreak->GetBreakPiece(j); nTotal += Piece->GetLength(); } LineBaseArr.Add(nTotal); diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp index 0e8e91e8b1..02b1522823 100644 --- a/xfa/fde/tto/fde_textout.cpp +++ b/xfa/fde/tto/fde_textout.cpp @@ -245,7 +245,7 @@ bool CFDE_TextOut::RetrieveLineWidth(CFX_BreakType dwBreakStatus, FX_FLOAT fLineWidth = 0.0f; int32_t iCount = m_pTxtBreak->CountBreakPieces(); for (int32_t i = 0; i < iCount; i++) { - const CFX_TxtPiece* pPiece = m_pTxtBreak->GetBreakPiece(i); + const CFX_BreakPiece* pPiece = m_pTxtBreak->GetBreakPiece(i); fLineWidth += static_cast<FX_FLOAT>(pPiece->m_iWidth) / 20000.0f; fStartPos = std::min(fStartPos, static_cast<FX_FLOAT>(pPiece->m_iStartPos) / 20000.0f); @@ -387,10 +387,11 @@ void CFDE_TextOut::RetrieveEllPieces(std::vector<int32_t>* pCharWidths) { int32_t iCount = m_pTxtBreak->CountBreakPieces(); int32_t iCharIndex = 0; for (int32_t i = 0; i < iCount; i++) { - const CFX_TxtPiece* pPiece = m_pTxtBreak->GetBreakPiece(i); + const CFX_BreakPiece* pPiece = m_pTxtBreak->GetBreakPiece(i); int32_t iPieceChars = pPiece->GetLength(); for (int32_t j = 0; j < iPieceChars; j++) { - (*pCharWidths)[iCharIndex] = std::max(pPiece->GetChar(j).m_iCharWidth, 0); + (*pCharWidths)[iCharIndex] = + std::max(pPiece->GetChar(j)->m_iCharWidth, 0); m_iEllipsisWidth += (*pCharWidths)[iCharIndex]; iCharIndex++; } @@ -468,14 +469,14 @@ bool CFDE_TextOut::RetrievePieces(CFX_BreakType dwBreakStatus, int32_t iLineWidth = FXSYS_round(fLineWidth * 20000.0f); int32_t iCount = m_pTxtBreak->CountBreakPieces(); for (int32_t i = 0; i < iCount; i++) { - const CFX_TxtPiece* pPiece = m_pTxtBreak->GetBreakPiece(i); + const CFX_BreakPiece* pPiece = m_pTxtBreak->GetBreakPiece(i); int32_t iPieceChars = pPiece->GetLength(); int32_t iChar = iStartChar; int32_t iWidth = 0; int32_t j = 0; for (; j < iPieceChars; j++) { - const CFX_Char& pTC = pPiece->GetChar(j); - int32_t iCurCharWidth = pTC.m_iCharWidth > 0 ? pTC.m_iCharWidth : 0; + const CFX_Char* pTC = pPiece->GetChar(j); + int32_t iCurCharWidth = pTC->m_iCharWidth > 0 ? pTC->m_iCharWidth : 0; if (bSingleLine || !bLineWrap) { if (iLineWidth - iPieceWidths - iWidth < iCurCharWidth) { bNeedReload = true; diff --git a/xfa/fde/tto/fde_textout.h b/xfa/fde/tto/fde_textout.h index fa4444822d..1519a81e8f 100644 --- a/xfa/fde/tto/fde_textout.h +++ b/xfa/fde/tto/fde_textout.h @@ -11,7 +11,7 @@ #include <memory> #include <vector> -#include "core/fxcrt/fx_ucd.h" +#include "core/fxcrt/cfx_char.h" #include "core/fxge/cfx_fxgedevice.h" #include "core/fxge/cfx_renderdevice.h" #include "core/fxge/fx_dib.h" diff --git a/xfa/fgas/layout/cfx_breakline.cpp b/xfa/fgas/layout/cfx_breakline.cpp new file mode 100644 index 0000000000..4e9d8ad5ae --- /dev/null +++ b/xfa/fgas/layout/cfx_breakline.cpp @@ -0,0 +1,55 @@ +// Copyright 2017 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 + +#include "xfa/fgas/layout/cfx_breakline.h" + +#include "third_party/base/stl_util.h" + +CFX_BreakLine::CFX_BreakLine() : m_iStart(0), m_iWidth(0), m_iArabicChars(0) {} + +CFX_BreakLine::~CFX_BreakLine() {} + +int32_t CFX_BreakLine::CountChars() const { + return pdfium::CollectionSize<int32_t>(m_LineChars); +} + +CFX_Char* CFX_BreakLine::GetChar(int32_t index) { + ASSERT(index >= 0 && index < pdfium::CollectionSize<int32_t>(m_LineChars)); + return &m_LineChars[index]; +} + +const CFX_Char* CFX_BreakLine::GetChar(int32_t index) const { + ASSERT(index >= 0 && index < pdfium::CollectionSize<int32_t>(m_LineChars)); + return &m_LineChars[index]; +} + +int32_t CFX_BreakLine::CountPieces() const { + return pdfium::CollectionSize<int32_t>(m_LinePieces); +} + +const CFX_BreakPiece* CFX_BreakLine::GetPiece(int32_t index) const { + ASSERT(index >= 0 && index < CountPieces()); + return &m_LinePieces[index]; +} + +void CFX_BreakLine::GetString(CFX_WideString& wsStr) const { + int32_t iCount = pdfium::CollectionSize<int32_t>(m_LineChars); + FX_WCHAR* pBuf = wsStr.GetBuffer(iCount); + for (int32_t i = 0; i < iCount; i++) + *pBuf++ = static_cast<FX_WCHAR>(m_LineChars[i].m_wCharCode); + wsStr.ReleaseBuffer(iCount); +} + +int32_t CFX_BreakLine::GetLineEnd() const { + return m_iStart + m_iWidth; +} + +void CFX_BreakLine::Clear() { + m_LineChars.clear(); + m_LinePieces.clear(); + m_iWidth = 0; + m_iArabicChars = 0; +} diff --git a/xfa/fgas/layout/cfx_breakline.h b/xfa/fgas/layout/cfx_breakline.h new file mode 100644 index 0000000000..138ee3104e --- /dev/null +++ b/xfa/fgas/layout/cfx_breakline.h @@ -0,0 +1,39 @@ +// Copyright 2017 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 XFA_FGAS_LAYOUT_CFX_BREAKLINE_H_ +#define XFA_FGAS_LAYOUT_CFX_BREAKLINE_H_ + +#include <vector> + +#include "core/fxcrt/cfx_char.h" +#include "xfa/fgas/layout/cfx_breakpiece.h" + +class CFX_BreakLine { + public: + CFX_BreakLine(); + ~CFX_BreakLine(); + + int32_t CountChars() const; + CFX_Char* GetChar(int32_t index); + const CFX_Char* GetChar(int32_t index) const; + + int32_t CountPieces() const; + const CFX_BreakPiece* GetPiece(int32_t index) const; + + void GetString(CFX_WideString& wsStr) const; + int32_t GetLineEnd() const; + + void Clear(); + + std::vector<CFX_Char> m_LineChars; + std::vector<CFX_BreakPiece> m_LinePieces; + int32_t m_iStart; + int32_t m_iWidth; + int32_t m_iArabicChars; +}; + +#endif // XFA_FGAS_LAYOUT_CFX_BREAKLINE_H_ diff --git a/xfa/fgas/layout/cfx_breakpiece.cpp b/xfa/fgas/layout/cfx_breakpiece.cpp new file mode 100644 index 0000000000..d31c53f964 --- /dev/null +++ b/xfa/fgas/layout/cfx_breakpiece.cpp @@ -0,0 +1,53 @@ +// Copyright 2017 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 + +#include "xfa/fgas/layout/cfx_breakpiece.h" + +CFX_BreakPiece::CFX_BreakPiece() + : m_dwStatus(CFX_BreakType::Piece), + m_iStartPos(0), + m_iWidth(-1), + m_iStartChar(0), + m_iChars(0), + m_iBidiLevel(0), + m_iBidiPos(0), + m_iFontSize(0), + m_iFontHeight(0), + m_iHorizontalScale(100), + m_iVerticalScale(100), + m_dwIdentity(0), + m_dwCharStyles(0), + m_pChars(nullptr), + m_pUserData(nullptr) {} + +CFX_BreakPiece::CFX_BreakPiece(const CFX_BreakPiece& other) = default; + +CFX_BreakPiece::~CFX_BreakPiece() = default; + +int32_t CFX_BreakPiece::GetEndPos() const { + return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; +} + +CFX_Char* CFX_BreakPiece::GetChar(int32_t index) const { + ASSERT(index >= 0 && index < m_iChars && m_pChars); + return &(*m_pChars)[m_iStartChar + index]; +} + +CFX_WideString CFX_BreakPiece::GetString() const { + CFX_WideString ret; + ret.Reserve(m_iChars); + for (int32_t i = m_iStartChar; i < m_iStartChar + m_iChars; i++) + ret += static_cast<FX_WCHAR>((*m_pChars)[i].m_wCharCode); + return ret; +} + +std::vector<int32_t> CFX_BreakPiece::GetWidths() const { + std::vector<int32_t> ret; + ret.reserve(m_iChars); + for (int32_t i = m_iStartChar; i < m_iStartChar + m_iChars; i++) + ret.push_back((*m_pChars)[i].m_iCharWidth); + return ret; +} diff --git a/xfa/fgas/layout/cfx_breakpiece.h b/xfa/fgas/layout/cfx_breakpiece.h new file mode 100644 index 0000000000..64622b25c1 --- /dev/null +++ b/xfa/fgas/layout/cfx_breakpiece.h @@ -0,0 +1,46 @@ +// Copyright 2017 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 XFA_FGAS_LAYOUT_CFX_BREAKPIECE_H_ +#define XFA_FGAS_LAYOUT_CFX_BREAKPIECE_H_ + +#include <vector> + +#include "core/fxcrt/cfx_char.h" +#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/fx_string.h" + +class CFX_BreakPiece { + public: + CFX_BreakPiece(); + CFX_BreakPiece(const CFX_BreakPiece& other); + ~CFX_BreakPiece(); + + int32_t GetEndPos() const; + int32_t GetLength() const { return m_iChars; } + + CFX_Char* GetChar(int32_t index) const; + CFX_WideString GetString() const; + std::vector<int32_t> GetWidths() const; + + CFX_BreakType m_dwStatus; + int32_t m_iStartPos; + int32_t m_iWidth; + int32_t m_iStartChar; + int32_t m_iChars; + int32_t m_iBidiLevel; + int32_t m_iBidiPos; + int32_t m_iFontSize; + int32_t m_iFontHeight; + int32_t m_iHorizontalScale; + int32_t m_iVerticalScale; + uint32_t m_dwIdentity; + uint32_t m_dwCharStyles; + std::vector<CFX_Char>* m_pChars; // not owned. + CFX_RetainPtr<CFX_Retainable> m_pUserData; +}; + +#endif // XFA_FGAS_LAYOUT_CFX_BREAKPIECE_H_ diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp index c725dfb268..85edaf7f99 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.cpp +++ b/xfa/fgas/layout/fgas_rtfbreak.cpp @@ -148,20 +148,20 @@ void CFX_RTFBreak::SetBreakStatus() { if (iCount < 1) return; - CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1); - if (tc.m_dwStatus == CFX_BreakType::None) - tc.m_dwStatus = CFX_BreakType::Piece; + CFX_Char* tc = m_pCurLine->GetChar(iCount - 1); + if (tc->m_dwStatus == CFX_BreakType::None) + tc->m_dwStatus = CFX_BreakType::Piece; } -CFX_RTFChar* CFX_RTFBreak::GetLastChar(int32_t index) const { - std::vector<CFX_RTFChar>& tca = m_pCurLine->m_LineChars; +CFX_Char* CFX_RTFBreak::GetLastChar(int32_t index) const { + std::vector<CFX_Char>& tca = m_pCurLine->m_LineChars; int32_t iCount = pdfium::CollectionSize<int32_t>(tca); if (index < 0 || index >= iCount) return nullptr; int32_t iStart = iCount - 1; while (iStart > -1) { - CFX_RTFChar* pTC = &tca[iStart--]; + CFX_Char* pTC = &tca[iStart--]; if (pTC->m_iCharWidth >= 0 || pTC->GetCharType() != FX_CHARTYPE_Combination) { if (--index < 0) @@ -197,7 +197,7 @@ CFX_BreakType CFX_RTFBreak::AppendChar(FX_WCHAR wch) { FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps); m_pCurLine->m_LineChars.emplace_back(); - CFX_RTFChar* pCurChar = &m_pCurLine->m_LineChars.back(); + CFX_Char* pCurChar = &m_pCurLine->m_LineChars.back(); pCurChar->m_dwStatus = CFX_BreakType::None; pCurChar->m_wCharCode = wch; pCurChar->m_dwCharProps = dwProps; @@ -253,14 +253,14 @@ CFX_BreakType CFX_RTFBreak::AppendChar(FX_WCHAR wch) { return std::max(dwRet1, dwRet2); } -void CFX_RTFBreak::AppendChar_Combination(CFX_RTFChar* pCurChar) { +void CFX_RTFBreak::AppendChar_Combination(CFX_Char* pCurChar) { int32_t iCharWidth = 0; if (!m_pFont->GetCharWidth(pCurChar->m_wCharCode, iCharWidth, false)) iCharWidth = 0; iCharWidth *= m_iFontSize; iCharWidth = iCharWidth * m_iHorizontalScale / 100; - CFX_RTFChar* pLastChar = GetLastChar(0); + CFX_Char* pLastChar = GetLastChar(0); if (pLastChar && pLastChar->GetCharType() > FX_CHARTYPE_Combination) iCharWidth = -iCharWidth; else @@ -271,7 +271,7 @@ void CFX_RTFBreak::AppendChar_Combination(CFX_RTFChar* pCurChar) { m_pCurLine->m_iWidth += iCharWidth; } -void CFX_RTFBreak::AppendChar_Tab(CFX_RTFChar* pCurChar) { +void CFX_RTFBreak::AppendChar_Tab(CFX_Char* pCurChar) { if (!(m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_ExpandTab)) return; @@ -286,7 +286,7 @@ void CFX_RTFBreak::AppendChar_Tab(CFX_RTFChar* pCurChar) { iLineWidth += iCharWidth; } -CFX_BreakType CFX_RTFBreak::AppendChar_Control(CFX_RTFChar* pCurChar) { +CFX_BreakType CFX_RTFBreak::AppendChar_Control(CFX_Char* pCurChar) { CFX_BreakType dwRet2 = CFX_BreakType::None; switch (pCurChar->m_wCharCode) { case L'\v': @@ -310,8 +310,8 @@ CFX_BreakType CFX_RTFBreak::AppendChar_Control(CFX_RTFChar* pCurChar) { return dwRet2; } -CFX_BreakType CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar) { - CFX_RTFChar* pLastChar = nullptr; +CFX_BreakType CFX_RTFBreak::AppendChar_Arabic(CFX_Char* pCurChar) { + CFX_Char* pLastChar = nullptr; int32_t iCharWidth = 0; FX_WCHAR wForm; bool bAlef = false; @@ -320,7 +320,7 @@ CFX_BreakType CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar) { pLastChar = GetLastChar(1); if (pLastChar) { m_pCurLine->m_iWidth -= pLastChar->m_iCharWidth; - CFX_RTFChar* pPrevChar = GetLastChar(2); + CFX_Char* pPrevChar = GetLastChar(2); wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar); bAlef = (wForm == 0xFEFF && pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); @@ -355,7 +355,7 @@ CFX_BreakType CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar) { return CFX_BreakType::None; } -CFX_BreakType CFX_RTFBreak::AppendChar_Others(CFX_RTFChar* pCurChar) { +CFX_BreakType CFX_RTFBreak::AppendChar_Others(CFX_Char* pCurChar) { FX_CHARTYPE chartype = pCurChar->GetCharType(); FX_WCHAR wForm = pCurChar->m_wCharCode; int32_t iCharWidth = 0; @@ -398,13 +398,13 @@ CFX_BreakType CFX_RTFBreak::EndBreak(CFX_BreakType dwStatus) { if (iCount < 1) return CFX_BreakType::None; - CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1); - tc.m_dwStatus = dwStatus; + CFX_Char* tc = m_pCurLine->GetChar(iCount - 1); + tc->m_dwStatus = dwStatus; if (dwStatus == CFX_BreakType::Piece) return dwStatus; m_iReadyLineIndex = m_pCurLine == &m_RTFLine[0] ? 0 : 1; - CFX_RTFLine* pNextLine = &m_RTFLine[1 - m_iReadyLineIndex]; + CFX_BreakLine* pNextLine = &m_RTFLine[1 - m_iReadyLineIndex]; bool bAllChars = m_iAlignment == CFX_RTFLineAlignment::Justified || m_iAlignment == CFX_RTFLineAlignment::Distributed; @@ -417,18 +417,18 @@ CFX_BreakType CFX_RTFBreak::EndBreak(CFX_BreakType dwStatus) { m_pCurLine = pNextLine; m_pCurLine->m_iStart = m_iBoundaryStart; - CFX_RTFChar* pTC = GetLastChar(0); + CFX_Char* pTC = GetLastChar(0); m_eCharType = pTC ? pTC->GetCharType() : FX_CHARTYPE_Unknown; return dwStatus; } -bool CFX_RTFBreak::EndBreak_SplitLine(CFX_RTFLine* pNextLine, +bool CFX_RTFBreak::EndBreak_SplitLine(CFX_BreakLine* pNextLine, bool bAllChars, CFX_BreakType dwStatus) { bool bDone = false; if (m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { - const CFX_RTFChar& tc = m_pCurLine->GetChar(m_pCurLine->CountChars() - 1); - switch (tc.GetCharType()) { + const CFX_Char* tc = m_pCurLine->GetChar(m_pCurLine->CountChars() - 1); + switch (tc->GetCharType()) { case FX_CHARTYPE_Tab: case FX_CHARTYPE_Control: case FX_CHARTYPE_Space: @@ -448,15 +448,15 @@ bool CFX_RTFBreak::EndBreak_SplitLine(CFX_RTFLine* pNextLine, return false; } - const CFX_RTFChar* pCurChars = m_pCurLine->m_LineChars.data(); - CFX_RTFPiece tp; + const CFX_Char* pCurChars = m_pCurLine->m_LineChars.data(); + CFX_BreakPiece tp; tp.m_pChars = &m_pCurLine->m_LineChars; bool bNew = true; uint32_t dwIdentity = static_cast<uint32_t>(-1); int32_t iLast = m_pCurLine->CountChars() - 1; int32_t j = 0; for (int32_t i = 0; i <= iLast;) { - const CFX_RTFChar* pTC = pCurChars + i; + const CFX_Char* pTC = pCurChars + i; if (bNew) { tp.m_iStartChar = i; tp.m_iStartPos += tp.m_iWidth; @@ -494,8 +494,8 @@ bool CFX_RTFBreak::EndBreak_SplitLine(CFX_RTFLine* pNextLine, void CFX_RTFBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos, CFX_BreakType dwStatus) { - CFX_RTFChar* pTC; - std::vector<CFX_RTFChar>& chars = m_pCurLine->m_LineChars; + CFX_Char* pTC; + std::vector<CFX_Char>& chars = m_pCurLine->m_LineChars; int32_t iCount = m_pCurLine->CountChars(); if (!m_bPagination && m_pCurLine->m_iArabicChars > 0) { int32_t iBidiNum = 0; @@ -517,7 +517,7 @@ void CFX_RTFBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos, } } - CFX_RTFPiece tp; + CFX_BreakPiece tp; tp.m_dwStatus = CFX_BreakType::Piece; tp.m_iStartPos = m_pCurLine->m_iStart; tp.m_pChars = &chars; @@ -577,7 +577,7 @@ void CFX_RTFBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos, std::sort(tpos->begin(), tpos->end()); int32_t iStartPos = m_pCurLine->m_iStart; for (const auto& it : *tpos) { - CFX_RTFPiece& ttp = m_pCurLine->m_LinePieces[it.index]; + CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[it.index]; ttp.m_iStartPos = iStartPos; iStartPos += ttp.m_iWidth; } @@ -590,23 +590,23 @@ void CFX_RTFBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos, int32_t iGapChars = 0; bool bFind = false; for (auto it = tpos.rbegin(); it != tpos.rend(); it++) { - CFX_RTFPiece& ttp = m_pCurLine->m_LinePieces[it->index]; + CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[it->index]; if (!bFind) iNetWidth = ttp.GetEndPos(); bool bArabic = FX_IsOdd(ttp.m_iBidiLevel); int32_t j = bArabic ? 0 : ttp.m_iChars - 1; while (j > -1 && j < ttp.m_iChars) { - const CFX_RTFChar& tc = ttp.GetChar(j); - if (tc.m_nBreakType == FX_LBT_DIRECT_BRK) + const CFX_Char* tc = ttp.GetChar(j); + if (tc->m_nBreakType == FX_LBT_DIRECT_BRK) ++iGapChars; if (!bFind || !bAllChars) { - uint32_t dwCharType = tc.GetCharType(); + uint32_t dwCharType = tc->GetCharType(); if (dwCharType == FX_CHARTYPE_Space || dwCharType == FX_CHARTYPE_Control) { if (!bFind) { - int32_t iCharWidth = tc.m_iCharWidth; + int32_t iCharWidth = tc->m_iCharWidth; if (bAllChars && iCharWidth > 0) iNetWidth -= iCharWidth; } @@ -628,19 +628,19 @@ void CFX_RTFBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos, dwStatus != CFX_BreakType::Paragraph))) { int32_t iStart = -1; for (const auto& tpo : tpos) { - CFX_RTFPiece& ttp = m_pCurLine->m_LinePieces[tpo.index]; + CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[tpo.index]; if (iStart < 0) iStart = ttp.m_iStartPos; else ttp.m_iStartPos = iStart; for (int32_t j = 0; j < ttp.m_iChars; ++j) { - CFX_RTFChar& tc = ttp.GetChar(j); - if (tc.m_nBreakType != FX_LBT_DIRECT_BRK || tc.m_iCharWidth < 0) + CFX_Char* tc = ttp.GetChar(j); + if (tc->m_nBreakType != FX_LBT_DIRECT_BRK || tc->m_iCharWidth < 0) continue; int32_t k = iOffset / iGapChars; - tc.m_iCharWidth += k; + tc->m_iCharWidth += k; ttp.m_iWidth += k; iOffset -= k; --iGapChars; @@ -660,7 +660,7 @@ void CFX_RTFBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos, } } -int32_t CFX_RTFBreak::GetBreakPos(std::vector<CFX_RTFChar>& tca, +int32_t CFX_RTFBreak::GetBreakPos(std::vector<CFX_Char>& tca, int32_t& iEndPos, bool bAllChars, bool bOnlyBrk) { @@ -682,8 +682,8 @@ int32_t CFX_RTFBreak::GetBreakPos(std::vector<CFX_RTFChar>& tca, iBreakPos = iEndPos; } - CFX_RTFChar* pCharArray = tca.data(); - CFX_RTFChar* pCur = pCharArray + iLength; + CFX_Char* pCharArray = tca.data(); + CFX_Char* pCur = pCharArray + iLength; --iLength; if (bAllChars) pCur->m_nBreakType = FX_LBT_UNKNOWN; @@ -755,8 +755,8 @@ int32_t CFX_RTFBreak::GetBreakPos(std::vector<CFX_RTFChar>& tca, return 0; } -void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine, - CFX_RTFLine* pNextLine, +void CFX_RTFBreak::SplitTextLine(CFX_BreakLine* pCurLine, + CFX_BreakLine* pNextLine, bool bAllChars) { ASSERT(pCurLine && pNextLine); int32_t iCount = pCurLine->CountChars(); @@ -764,7 +764,7 @@ void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine, return; int32_t iEndPos = pCurLine->GetLineEnd(); - std::vector<CFX_RTFChar>& curChars = pCurLine->m_LineChars; + std::vector<CFX_Char>& curChars = pCurLine->m_LineChars; int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, false); if (iCharPos < 0) iCharPos = 0; @@ -777,7 +777,7 @@ void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine, } pNextLine->m_LineChars = - std::vector<CFX_RTFChar>(curChars.begin() + iCharPos, curChars.end()); + std::vector<CFX_Char>(curChars.begin() + iCharPos, curChars.end()); curChars.erase(curChars.begin() + iCharPos, curChars.end()); pNextLine->m_iStart = pCurLine->m_iStart; pNextLine->m_iWidth = pCurLine->GetLineEnd() - iEndPos; @@ -799,11 +799,11 @@ int32_t CFX_RTFBreak::CountBreakPieces() const { : 0; } -const CFX_RTFPiece* CFX_RTFBreak::GetBreakPieceUnstable(int32_t index) const { +const CFX_BreakPiece* CFX_RTFBreak::GetBreakPieceUnstable(int32_t index) const { if (!HasRTFLine()) return nullptr; - const std::vector<CFX_RTFPiece>& pRTFPieces = + const std::vector<CFX_BreakPiece>& pRTFPieces = m_RTFLine[m_iReadyLineIndex].m_LinePieces; if (index < 0 || index >= pdfium::CollectionSize<int32_t>(pRTFPieces)) return nullptr; @@ -937,30 +937,6 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, return iCount; } -CFX_RTFPiece::CFX_RTFPiece() - : m_dwStatus(CFX_BreakType::Piece), - m_iStartPos(0), - m_iWidth(-1), - m_iStartChar(0), - m_iChars(0), - m_iBidiLevel(0), - m_iBidiPos(0), - m_iFontSize(0), - m_iFontHeight(0), - m_iHorizontalScale(100), - m_iVerticalScale(100), - m_dwIdentity(0), - m_pChars(nullptr), - m_pUserData(nullptr) {} - -CFX_RTFPiece::CFX_RTFPiece(const CFX_RTFPiece& other) = default; - -CFX_RTFPiece::~CFX_RTFPiece() {} - -CFX_RTFLine::CFX_RTFLine() : m_iStart(0), m_iWidth(0), m_iArabicChars(0) {} - -CFX_RTFLine::~CFX_RTFLine() {} - FX_RTFTEXTOBJ::FX_RTFTEXTOBJ() : pFont(nullptr), pRect(nullptr), diff --git a/xfa/fgas/layout/fgas_rtfbreak.h b/xfa/fgas/layout/fgas_rtfbreak.h index d71eeeef17..b3def63251 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.h +++ b/xfa/fgas/layout/fgas_rtfbreak.h @@ -44,82 +44,6 @@ struct FX_RTFTEXTOBJ { int32_t iVerticalScale; }; -class CFX_RTFPiece { - public: - CFX_RTFPiece(); - CFX_RTFPiece(const CFX_RTFPiece& other); - ~CFX_RTFPiece(); - - int32_t GetEndPos() const { - return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; - } - - CFX_RTFChar& GetChar(int32_t index) { - ASSERT(index > -1 && index < m_iChars && m_pChars); - return (*m_pChars)[m_iStartChar + index]; - } - - CFX_WideString GetString() const { - CFX_WideString ret; - ret.Reserve(m_iChars); - for (int32_t i = m_iStartChar; i < m_iStartChar + m_iChars; i++) - ret += static_cast<FX_WCHAR>((*m_pChars)[i].m_wCharCode); - return ret; - } - - std::vector<int32_t> GetWidths() const { - std::vector<int32_t> ret; - ret.reserve(m_iChars); - for (int32_t i = m_iStartChar; i < m_iStartChar + m_iChars; i++) - ret.push_back((*m_pChars)[i].m_iCharWidth); - return ret; - } - - CFX_BreakType m_dwStatus; - int32_t m_iStartPos; - int32_t m_iWidth; - int32_t m_iStartChar; - int32_t m_iChars; - int32_t m_iBidiLevel; - int32_t m_iBidiPos; - int32_t m_iFontSize; - int32_t m_iFontHeight; - int32_t m_iHorizontalScale; - int32_t m_iVerticalScale; - uint32_t m_dwIdentity; - std::vector<CFX_RTFChar>* m_pChars; // not owned. - CFX_RetainPtr<CFX_Retainable> m_pUserData; -}; - -class CFX_RTFLine { - public: - CFX_RTFLine(); - ~CFX_RTFLine(); - - int32_t CountChars() const { - return pdfium::CollectionSize<int32_t>(m_LineChars); - } - - CFX_RTFChar& GetChar(int32_t index) { - ASSERT(index >= 0 && index < pdfium::CollectionSize<int32_t>(m_LineChars)); - return m_LineChars[index]; - } - - int32_t GetLineEnd() const { return m_iStart + m_iWidth; } - void Clear() { - m_LineChars.clear(); - m_LinePieces.clear(); - m_iWidth = 0; - m_iArabicChars = 0; - } - - std::vector<CFX_RTFChar> m_LineChars; - std::vector<CFX_RTFPiece> m_LinePieces; - int32_t m_iStart; - int32_t m_iWidth; - int32_t m_iArabicChars; -}; - class CFX_RTFBreak { public: explicit CFX_RTFBreak(uint32_t dwLayoutStyles); @@ -141,7 +65,7 @@ class CFX_RTFBreak { CFX_BreakType EndBreak(CFX_BreakType dwStatus); int32_t CountBreakPieces() const; - const CFX_RTFPiece* GetBreakPieceUnstable(int32_t index) const; + const CFX_BreakPiece* GetBreakPieceUnstable(int32_t index) const; void ClearBreakPieces(); void Reset(); @@ -152,30 +76,30 @@ class CFX_RTFBreak { CFX_BreakType AppendChar(FX_WCHAR wch); - CFX_RTFLine* GetCurrentLineForTesting() const { return m_pCurLine; } + CFX_BreakLine* GetCurrentLineForTesting() const { return m_pCurLine; } private: - void AppendChar_Combination(CFX_RTFChar* pCurChar); - void AppendChar_Tab(CFX_RTFChar* pCurChar); - CFX_BreakType AppendChar_Control(CFX_RTFChar* pCurChar); - CFX_BreakType AppendChar_Arabic(CFX_RTFChar* pCurChar); - CFX_BreakType AppendChar_Others(CFX_RTFChar* pCurChar); + void AppendChar_Combination(CFX_Char* pCurChar); + void AppendChar_Tab(CFX_Char* pCurChar); + CFX_BreakType AppendChar_Control(CFX_Char* pCurChar); + CFX_BreakType AppendChar_Arabic(CFX_Char* pCurChar); + CFX_BreakType AppendChar_Others(CFX_Char* pCurChar); void FontChanged(); void SetBreakStatus(); - CFX_RTFChar* GetLastChar(int32_t index) const; + CFX_Char* GetLastChar(int32_t index) const; bool HasRTFLine() const { return m_iReadyLineIndex >= 0; } FX_CHARTYPE GetUnifiedCharType(FX_CHARTYPE chartype) const; int32_t GetLastPositionedTab() const; bool GetPositionedTab(int32_t* iTabPos) const; - int32_t GetBreakPos(std::vector<CFX_RTFChar>& tca, + int32_t GetBreakPos(std::vector<CFX_Char>& tca, int32_t& iEndPos, bool bAllChars, bool bOnlyBrk); - void SplitTextLine(CFX_RTFLine* pCurLine, - CFX_RTFLine* pNextLine, + void SplitTextLine(CFX_BreakLine* pCurLine, + CFX_BreakLine* pNextLine, bool bAllChars); - bool EndBreak_SplitLine(CFX_RTFLine* pNextLine, + bool EndBreak_SplitLine(CFX_BreakLine* pNextLine, bool bAllChars, CFX_BreakType dwStatus); void EndBreak_BidiLine(std::deque<FX_TPO>* tpos, CFX_BreakType dwStatus); @@ -202,8 +126,8 @@ class CFX_RTFBreak { CFX_RetainPtr<CFX_Retainable> m_pUserData; FX_CHARTYPE m_eCharType; uint32_t m_dwIdentity; - CFX_RTFLine m_RTFLine[2]; - CFX_RTFLine* m_pCurLine; + CFX_BreakLine m_RTFLine[2]; + CFX_BreakLine* m_pCurLine; int32_t m_iTolerance; int8_t m_iReadyLineIndex; }; diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp index e168613882..9343f94cc6 100644 --- a/xfa/fgas/layout/fgas_textbreak.cpp +++ b/xfa/fgas/layout/fgas_textbreak.cpp @@ -17,7 +17,7 @@ namespace { typedef CFX_BreakType (CFX_TxtBreak::*FX_TxtBreak_LPFAppendChar)( - CFX_TxtChar* pCurChar); + CFX_Char* pCurChar); const FX_TxtBreak_LPFAppendChar g_FX_TxtBreak_lpfAppendChar[16] = { &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Tab, &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Control, @@ -156,7 +156,7 @@ void CFX_TxtBreak::SetBreakStatus() { if (iCount < 1) return; - CFX_TxtChar* pTC = m_pCurLine->GetCharPtr(iCount - 1); + CFX_Char* pTC = m_pCurLine->GetChar(iCount - 1); if (pTC->m_dwStatus == CFX_BreakType::None) pTC->m_dwStatus = CFX_BreakType::Piece; } @@ -175,15 +175,15 @@ void CFX_TxtBreak::SetCharSpace(FX_FLOAT fCharSpace) { m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f); } -CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, bool bOmitChar) const { - std::vector<CFX_TxtChar>& ca = m_pCurLine->m_LineChars; +CFX_Char* CFX_TxtBreak::GetLastChar(int32_t index, bool bOmitChar) const { + std::vector<CFX_Char>& ca = m_pCurLine->m_LineChars; int32_t iCount = pdfium::CollectionSize<int32_t>(ca); if (index < 0 || index >= iCount) return nullptr; int32_t iStart = iCount - 1; while (iStart > -1) { - CFX_TxtChar* pTC = &ca[iStart--]; + CFX_Char* pTC = &ca[iStart--]; if (bOmitChar && pTC->GetCharType() == FX_CHARTYPE_Combination) continue; if (--index < 0) @@ -202,13 +202,12 @@ void CFX_TxtBreak::ResetArabicContext() { ResetContextCharStyles(); } -void CFX_TxtBreak::AppendChar_PageLoad(CFX_TxtChar* pCurChar, - uint32_t dwProps) { +void CFX_TxtBreak::AppendChar_PageLoad(CFX_Char* pCurChar, uint32_t dwProps) { pCurChar->m_dwStatus = CFX_BreakType::None; pCurChar->m_dwCharStyles = m_dwContextCharStyles; } -CFX_BreakType CFX_TxtBreak::AppendChar_Combination(CFX_TxtChar* pCurChar) { +CFX_BreakType CFX_TxtBreak::AppendChar_Combination(CFX_Char* pCurChar) { FX_WCHAR wch = pCurChar->m_wCharCode; FX_WCHAR wForm; int32_t iCharWidth = 0; @@ -217,7 +216,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Combination(CFX_TxtChar* pCurChar) { iCharWidth = m_iCombWidth; } else { wForm = wch; - CFX_TxtChar* pLastChar = GetLastChar(0, false); + CFX_Char* pLastChar = GetLastChar(0, false); if (pLastChar && (pLastChar->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicShadda) == 0) { bool bShadda = false; @@ -249,12 +248,12 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Combination(CFX_TxtChar* pCurChar) { return CFX_BreakType::None; } -CFX_BreakType CFX_TxtBreak::AppendChar_Tab(CFX_TxtChar* pCurChar) { +CFX_BreakType CFX_TxtBreak::AppendChar_Tab(CFX_Char* pCurChar) { m_eCharType = FX_CHARTYPE_Tab; return CFX_BreakType::None; } -CFX_BreakType CFX_TxtBreak::AppendChar_Control(CFX_TxtChar* pCurChar) { +CFX_BreakType CFX_TxtBreak::AppendChar_Control(CFX_Char* pCurChar) { m_eCharType = FX_CHARTYPE_Control; CFX_BreakType dwRet = CFX_BreakType::None; if (!m_bSingleLine) { @@ -281,12 +280,12 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Control(CFX_TxtChar* pCurChar) { return dwRet; } -CFX_BreakType CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar) { +CFX_BreakType CFX_TxtBreak::AppendChar_Arabic(CFX_Char* pCurChar) { FX_CHARTYPE chartype = pCurChar->GetCharType(); int32_t& iLineWidth = m_pCurLine->m_iWidth; FX_WCHAR wForm; int32_t iCharWidth = 0; - CFX_TxtChar* pLastChar = nullptr; + CFX_Char* pLastChar = nullptr; bool bAlef = false; if (!m_bCombText && m_eCharType >= FX_CHARTYPE_ArabicAlef && m_eCharType <= FX_CHARTYPE_ArabicDistortion) { @@ -335,7 +334,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar) { return CFX_BreakType::None; } -CFX_BreakType CFX_TxtBreak::AppendChar_Others(CFX_TxtChar* pCurChar) { +CFX_BreakType CFX_TxtBreak::AppendChar_Others(CFX_Char* pCurChar) { FX_CHARTYPE chartype = pCurChar->GetCharType(); int32_t& iLineWidth = m_pCurLine->m_iWidth; int32_t iCharWidth = 0; @@ -369,7 +368,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar(FX_WCHAR wch) { FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps); m_pCurLine->m_LineChars.emplace_back(); - CFX_TxtChar* pCurChar = &m_pCurLine->m_LineChars.back(); + CFX_Char* pCurChar = &m_pCurLine->m_LineChars.back(); pCurChar->m_wCharCode = static_cast<uint16_t>(wch); pCurChar->m_dwCharProps = dwProps; pCurChar->m_dwCharStyles = 0; @@ -401,12 +400,13 @@ CFX_BreakType CFX_TxtBreak::AppendChar(FX_WCHAR wch) { return std::max(dwRet1, dwRet2); } -bool CFX_TxtBreak::EndBreak_SplitLine(CFX_TxtLine* pNextLine, bool bAllChars) { +bool CFX_TxtBreak::EndBreak_SplitLine(CFX_BreakLine* pNextLine, + bool bAllChars) { int32_t iCount = m_pCurLine->CountChars(); bool bDone = false; - CFX_TxtChar* pTC; + CFX_Char* pTC; if (!m_bSingleLine && m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance) { - pTC = m_pCurLine->GetCharPtr(iCount - 1); + pTC = m_pCurLine->GetChar(iCount - 1); switch (pTC->GetCharType()) { case FX_CHARTYPE_Tab: case FX_CHARTYPE_Control: @@ -420,7 +420,7 @@ bool CFX_TxtBreak::EndBreak_SplitLine(CFX_TxtLine* pNextLine, bool bAllChars) { } iCount = m_pCurLine->CountChars(); - CFX_TxtPiece tp; + CFX_BreakPiece tp; if (bAllChars && !bDone) { int32_t iEndPos = m_pCurLine->m_iWidth; GetBreakPos(m_pCurLine->m_LineChars, iEndPos, bAllChars, true); @@ -430,12 +430,12 @@ bool CFX_TxtBreak::EndBreak_SplitLine(CFX_TxtLine* pNextLine, bool bAllChars) { void CFX_TxtBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos, CFX_BreakType dwStatus) { - CFX_TxtPiece tp; + CFX_BreakPiece tp; FX_TPO tpo; - CFX_TxtChar* pTC; + CFX_Char* pTC; int32_t i; int32_t j; - std::vector<CFX_TxtChar>& chars = m_pCurLine->m_LineChars; + std::vector<CFX_Char>& chars = m_pCurLine->m_LineChars; int32_t iCount = m_pCurLine->CountChars(); bool bDone = m_pCurLine->m_iArabicChars > 0; if (bDone) { @@ -511,7 +511,7 @@ void CFX_TxtBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos, int32_t iStartPos = 0; for (i = 0; i <= j; i++) { tpo = (*tpos)[i]; - CFX_TxtPiece& ttp = m_pCurLine->m_LinePieces[tpo.index]; + CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[tpo.index]; ttp.m_iStartPos = iStartPos; iStartPos += ttp.m_iWidth; } @@ -541,21 +541,21 @@ void CFX_TxtBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos, int32_t iGapChars = 0; bool bFind = false; for (auto it = tpos.rbegin(); it != tpos.rend(); ++it) { - CFX_TxtPiece& ttp = m_pCurLine->m_LinePieces[it->index]; + CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[it->index]; if (!bFind) iNetWidth = ttp.GetEndPos(); bool bArabic = FX_IsOdd(ttp.m_iBidiLevel); int32_t j = bArabic ? 0 : ttp.m_iChars - 1; while (j > -1 && j < ttp.m_iChars) { - const CFX_TxtChar& pTC = ttp.GetChar(j); - if (pTC.m_nBreakType == FX_LBT_DIRECT_BRK) + const CFX_Char* pTC = ttp.GetChar(j); + if (pTC->m_nBreakType == FX_LBT_DIRECT_BRK) iGapChars++; if (!bFind || !bAllChars) { - FX_CHARTYPE chartype = pTC.GetCharType(); + FX_CHARTYPE chartype = pTC->GetCharType(); if (chartype == FX_CHARTYPE_Space || chartype == FX_CHARTYPE_Control) { - if (!bFind && bAllChars && pTC.m_iCharWidth > 0) - iNetWidth -= pTC.m_iCharWidth; + if (!bFind && bAllChars && pTC->m_iCharWidth > 0) + iNetWidth -= pTC->m_iCharWidth; } else { bFind = true; if (!bAllChars) @@ -573,19 +573,19 @@ void CFX_TxtBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos, dwStatus != CFX_BreakType::Paragraph) { int32_t iStart = -1; for (auto& tpo : tpos) { - CFX_TxtPiece& ttp = m_pCurLine->m_LinePieces[tpo.index]; + CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[tpo.index]; if (iStart < -1) iStart = ttp.m_iStartPos; else ttp.m_iStartPos = iStart; for (int32_t j = 0; j < ttp.m_iChars; j++) { - CFX_TxtChar& pTC = ttp.GetChar(j); - if (pTC.m_nBreakType != FX_LBT_DIRECT_BRK || pTC.m_iCharWidth < 0) + CFX_Char* pTC = ttp.GetChar(j); + if (pTC->m_nBreakType != FX_LBT_DIRECT_BRK || pTC->m_iCharWidth < 0) continue; int32_t k = iOffset / iGapChars; - pTC.m_iCharWidth += k; + pTC->m_iCharWidth += k; ttp.m_iWidth += k; iOffset -= k; iGapChars--; @@ -629,12 +629,12 @@ CFX_BreakType CFX_TxtBreak::EndBreak(CFX_BreakType dwStatus) { if (iCount < 1) return CFX_BreakType::None; - m_pCurLine->GetCharPtr(iCount - 1)->m_dwStatus = dwStatus; + m_pCurLine->GetChar(iCount - 1)->m_dwStatus = dwStatus; if (dwStatus == CFX_BreakType::Piece) return dwStatus; m_iReadyLineIndex = m_pCurLine == &m_TxtLine[0] ? 0 : 1; - CFX_TxtLine* pNextLine = &m_TxtLine[1 - m_iReadyLineIndex]; + CFX_BreakLine* pNextLine = &m_TxtLine[1 - m_iReadyLineIndex]; bool bAllChars = m_iCurAlignment > CFX_TxtLineAlignment_Right; if (!EndBreak_SplitLine(pNextLine, bAllChars)) { std::deque<FX_TPO> tpos; @@ -653,7 +653,7 @@ CFX_BreakType CFX_TxtBreak::EndBreak(CFX_BreakType dwStatus) { return dwStatus; } -int32_t CFX_TxtBreak::GetBreakPos(std::vector<CFX_TxtChar>& ca, +int32_t CFX_TxtBreak::GetBreakPos(std::vector<CFX_Char>& ca, int32_t& iEndPos, bool bAllChars, bool bOnlyBrk) { @@ -746,8 +746,8 @@ int32_t CFX_TxtBreak::GetBreakPos(std::vector<CFX_TxtChar>& ca, return 0; } -void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine, - CFX_TxtLine* pNextLine, +void CFX_TxtBreak::SplitTextLine(CFX_BreakLine* pCurLine, + CFX_BreakLine* pNextLine, bool bAllChars) { ASSERT(pCurLine && pNextLine); int32_t iCount = pCurLine->CountChars(); @@ -755,7 +755,7 @@ void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine, return; int32_t iEndPos = pCurLine->m_iWidth; - std::vector<CFX_TxtChar>& curChars = pCurLine->m_LineChars; + std::vector<CFX_Char>& curChars = pCurLine->m_LineChars; int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, false); if (iCharPos < 0) iCharPos = 0; @@ -769,10 +769,10 @@ void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine, } pNextLine->m_LineChars = - std::vector<CFX_TxtChar>(curChars.begin() + iCharPos, curChars.end()); + std::vector<CFX_Char>(curChars.begin() + iCharPos, curChars.end()); curChars.erase(curChars.begin() + iCharPos, curChars.end()); pCurLine->m_iWidth = iEndPos; - CFX_TxtChar* pTC = &curChars[iCharPos - 1]; + CFX_Char* pTC = &curChars[iCharPos - 1]; pTC->m_nBreakType = FX_LBT_UNKNOWN; iCount = pdfium::CollectionSize<int>(pNextLine->m_LineChars); int32_t iWidth = 0; @@ -793,7 +793,7 @@ int32_t CFX_TxtBreak::CountBreakPieces() const { : 0; } -const CFX_TxtPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const { +const CFX_BreakPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const { if (!HasTxtLine()) return nullptr; if (index < 0 || @@ -1194,24 +1194,3 @@ FX_TXTRUN::FX_TXTRUN() FX_TXTRUN::~FX_TXTRUN() {} FX_TXTRUN::FX_TXTRUN(const FX_TXTRUN& other) = default; - -CFX_TxtPiece::CFX_TxtPiece() - : m_dwStatus(CFX_BreakType::Piece), - m_iStartPos(0), - m_iWidth(-1), - m_iStartChar(0), - m_iChars(0), - m_iBidiLevel(0), - m_iBidiPos(0), - m_iHorizontalScale(100), - m_iVerticalScale(100), - m_dwCharStyles(0), - m_pChars(nullptr) {} - -CFX_TxtPiece::CFX_TxtPiece(const CFX_TxtPiece& other) = default; - -CFX_TxtPiece::~CFX_TxtPiece() = default; - -CFX_TxtLine::CFX_TxtLine() : m_iStart(0), m_iWidth(0), m_iArabicChars(0) {} - -CFX_TxtLine::~CFX_TxtLine() {} diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h index c023955aab..9aa576f380 100644 --- a/xfa/fgas/layout/fgas_textbreak.h +++ b/xfa/fgas/layout/fgas_textbreak.h @@ -11,15 +11,13 @@ #include <memory> #include <vector> -#include "core/fxcrt/fx_ucd.h" +#include "core/fxcrt/cfx_char.h" #include "core/fxge/cfx_renderdevice.h" #include "third_party/base/stl_util.h" #include "xfa/fde/cfde_txtedtpage.h" +#include "xfa/fgas/layout/cfx_breakline.h" -class CFX_Char; class CFGAS_GEFont; -class CFX_TxtChar; -class CFX_TxtPiece; struct FDE_TEXTEDITPIECE; #define FX_TXTLAYOUTSTYLE_SingleLine 0x0200 @@ -67,93 +65,6 @@ struct FX_TXTRUN { bool bSkipSpace; }; -class CFX_TxtPiece { - public: - CFX_TxtPiece(); - CFX_TxtPiece(const CFX_TxtPiece& other); - ~CFX_TxtPiece(); - - int32_t GetEndPos() const { - return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth; - } - int32_t GetLength() const { return m_iChars; } - - CFX_TxtChar& GetChar(int32_t index) const { - ASSERT(index > -1 && index < m_iChars && m_pChars); - return (*m_pChars)[m_iStartChar + index]; - } - - CFX_WideString GetString() const { - CFX_WideString ret; - ret.Reserve(m_iChars); - for (int32_t i = m_iStartChar; i < m_iStartChar + m_iChars; i++) - ret += static_cast<FX_WCHAR>((*m_pChars)[i].m_wCharCode); - return ret; - } - - CFX_BreakType m_dwStatus; - int32_t m_iStartPos; - int32_t m_iWidth; - int32_t m_iStartChar; - int32_t m_iChars; - int32_t m_iBidiLevel; - int32_t m_iBidiPos; - int32_t m_iHorizontalScale; - int32_t m_iVerticalScale; - uint32_t m_dwCharStyles; - std::vector<CFX_TxtChar>* m_pChars; -}; - -class CFX_TxtLine { - public: - CFX_TxtLine(); - ~CFX_TxtLine(); - - int32_t CountChars() const { - return pdfium::CollectionSize<int32_t>(m_LineChars); - } - - CFX_TxtChar* GetCharPtr(int32_t index) { - ASSERT(index >= 0 && index < pdfium::CollectionSize<int32_t>(m_LineChars)); - return &m_LineChars[index]; - } - - const CFX_TxtChar* GetCharPtr(int32_t index) const { - ASSERT(index >= 0 && index < pdfium::CollectionSize<int32_t>(m_LineChars)); - return &m_LineChars[index]; - } - - int32_t CountPieces() const { - return pdfium::CollectionSize<int32_t>(m_LinePieces); - } - - const CFX_TxtPiece* GetPiecePtr(int32_t index) const { - ASSERT(index >= 0 && index < CountPieces()); - return &m_LinePieces[index]; - } - - void GetString(CFX_WideString& wsStr) const { - int32_t iCount = pdfium::CollectionSize<int32_t>(m_LineChars); - FX_WCHAR* pBuf = wsStr.GetBuffer(iCount); - for (int32_t i = 0; i < iCount; i++) - *pBuf++ = static_cast<FX_WCHAR>(m_LineChars[i].m_wCharCode); - wsStr.ReleaseBuffer(iCount); - } - - void Clear() { - m_LineChars.clear(); - m_LinePieces.clear(); - m_iWidth = 0; - m_iArabicChars = 0; - } - - std::vector<CFX_TxtChar> m_LineChars; - std::vector<CFX_TxtPiece> m_LinePieces; - int32_t m_iStart; - int32_t m_iWidth; - int32_t m_iArabicChars; -}; - class CFX_TxtBreak { public: CFX_TxtBreak(); @@ -174,7 +85,7 @@ class CFX_TxtBreak { void SetCombWidth(FX_FLOAT fCombWidth); CFX_BreakType EndBreak(CFX_BreakType dwStatus); int32_t CountBreakPieces() const; - const CFX_TxtPiece* GetBreakPiece(int32_t index) const; + const CFX_BreakPiece* GetBreakPiece(int32_t index) const; void ClearBreakPieces(); void Reset(); int32_t GetDisplayPos(const FX_TXTRUN* pTxtRun, @@ -183,33 +94,33 @@ class CFX_TxtBreak { CFX_WideString* pWSForms = nullptr) const; std::vector<CFX_RectF> GetCharRects(const FX_TXTRUN* pTxtRun, bool bCharBBox = false) const; - void AppendChar_PageLoad(CFX_TxtChar* pCurChar, uint32_t dwProps); + void AppendChar_PageLoad(CFX_Char* pCurChar, uint32_t dwProps); CFX_BreakType AppendChar(FX_WCHAR wch); - CFX_BreakType AppendChar_Combination(CFX_TxtChar* pCurChar); - CFX_BreakType AppendChar_Tab(CFX_TxtChar* pCurChar); - CFX_BreakType AppendChar_Control(CFX_TxtChar* pCurChar); - CFX_BreakType AppendChar_Arabic(CFX_TxtChar* pCurChar); - CFX_BreakType AppendChar_Others(CFX_TxtChar* pCurChar); + CFX_BreakType AppendChar_Combination(CFX_Char* pCurChar); + CFX_BreakType AppendChar_Tab(CFX_Char* pCurChar); + CFX_BreakType AppendChar_Control(CFX_Char* pCurChar); + CFX_BreakType AppendChar_Arabic(CFX_Char* pCurChar); + CFX_BreakType AppendChar_Others(CFX_Char* pCurChar); private: void FontChanged(); void SetBreakStatus(); - CFX_TxtChar* GetLastChar(int32_t index, bool bOmitChar = true) const; + CFX_Char* GetLastChar(int32_t index, bool bOmitChar = true) const; bool HasTxtLine() const { return m_iReadyLineIndex >= 0; } FX_CHARTYPE GetUnifiedCharType(FX_CHARTYPE dwType) const; void ResetArabicContext(); void ResetContextCharStyles(); - bool EndBreak_SplitLine(CFX_TxtLine* pNextLine, bool bAllChars); + bool EndBreak_SplitLine(CFX_BreakLine* pNextLine, bool bAllChars); void EndBreak_BidiLine(std::deque<FX_TPO>* tpos, CFX_BreakType dwStatus); void EndBreak_Alignment(const std::deque<FX_TPO>& tpos, bool bAllChars, CFX_BreakType dwStatus); - int32_t GetBreakPos(std::vector<CFX_TxtChar>& ca, + int32_t GetBreakPos(std::vector<CFX_Char>& ca, int32_t& iEndPos, bool bAllChars = false, bool bOnlyBrk = false); - void SplitTextLine(CFX_TxtLine* pCurLine, - CFX_TxtLine* pNextLine, + void SplitTextLine(CFX_BreakLine* pCurLine, + CFX_BreakLine* pNextLine, bool bAllChars = false); int32_t m_iLineWidth; @@ -230,8 +141,8 @@ class CFX_TxtBreak { int32_t m_iCombWidth; FX_CHARTYPE m_eCharType; int32_t m_iCurAlignment; - CFX_TxtLine m_TxtLine[2]; - CFX_TxtLine* m_pCurLine; + CFX_BreakLine m_TxtLine[2]; + CFX_BreakLine* m_pCurLine; int32_t m_iTolerance; int32_t m_iHorScale; int32_t m_iCharSpace; diff --git a/xfa/fxfa/app/cxfa_textlayout.cpp b/xfa/fxfa/app/cxfa_textlayout.cpp index 3c2c37dcff..c2d2a9ef6d 100644 --- a/xfa/fxfa/app/cxfa_textlayout.cpp +++ b/xfa/fxfa/app/cxfa_textlayout.cpp @@ -1032,7 +1032,7 @@ void CXFA_TextLayout::AppendTextLine(CFX_BreakType dwStatus, FX_FLOAT fLineStep = 0, fBaseLine = 0; int32_t i = 0; for (i = 0; i < iPieces; i++) { - const CFX_RTFPiece* pPiece = m_pBreak->GetBreakPieceUnstable(i); + const CFX_BreakPiece* pPiece = m_pBreak->GetBreakPieceUnstable(i); CXFA_TextUserData* pUserData = static_cast<CXFA_TextUserData*>(pPiece->m_pUserData.Get()); if (pUserData) @@ -1087,7 +1087,7 @@ void CXFA_TextLayout::AppendTextLine(CFX_BreakType dwStatus, FX_FLOAT fLineStep = 0; FX_FLOAT fLineWidth = 0; for (int32_t i = 0; i < iPieces; i++) { - const CFX_RTFPiece* pPiece = m_pBreak->GetBreakPieceUnstable(i); + const CFX_BreakPiece* pPiece = m_pBreak->GetBreakPieceUnstable(i); CXFA_TextUserData* pUserData = static_cast<CXFA_TextUserData*>(pPiece->m_pUserData.Get()); if (pUserData) |