summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_allstates.cpp71
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_clippath.cpp9
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_colorstate.cpp12
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_generalstate.cpp3
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_pageobject.cpp6
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_pathobject.cpp4
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp2
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_textobject.cpp10
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_textstate.cpp19
-rw-r--r--core/fpdfapi/fpdf_page/fpdf_page_parser.cpp100
-rw-r--r--core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp11
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_path.h3
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render.cpp28
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_text.cpp5
-rw-r--r--core/fpdftext/cpdf_textpage.cpp8
-rw-r--r--core/fxcrt/cfx_count_ref_unittest.cpp9
-rw-r--r--core/fxcrt/include/cfx_count_ref.h11
-rw-r--r--core/fxge/ge/cfx_cliprgn.cpp4
-rw-r--r--fpdfsdk/fpdf_transformpage.cpp4
-rw-r--r--fpdfsdk/fpdfeditimg.cpp4
-rw-r--r--fpdfsdk/fxedit/fxet_edit.cpp25
21 files changed, 188 insertions, 160 deletions
diff --git a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp
index e4b6e328b9..fb0c2445e7 100644
--- a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp
@@ -45,16 +45,16 @@ void CPDF_AllStates::Copy(const CPDF_AllStates& src) {
void CPDF_AllStates::SetLineDash(CPDF_Array* pArray,
FX_FLOAT phase,
FX_FLOAT scale) {
- CFX_GraphStateData* pData = m_GraphState.GetPrivateCopy();
- pData->m_DashPhase = phase * scale;
- pData->SetDashCount(static_cast<int>(pArray->GetCount()));
+ m_GraphState.MakePrivateCopy();
+ m_GraphState->m_DashPhase = phase * scale;
+ m_GraphState->SetDashCount(static_cast<int>(pArray->GetCount()));
for (size_t i = 0; i < pArray->GetCount(); i++)
- pData->m_DashArray[i] = pArray->GetNumberAt(i) * scale;
+ m_GraphState->m_DashArray[i] = pArray->GetNumberAt(i) * scale;
}
void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
CPDF_StreamContentParser* pParser) {
- CPDF_GeneralStateData* pGeneralState = m_GeneralState.GetPrivateCopy();
+ m_GeneralState.MakePrivateCopy();
for (const auto& it : *pGS) {
const CFX_ByteString& key_str = it.first;
CPDF_Object* pElement = it.second;
@@ -65,18 +65,22 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
uint32_t key = key_str.GetID();
switch (key) {
case FXBSTR_ID('L', 'W', 0, 0):
- m_GraphState.GetPrivateCopy()->m_LineWidth = pObject->GetNumber();
+ m_GraphState.MakePrivateCopy();
+ m_GraphState->m_LineWidth = pObject->GetNumber();
break;
case FXBSTR_ID('L', 'C', 0, 0):
- m_GraphState.GetPrivateCopy()->m_LineCap =
- (CFX_GraphStateData::LineCap)pObject->GetInteger();
+ m_GraphState.MakePrivateCopy();
+ m_GraphState->m_LineCap =
+ static_cast<CFX_GraphStateData::LineCap>(pObject->GetInteger());
break;
case FXBSTR_ID('L', 'J', 0, 0):
- m_GraphState.GetPrivateCopy()->m_LineJoin =
- (CFX_GraphStateData::LineJoin)pObject->GetInteger();
+ m_GraphState.MakePrivateCopy();
+ m_GraphState->m_LineJoin =
+ static_cast<CFX_GraphStateData::LineJoin>(pObject->GetInteger());
break;
case FXBSTR_ID('M', 'L', 0, 0):
- m_GraphState.GetPrivateCopy()->m_MiterLimit = pObject->GetNumber();
+ m_GraphState.MakePrivateCopy();
+ m_GraphState->m_MiterLimit = pObject->GetNumber();
break;
case FXBSTR_ID('D', 0, 0, 0): {
CPDF_Array* pDash = pObject->AsArray();
@@ -98,7 +102,8 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
if (!pFont)
break;
- m_TextState.GetPrivateCopy()->m_FontSize = pFont->GetNumberAt(1);
+ m_TextState.MakePrivateCopy();
+ m_TextState->m_FontSize = pFont->GetNumberAt(1);
m_TextState.SetFont(pParser->FindFont(pFont->GetStringAt(0)));
break;
}
@@ -107,7 +112,7 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
continue;
}
case FXBSTR_ID('T', 'R', '2', 0):
- pGeneralState->m_pTR =
+ m_GeneralState->m_pTR =
(pObject && !pObject->IsName()) ? pObject : nullptr;
break;
case FXBSTR_ID('B', 'M', 0, 0): {
@@ -115,72 +120,72 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
CFX_ByteString mode =
pArray ? pArray->GetStringAt(0) : pObject->GetString();
- pGeneralState->SetBlendMode(mode.AsStringC());
- if (pGeneralState->m_BlendType > FXDIB_BLEND_MULTIPLY) {
+ m_GeneralState->SetBlendMode(mode.AsStringC());
+ if (m_GeneralState->m_BlendType > FXDIB_BLEND_MULTIPLY) {
pParser->GetPageObjectHolder()->SetBackgroundAlphaNeeded(TRUE);
}
break;
}
case FXBSTR_ID('S', 'M', 'a', 's'):
if (ToDictionary(pObject)) {
- pGeneralState->m_pSoftMask = pObject;
- FXSYS_memcpy(pGeneralState->m_SMaskMatrix,
+ m_GeneralState->m_pSoftMask = pObject;
+ FXSYS_memcpy(m_GeneralState->m_SMaskMatrix,
&pParser->GetCurStates()->m_CTM, sizeof(CFX_Matrix));
} else {
- pGeneralState->m_pSoftMask = nullptr;
+ m_GeneralState->m_pSoftMask = nullptr;
}
break;
case FXBSTR_ID('C', 'A', 0, 0):
- pGeneralState->m_StrokeAlpha = ClipFloat(pObject->GetNumber());
+ m_GeneralState->m_StrokeAlpha = ClipFloat(pObject->GetNumber());
break;
case FXBSTR_ID('c', 'a', 0, 0):
- pGeneralState->m_FillAlpha = ClipFloat(pObject->GetNumber());
+ m_GeneralState->m_FillAlpha = ClipFloat(pObject->GetNumber());
break;
case FXBSTR_ID('O', 'P', 0, 0):
- pGeneralState->m_StrokeOP = pObject->GetInteger();
+ m_GeneralState->m_StrokeOP = pObject->GetInteger();
if (!pGS->KeyExist("op")) {
- pGeneralState->m_FillOP = pObject->GetInteger();
+ m_GeneralState->m_FillOP = pObject->GetInteger();
}
break;
case FXBSTR_ID('o', 'p', 0, 0):
- pGeneralState->m_FillOP = pObject->GetInteger();
+ m_GeneralState->m_FillOP = pObject->GetInteger();
break;
case FXBSTR_ID('O', 'P', 'M', 0):
- pGeneralState->m_OPMode = pObject->GetInteger();
+ m_GeneralState->m_OPMode = pObject->GetInteger();
break;
case FXBSTR_ID('B', 'G', 0, 0):
if (pGS->KeyExist("BG2")) {
continue;
}
case FXBSTR_ID('B', 'G', '2', 0):
- pGeneralState->m_pBG = pObject;
+ m_GeneralState->m_pBG = pObject;
break;
case FXBSTR_ID('U', 'C', 'R', 0):
if (pGS->KeyExist("UCR2")) {
continue;
}
case FXBSTR_ID('U', 'C', 'R', '2'):
- pGeneralState->m_pUCR = pObject;
+ m_GeneralState->m_pUCR = pObject;
break;
case FXBSTR_ID('H', 'T', 0, 0):
- pGeneralState->m_pHT = pObject;
+ m_GeneralState->m_pHT = pObject;
break;
case FXBSTR_ID('F', 'L', 0, 0):
- pGeneralState->m_Flatness = pObject->GetNumber();
+ m_GeneralState->m_Flatness = pObject->GetNumber();
break;
case FXBSTR_ID('S', 'M', 0, 0):
- pGeneralState->m_Smoothness = pObject->GetNumber();
+ m_GeneralState->m_Smoothness = pObject->GetNumber();
break;
case FXBSTR_ID('S', 'A', 0, 0):
- pGeneralState->m_StrokeAdjust = pObject->GetInteger();
+ m_GeneralState->m_StrokeAdjust = pObject->GetInteger();
break;
case FXBSTR_ID('A', 'I', 'S', 0):
- pGeneralState->m_AlphaSource = pObject->GetInteger();
+ m_GeneralState->m_AlphaSource = pObject->GetInteger();
break;
case FXBSTR_ID('T', 'K', 0, 0):
- pGeneralState->m_TextKnockout = pObject->GetInteger();
+ m_GeneralState->m_TextKnockout = pObject->GetInteger();
break;
}
}
- pGeneralState->m_Matrix = m_CTM;
+ m_GeneralState->m_Matrix = m_CTM;
}
diff --git a/core/fpdfapi/fpdf_page/cpdf_clippath.cpp b/core/fpdfapi/fpdf_page/cpdf_clippath.cpp
index e820260131..2c05df0d19 100644
--- a/core/fpdfapi/fpdf_page/cpdf_clippath.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_clippath.cpp
@@ -73,7 +73,8 @@ CFX_FloatRect CPDF_ClipPath::GetClipBox() const {
}
void CPDF_ClipPath::AppendPath(CPDF_Path path, uint8_t type, bool bAutoMerge) {
- CPDF_ClipPathData* pData = GetPrivateCopy();
+ MakePrivateCopy();
+ CPDF_ClipPathData* pData = GetObject();
if (!pData->m_PathAndTypeList.empty() && bAutoMerge) {
const CPDF_Path& old_path = pData->m_PathAndTypeList.back().first;
if (old_path.IsRect()) {
@@ -89,7 +90,8 @@ void CPDF_ClipPath::AppendPath(CPDF_Path path, uint8_t type, bool bAutoMerge) {
void CPDF_ClipPath::AppendTexts(
std::vector<std::unique_ptr<CPDF_TextObject>>* pTexts) {
- CPDF_ClipPathData* pData = GetPrivateCopy();
+ MakePrivateCopy();
+ CPDF_ClipPathData* pData = GetObject();
if (pData->m_TextList.size() + pTexts->size() <= FPDF_CLIPPATH_MAX_TEXTS) {
for (size_t i = 0; i < pTexts->size(); i++)
pData->m_TextList.push_back(std::move((*pTexts)[i]));
@@ -99,7 +101,8 @@ void CPDF_ClipPath::AppendTexts(
}
void CPDF_ClipPath::Transform(const CFX_Matrix& matrix) {
- CPDF_ClipPathData* pData = GetPrivateCopy();
+ MakePrivateCopy();
+ CPDF_ClipPathData* pData = GetObject();
for (auto& obj : pData->m_PathAndTypeList)
obj.first.Transform(&matrix);
for (auto& text : pData->m_TextList) {
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp b/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
index a2234378eb..a46dea3bb8 100644
--- a/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
@@ -13,14 +13,16 @@
void CPDF_ColorState::SetFillColor(CPDF_ColorSpace* pCS,
FX_FLOAT* pValue,
uint32_t nValues) {
- CPDF_ColorStateData* pData = GetPrivateCopy();
+ MakePrivateCopy();
+ CPDF_ColorStateData* pData = GetObject();
SetColor(pData->m_FillColor, pData->m_FillRGB, pCS, pValue, nValues);
}
void CPDF_ColorState::SetStrokeColor(CPDF_ColorSpace* pCS,
FX_FLOAT* pValue,
uint32_t nValues) {
- CPDF_ColorStateData* pData = GetPrivateCopy();
+ MakePrivateCopy();
+ CPDF_ColorStateData* pData = GetObject();
SetColor(pData->m_StrokeColor, pData->m_StrokeRGB, pCS, pValue, nValues);
}
@@ -45,7 +47,8 @@ void CPDF_ColorState::SetColor(CPDF_Color& color,
void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
FX_FLOAT* pValue,
uint32_t nValues) {
- CPDF_ColorStateData* pData = GetPrivateCopy();
+ MakePrivateCopy();
+ CPDF_ColorStateData* pData = GetObject();
pData->m_FillColor.SetValue(pPattern, pValue, nValues);
int R, G, B;
FX_BOOL ret = pData->m_FillColor.GetRGB(R, G, B);
@@ -61,7 +64,8 @@ void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern,
FX_FLOAT* pValue,
uint32_t nValues) {
- CPDF_ColorStateData* pData = GetPrivateCopy();
+ MakePrivateCopy();
+ CPDF_ColorStateData* pData = GetObject();
pData->m_StrokeColor.SetValue(pPattern, pValue, nValues);
int R, G, B;
FX_BOOL ret = pData->m_StrokeColor.GetRGB(R, G, B);
diff --git a/core/fpdfapi/fpdf_page/cpdf_generalstate.cpp b/core/fpdfapi/fpdf_page/cpdf_generalstate.cpp
index 0f6cce6e29..ff22d4d74b 100644
--- a/core/fpdfapi/fpdf_page/cpdf_generalstate.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_generalstate.cpp
@@ -25,5 +25,6 @@ int RI_StringToId(const CFX_ByteString& ri) {
} // namespace
void CPDF_GeneralState::SetRenderIntent(const CFX_ByteString& ri) {
- GetPrivateCopy()->m_RenderIntent = RI_StringToId(ri);
+ MakePrivateCopy();
+ GetObject()->m_RenderIntent = RI_StringToId(ri);
}
diff --git a/core/fpdfapi/fpdf_page/cpdf_pageobject.cpp b/core/fpdfapi/fpdf_page/cpdf_pageobject.cpp
index 17014c4883..df777dfb92 100644
--- a/core/fpdfapi/fpdf_page/cpdf_pageobject.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_pageobject.cpp
@@ -81,15 +81,15 @@ void CPDF_PageObject::CopyData(const CPDF_PageObject* pSrc) {
void CPDF_PageObject::TransformClipPath(CFX_Matrix& matrix) {
if (!m_ClipPath)
return;
- m_ClipPath.GetPrivateCopy();
+ m_ClipPath.MakePrivateCopy();
m_ClipPath.Transform(matrix);
}
void CPDF_PageObject::TransformGeneralState(CFX_Matrix& matrix) {
if (!m_GeneralState)
return;
- CPDF_GeneralStateData* pGS = m_GeneralState.GetPrivateCopy();
- pGS->m_Matrix.Concat(matrix);
+ m_GeneralState.MakePrivateCopy();
+ m_GeneralState->m_Matrix.Concat(matrix);
}
FX_RECT CPDF_PageObject::GetBBox(const CFX_Matrix* pMatrix) const {
diff --git a/core/fpdfapi/fpdf_page/cpdf_pathobject.cpp b/core/fpdfapi/fpdf_page/cpdf_pathobject.cpp
index 0055d6a133..ceb3dd43cc 100644
--- a/core/fpdfapi/fpdf_page/cpdf_pathobject.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_pathobject.cpp
@@ -46,9 +46,9 @@ void CPDF_PathObject::CalcBoundingBox() {
if (!m_Path)
return;
CFX_FloatRect rect;
- FX_FLOAT width = m_GraphState.GetObject()->m_LineWidth;
+ FX_FLOAT width = m_GraphState->m_LineWidth;
if (m_bStroke && width != 0) {
- rect = m_Path.GetBoundingBox(width, m_GraphState.GetObject()->m_MiterLimit);
+ rect = m_Path.GetBoundingBox(width, m_GraphState->m_MiterLimit);
} else {
rect = m_Path.GetBoundingBox();
}
diff --git a/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp b/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp
index d869bc20b3..383fd154e5 100644
--- a/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp
@@ -36,7 +36,7 @@ CPDF_PageObject::Type CPDF_ShadingObject::GetType() const {
void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) {
if (m_ClipPath) {
- m_ClipPath.GetPrivateCopy();
+ m_ClipPath.MakePrivateCopy();
m_ClipPath.Transform(matrix);
}
m_Matrix.Concat(matrix);
diff --git a/core/fpdfapi/fpdf_page/cpdf_textobject.cpp b/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
index bd17dea86e..a3653359de 100644
--- a/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
@@ -133,7 +133,7 @@ CPDF_PageObject::Type CPDF_TextObject::GetType() const {
}
void CPDF_TextObject::Transform(const CFX_Matrix& matrix) {
- m_TextState.GetPrivateCopy();
+ m_TextState.MakePrivateCopy();
CFX_Matrix text_matrix;
GetTextMatrix(&text_matrix);
text_matrix.Concat(matrix);
@@ -334,9 +334,9 @@ void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX,
}
curpos += charwidth;
if (charcode == ' ' && (!pCIDFont || pCIDFont->GetCharSize(32) == 1)) {
- curpos += m_TextState.GetObject()->m_WordSpace;
+ curpos += m_TextState->m_WordSpace;
}
- curpos += m_TextState.GetObject()->m_CharSpace;
+ curpos += m_TextState->m_CharSpace;
}
if (bVertWriting) {
if (pTextAdvanceX) {
@@ -364,8 +364,8 @@ void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX,
m_Bottom = min_y;
m_Top = max_y;
matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom);
- if (TextRenderingModeIsStrokeMode(m_TextState.GetObject()->m_TextMode)) {
- FX_FLOAT half_width = m_GraphState.GetObject()->m_LineWidth / 2;
+ if (TextRenderingModeIsStrokeMode(m_TextState->m_TextMode)) {
+ FX_FLOAT half_width = m_GraphState->m_LineWidth / 2;
m_Left -= half_width;
m_Right += half_width;
m_Top += half_width;
diff --git a/core/fpdfapi/fpdf_page/cpdf_textstate.cpp b/core/fpdfapi/fpdf_page/cpdf_textstate.cpp
index ae75876664..47e2116836 100644
--- a/core/fpdfapi/fpdf_page/cpdf_textstate.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_textstate.cpp
@@ -10,16 +10,15 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
void CPDF_TextState::SetFont(CPDF_Font* pFont) {
- CPDF_TextStateData* pStateData = GetPrivateCopy();
- if (pStateData) {
- CPDF_Document* pDoc = pStateData->m_pDocument;
- CPDF_DocPageData* pPageData = pDoc ? pDoc->GetPageData() : nullptr;
- if (pPageData && pStateData->m_pFont && !pPageData->IsForceClear()) {
- pPageData->ReleaseFont(pStateData->m_pFont->GetFontDict());
- }
- pStateData->m_pDocument = pFont ? pFont->m_pDocument : nullptr;
- pStateData->m_pFont = pFont;
- }
+ MakePrivateCopy();
+ CPDF_TextStateData* pStateData = GetObject();
+ CPDF_Document* pDoc = pStateData->m_pDocument;
+ CPDF_DocPageData* pPageData = pDoc ? pDoc->GetPageData() : nullptr;
+ if (pPageData && pStateData->m_pFont && !pPageData->IsForceClear())
+ pPageData->ReleaseFont(pStateData->m_pFont->GetFontDict());
+
+ pStateData->m_pDocument = pFont ? pFont->m_pDocument : nullptr;
+ pStateData->m_pFont = pFont;
}
FX_FLOAT CPDF_TextState::GetFontSizeV() const {
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index f1101034ae..3afcf4b7d1 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -583,7 +583,8 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() {
bDirect = FALSE;
}
if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) {
- m_CurContentMark.GetPrivateCopy()->AddMark(tag, pDict, bDirect);
+ m_CurContentMark.MakePrivateCopy();
+ m_CurContentMark->AddMark(tag, pDict, bDirect);
}
}
@@ -658,8 +659,8 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
}
void CPDF_StreamContentParser::Handle_BeginMarkedContent() {
- CFX_ByteString tag = GetString(0);
- m_CurContentMark.GetPrivateCopy()->AddMark(tag, nullptr, FALSE);
+ m_CurContentMark.MakePrivateCopy();
+ m_CurContentMark->AddMark(GetString(0), nullptr, FALSE);
}
void CPDF_StreamContentParser::Handle_BeginText() {
@@ -686,21 +687,21 @@ void CPDF_StreamContentParser::Handle_ConcatMatrix() {
}
void CPDF_StreamContentParser::Handle_SetColorSpace_Fill() {
- CFX_ByteString csname = GetString(0);
- CPDF_ColorSpace* pCS = FindColorSpace(csname);
- if (!pCS) {
+ CPDF_ColorSpace* pCS = FindColorSpace(GetString(0));
+ if (!pCS)
return;
- }
- m_pCurStates->m_ColorState.GetPrivateCopy()->m_FillColor.SetColorSpace(pCS);
+
+ m_pCurStates->m_ColorState.MakePrivateCopy();
+ m_pCurStates->m_ColorState->m_FillColor.SetColorSpace(pCS);
}
void CPDF_StreamContentParser::Handle_SetColorSpace_Stroke() {
- CFX_ByteString csname = GetString(0);
- CPDF_ColorSpace* pCS = FindColorSpace(csname);
- if (!pCS) {
+ CPDF_ColorSpace* pCS = FindColorSpace(GetString(0));
+ if (!pCS)
return;
- }
- m_pCurStates->m_ColorState.GetPrivateCopy()->m_StrokeColor.SetColorSpace(pCS);
+
+ m_pCurStates->m_ColorState.MakePrivateCopy();
+ m_pCurStates->m_ColorState->m_StrokeColor.SetColorSpace(pCS);
}
void CPDF_StreamContentParser::Handle_SetDash() {
@@ -811,22 +812,22 @@ void CPDF_StreamContentParser::Handle_EndMarkedContent() {
if (!m_CurContentMark)
return;
- int count = m_CurContentMark.GetObject()->CountItems();
- if (count == 1) {
- m_CurContentMark.SetNull();
+ if (m_CurContentMark->CountItems() == 1) {
+ m_CurContentMark.Clear();
return;
}
- m_CurContentMark.GetPrivateCopy()->DeleteLastMark();
+
+ m_CurContentMark.MakePrivateCopy();
+ m_CurContentMark->DeleteLastMark();
}
void CPDF_StreamContentParser::Handle_EndText() {
if (m_ClipTextList.empty())
return;
- if (TextRenderingModeIsClipMode(
- m_pCurStates->m_TextState.GetObject()->m_TextMode)) {
+ if (TextRenderingModeIsClipMode(m_pCurStates->m_TextState->m_TextMode))
m_pCurStates->m_ClipPath.AppendTexts(&m_ClipTextList);
- }
+
m_ClipTextList.clear();
}
@@ -876,19 +877,22 @@ void CPDF_StreamContentParser::Handle_ClosePath() {
}
void CPDF_StreamContentParser::Handle_SetFlat() {
- m_pCurStates->m_GeneralState.GetPrivateCopy()->m_Flatness = GetNumber(0);
+ m_pCurStates->m_GeneralState.MakePrivateCopy();
+ m_pCurStates->m_GeneralState->m_Flatness = GetNumber(0);
}
void CPDF_StreamContentParser::Handle_BeginImageData() {}
void CPDF_StreamContentParser::Handle_SetLineJoin() {
- m_pCurStates->m_GraphState.GetPrivateCopy()->m_LineJoin =
- (CFX_GraphStateData::LineJoin)GetInteger(0);
+ m_pCurStates->m_GraphState.MakePrivateCopy();
+ m_pCurStates->m_GraphState->m_LineJoin =
+ static_cast<CFX_GraphStateData::LineJoin>(GetInteger(0));
}
void CPDF_StreamContentParser::Handle_SetLineCap() {
- m_pCurStates->m_GraphState.GetPrivateCopy()->m_LineCap =
- (CFX_GraphStateData::LineCap)GetInteger(0);
+ m_pCurStates->m_GraphState.MakePrivateCopy();
+ m_pCurStates->m_GraphState->m_LineCap =
+ static_cast<CFX_GraphStateData::LineCap>(GetInteger(0));
}
void CPDF_StreamContentParser::Handle_SetCMYKColor_Fill() {
@@ -931,7 +935,8 @@ void CPDF_StreamContentParser::Handle_MoveTo() {
}
void CPDF_StreamContentParser::Handle_SetMiterLimit() {
- m_pCurStates->m_GraphState.GetPrivateCopy()->m_MiterLimit = GetNumber(0);
+ m_pCurStates->m_GraphState.MakePrivateCopy();
+ m_pCurStates->m_GraphState->m_MiterLimit = GetNumber(0);
}
void CPDF_StreamContentParser::Handle_MarkPlace() {}
@@ -1114,7 +1119,8 @@ void CPDF_StreamContentParser::Handle_ShadeFill() {
}
void CPDF_StreamContentParser::Handle_SetCharSpace() {
- m_pCurStates->m_TextState.GetPrivateCopy()->m_CharSpace = GetNumber(0);
+ m_pCurStates->m_TextState.MakePrivateCopy();
+ m_pCurStates->m_TextState->m_CharSpace = GetNumber(0);
}
void CPDF_StreamContentParser::Handle_MoveTextPoint() {
@@ -1131,14 +1137,14 @@ void CPDF_StreamContentParser::Handle_MoveTextPoint_SetLeading() {
void CPDF_StreamContentParser::Handle_SetFont() {
FX_FLOAT fs = GetNumber(0);
- if (fs == 0) {
+ if (fs == 0)
fs = m_DefFontSize;
- }
- m_pCurStates->m_TextState.GetPrivateCopy()->m_FontSize = fs;
+
+ m_pCurStates->m_TextState.MakePrivateCopy();
+ m_pCurStates->m_TextState->m_FontSize = fs;
CPDF_Font* pFont = FindFont(GetString(1));
- if (pFont) {
+ if (pFont)
m_pCurStates->m_TextState.SetFont(pFont);
- }
}
CPDF_Object* CPDF_StreamContentParser::FindResourceObj(
@@ -1243,13 +1249,14 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs,
}
const TextRenderingMode text_mode =
pFont->IsType3Font() ? TextRenderingMode::MODE_FILL
- : m_pCurStates->m_TextState.GetObject()->m_TextMode;
+ : m_pCurStates->m_TextState->m_TextMode;
{
std::unique_ptr<CPDF_TextObject> pText(new CPDF_TextObject);
m_pLastTextObject = pText.get();
SetGraphicStates(m_pLastTextObject, TRUE, TRUE, TRUE);
if (TextRenderingModeIsStrokeMode(text_mode)) {
- FX_FLOAT* pCTM = pText->m_TextState.GetPrivateCopy()->m_CTM;
+ pText->m_TextState.MakePrivateCopy();
+ FX_FLOAT* pCTM = pText->m_TextState->m_CTM;
pCTM[0] = m_pCurStates->m_CTM.a;
pCTM[1] = m_pCurStates->m_CTM.c;
pCTM[2] = m_pCurStates->m_CTM.b;
@@ -1358,7 +1365,8 @@ void CPDF_StreamContentParser::OnChangeTextMatrix() {
text_matrix.Concat(m_pCurStates->m_TextMatrix);
text_matrix.Concat(m_pCurStates->m_CTM);
text_matrix.Concat(m_mtContentToUser);
- FX_FLOAT* pTextMatrix = m_pCurStates->m_TextState.GetPrivateCopy()->m_Matrix;
+ m_pCurStates->m_TextState.MakePrivateCopy();
+ FX_FLOAT* pTextMatrix = m_pCurStates->m_TextState->m_Matrix;
pTextMatrix[0] = text_matrix.a;
pTextMatrix[1] = text_matrix.c;
pTextMatrix[2] = text_matrix.b;
@@ -1366,9 +1374,9 @@ void CPDF_StreamContentParser::OnChangeTextMatrix() {
}
void CPDF_StreamContentParser::Handle_SetTextRenderMode() {
- int mode = GetInteger(0);
- SetTextRenderingModeFromInt(
- mode, &m_pCurStates->m_TextState.GetPrivateCopy()->m_TextMode);
+ m_pCurStates->m_TextState.MakePrivateCopy();
+ SetTextRenderingModeFromInt(GetInteger(0),
+ &m_pCurStates->m_TextState->m_TextMode);
}
void CPDF_StreamContentParser::Handle_SetTextRise() {
@@ -1376,13 +1384,14 @@ void CPDF_StreamContentParser::Handle_SetTextRise() {
}
void CPDF_StreamContentParser::Handle_SetWordSpace() {
- m_pCurStates->m_TextState.GetPrivateCopy()->m_WordSpace = GetNumber(0);
+ m_pCurStates->m_TextState.MakePrivateCopy();
+ m_pCurStates->m_TextState->m_WordSpace = GetNumber(0);
}
void CPDF_StreamContentParser::Handle_SetHorzScale() {
- if (m_ParamCount != 1) {
+ if (m_ParamCount != 1)
return;
- }
+
m_pCurStates->m_TextHorzScale = GetNumber(0) / 100;
OnChangeTextMatrix();
}
@@ -1400,8 +1409,8 @@ void CPDF_StreamContentParser::Handle_CurveTo_23() {
}
void CPDF_StreamContentParser::Handle_SetLineWidth() {
- FX_FLOAT width = GetNumber(0);
- m_pCurStates->m_GraphState.GetPrivateCopy()->m_LineWidth = width;
+ m_pCurStates->m_GraphState.MakePrivateCopy();
+ m_pCurStates->m_GraphState->m_LineWidth = GetNumber(0);
}
void CPDF_StreamContentParser::Handle_Clip() {
@@ -1424,8 +1433,9 @@ void CPDF_StreamContentParser::Handle_NextLineShowText() {
}
void CPDF_StreamContentParser::Handle_NextLineShowText_Space() {
- m_pCurStates->m_TextState.GetPrivateCopy()->m_WordSpace = GetNumber(2);
- m_pCurStates->m_TextState.GetPrivateCopy()->m_CharSpace = GetNumber(1);
+ m_pCurStates->m_TextState.MakePrivateCopy();
+ m_pCurStates->m_TextState->m_WordSpace = GetNumber(2);
+ m_pCurStates->m_TextState->m_CharSpace = GetNumber(1);
Handle_NextLineShowText();
}
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index 6fa1df26cd..1b37862e99 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -711,8 +711,9 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm,
TRUE);
}
if (pForm->m_Transparency & PDFTRANS_GROUP) {
+ m_pParser->GetCurStates()->m_GeneralState.MakePrivateCopy();
CPDF_GeneralStateData* pData =
- m_pParser->GetCurStates()->m_GeneralState.GetPrivateCopy();
+ m_pParser->GetCurStates()->m_GeneralState.GetObject();
pData->m_BlendType = FXDIB_BLEND_NORMAL;
pData->m_StrokeAlpha = 1.0f;
pData->m_FillAlpha = 1.0f;
@@ -774,7 +775,8 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
m_pObjectHolder->m_pDocument, m_pObjectHolder->m_pPageResources,
nullptr, nullptr, m_pObjectHolder, m_pObjectHolder->m_pResources,
&m_pObjectHolder->m_BBox, nullptr, 0));
- m_pParser->GetCurStates()->m_ColorState.GetPrivateCopy()->Default();
+ m_pParser->GetCurStates()->m_ColorState.MakePrivateCopy();
+ m_pParser->GetCurStates()->m_ColorState->Default();
}
if (m_CurrentOffset >= m_Size) {
m_InternalStage = STAGE_CHECKCLIP;
@@ -812,9 +814,8 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
ClipPath.GetPointX(2), ClipPath.GetPointY(2));
CFX_FloatRect obj_rect(pObj->m_Left, pObj->m_Bottom, pObj->m_Right,
pObj->m_Top);
- if (old_rect.Contains(obj_rect)) {
- pObj->m_ClipPath.SetNull();
- }
+ if (old_rect.Contains(obj_rect))
+ pObj->m_ClipPath.Clear();
}
m_Status = Done;
return;
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_path.h b/core/fpdfapi/fpdf_page/include/cpdf_path.h
index 98de696004..33db4d755a 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_path.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_path.h
@@ -27,7 +27,8 @@ class CPDF_Path : public CFX_CountRef<CFX_PathData> {
FX_BOOL IsRect() const { return GetObject()->IsRect(); }
void Transform(const CFX_Matrix* pMatrix) {
- GetPrivateCopy()->Transform(pMatrix);
+ MakePrivateCopy();
+ GetObject()->Transform(pMatrix);
}
void Append(const CPDF_Path& other, const CFX_Matrix* pMatrix) {
GetObject()->Append(other.GetObject(), pMatrix);
diff --git a/core/fpdfapi/fpdf_render/fpdf_render.cpp b/core/fpdfapi/fpdf_render/fpdf_render.cpp
index f77e46d923..f5ab9696c7 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -199,16 +199,16 @@ FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext,
const CPDF_ColorStateData* pParentData =
pParentState->m_InitialStates.m_ColorState.GetObject();
if (!pColorData || pColorData->m_FillColor.IsNull()) {
- CPDF_ColorStateData* pData =
- m_InitialStates.m_ColorState.GetPrivateCopy();
- pData->m_FillRGB = pParentData->m_FillRGB;
- pData->m_FillColor.Copy(&pParentData->m_FillColor);
+ m_InitialStates.m_ColorState.MakePrivateCopy();
+ m_InitialStates.m_ColorState->m_FillRGB = pParentData->m_FillRGB;
+ m_InitialStates.m_ColorState->m_FillColor.Copy(
+ &pParentData->m_FillColor);
}
if (!pColorData || pColorData->m_StrokeColor.IsNull()) {
- CPDF_ColorStateData* pData =
- m_InitialStates.m_ColorState.GetPrivateCopy();
- pData->m_StrokeRGB = pParentData->m_FillRGB;
- pData->m_StrokeColor.Copy(&pParentData->m_StrokeColor);
+ m_InitialStates.m_ColorState.MakePrivateCopy();
+ m_InitialStates.m_ColorState->m_StrokeRGB = pParentData->m_FillRGB;
+ m_InitialStates.m_ColorState->m_StrokeColor.Copy(
+ &pParentData->m_StrokeColor);
}
}
} else {
@@ -579,7 +579,7 @@ void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath,
if (!ClipPath) {
if (m_LastClipPath) {
m_pDevice->RestoreState(true);
- m_LastClipPath.SetNull();
+ m_LastClipPath.Clear();
}
return;
}
@@ -921,11 +921,11 @@ CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates(
? pSrcStates->m_ColorState.GetStrokeColor()
: pSrcStates->m_ColorState.GetFillColor();
if (!pObjColor->IsNull()) {
- CPDF_ColorStateData* pColorData = pStates->m_ColorState.GetPrivateCopy();
- pColorData->m_FillRGB =
- bStroke ? pSrcStates->m_ColorState.GetObject()->m_StrokeRGB
- : pSrcStates->m_ColorState.GetObject()->m_FillRGB;
- pColorData->m_StrokeRGB = pColorData->m_FillRGB;
+ pStates->m_ColorState.MakePrivateCopy();
+ pStates->m_ColorState->m_FillRGB =
+ bStroke ? pSrcStates->m_ColorState->m_StrokeRGB
+ : pSrcStates->m_ColorState->m_FillRGB;
+ pStates->m_ColorState->m_StrokeRGB = pStates->m_ColorState->m_FillRGB;
}
return pStates;
}
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
index 16d1235f4d..4b59f1d61a 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
@@ -231,8 +231,7 @@ FX_BOOL CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj,
if (textobj->m_nChars == 0)
return TRUE;
- const TextRenderingMode& text_render_mode =
- textobj->m_TextState.GetObject()->m_TextMode;
+ const TextRenderingMode& text_render_mode = textobj->m_TextState->m_TextMode;
if (text_render_mode == TextRenderingMode::MODE_INVISIBLE)
return TRUE;
@@ -308,7 +307,7 @@ FX_BOOL CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj,
const CFX_Matrix* pDeviceMatrix = pObj2Device;
CFX_Matrix device_matrix;
if (bStroke) {
- const FX_FLOAT* pCTM = textobj->m_TextState.GetObject()->m_CTM;
+ const FX_FLOAT* pCTM = textobj->m_TextState->m_CTM;
if (pCTM[0] != 1.0f || pCTM[3] != 1.0f) {
CFX_Matrix ctm(pCTM[0], pCTM[1], pCTM[2], pCTM[3], 0, 0);
text_matrix.ConcatInverse(ctm);
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index 3981cfee40..ca1cbf1925 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -45,10 +45,10 @@ FX_FLOAT CalculateBaseSpace(const CPDF_TextObject* pTextObj,
const CFX_Matrix& matrix) {
FX_FLOAT baseSpace = 0.0;
const int nItems = pTextObj->CountItems();
- if (pTextObj->m_TextState.GetObject()->m_CharSpace && nItems >= 3) {
+ if (pTextObj->m_TextState->m_CharSpace && nItems >= 3) {
bool bAllChar = true;
- FX_FLOAT spacing = matrix.TransformDistance(
- pTextObj->m_TextState.GetObject()->m_CharSpace);
+ FX_FLOAT spacing =
+ matrix.TransformDistance(pTextObj->m_TextState->m_CharSpace);
baseSpace = spacing;
for (int i = 0; i < nItems; i++) {
CPDF_TextObjectItem item;
@@ -1088,7 +1088,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
spacing = -fontsize_h * item.m_OriginX / 1000;
continue;
}
- FX_FLOAT charSpace = pTextObj->m_TextState.GetObject()->m_CharSpace;
+ FX_FLOAT charSpace = pTextObj->m_TextState->m_CharSpace;
if (charSpace > 0.001)
spacing += matrix.TransformDistance(charSpace);
else if (charSpace < -0.001)
diff --git a/core/fxcrt/cfx_count_ref_unittest.cpp b/core/fxcrt/cfx_count_ref_unittest.cpp
index 7651c93f25..2a36292b54 100644
--- a/core/fxcrt/cfx_count_ref_unittest.cpp
+++ b/core/fxcrt/cfx_count_ref_unittest.cpp
@@ -109,16 +109,19 @@ TEST(fxcrt, CountRefGetModify) {
Observer observer;
{
CFX_CountRef<Object> ptr;
- EXPECT_NE(nullptr, ptr.GetPrivateCopy(&observer, std::string("one")));
+ ptr.MakePrivateCopy(&observer, std::string("one"));
+ EXPECT_NE(nullptr, ptr.GetObject());
EXPECT_EQ(1, observer.GetConstructionCount("one"));
EXPECT_EQ(0, observer.GetDestructionCount("one"));
- EXPECT_NE(nullptr, ptr.GetPrivateCopy(&observer, std::string("one")));
+ ptr.MakePrivateCopy(&observer, std::string("one"));
+ EXPECT_NE(nullptr, ptr.GetObject());
EXPECT_EQ(1, observer.GetConstructionCount("one"));
EXPECT_EQ(0, observer.GetDestructionCount("one"));
{
CFX_CountRef<Object> other(ptr);
- EXPECT_NE(nullptr, ptr.GetPrivateCopy(&observer, std::string("one")));
+ ptr.MakePrivateCopy(&observer, std::string("one"));
+ EXPECT_NE(nullptr, ptr.GetObject());
EXPECT_EQ(2, observer.GetConstructionCount("one"));
EXPECT_EQ(0, observer.GetDestructionCount("one"));
}
diff --git a/core/fxcrt/include/cfx_count_ref.h b/core/fxcrt/include/cfx_count_ref.h
index 817ce95add..0837894c66 100644
--- a/core/fxcrt/include/cfx_count_ref.h
+++ b/core/fxcrt/include/cfx_count_ref.h
@@ -29,17 +29,16 @@ class CFX_CountRef {
return *this;
}
- void SetNull() { m_pObject.Reset(); }
+ void Clear() { m_pObject.Reset(); }
ObjClass* GetObject() { return m_pObject.Get(); }
const ObjClass* GetObject() const { return m_pObject.Get(); }
template <typename... Args>
- ObjClass* GetPrivateCopy(Args... params) {
+ void MakePrivateCopy(Args... params) {
if (!m_pObject)
- return New(params...);
- if (!m_pObject->HasOneRef())
+ m_pObject.Reset(new CountedObj(params...));
+ else if (!m_pObject->HasOneRef())
m_pObject.Reset(new CountedObj(*m_pObject));
- return m_pObject.Get();
}
bool operator==(const CFX_CountRef& that) const {
@@ -47,6 +46,8 @@ class CFX_CountRef {
}
bool operator!=(const CFX_CountRef& that) const { return !(*this == that); }
operator bool() const { return m_pObject; }
+ ObjClass& operator*() const { return *m_pObject.Get(); }
+ ObjClass* operator->() const { return m_pObject.Get(); }
private:
class CountedObj : public ObjClass {
diff --git a/core/fxge/ge/cfx_cliprgn.cpp b/core/fxge/ge/cfx_cliprgn.cpp
index 41975e4b84..9b20633ee2 100644
--- a/core/fxge/ge/cfx_cliprgn.cpp
+++ b/core/fxge/ge/cfx_cliprgn.cpp
@@ -20,7 +20,7 @@ CFX_ClipRgn::~CFX_ClipRgn() {}
void CFX_ClipRgn::Reset(const FX_RECT& rect) {
m_Type = RectI;
m_Box = rect;
- m_Mask.SetNull();
+ m_Mask.Clear();
}
void CFX_ClipRgn::IntersectRect(const FX_RECT& rect) {
@@ -77,7 +77,7 @@ void CFX_ClipRgn::IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask) {
new_box.Intersect(mask_box);
if (new_box.IsEmpty()) {
m_Type = RectI;
- m_Mask.SetNull();
+ m_Mask.Clear();
m_Box = new_box;
return;
}
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index 712080a9de..af8bb7de5b 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -220,9 +220,9 @@ DLLEXPORT FPDF_CLIPPATH STDCALL FPDF_CreateClipPath(float left,
float right,
float top) {
CPDF_ClipPath* pNewClipPath = new CPDF_ClipPath();
- pNewClipPath->GetPrivateCopy();
+ pNewClipPath->MakePrivateCopy();
CPDF_Path Path;
- Path.GetPrivateCopy();
+ Path.MakePrivateCopy();
Path.AppendRect(left, bottom, right, top);
pNewClipPath->AppendPath(Path, FXFILL_ALTERNATE, FALSE);
return pNewClipPath;
diff --git a/fpdfsdk/fpdfeditimg.cpp b/fpdfsdk/fpdfeditimg.cpp
index 1fe832b877..372e676127 100644
--- a/fpdfsdk/fpdfeditimg.cpp
+++ b/fpdfsdk/fpdfeditimg.cpp
@@ -33,7 +33,7 @@ FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages,
IFX_FileRead* pFile = new CPDF_CustomAccess(fileAccess);
CPDF_ImageObject* pImgObj = reinterpret_cast<CPDF_ImageObject*>(image_object);
- pImgObj->m_GeneralState.GetPrivateCopy();
+ pImgObj->m_GeneralState.MakePrivateCopy();
for (int index = 0; index < nCount; index++) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(pages[index]);
if (pPage)
@@ -73,7 +73,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages,
return FALSE;
CPDF_ImageObject* pImgObj = reinterpret_cast<CPDF_ImageObject*>(image_object);
- pImgObj->m_GeneralState.GetPrivateCopy();
+ pImgObj->m_GeneralState.MakePrivateCopy();
for (int index = 0; index < nCount; index++) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(pages[index]);
if (pPage)
diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp
index 479fa970a1..c744958e5e 100644
--- a/fpdfsdk/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/fxedit/fxet_edit.cpp
@@ -137,8 +137,9 @@ void AddRectToPageObjects(CPDF_PageObjectHolder* pObjectHolder,
FX_COLORREF crFill,
const CFX_FloatRect& rcFill) {
std::unique_ptr<CPDF_PathObject> pPathObj(new CPDF_PathObject);
- CFX_PathData* pPathData = pPathObj->m_Path.GetPrivateCopy();
- pPathData->AppendRect(rcFill.left, rcFill.bottom, rcFill.right, rcFill.top);
+ pPathObj->m_Path.MakePrivateCopy();
+ pPathObj->m_Path->AppendRect(rcFill.left, rcFill.bottom, rcFill.right,
+ rcFill.top);
FX_FLOAT rgb[3];
rgb[0] = FXARGB_R(crFill) / 255.0f;
@@ -161,16 +162,16 @@ CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjectHolder* pObjectHolder,
const CFX_FloatPoint& point,
const CFX_ByteString& text) {
std::unique_ptr<CPDF_TextObject> pTxtObj(new CPDF_TextObject);
- CPDF_TextStateData* pTextStateData = pTxtObj->m_TextState.GetPrivateCopy();
- pTextStateData->m_pFont = pFont;
- pTextStateData->m_FontSize = fFontSize;
- pTextStateData->m_CharSpace = fCharSpace;
- pTextStateData->m_WordSpace = 0;
- pTextStateData->m_TextMode = TextRenderingMode::MODE_FILL;
- pTextStateData->m_Matrix[0] = nHorzScale / 100.0f;
- pTextStateData->m_Matrix[1] = 0;
- pTextStateData->m_Matrix[2] = 0;
- pTextStateData->m_Matrix[3] = 1;
+ pTxtObj->m_TextState.MakePrivateCopy();
+ pTxtObj->m_TextState->m_pFont = pFont;
+ pTxtObj->m_TextState->m_FontSize = fFontSize;
+ pTxtObj->m_TextState->m_CharSpace = fCharSpace;
+ pTxtObj->m_TextState->m_WordSpace = 0;
+ pTxtObj->m_TextState->m_TextMode = TextRenderingMode::MODE_FILL;
+ pTxtObj->m_TextState->m_Matrix[0] = nHorzScale / 100.0f;
+ pTxtObj->m_TextState->m_Matrix[1] = 0;
+ pTxtObj->m_TextState->m_Matrix[2] = 0;
+ pTxtObj->m_TextState->m_Matrix[3] = 1;
FX_FLOAT rgb[3];
rgb[0] = FXARGB_R(crText) / 255.0f;