summaryrefslogtreecommitdiff
path: root/xfa/fgas
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fgas')
-rw-r--r--xfa/fgas/font/fgas_gefont.cpp52
-rw-r--r--xfa/fgas/font/fgas_gefont.h17
-rw-r--r--xfa/fgas/layout/fgas_textbreak.cpp107
-rw-r--r--xfa/fgas/layout/fgas_textbreak.h10
4 files changed, 101 insertions, 85 deletions
diff --git a/xfa/fgas/font/fgas_gefont.cpp b/xfa/fgas/font/fgas_gefont.cpp
index 48635cabf7..7492de246b 100644
--- a/xfa/fgas/font/fgas_gefont.cpp
+++ b/xfa/fgas/font/fgas_gefont.cpp
@@ -77,12 +77,6 @@ CFGAS_GEFont::CFGAS_GEFont(IFGAS_FontMgr* pFontMgr)
m_pFontMgr(pFontMgr),
m_iRefCount(1),
m_bExtFont(FALSE),
- m_pStream(nullptr),
- m_pFileRead(nullptr),
- m_pFontEncoding(nullptr),
- m_pCharWidthMap(nullptr),
- m_pRectArray(nullptr),
- m_pBBoxMap(nullptr),
m_pProvider(nullptr) {
}
@@ -96,12 +90,6 @@ CFGAS_GEFont::CFGAS_GEFont(const CFGAS_GEFont& src, uint32_t dwFontStyles)
m_pFontMgr(src.m_pFontMgr),
m_iRefCount(1),
m_bExtFont(FALSE),
- m_pStream(nullptr),
- m_pFileRead(nullptr),
- m_pFontEncoding(nullptr),
- m_pCharWidthMap(nullptr),
- m_pRectArray(nullptr),
- m_pBBoxMap(nullptr),
m_pProvider(nullptr) {
ASSERT(src.m_pFont);
m_pFont = new CFX_Font;
@@ -125,16 +113,7 @@ CFGAS_GEFont::~CFGAS_GEFont() {
m_SubstFonts.RemoveAll();
m_FontMapper.clear();
- if (m_pFileRead)
- m_pFileRead->Release();
- if (m_pStream)
- m_pStream->Release();
-
- delete m_pFontEncoding;
- delete m_pCharWidthMap;
- delete m_pRectArray;
- delete m_pBBoxMap;
if (!m_bExtFont)
delete m_pFont;
}
@@ -213,22 +192,17 @@ FX_BOOL CFGAS_GEFont::LoadFontInternal(const uint8_t* pBuffer, int32_t length) {
FX_BOOL CFGAS_GEFont::LoadFontInternal(IFX_Stream* pFontStream,
FX_BOOL bSaveStream) {
- if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) {
+ if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1)
return FALSE;
- }
- if (bSaveStream) {
- m_pStream = pFontStream;
- }
- m_pFileRead = FX_CreateFileRead(pFontStream, FALSE);
+ if (bSaveStream)
+ m_pStream.reset(pFontStream);
+
+ m_pFileRead.reset(FX_CreateFileRead(pFontStream, FALSE));
m_pFont = new CFX_Font;
- FX_BOOL bRet = m_pFont->LoadFile(m_pFileRead);
- if (bRet) {
- bRet = InitFont();
- } else {
- m_pFileRead->Release();
- m_pFileRead = nullptr;
- }
- return bRet;
+ if (m_pFont->LoadFile(m_pFileRead.get()))
+ return InitFont();
+ m_pFileRead.reset();
+ return FALSE;
}
#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
@@ -245,16 +219,16 @@ FX_BOOL CFGAS_GEFont::InitFont() {
if (!m_pFont)
return FALSE;
if (!m_pFontEncoding) {
- m_pFontEncoding = FX_CreateFontEncodingEx(m_pFont);
+ m_pFontEncoding.reset(FX_CreateFontEncodingEx(m_pFont));
if (!m_pFontEncoding)
return FALSE;
}
if (!m_pCharWidthMap)
- m_pCharWidthMap = new CFX_DiscreteArrayTemplate<uint16_t>(1024);
+ m_pCharWidthMap.reset(new CFX_DiscreteArrayTemplate<uint16_t>(1024));
if (!m_pRectArray)
- m_pRectArray = new CFX_MassArrayTemplate<CFX_Rect>(16);
+ m_pRectArray.reset(new CFX_MassArrayTemplate<CFX_Rect>(16));
if (!m_pBBoxMap)
- m_pBBoxMap = new CFX_MapPtrToPtr(16);
+ m_pBBoxMap.reset(new CFX_MapPtrToPtr(16));
return TRUE;
}
diff --git a/xfa/fgas/font/fgas_gefont.h b/xfa/fgas/font/fgas_gefont.h
index a94583fa65..37aa03eda9 100644
--- a/xfa/fgas/font/fgas_gefont.h
+++ b/xfa/fgas/font/fgas_gefont.h
@@ -9,6 +9,7 @@
#include <map>
+#include "core/fxcrt/include/fx_memory.h"
#include "xfa/fgas/crt/fgas_utils.h"
#include "xfa/fgas/font/fgas_font.h"
@@ -92,16 +93,16 @@ class CFGAS_GEFont {
uint32_t m_dwLogFontStyle;
#endif
CFX_Font* m_pFont;
- IFGAS_FontMgr* m_pFontMgr;
+ IFGAS_FontMgr* const m_pFontMgr;
int32_t m_iRefCount;
FX_BOOL m_bExtFont;
- IFX_Stream* m_pStream;
- IFX_FileRead* m_pFileRead;
- CFX_UnicodeEncoding* m_pFontEncoding;
- CFX_DiscreteArrayTemplate<uint16_t>* m_pCharWidthMap;
- CFX_MassArrayTemplate<CFX_Rect>* m_pRectArray;
- CFX_MapPtrToPtr* m_pBBoxMap;
- CXFA_PDFFontMgr* m_pProvider;
+ std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> m_pStream;
+ std::unique_ptr<IFX_FileRead, ReleaseDeleter<IFX_FileRead>> m_pFileRead;
+ std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding;
+ std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap;
+ std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray;
+ std::unique_ptr<CFX_MapPtrToPtr> m_pBBoxMap;
+ CXFA_PDFFontMgr* m_pProvider; // not owned.
CFX_ArrayTemplate<CFGAS_GEFont*> m_SubstFonts;
std::map<FX_WCHAR, CFGAS_GEFont*> m_FontMapper;
};
diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp
index 89b17ccb9b..5ee399fead 100644
--- a/xfa/fgas/layout/fgas_textbreak.cpp
+++ b/xfa/fgas/layout/fgas_textbreak.cpp
@@ -69,25 +69,22 @@ CFX_TxtBreak::CFX_TxtBreak(uint32_t dwPolicies)
m_iVerScale(100),
m_iCharSpace(0) {
m_bPagination = (m_dwPolicies & FX_TXTBREAKPOLICY_Pagination) != 0;
- if (m_bPagination) {
- m_pTxtLine1 = new CFX_TxtLine(sizeof(CFX_Char));
- m_pTxtLine2 = new CFX_TxtLine(sizeof(CFX_Char));
- } else {
- m_pTxtLine1 = new CFX_TxtLine(sizeof(CFX_TxtChar));
- m_pTxtLine2 = new CFX_TxtLine(sizeof(CFX_TxtChar));
- }
- m_pCurLine = m_pTxtLine1;
+ int32_t iSize = m_bPagination ? sizeof(CFX_Char) : sizeof(CFX_TxtChar);
+ m_pTxtLine1.reset(new CFX_TxtLine(iSize));
+ m_pTxtLine2.reset(new CFX_TxtLine(iSize));
+ m_pCurLine = m_pTxtLine1.get();
ResetArabicContext();
}
+
CFX_TxtBreak::~CFX_TxtBreak() {
Reset();
- delete m_pTxtLine1;
- delete m_pTxtLine2;
}
+
void CFX_TxtBreak::SetLineWidth(FX_FLOAT fLineWidth) {
m_iLineWidth = FXSYS_round(fLineWidth * 20000.0f);
ASSERT(m_iLineWidth >= 20000);
}
+
void CFX_TxtBreak::SetLinePos(FX_FLOAT fLinePos) {
int32_t iLinePos = FXSYS_round(fLinePos * 20000.0f);
if (iLinePos < 0) {
@@ -99,6 +96,7 @@ void CFX_TxtBreak::SetLinePos(FX_FLOAT fLinePos) {
m_pCurLine->m_iStart = iLinePos;
m_pCurLine->m_iWidth += iLinePos;
}
+
void CFX_TxtBreak::SetLayoutStyles(uint32_t dwLayoutStyles) {
m_dwLayoutStyles = dwLayoutStyles;
m_bVertical = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_VerticalChars) != 0;
@@ -112,6 +110,7 @@ void CFX_TxtBreak::SetLayoutStyles(uint32_t dwLayoutStyles) {
m_iRotation = m_iLineRotation + m_iCharRotation;
m_iRotation %= 4;
}
+
void CFX_TxtBreak::SetFont(CFGAS_GEFont* pFont) {
if (!pFont) {
return;
@@ -127,6 +126,7 @@ void CFX_TxtBreak::SetFont(CFGAS_GEFont* pFont) {
m_iDefChar *= m_iFontSize;
}
}
+
void CFX_TxtBreak::SetFontSize(FX_FLOAT fFontSize) {
int32_t iFontSize = FXSYS_round(fFontSize * 20.0f);
if (m_iFontSize == iFontSize) {
@@ -140,6 +140,7 @@ void CFX_TxtBreak::SetFontSize(FX_FLOAT fFontSize) {
m_iDefChar *= m_iFontSize;
}
}
+
void CFX_TxtBreak::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
m_iTabWidth = FXSYS_round(fTabWidth * 20000.0f);
if (m_iTabWidth < FX_TXTBREAK_MinimumTabWidth) {
@@ -147,6 +148,7 @@ void CFX_TxtBreak::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
}
m_bEquidistant = bEquidistant;
}
+
void CFX_TxtBreak::SetDefaultChar(FX_WCHAR wch) {
m_wDefChar = wch;
m_iDefChar = 0;
@@ -159,15 +161,18 @@ void CFX_TxtBreak::SetDefaultChar(FX_WCHAR wch) {
}
}
}
+
void CFX_TxtBreak::SetParagraphBreakChar(FX_WCHAR wch) {
if (wch != L'\r' && wch != L'\n') {
return;
}
m_wParagBreakChar = wch;
}
+
void CFX_TxtBreak::SetLineBreakTolerance(FX_FLOAT fTolerance) {
m_iTolerance = FXSYS_round(fTolerance * 20000.0f);
}
+
void CFX_TxtBreak::SetCharRotation(int32_t iCharRotation) {
if (iCharRotation < 0) {
iCharRotation += (-iCharRotation / 4 + 1) * 4;
@@ -182,12 +187,14 @@ void CFX_TxtBreak::SetCharRotation(int32_t iCharRotation) {
m_iRotation = m_iLineRotation + m_iCharRotation;
m_iRotation %= 4;
}
+
void CFX_TxtBreak::SetAlignment(int32_t iAlignment) {
ASSERT(iAlignment >= FX_TXTLINEALIGNMENT_Left &&
iAlignment <= FX_TXTLINEALIGNMENT_Distributed);
m_iAlignment = iAlignment;
ResetArabicContext();
}
+
void CFX_TxtBreak::ResetContextCharStyles() {
m_dwContextCharStyles = m_bArabicContext ? m_iCurAlignment : m_iAlignment;
if (m_bArabicNumber) {
@@ -201,9 +208,11 @@ void CFX_TxtBreak::ResetContextCharStyles() {
}
m_dwContextCharStyles |= (m_iArabicContext << 8);
}
+
uint32_t CFX_TxtBreak::GetContextCharStyles() const {
return m_dwContextCharStyles;
}
+
void CFX_TxtBreak::SetContextCharStyles(uint32_t dwCharStyles) {
m_iCurAlignment = dwCharStyles & 0x0F;
m_bArabicNumber = (dwCharStyles & FX_TXTCHARSTYLE_ArabicNumber) != 0;
@@ -212,9 +221,11 @@ void CFX_TxtBreak::SetContextCharStyles(uint32_t dwCharStyles) {
m_iCurArabicContext = m_iArabicContext = ((dwCharStyles & 0x0300) >> 8);
ResetContextCharStyles();
}
+
void CFX_TxtBreak::SetCombWidth(FX_FLOAT fCombWidth) {
m_iCombWidth = FXSYS_round(fCombWidth * 20000.0f);
}
+
void CFX_TxtBreak::SetUserData(void* pUserData) {
if (m_pUserData == pUserData) {
return;
@@ -222,6 +233,7 @@ void CFX_TxtBreak::SetUserData(void* pUserData) {
SetBreakStatus();
m_pUserData = pUserData;
}
+
void CFX_TxtBreak::SetBreakStatus() {
if (m_bPagination) {
return;
@@ -235,6 +247,7 @@ void CFX_TxtBreak::SetBreakStatus() {
pTC->m_dwStatus = FX_TXTBREAK_PieceBreak;
}
}
+
void CFX_TxtBreak::SetHorizontalScale(int32_t iScale) {
if (iScale < 0) {
iScale = 0;
@@ -245,6 +258,7 @@ void CFX_TxtBreak::SetHorizontalScale(int32_t iScale) {
SetBreakStatus();
m_iHorScale = iScale;
}
+
void CFX_TxtBreak::SetVerticalScale(int32_t iScale) {
if (iScale < 0) {
iScale = 0;
@@ -255,15 +269,18 @@ void CFX_TxtBreak::SetVerticalScale(int32_t iScale) {
SetBreakStatus();
m_iVerScale = iScale;
}
+
void CFX_TxtBreak::SetCharSpace(FX_FLOAT fCharSpace) {
m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f);
}
+
static const int32_t gs_FX_TxtLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2};
int32_t CFX_TxtBreak::GetLineRotation(uint32_t dwStyles) const {
return gs_FX_TxtLineRotations[(dwStyles & 0x0E) >> 1];
}
+
CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, FX_BOOL bOmitChar) const {
- CFX_TxtCharArray& ca = *m_pCurLine->m_pLineChars;
+ CFX_TxtCharArray& ca = *m_pCurLine->m_pLineChars.get();
int32_t iCount = ca.GetSize();
if (index < 0 || index >= iCount) {
return nullptr;
@@ -281,26 +298,30 @@ CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, FX_BOOL bOmitChar) const {
}
return nullptr;
}
+
CFX_TxtLine* CFX_TxtBreak::GetTxtLine(FX_BOOL bReady) const {
if (!bReady)
return m_pCurLine;
if (m_iReady == 1)
- return m_pTxtLine1;
+ return m_pTxtLine1.get();
if (m_iReady == 2)
- return m_pTxtLine2;
+ return m_pTxtLine2.get();
return nullptr;
}
+
CFX_TxtPieceArray* CFX_TxtBreak::GetTxtPieces(FX_BOOL bReady) const {
CFX_TxtLine* pTxtLine = GetTxtLine(bReady);
if (!pTxtLine) {
return nullptr;
}
- return pTxtLine->m_pLinePieces;
+ return pTxtLine->m_pLinePieces.get();
}
+
inline FX_CHARTYPE CFX_TxtBreak::GetUnifiedCharType(
FX_CHARTYPE chartype) const {
return chartype >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : chartype;
}
+
void CFX_TxtBreak::ResetArabicContext() {
if (m_bArabicContext) {
m_bCurRTL = m_iCurArabicContext > 1;
@@ -326,6 +347,7 @@ void CFX_TxtBreak::ResetArabicContext() {
m_bArabicComma = m_bArabicNumber;
ResetContextCharStyles();
}
+
void CFX_TxtBreak::AppendChar_PageLoad(CFX_TxtChar* pCurChar,
uint32_t dwProps) {
if (!m_bPagination) {
@@ -355,6 +377,7 @@ void CFX_TxtBreak::AppendChar_PageLoad(CFX_TxtChar* pCurChar,
}
pCurChar->m_dwCharStyles = m_dwContextCharStyles;
}
+
uint32_t CFX_TxtBreak::AppendChar_Combination(CFX_TxtChar* pCurChar,
int32_t iRotation) {
FX_WCHAR wch = pCurChar->m_wCharCode;
@@ -402,6 +425,7 @@ uint32_t CFX_TxtBreak::AppendChar_Combination(CFX_TxtChar* pCurChar,
pCurChar->m_iCharWidth = -iCharWidth;
return FX_TXTBREAK_None;
}
+
uint32_t CFX_TxtBreak::AppendChar_Tab(CFX_TxtChar* pCurChar,
int32_t iRotation) {
m_eCharType = FX_CHARTYPE_Tab;
@@ -430,6 +454,7 @@ uint32_t CFX_TxtBreak::AppendChar_Tab(CFX_TxtChar* pCurChar,
}
return FX_TXTBREAK_None;
}
+
uint32_t CFX_TxtBreak::AppendChar_Control(CFX_TxtChar* pCurChar,
int32_t iRotation) {
m_eCharType = FX_CHARTYPE_Control;
@@ -459,6 +484,7 @@ uint32_t CFX_TxtBreak::AppendChar_Control(CFX_TxtChar* pCurChar,
}
return dwRet;
}
+
uint32_t CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar,
int32_t iRotation) {
FX_CHARTYPE chartype = pCurChar->GetCharType();
@@ -523,6 +549,7 @@ uint32_t CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar,
}
return FX_TXTBREAK_None;
}
+
uint32_t CFX_TxtBreak::AppendChar_Others(CFX_TxtChar* pCurChar,
int32_t iRotation) {
uint32_t dwProps = pCurChar->m_dwCharProps;
@@ -608,6 +635,7 @@ uint32_t CFX_TxtBreak::AppendChar(FX_WCHAR wch) {
pCurChar, iRotation);
return std::max(dwRet1, dwRet2);
}
+
void CFX_TxtBreak::EndBreak_UpdateArabicShapes() {
ASSERT(m_bArabicShapes);
int32_t iCount = m_pCurLine->CountChars();
@@ -659,6 +687,7 @@ void CFX_TxtBreak::EndBreak_UpdateArabicShapes() {
pCur = pNext;
} while (i < iCount);
}
+
FX_BOOL CFX_TxtBreak::EndBreak_SplitLine(CFX_TxtLine* pNextLine,
FX_BOOL bAllChars,
uint32_t dwStatus) {
@@ -684,7 +713,7 @@ FX_BOOL CFX_TxtBreak::EndBreak_SplitLine(CFX_TxtLine* pNextLine,
}
}
iCount = m_pCurLine->CountChars();
- CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces;
+ CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces.get();
CFX_TxtPiece tp;
if (m_bPagination) {
tp.m_dwStatus = dwStatus;
@@ -692,7 +721,7 @@ FX_BOOL CFX_TxtBreak::EndBreak_SplitLine(CFX_TxtLine* pNextLine,
tp.m_iWidth = m_pCurLine->m_iWidth;
tp.m_iStartChar = 0;
tp.m_iChars = iCount;
- tp.m_pChars = m_pCurLine->m_pLineChars;
+ tp.m_pChars = m_pCurLine->m_pLineChars.get();
tp.m_pUserData = m_pUserData;
pTC = m_pCurLine->GetCharPtr(0);
tp.m_dwCharStyles = pTC->m_dwCharStyles;
@@ -705,16 +734,17 @@ FX_BOOL CFX_TxtBreak::EndBreak_SplitLine(CFX_TxtLine* pNextLine,
}
if (bAllChars && !bDone) {
int32_t iEndPos = m_pCurLine->m_iWidth;
- GetBreakPos(*m_pCurLine->m_pLineChars, iEndPos, bAllChars, TRUE);
+ GetBreakPos(*m_pCurLine->m_pLineChars.get(), iEndPos, bAllChars, TRUE);
}
return FALSE;
}
+
void CFX_TxtBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) {
CFX_TxtPiece tp;
FX_TPO tpo;
CFX_TxtChar* pTC;
int32_t i, j;
- CFX_TxtCharArray& chars = *m_pCurLine->m_pLineChars;
+ CFX_TxtCharArray& chars = *m_pCurLine->m_pLineChars.get();
int32_t iCount = m_pCurLine->CountChars();
FX_BOOL bDone = (m_pCurLine->m_iArabicChars > 0 || m_bCurRTL);
if (!m_bPagination && bDone) {
@@ -731,12 +761,12 @@ void CFX_TxtBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) {
}
FX_BidiLine(chars, iBidiNum + 1, m_bCurRTL ? 1 : 0);
}
- CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces;
+ CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces.get();
if (!m_bPagination &&
(bDone || (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_MutipleFormat) != 0)) {
tp.m_dwStatus = FX_TXTBREAK_PieceBreak;
tp.m_iStartPos = m_pCurLine->m_iStart;
- tp.m_pChars = m_pCurLine->m_pLineChars;
+ tp.m_pChars = m_pCurLine->m_pLineChars.get();
int32_t iBidiLevel = -1, iCharWidth;
i = 0, j = -1;
while (i < iCount) {
@@ -805,7 +835,7 @@ void CFX_TxtBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) {
tp.m_iWidth = m_pCurLine->m_iWidth;
tp.m_iStartChar = 0;
tp.m_iChars = iCount;
- tp.m_pChars = m_pCurLine->m_pLineChars;
+ tp.m_pChars = m_pCurLine->m_pLineChars.get();
tp.m_pUserData = m_pUserData;
pTC = chars.GetDataPtr(0);
tp.m_dwCharStyles = pTC->m_dwCharStyles;
@@ -817,11 +847,12 @@ void CFX_TxtBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) {
tpos.Add(tpo);
}
}
+
void CFX_TxtBreak::EndBreak_Alignment(CFX_TPOArray& tpos,
FX_BOOL bAllChars,
uint32_t dwStatus) {
int32_t iNetWidth = m_pCurLine->m_iWidth, iGapChars = 0, iCharWidth;
- CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces;
+ CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces.get();
int32_t i, j, iCount = pCurPieces->GetSize();
FX_BOOL bFind = FALSE;
FX_TPO tpo;
@@ -906,10 +937,11 @@ void CFX_TxtBreak::EndBreak_Alignment(CFX_TPOArray& tpos,
}
}
}
+
uint32_t CFX_TxtBreak::EndBreak(uint32_t dwStatus) {
ASSERT(dwStatus >= FX_TXTBREAK_PieceBreak &&
dwStatus <= FX_TXTBREAK_PageBreak);
- CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces;
+ CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces.get();
int32_t iCount = pCurPieces->GetSize();
if (iCount > 0) {
CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount);
@@ -922,7 +954,7 @@ uint32_t CFX_TxtBreak::EndBreak(uint32_t dwStatus) {
} else {
CFX_TxtLine* pLastLine = GetTxtLine(TRUE);
if (pLastLine) {
- pCurPieces = pLastLine->m_pLinePieces;
+ pCurPieces = pLastLine->m_pLinePieces.get();
iCount = pCurPieces->GetSize();
if (iCount-- > 0) {
CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(iCount);
@@ -947,9 +979,9 @@ uint32_t CFX_TxtBreak::EndBreak(uint32_t dwStatus) {
return dwStatus;
}
}
- m_iReady = (m_pCurLine == m_pTxtLine1) ? 1 : 2;
+ m_iReady = (m_pCurLine == m_pTxtLine1.get()) ? 1 : 2;
CFX_TxtLine* pNextLine =
- (m_pCurLine == m_pTxtLine1) ? m_pTxtLine2 : m_pTxtLine1;
+ (m_pCurLine == m_pTxtLine1.get()) ? m_pTxtLine2.get() : m_pTxtLine1.get();
FX_BOOL bAllChars = (m_iCurAlignment > FX_TXTLINEALIGNMENT_Right);
CFX_TPOArray tpos(100);
CFX_Char* pTC;
@@ -973,6 +1005,7 @@ EndBreak_Ret:
}
return dwStatus;
}
+
int32_t CFX_TxtBreak::GetBreakPos(CFX_TxtCharArray& ca,
int32_t& iEndPos,
FX_BOOL bAllChars,
@@ -1069,6 +1102,7 @@ int32_t CFX_TxtBreak::GetBreakPos(CFX_TxtCharArray& ca,
}
return 0;
}
+
void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine,
CFX_TxtLine* pNextLine,
FX_BOOL bAllChars) {
@@ -1078,7 +1112,7 @@ void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine,
return;
}
int32_t iEndPos = pCurLine->m_iWidth;
- CFX_TxtCharArray& curChars = *pCurLine->m_pLineChars;
+ CFX_TxtCharArray& curChars = *pCurLine->m_pLineChars.get();
int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, FALSE);
if (iCharPos < 0) {
iCharPos = 0;
@@ -1090,7 +1124,7 @@ void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine,
pTC->m_nBreakType = FX_LBT_UNKNOWN;
return;
}
- CFX_TxtCharArray& nextChars = *pNextLine->m_pLineChars;
+ CFX_TxtCharArray& nextChars = *pNextLine->m_pLineChars.get();
int cur_size = curChars.GetSize();
nextChars.SetSize(cur_size - iCharPos);
FXSYS_memcpy(nextChars.GetData(), curChars.GetDataPtr(iCharPos),
@@ -1120,14 +1154,17 @@ void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine,
}
pNextLine->m_iWidth = iWidth;
}
+
int32_t CFX_TxtBreak::CountBreakChars() const {
CFX_TxtLine* pTxtLine = GetTxtLine(TRUE);
return pTxtLine ? pTxtLine->CountChars() : 0;
}
+
int32_t CFX_TxtBreak::CountBreakPieces() const {
CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE);
return pTxtPieces ? pTxtPieces->GetSize() : 0;
}
+
const CFX_TxtPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const {
CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE);
if (!pTxtPieces) {
@@ -1138,6 +1175,7 @@ const CFX_TxtPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const {
}
return pTxtPieces->GetPtrAt(index);
}
+
void CFX_TxtBreak::ClearBreakPieces() {
CFX_TxtLine* pTxtLine = GetTxtLine(TRUE);
if (pTxtLine) {
@@ -1145,6 +1183,7 @@ void CFX_TxtBreak::ClearBreakPieces() {
}
m_iReady = 0;
}
+
void CFX_TxtBreak::Reset() {
m_eCharType = FX_CHARTYPE_Unknown;
m_iArabicContext = m_iCurArabicContext = 1;
@@ -1548,6 +1587,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun,
}
return iCount;
}
+
int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun,
CFX_RectFArray& rtArray,
FX_BOOL bCharBBox) const {
@@ -1695,13 +1735,12 @@ CFX_TxtPiece::CFX_TxtPiece()
m_pUserData(nullptr) {}
CFX_TxtLine::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);
-}
+ : m_pLineChars(new CFX_TxtCharArray),
+ m_pLinePieces(new CFX_TxtPieceArray(16)),
+ m_iStart(0),
+ m_iWidth(0),
+ m_iArabicChars(0) {}
CFX_TxtLine::~CFX_TxtLine() {
RemoveAll();
- delete m_pLineChars;
- delete m_pLinePieces;
}
diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h
index 3d8e3bdbb8..366ba80cd0 100644
--- a/xfa/fgas/layout/fgas_textbreak.h
+++ b/xfa/fgas/layout/fgas_textbreak.h
@@ -7,6 +7,8 @@
#ifndef XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_
#define XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_ucd.h"
#include "core/fxge/include/fx_ge.h"
#include "xfa/fgas/crt/fgas_utils.h"
@@ -188,8 +190,8 @@ class CFX_TxtLine {
m_iArabicChars = 0;
}
- CFX_TxtCharArray* m_pLineChars;
- CFX_TxtPieceArray* m_pLinePieces;
+ std::unique_ptr<CFX_TxtCharArray> m_pLineChars;
+ std::unique_ptr<CFX_TxtPieceArray> m_pLinePieces;
int32_t m_iStart;
int32_t m_iWidth;
int32_t m_iArabicChars;
@@ -297,8 +299,8 @@ class CFX_TxtBreak {
int32_t m_iCurAlignment;
FX_BOOL m_bArabicNumber;
FX_BOOL m_bArabicComma;
- CFX_TxtLine* m_pTxtLine1;
- CFX_TxtLine* m_pTxtLine2;
+ std::unique_ptr<CFX_TxtLine> m_pTxtLine1;
+ std::unique_ptr<CFX_TxtLine> m_pTxtLine2;
CFX_TxtLine* m_pCurLine;
int32_t m_iReady;
int32_t m_iTolerance;