summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-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
-rw-r--r--xfa/fwl/basewidget/cfx_barcode.cpp71
-rw-r--r--xfa/fwl/basewidget/cfx_barcode.h4
-rw-r--r--xfa/fwl/basewidget/fwl_caretimp.cpp6
-rw-r--r--xfa/fwl/basewidget/fwl_caretimp.h6
-rw-r--r--xfa/fwl/basewidget/fwl_editimp.cpp13
-rw-r--r--xfa/fwl/basewidget/fwl_editimp.h2
-rw-r--r--xfa/fwl/basewidget/fwl_monthcalendarimp.cpp9
-rw-r--r--xfa/fwl/basewidget/fwl_monthcalendarimp.h4
-rw-r--r--xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp8
-rw-r--r--xfa/fwl/basewidget/fwl_tooltipctrlimp.h1
-rw-r--r--xfa/fwl/core/fwl_formimp.cpp15
-rw-r--r--xfa/fwl/core/fwl_formimp.h4
-rw-r--r--xfa/fwl/core/fwl_noteimp.cpp21
-rw-r--r--xfa/fwl/core/fwl_noteimp.h5
-rw-r--r--xfa/fwl/core/fwl_widgetimp.cpp9
-rw-r--r--xfa/fwl/core/fwl_widgetimp.h6
20 files changed, 188 insertions, 182 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;
diff --git a/xfa/fwl/basewidget/cfx_barcode.cpp b/xfa/fwl/basewidget/cfx_barcode.cpp
index 723619fc5f..cb554f5c5b 100644
--- a/xfa/fwl/basewidget/cfx_barcode.cpp
+++ b/xfa/fwl/basewidget/cfx_barcode.cpp
@@ -54,12 +54,10 @@ CBC_CodeBase* CreateBarCodeEngineObject(BC_TYPE type) {
CFX_Barcode::CFX_Barcode() {}
-CFX_Barcode::~CFX_Barcode() {
- delete m_pBCEngine;
-}
+CFX_Barcode::~CFX_Barcode() {}
FX_BOOL CFX_Barcode::Create(BC_TYPE type) {
- m_pBCEngine = CreateBarCodeEngineObject(type);
+ m_pBCEngine.reset(CreateBarCodeEngineObject(type));
return !!m_pBCEngine;
}
BC_TYPE CFX_Barcode::GetType() {
@@ -91,7 +89,7 @@ FX_BOOL CFX_Barcode::CheckContentValidity(const CFX_WideStringC& contents) {
case BC_EAN13:
case BC_UPCA:
return m_pBCEngine
- ? static_cast<CBC_OneCode*>(m_pBCEngine)
+ ? static_cast<CBC_OneCode*>(m_pBCEngine.get())
->CheckContentValidity(contents)
: TRUE;
default:
@@ -108,7 +106,7 @@ FX_BOOL CFX_Barcode::SetPrintChecksum(FX_BOOL checksum) {
case BC_EAN8:
case BC_EAN13:
case BC_UPCA:
- return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine)
+ return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
->SetPrintChecksum(checksum),
TRUE)
: FALSE;
@@ -126,7 +124,7 @@ FX_BOOL CFX_Barcode::SetDataLength(int32_t length) {
case BC_EAN8:
case BC_EAN13:
case BC_UPCA:
- return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine)
+ return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
->SetDataLength(length),
TRUE)
: FALSE;
@@ -144,7 +142,7 @@ FX_BOOL CFX_Barcode::SetCalChecksum(int32_t state) {
case BC_EAN8:
case BC_EAN13:
case BC_UPCA:
- return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine)
+ return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
->SetCalChecksum(state),
TRUE)
: FALSE;
@@ -163,7 +161,7 @@ FX_BOOL CFX_Barcode::SetFont(CFX_Font* pFont) {
case BC_EAN13:
case BC_UPCA:
return m_pBCEngine
- ? static_cast<CBC_OneCode*>(m_pBCEngine)->SetFont(pFont)
+ ? static_cast<CBC_OneCode*>(m_pBCEngine.get())->SetFont(pFont)
: FALSE;
default:
return FALSE;
@@ -179,10 +177,10 @@ FX_BOOL CFX_Barcode::SetFontSize(FX_FLOAT size) {
case BC_EAN8:
case BC_EAN13:
case BC_UPCA:
- return m_pBCEngine
- ? (static_cast<CBC_OneCode*>(m_pBCEngine)->SetFontSize(size),
- TRUE)
- : FALSE;
+ return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
+ ->SetFontSize(size),
+ TRUE)
+ : FALSE;
default:
return FALSE;
}
@@ -197,10 +195,10 @@ FX_BOOL CFX_Barcode::SetFontStyle(int32_t style) {
case BC_EAN8:
case BC_EAN13:
case BC_UPCA:
- return m_pBCEngine
- ? (static_cast<CBC_OneCode*>(m_pBCEngine)->SetFontStyle(style),
- TRUE)
- : FALSE;
+ return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
+ ->SetFontStyle(style),
+ TRUE)
+ : FALSE;
default:
return FALSE;
}
@@ -215,10 +213,10 @@ FX_BOOL CFX_Barcode::SetFontColor(FX_ARGB color) {
case BC_EAN8:
case BC_EAN13:
case BC_UPCA:
- return m_pBCEngine
- ? (static_cast<CBC_OneCode*>(m_pBCEngine)->SetFontColor(color),
- TRUE)
- : FALSE;
+ return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
+ ->SetFontColor(color),
+ TRUE)
+ : FALSE;
default:
return FALSE;
}
@@ -241,7 +239,7 @@ FX_BOOL CFX_Barcode::SetTextLocation(BC_TEXT_LOC location) {
default:
break;
}
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(location) : FALSE;
+ return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(location) : FALSE;
}
FX_BOOL CFX_Barcode::SetWideNarrowRatio(int32_t ratio) {
typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
@@ -256,7 +254,7 @@ FX_BOOL CFX_Barcode::SetWideNarrowRatio(int32_t ratio) {
default:
break;
}
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(ratio) : FALSE;
+ return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(ratio) : FALSE;
}
FX_BOOL CFX_Barcode::SetStartChar(FX_CHAR start) {
typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR);
@@ -268,7 +266,7 @@ FX_BOOL CFX_Barcode::SetStartChar(FX_CHAR start) {
default:
break;
}
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(start) : FALSE;
+ return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(start) : FALSE;
}
FX_BOOL CFX_Barcode::SetEndChar(FX_CHAR end) {
typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR);
@@ -280,7 +278,7 @@ FX_BOOL CFX_Barcode::SetEndChar(FX_CHAR end) {
default:
break;
}
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(end) : FALSE;
+ return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(end) : FALSE;
}
FX_BOOL CFX_Barcode::SetVersion(int32_t version) {
typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
@@ -292,7 +290,7 @@ FX_BOOL CFX_Barcode::SetVersion(int32_t version) {
default:
break;
}
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(version) : FALSE;
+ return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(version) : FALSE;
}
FX_BOOL CFX_Barcode::SetErrorCorrectionLevel(int32_t level) {
typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
@@ -307,7 +305,7 @@ FX_BOOL CFX_Barcode::SetErrorCorrectionLevel(int32_t level) {
default:
return FALSE;
}
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(level) : FALSE;
+ return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(level) : FALSE;
}
FX_BOOL CFX_Barcode::SetTruncated(FX_BOOL truncated) {
typedef void (CBC_CodeBase::*memptrtype)(FX_BOOL);
@@ -319,29 +317,22 @@ FX_BOOL CFX_Barcode::SetTruncated(FX_BOOL truncated) {
default:
break;
}
- return m_pBCEngine && memptr ? ((m_pBCEngine->*memptr)(truncated), TRUE)
+ return m_pBCEngine && memptr ? ((m_pBCEngine.get()->*memptr)(truncated), TRUE)
: FALSE;
}
FX_BOOL CFX_Barcode::Encode(const CFX_WideStringC& contents,
FX_BOOL isDevice,
int32_t& e) {
- if (!m_pBCEngine) {
- return FALSE;
- }
- return m_pBCEngine->Encode(contents, isDevice, e);
+ return m_pBCEngine && m_pBCEngine->Encode(contents, isDevice, e);
}
+
FX_BOOL CFX_Barcode::RenderDevice(CFX_RenderDevice* device,
const CFX_Matrix* matrix,
int32_t& e) {
- if (!m_pBCEngine) {
- return FALSE;
- }
- return m_pBCEngine->RenderDevice(device, matrix, e);
+ return m_pBCEngine && m_pBCEngine->RenderDevice(device, matrix, e);
}
+
FX_BOOL CFX_Barcode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
- if (!m_pBCEngine) {
- return FALSE;
- }
- return m_pBCEngine->RenderBitmap(pOutBitmap, e);
+ return m_pBCEngine && m_pBCEngine->RenderBitmap(pOutBitmap, e);
}
diff --git a/xfa/fwl/basewidget/cfx_barcode.h b/xfa/fwl/basewidget/cfx_barcode.h
index 2ba1f7f77d..758ba20b1a 100644
--- a/xfa/fwl/basewidget/cfx_barcode.h
+++ b/xfa/fwl/basewidget/cfx_barcode.h
@@ -7,6 +7,8 @@
#ifndef XFA_FWL_BASEWIDGET_CFX_BARCODE_H_
#define XFA_FWL_BASEWIDGET_CFX_BARCODE_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
@@ -52,7 +54,7 @@ class CFX_Barcode {
FX_BOOL SetTruncated(FX_BOOL truncated);
protected:
- CBC_CodeBase* m_pBCEngine;
+ std::unique_ptr<CBC_CodeBase> m_pBCEngine;
};
#endif // XFA_FWL_BASEWIDGET_CFX_BARCODE_H_
diff --git a/xfa/fwl/basewidget/fwl_caretimp.cpp b/xfa/fwl/basewidget/fwl_caretimp.cpp
index dbe8e50bc2..cd51bd7430 100644
--- a/xfa/fwl/basewidget/fwl_caretimp.cpp
+++ b/xfa/fwl/basewidget/fwl_caretimp.cpp
@@ -38,16 +38,14 @@ FWL_Error IFWL_Caret::SetColor(CFX_Color crFill) {
CFWL_CaretImp::CFWL_CaretImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
: CFWL_WidgetImp(properties, pOuter),
+ m_pTimer(new CFWL_CaretTimer(this)),
m_pTimerInfo(nullptr),
m_dwElapse(400),
m_bSetColor(FALSE) {
- m_pTimer = new CFWL_CaretTimer(this);
SetStates(FWL_STATE_CAT_HightLight);
}
-CFWL_CaretImp::~CFWL_CaretImp() {
- delete m_pTimer;
-}
+CFWL_CaretImp::~CFWL_CaretImp() {}
FWL_Error CFWL_CaretImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_Caret;
diff --git a/xfa/fwl/basewidget/fwl_caretimp.h b/xfa/fwl/basewidget/fwl_caretimp.h
index 4f16715cd1..d8b621b43c 100644
--- a/xfa/fwl/basewidget/fwl_caretimp.h
+++ b/xfa/fwl/basewidget/fwl_caretimp.h
@@ -7,6 +7,8 @@
#ifndef XFA_FWL_BASEWIDGET_FWL_CARETIMP_H_
#define XFA_FWL_BASEWIDGET_FWL_CARETIMP_H_
+#include <memory>
+
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_timer.h"
#include "xfa/fwl/core/ifwl_widget.h"
@@ -51,8 +53,8 @@ class CFWL_CaretImp : public CFWL_WidgetImp {
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix);
- CFWL_CaretTimer* m_pTimer;
- IFWL_TimerInfo* m_pTimerInfo;
+ std::unique_ptr<CFWL_CaretTimer> m_pTimer;
+ IFWL_TimerInfo* m_pTimerInfo; // not owned.
uint32_t m_dwElapse;
CFX_Color m_crFill;
FX_BOOL m_bSetColor;
diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp
index ae0b7bcc9f..104054f4e1 100644
--- a/xfa/fwl/basewidget/fwl_editimp.cpp
+++ b/xfa/fwl/basewidget/fwl_editimp.cpp
@@ -203,7 +203,6 @@ CFWL_EditImp::CFWL_EditImp(const CFWL_WidgetImpProperties& properties,
m_fVAlignOffset(0.0f),
m_fScrollOffsetX(0.0f),
m_fScrollOffsetY(0.0f),
- m_pEdtEngine(nullptr),
m_bLButtonDown(FALSE),
m_nSelStart(0),
m_nLimit(-1),
@@ -223,7 +222,6 @@ CFWL_EditImp::CFWL_EditImp(const CFWL_WidgetImpProperties& properties,
}
CFWL_EditImp::~CFWL_EditImp() {
- delete m_pEdtEngine;
ClearRecord();
}
@@ -898,26 +896,27 @@ void CFWL_EditImp::On_TextChanged(CFDE_TxtEdtEngine* pEdit,
LayoutScrollBar();
Repaint(&rtTemp);
}
+
void CFWL_EditImp::On_SelChanged(CFDE_TxtEdtEngine* pEdit) {
CFX_RectF rtTemp;
GetClientRect(rtTemp);
Repaint(&rtTemp);
}
+
FX_BOOL CFWL_EditImp::On_PageLoad(CFDE_TxtEdtEngine* pEdit,
int32_t nPageIndex,
int32_t nPurpose) {
- CFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine;
- IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex);
+ IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(nPageIndex);
if (!pPage)
return FALSE;
pPage->LoadPage(nullptr, nullptr);
return TRUE;
}
+
FX_BOOL CFWL_EditImp::On_PageUnload(CFDE_TxtEdtEngine* pEdit,
int32_t nPageIndex,
int32_t nPurpose) {
- CFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine;
- IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex);
+ IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(nPageIndex);
if (!pPage)
return FALSE;
pPage->UnloadPage(nullptr);
@@ -1630,7 +1629,7 @@ void CFWL_EditImp::InitScrollBar(FX_BOOL bVert) {
void CFWL_EditImp::InitEngine() {
if (!m_pEdtEngine)
- m_pEdtEngine = new CFDE_TxtEdtEngine;
+ m_pEdtEngine.reset(new CFDE_TxtEdtEngine);
}
FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget,
diff --git a/xfa/fwl/basewidget/fwl_editimp.h b/xfa/fwl/basewidget/fwl_editimp.h
index 3f7a3862dd..e17a4cfc09 100644
--- a/xfa/fwl/basewidget/fwl_editimp.h
+++ b/xfa/fwl/basewidget/fwl_editimp.h
@@ -152,7 +152,7 @@ class CFWL_EditImp : public CFWL_WidgetImp {
FX_FLOAT m_fVAlignOffset;
FX_FLOAT m_fScrollOffsetX;
FX_FLOAT m_fScrollOffsetY;
- CFDE_TxtEdtEngine* m_pEdtEngine;
+ std::unique_ptr<CFDE_TxtEdtEngine> m_pEdtEngine;
FX_BOOL m_bLButtonDown;
int32_t m_nSelStart;
int32_t m_nLimit;
diff --git a/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp b/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp
index ca141a2d7a..7477f04bdc 100644
--- a/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp
+++ b/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp
@@ -151,6 +151,8 @@ CFWL_MonthCalendarImp::CFWL_MonthCalendarImp(
const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
: CFWL_WidgetImp(properties, pOuter),
+ m_bInit(FALSE),
+ m_pDateTime(new CFX_DateTime),
m_iCurYear(2011),
m_iCurMonth(1),
m_iYear(2011),
@@ -158,7 +160,8 @@ CFWL_MonthCalendarImp::CFWL_MonthCalendarImp(
m_iDay(1),
m_iHovered(-1),
m_iLBtnPartStates(CFWL_PartState_Normal),
- m_iRBtnPartStates(CFWL_PartState_Normal) {
+ m_iRBtnPartStates(CFWL_PartState_Normal),
+ m_iMaxSel(1) {
m_rtHead.Reset();
m_rtWeek.Reset();
m_rtLBtn.Reset();
@@ -171,14 +174,10 @@ CFWL_MonthCalendarImp::CFWL_MonthCalendarImp(
m_rtClient.Reset();
m_rtWeekNum.Reset();
m_rtWeekNumSep.Reset();
- m_pDateTime = new CFX_DateTime;
- m_bInit = FALSE;
- m_iMaxSel = 1;
}
CFWL_MonthCalendarImp::~CFWL_MonthCalendarImp() {
ClearDateItem();
- delete m_pDateTime;
m_arrSelDays.RemoveAll();
}
diff --git a/xfa/fwl/basewidget/fwl_monthcalendarimp.h b/xfa/fwl/basewidget/fwl_monthcalendarimp.h
index db6ce7801c..2716f59f95 100644
--- a/xfa/fwl/basewidget/fwl_monthcalendarimp.h
+++ b/xfa/fwl/basewidget/fwl_monthcalendarimp.h
@@ -7,6 +7,8 @@
#ifndef XFA_FWL_BASEWIDGET_FWL_MONTHCALENDARIMP_H_
#define XFA_FWL_BASEWIDGET_FWL_MONTHCALENDARIMP_H_
+#include <memory>
+
#include "xfa/fgas/localization/fgas_datetime.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_widget.h"
@@ -164,7 +166,7 @@ class CFWL_MonthCalendarImp : public CFWL_WidgetImp {
CFX_RectF m_rtTemp;
CFX_WideString m_wsHead;
CFX_WideString m_wsToday;
- CFX_DateTime* m_pDateTime;
+ std::unique_ptr<CFX_DateTime> m_pDateTime;
CFX_ArrayTemplate<FWL_DATEINFO*> m_arrDates;
int32_t m_iCurYear;
int32_t m_iCurMonth;
diff --git a/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp b/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp
index 85af738555..cf89483a9d 100644
--- a/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp
+++ b/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp
@@ -48,8 +48,7 @@ CFWL_ToolTipImp::CFWL_ToolTipImp(const CFWL_WidgetImpProperties& properties,
m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
m_iTTOAlign(FDE_TTOALIGNMENT_Center),
m_pTimerInfoShow(nullptr),
- m_pTimerInfoHide(nullptr),
- m_pTimer(nullptr) {
+ m_pTimerInfoHide(nullptr) {
m_rtClient.Set(0, 0, 0, 0);
m_rtCaption.Set(0, 0, 0, 0);
m_rtAnchor.Set(0, 0, 0, 0);
@@ -57,10 +56,7 @@ CFWL_ToolTipImp::CFWL_ToolTipImp(const CFWL_WidgetImpProperties& properties,
m_TimerHide.m_pToolTip = this;
}
-CFWL_ToolTipImp::~CFWL_ToolTipImp() {
- delete m_pTimer;
- m_pTimer = nullptr;
-}
+CFWL_ToolTipImp::~CFWL_ToolTipImp() {}
FWL_Error CFWL_ToolTipImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_ToolTip;
diff --git a/xfa/fwl/basewidget/fwl_tooltipctrlimp.h b/xfa/fwl/basewidget/fwl_tooltipctrlimp.h
index 79e3f49f18..f814eea256 100644
--- a/xfa/fwl/basewidget/fwl_tooltipctrlimp.h
+++ b/xfa/fwl/basewidget/fwl_tooltipctrlimp.h
@@ -69,7 +69,6 @@ class CFWL_ToolTipImp : public CFWL_FormImp {
CFX_RectF m_rtAnchor;
IFWL_TimerInfo* m_pTimerInfoShow;
IFWL_TimerInfo* m_pTimerInfoHide;
- CFWL_ToolTipTimer* m_pTimer;
CFWL_ToolTipTimer m_TimerShow;
CFWL_ToolTipTimer m_TimerHide;
};
diff --git a/xfa/fwl/core/fwl_formimp.cpp b/xfa/fwl/core/fwl_formimp.cpp
index a3fc6be816..1b82ff59f8 100644
--- a/xfa/fwl/core/fwl_formimp.cpp
+++ b/xfa/fwl/core/fwl_formimp.cpp
@@ -75,7 +75,6 @@ CFWL_FormImp::CFWL_FormImp(const CFWL_WidgetImpProperties& properties,
m_pMinBox(nullptr),
m_pMaxBox(nullptr),
m_pCaptionBox(nullptr),
- m_pNoteLoop(nullptr),
m_pSubFocus(nullptr),
m_fCXBorder(0),
m_fCYBorder(0),
@@ -100,7 +99,6 @@ CFWL_FormImp::CFWL_FormImp(const CFWL_WidgetImpProperties& properties,
CFWL_FormImp::~CFWL_FormImp() {
RemoveSysButtons();
- delete m_pNoteLoop;
}
FWL_Error CFWL_FormImp::GetClassName(CFX_WideString& wsClass) const {
@@ -371,13 +369,16 @@ FWL_Error CFWL_FormImp::DrawWidget(CFX_Graphics* pGraphics,
#endif
return FWL_Error::Succeeded;
}
+
FWL_FORMSIZE CFWL_FormImp::GetFormSize() {
return m_eFormSize;
}
+
FWL_Error CFWL_FormImp::SetFormSize(FWL_FORMSIZE eFormSize) {
m_eFormSize = eFormSize;
return FWL_Error::Succeeded;
}
+
IFWL_Widget* CFWL_FormImp::DoModal() {
IFWL_App* pApp = GetOwnerApp();
if (!pApp)
@@ -387,8 +388,8 @@ IFWL_Widget* CFWL_FormImp::DoModal() {
if (!pDriver)
return nullptr;
- m_pNoteLoop = new CFWL_NoteLoop(this);
- pDriver->PushNoteLoop(m_pNoteLoop);
+ m_pNoteLoop.reset(new CFWL_NoteLoop(this));
+ pDriver->PushNoteLoop(m_pNoteLoop.get());
m_bDoModalFlag = TRUE;
SetStates(FWL_WGTSTATE_Invisible, FALSE);
pDriver->Run();
@@ -396,13 +397,14 @@ IFWL_Widget* CFWL_FormImp::DoModal() {
#else
pDriver->PopNoteLoop();
#endif
- delete m_pNoteLoop;
- m_pNoteLoop = nullptr;
+ m_pNoteLoop.reset();
return nullptr;
}
+
IFWL_Widget* CFWL_FormImp::DoModal(uint32_t& dwCommandID) {
return DoModal();
}
+
FWL_Error CFWL_FormImp::EndDoModal() {
if (!m_pNoteLoop)
return FWL_Error::Indefinite;
@@ -426,6 +428,7 @@ FWL_Error CFWL_FormImp::EndDoModal() {
return m_pNoteLoop->EndModalLoop();
#endif
}
+
FWL_Error CFWL_FormImp::SetBorderRegion(CFX_Path* pPath) {
return FWL_Error::Succeeded;
}
diff --git a/xfa/fwl/core/fwl_formimp.h b/xfa/fwl/core/fwl_formimp.h
index ee1507d17e..c88b5e683b 100644
--- a/xfa/fwl/core/fwl_formimp.h
+++ b/xfa/fwl/core/fwl_formimp.h
@@ -7,6 +7,8 @@
#ifndef XFA_FWL_CORE_FWL_FORMIMP_H_
#define XFA_FWL_CORE_FWL_FORMIMP_H_
+#include <memory>
+
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_form.h"
@@ -134,7 +136,7 @@ class CFWL_FormImp : public CFWL_WidgetImp {
CFWL_SysBtn* m_pMinBox;
CFWL_SysBtn* m_pMaxBox;
CFWL_SysBtn* m_pCaptionBox;
- CFWL_NoteLoop* m_pNoteLoop;
+ std::unique_ptr<CFWL_NoteLoop> m_pNoteLoop;
CFWL_WidgetImp* m_pSubFocus;
RestoreInfo m_InfoStart;
FX_FLOAT m_fCXBorder;
diff --git a/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp
index f115e2fd1b..8ecec2df65 100644
--- a/xfa/fwl/core/fwl_noteimp.cpp
+++ b/xfa/fwl/core/fwl_noteimp.cpp
@@ -70,10 +70,9 @@ CFWL_NoteDriver::CFWL_NoteDriver()
m_pFocus(nullptr),
m_pGrab(nullptr),
m_pNoteLoop(new CFWL_NoteLoop) {
- PushNoteLoop(m_pNoteLoop);
+ PushNoteLoop(m_pNoteLoop.get());
}
CFWL_NoteDriver::~CFWL_NoteDriver() {
- delete m_pNoteLoop;
ClearInvalidEventTargets(TRUE);
}
@@ -655,6 +654,8 @@ void CFWL_NoteDriver::ClearInvalidEventTargets(FX_BOOL bRemoveAll) {
class CFWL_CoreToolTipDP : public IFWL_ToolTipDP {
public:
+ CFWL_CoreToolTipDP(int32_t iInitDelayTime, int32_t iAutoDelayTime);
+
// IFWL_ToolTipDP
FWL_Error GetCaption(IFWL_Widget* pWidget,
CFX_WideString& wsCaption) override;
@@ -664,7 +665,6 @@ class CFWL_CoreToolTipDP : public IFWL_ToolTipDP {
CFX_SizeF GetToolTipIconSize(IFWL_Widget* pWidget) override;
CFX_RectF GetAnchor();
- CFWL_CoreToolTipDP();
CFX_WideString m_wsCaption;
int32_t m_nInitDelayTime;
@@ -672,9 +672,9 @@ class CFWL_CoreToolTipDP : public IFWL_ToolTipDP {
CFX_RectF m_fAnchor;
};
-CFWL_CoreToolTipDP::CFWL_CoreToolTipDP() {
- m_nInitDelayTime = 500;
- m_nAutoPopDelayTime = 50000;
+CFWL_CoreToolTipDP::CFWL_CoreToolTipDP(int32_t iInitDelayTime,
+ int32_t iAutoDelayTime)
+ : m_nInitDelayTime(iInitDelayTime), m_nAutoPopDelayTime(iAutoDelayTime) {
m_fAnchor.Set(0.0, 0.0, 0.0, 0.0);
}
@@ -773,11 +773,9 @@ FX_BOOL CFWL_EventTarget::IsFilterEvent(CFWL_Event* pEvent, uint32_t dwFilter) {
CFWL_ToolTipContainer* CFWL_ToolTipContainer::s_pInstance = nullptr;
-CFWL_ToolTipContainer::CFWL_ToolTipContainer() : m_pToolTipImp(nullptr) {
- m_ToolTipDp = new CFWL_CoreToolTipDP;
- m_ToolTipDp->m_nInitDelayTime = 0;
- m_ToolTipDp->m_nAutoPopDelayTime = 2000;
-}
+CFWL_ToolTipContainer::CFWL_ToolTipContainer()
+ : m_pToolTipImp(nullptr), m_pToolTipDp(new CFWL_CoreToolTipDP(0, 2000)) {}
+
CFWL_ToolTipContainer::~CFWL_ToolTipContainer() {
if (m_pToolTipImp) {
IFWL_ToolTip* pToolTip =
@@ -785,7 +783,6 @@ CFWL_ToolTipContainer::~CFWL_ToolTipContainer() {
pToolTip->Finalize();
delete pToolTip;
}
- delete m_ToolTipDp;
}
// static
diff --git a/xfa/fwl/core/fwl_noteimp.h b/xfa/fwl/core/fwl_noteimp.h
index c92395a13a..f923c395d5 100644
--- a/xfa/fwl/core/fwl_noteimp.h
+++ b/xfa/fwl/core/fwl_noteimp.h
@@ -7,6 +7,7 @@
#ifndef XFA_FWL_CORE_FWL_NOTEIMP_H_
#define XFA_FWL_CORE_FWL_NOTEIMP_H_
+#include <memory>
#include <unordered_map>
#include "xfa/fwl/core/cfwl_event.h"
@@ -115,7 +116,7 @@ class CFWL_NoteDriver {
IFWL_Widget* m_pHover;
IFWL_Widget* m_pFocus;
IFWL_Widget* m_pGrab;
- CFWL_NoteLoop* m_pNoteLoop;
+ std::unique_ptr<CFWL_NoteLoop> m_pNoteLoop;
};
class CFWL_EventTarget {
@@ -147,7 +148,7 @@ class CFWL_ToolTipContainer final {
~CFWL_ToolTipContainer();
CFWL_ToolTipImp* m_pToolTipImp;
- CFWL_CoreToolTipDP* m_ToolTipDp;
+ std::unique_ptr<CFWL_CoreToolTipDP> m_pToolTipDp;
private:
static CFWL_ToolTipContainer* s_pInstance;
diff --git a/xfa/fwl/core/fwl_widgetimp.cpp b/xfa/fwl/core/fwl_widgetimp.cpp
index 52a2978908..3aa6233ae5 100644
--- a/xfa/fwl/core/fwl_widgetimp.cpp
+++ b/xfa/fwl/core/fwl_widgetimp.cpp
@@ -531,7 +531,8 @@ void CFWL_WidgetImp::SetAssociateWidget(void* pAssociate) {
CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : m_pProperties(new CFWL_WidgetImpProperties),
+ : m_pWidgetMgr(CFWL_WidgetMgr::GetInstance()),
+ m_pProperties(new CFWL_WidgetImpProperties(properties)),
m_pDelegate(nullptr),
m_pCurDelegate(nullptr),
m_pOuter(pOuter),
@@ -540,14 +541,10 @@ CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties,
m_pAssociate(nullptr),
m_iLock(0),
m_nEventKey(0) {
- *m_pProperties = properties;
- m_pWidgetMgr = CFWL_WidgetMgr::GetInstance();
ASSERT(m_pWidgetMgr);
}
-CFWL_WidgetImp::~CFWL_WidgetImp() {
- delete m_pProperties;
-}
+CFWL_WidgetImp::~CFWL_WidgetImp() {}
FX_BOOL CFWL_WidgetImp::IsEnabled() const {
return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0;
diff --git a/xfa/fwl/core/fwl_widgetimp.h b/xfa/fwl/core/fwl_widgetimp.h
index d8c4fe6eb6..cbc89b9a8b 100644
--- a/xfa/fwl/core/fwl_widgetimp.h
+++ b/xfa/fwl/core/fwl_widgetimp.h
@@ -7,6 +7,8 @@
#ifndef XFA_FWL_CORE_FWL_WIDGETIMP_H_
#define XFA_FWL_CORE_FWL_WIDGETIMP_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
#include "xfa/fwl/core/cfwl_event.h"
@@ -154,9 +156,9 @@ class CFWL_WidgetImp {
FX_BOOL IsParent(IFWL_Widget* pParent);
- CFWL_WidgetMgr* m_pWidgetMgr;
+ CFWL_WidgetMgr* const m_pWidgetMgr;
CFWL_AppImp* m_pOwnerApp;
- CFWL_WidgetImpProperties* m_pProperties;
+ std::unique_ptr<CFWL_WidgetImpProperties> m_pProperties;
IFWL_WidgetDelegate* m_pDelegate;
IFWL_WidgetDelegate* m_pCurDelegate;
IFWL_Widget* m_pOuter;