summaryrefslogtreecommitdiff
path: root/xfa/fgas/layout
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fgas/layout')
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.cpp23
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.h13
2 files changed, 10 insertions, 26 deletions
diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp
index e01578bdc9..7463eaa6c1 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.cpp
+++ b/xfa/fgas/layout/fgas_rtfbreak.cpp
@@ -57,8 +57,6 @@ CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies)
CFX_RTFBreak::~CFX_RTFBreak() {
Reset();
m_PositionedTabs.RemoveAll();
- if (m_pUserData)
- m_pUserData->Release();
}
void CFX_RTFBreak::SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) {
@@ -244,20 +242,17 @@ void CFX_RTFBreak::SetAlignment(int32_t iAlignment) {
iAlignment <= FX_RTFLINEALIGNMENT_Distributed);
m_iAlignment = iAlignment;
}
-void CFX_RTFBreak::SetUserData(IFX_Retainable* pUserData) {
- if (m_pUserData == pUserData) {
+
+void CFX_RTFBreak::SetUserData(const CFX_RetainPtr<CFX_Retainable>& pUserData) {
+ if (m_pUserData == pUserData)
return;
- }
+
SetBreakStatus();
- if (m_pUserData) {
- m_pUserData->Release();
- }
m_pUserData = pUserData;
- if (m_pUserData) {
- m_pUserData->Retain();
- }
}
+
static const int32_t gs_FX_RTFLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2};
+
int32_t CFX_RTFBreak::GetLineRotation(uint32_t dwStyles) const {
return gs_FX_RTFLineRotations[(dwStyles & 0x0E) >> 1];
}
@@ -362,9 +357,6 @@ uint32_t CFX_RTFBreak::AppendChar(FX_WCHAR wch) {
pCurChar->m_nRotation = m_iCharRotation;
pCurChar->m_iCharWidth = 0;
pCurChar->m_dwIdentity = m_dwIdentity;
- if (m_pUserData) {
- m_pUserData->Retain();
- }
pCurChar->m_pUserData = m_pUserData;
uint32_t dwRet1 = FX_RTFBREAK_None;
if (chartype != FX_CHARTYPE_Combination &&
@@ -410,9 +402,6 @@ uint32_t CFX_RTFBreak::AppendChar_CharCode(FX_WCHAR wch) {
pCurChar->m_nRotation = m_iCharRotation;
pCurChar->m_iCharWidth = 0;
pCurChar->m_dwIdentity = m_dwIdentity;
- if (m_pUserData)
- m_pUserData->Retain();
-
pCurChar->m_pUserData = m_pUserData;
int32_t iCharWidth = 0;
if (m_bVertical != FX_IsOdd(m_iRotation)) {
diff --git a/xfa/fgas/layout/fgas_rtfbreak.h b/xfa/fgas/layout/fgas_rtfbreak.h
index 613156a3e0..15fdbb807a 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.h
+++ b/xfa/fgas/layout/fgas_rtfbreak.h
@@ -9,6 +9,7 @@
#include <vector>
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_basic.h"
#include "core/fxcrt/fx_ucd.h"
#include "xfa/fgas/crt/fgas_utils.h"
@@ -163,7 +164,7 @@ class CFX_RTFPiece {
uint32_t m_dwLayoutStyles;
uint32_t m_dwIdentity;
std::vector<CFX_RTFChar>* m_pChars; // not owned.
- IFX_Retainable* m_pUserData;
+ CFX_RetainPtr<CFX_Retainable> m_pUserData;
};
typedef CFX_BaseArrayTemplate<CFX_RTFPiece> CFX_RTFPieceArray;
@@ -195,12 +196,6 @@ class CFX_RTFLine {
}
int32_t GetLineEnd() const { return m_iStart + m_iWidth; }
void RemoveAll(bool bLeaveMemory = false) {
- int32_t iCount = pdfium::CollectionSize<int32_t>(m_LineChars);
- for (int32_t i = 0; i < iCount; i++) {
- CFX_RTFChar* pChar = &m_LineChars[i];
- if (pChar->m_pUserData)
- pChar->m_pUserData->Release();
- }
m_LineChars.clear();
m_LinePieces.RemoveAll(bLeaveMemory);
m_iWidth = 0;
@@ -241,7 +236,7 @@ class CFX_RTFBreak {
void SetWordSpace(bool bDefault, FX_FLOAT fWordSpace);
void SetReadingOrder(bool bRTL = false);
void SetAlignment(int32_t iAlignment = FX_RTFLINEALIGNMENT_Left);
- void SetUserData(IFX_Retainable* pUserData);
+ void SetUserData(const CFX_RetainPtr<CFX_Retainable>& pUserData);
uint32_t AppendChar(FX_WCHAR wch);
uint32_t EndBreak(uint32_t dwStatus = FX_RTFBREAK_PieceBreak);
int32_t CountBreakPieces() const;
@@ -316,7 +311,7 @@ class CFX_RTFBreak {
int32_t m_iWordSpace;
bool m_bRTL;
int32_t m_iAlignment;
- IFX_Retainable* m_pUserData;
+ CFX_RetainPtr<CFX_Retainable> m_pUserData;
FX_CHARTYPE m_eCharType;
uint32_t m_dwIdentity;
CFX_RTFLine m_RTFLine1;