diff options
Diffstat (limited to 'core/fpdfapi')
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_allstates.cpp | 71 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_clippath.cpp | 9 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_colorstate.cpp | 12 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_generalstate.cpp | 3 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_pageobject.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_pathobject.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_textobject.cpp | 10 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_textstate.cpp | 19 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 100 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 11 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/include/cpdf_path.h | 3 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_render/fpdf_render.cpp | 28 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_render/fpdf_render_text.cpp | 5 |
14 files changed, 153 insertions, 130 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); |