diff options
Diffstat (limited to 'core/fpdfapi')
-rw-r--r-- | core/fpdfapi/page/cpdf_clippath.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_form.cpp | 9 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_form.h | 2 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_formobject.cpp | 9 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_formobject.h | 1 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_image.cpp | 22 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_image.h | 1 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_imageobject.cpp | 9 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_imageobject.h | 1 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_pageobject.h | 1 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_pathobject.cpp | 11 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_pathobject.h | 1 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_shadingobject.cpp | 16 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_shadingobject.h | 1 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_textobject.cpp | 5 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_textobject.h | 4 |
16 files changed, 9 insertions, 86 deletions
diff --git a/core/fpdfapi/page/cpdf_clippath.cpp b/core/fpdfapi/page/cpdf_clippath.cpp index 465a1c7997..cfcd9a1e64 100644 --- a/core/fpdfapi/page/cpdf_clippath.cpp +++ b/core/fpdfapi/page/cpdf_clippath.cpp @@ -123,7 +123,7 @@ CPDF_ClipPath::PathData::PathData(const PathData& that) { m_TextList.resize(that.m_TextList.size()); for (size_t i = 0; i < that.m_TextList.size(); ++i) { if (that.m_TextList[i]) - m_TextList[i].reset(that.m_TextList[i]->Clone()); + m_TextList[i] = that.m_TextList[i]->Clone(); } } diff --git a/core/fpdfapi/page/cpdf_form.cpp b/core/fpdfapi/page/cpdf_form.cpp index 18b9fdd94b..7291c88191 100644 --- a/core/fpdfapi/page/cpdf_form.cpp +++ b/core/fpdfapi/page/cpdf_form.cpp @@ -50,12 +50,3 @@ void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates, StartParse(pGraphicStates, pParentMatrix, pType3Char, level); ContinueParse(nullptr); } - -CPDF_Form* CPDF_Form::Clone() const { - CPDF_Form* pCloneForm = - new CPDF_Form(m_pDocument, m_pPageResources, m_pFormStream, m_pResources); - for (const auto& pObj : m_PageObjectList) - pCloneForm->m_PageObjectList.emplace_back(pObj->Clone()); - - return pCloneForm; -} diff --git a/core/fpdfapi/page/cpdf_form.h b/core/fpdfapi/page/cpdf_form.h index 1208e327bd..910f38fd08 100644 --- a/core/fpdfapi/page/cpdf_form.h +++ b/core/fpdfapi/page/cpdf_form.h @@ -29,8 +29,6 @@ class CPDF_Form : public CPDF_PageObjectHolder { CPDF_Type3Char* pType3Char, int level = 0); - CPDF_Form* Clone() const; - private: void StartParse(CPDF_AllStates* pGraphicStates, const CFX_Matrix* pParentMatrix, diff --git a/core/fpdfapi/page/cpdf_formobject.cpp b/core/fpdfapi/page/cpdf_formobject.cpp index dd3c2c2036..dc596e53c6 100644 --- a/core/fpdfapi/page/cpdf_formobject.cpp +++ b/core/fpdfapi/page/cpdf_formobject.cpp @@ -29,15 +29,6 @@ const CPDF_FormObject* CPDF_FormObject::AsForm() const { return this; } -CPDF_FormObject* CPDF_FormObject::Clone() const { - CPDF_FormObject* obj = new CPDF_FormObject; - obj->CopyData(this); - - obj->m_pForm.reset(m_pForm->Clone()); - obj->m_FormMatrix = m_FormMatrix; - return obj; -} - CPDF_PageObject::Type CPDF_FormObject::GetType() const { return FORM; } diff --git a/core/fpdfapi/page/cpdf_formobject.h b/core/fpdfapi/page/cpdf_formobject.h index 0fdc692019..b13cb5fbe4 100644 --- a/core/fpdfapi/page/cpdf_formobject.h +++ b/core/fpdfapi/page/cpdf_formobject.h @@ -20,7 +20,6 @@ class CPDF_FormObject : public CPDF_PageObject { ~CPDF_FormObject() override; // CPDF_PageObject: - CPDF_FormObject* Clone() const override; Type GetType() const override; void Transform(const CFX_Matrix& matrix) override; bool IsForm() const override; diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp index dafca2b764..8a5faa6d0a 100644 --- a/core/fpdfapi/page/cpdf_image.cpp +++ b/core/fpdfapi/page/cpdf_image.cpp @@ -61,24 +61,6 @@ void CPDF_Image::FinishInitialization() { m_Width = m_pDict->GetIntegerFor("Width"); } -CPDF_Image* CPDF_Image::Clone() { - CPDF_Image* pImage = new CPDF_Image(m_pDocument); - pImage->m_bIsInline = m_bIsInline; - if (m_pOwnedStream) { - pImage->m_pOwnedStream = ToStream(m_pOwnedStream->Clone()); - pImage->m_pStream = pImage->m_pOwnedStream.get(); - } else { - pImage->m_pStream = m_pStream; - } - if (m_pOwnedDict) { - pImage->m_pOwnedDict = ToDictionary(m_pOwnedDict->Clone()); - pImage->m_pDict = pImage->m_pOwnedDict.get(); - } else { - pImage->m_pDict = m_pDict; - } - return pImage; -} - void CPDF_Image::ConvertStreamToIndirectObject() { if (!m_pStream->IsInline()) return; @@ -329,7 +311,7 @@ CFX_DIBSource* CPDF_Image::LoadDIBSource(CFX_DIBSource** ppMask, bool bStdCS, uint32_t GroupFamily, bool bLoadMask) const { - std::unique_ptr<CPDF_DIBSource> source(new CPDF_DIBSource); + auto source = pdfium::MakeUnique<CPDF_DIBSource>(); if (source->Load(m_pDocument, m_pStream, reinterpret_cast<CPDF_DIBSource**>(ppMask), pMatteColor, nullptr, nullptr, bStdCS, GroupFamily, bLoadMask)) { @@ -355,7 +337,7 @@ bool CPDF_Image::StartLoadDIBSource(CPDF_Dictionary* pFormResource, bool bStdCS, uint32_t GroupFamily, bool bLoadMask) { - std::unique_ptr<CPDF_DIBSource> source(new CPDF_DIBSource); + auto source = pdfium::MakeUnique<CPDF_DIBSource>(); int ret = source->StartLoadDIBSource(m_pDocument, m_pStream, true, pFormResource, pPageResource, bStdCS, GroupFamily, bLoadMask); diff --git a/core/fpdfapi/page/cpdf_image.h b/core/fpdfapi/page/cpdf_image.h index 1491efe1c6..3438e2b98e 100644 --- a/core/fpdfapi/page/cpdf_image.h +++ b/core/fpdfapi/page/cpdf_image.h @@ -26,7 +26,6 @@ class CPDF_Image { CPDF_Image(CPDF_Document* pDoc, uint32_t dwStreamObjNum); ~CPDF_Image(); - CPDF_Image* Clone(); void ConvertStreamToIndirectObject(); CPDF_Dictionary* GetInlineDict() const { return m_pDict; } diff --git a/core/fpdfapi/page/cpdf_imageobject.cpp b/core/fpdfapi/page/cpdf_imageobject.cpp index 2893c525b1..bb91820548 100644 --- a/core/fpdfapi/page/cpdf_imageobject.cpp +++ b/core/fpdfapi/page/cpdf_imageobject.cpp @@ -19,15 +19,6 @@ CPDF_ImageObject::~CPDF_ImageObject() { Release(); } -CPDF_ImageObject* CPDF_ImageObject::Clone() const { - CPDF_ImageObject* obj = new CPDF_ImageObject; - obj->CopyData(this); - - obj->m_pImage = m_pImage->Clone(); - obj->m_Matrix = m_Matrix; - return obj; -} - CPDF_PageObject::Type CPDF_ImageObject::GetType() const { return IMAGE; } diff --git a/core/fpdfapi/page/cpdf_imageobject.h b/core/fpdfapi/page/cpdf_imageobject.h index 2bb1e8233d..1bbfc0509c 100644 --- a/core/fpdfapi/page/cpdf_imageobject.h +++ b/core/fpdfapi/page/cpdf_imageobject.h @@ -20,7 +20,6 @@ class CPDF_ImageObject : public CPDF_PageObject { ~CPDF_ImageObject() override; // CPDF_PageObject - CPDF_ImageObject* Clone() const override; Type GetType() const override; void Transform(const CFX_Matrix& matrix) override; bool IsImage() const override; diff --git a/core/fpdfapi/page/cpdf_pageobject.h b/core/fpdfapi/page/cpdf_pageobject.h index 97cac7e9aa..ffc59f4eee 100644 --- a/core/fpdfapi/page/cpdf_pageobject.h +++ b/core/fpdfapi/page/cpdf_pageobject.h @@ -31,7 +31,6 @@ class CPDF_PageObject : public CPDF_GraphicStates { CPDF_PageObject(); ~CPDF_PageObject() override; - virtual CPDF_PageObject* Clone() const = 0; virtual Type GetType() const = 0; virtual void Transform(const CFX_Matrix& matrix) = 0; virtual bool IsText() const; diff --git a/core/fpdfapi/page/cpdf_pathobject.cpp b/core/fpdfapi/page/cpdf_pathobject.cpp index a25f7891a6..27c4535fa5 100644 --- a/core/fpdfapi/page/cpdf_pathobject.cpp +++ b/core/fpdfapi/page/cpdf_pathobject.cpp @@ -10,17 +10,6 @@ CPDF_PathObject::CPDF_PathObject() {} CPDF_PathObject::~CPDF_PathObject() {} -CPDF_PathObject* CPDF_PathObject::Clone() const { - CPDF_PathObject* obj = new CPDF_PathObject; - obj->CopyData(this); - - obj->m_Path = m_Path; - obj->m_FillType = m_FillType; - obj->m_bStroke = m_bStroke; - obj->m_Matrix = m_Matrix; - return obj; -} - CPDF_PageObject::Type CPDF_PathObject::GetType() const { return PATH; } diff --git a/core/fpdfapi/page/cpdf_pathobject.h b/core/fpdfapi/page/cpdf_pathobject.h index d5ce5c0d02..58499b5a53 100644 --- a/core/fpdfapi/page/cpdf_pathobject.h +++ b/core/fpdfapi/page/cpdf_pathobject.h @@ -18,7 +18,6 @@ class CPDF_PathObject : public CPDF_PageObject { ~CPDF_PathObject() override; // CPDF_PageObject - CPDF_PathObject* Clone() const override; Type GetType() const override; void Transform(const CFX_Matrix& maxtrix) override; bool IsPath() const override; diff --git a/core/fpdfapi/page/cpdf_shadingobject.cpp b/core/fpdfapi/page/cpdf_shadingobject.cpp index 84b6aa7cd5..928b0af47e 100644 --- a/core/fpdfapi/page/cpdf_shadingobject.cpp +++ b/core/fpdfapi/page/cpdf_shadingobject.cpp @@ -14,22 +14,6 @@ CPDF_ShadingObject::CPDF_ShadingObject() : m_pShading(nullptr) {} CPDF_ShadingObject::~CPDF_ShadingObject() {} -CPDF_ShadingObject* CPDF_ShadingObject::Clone() const { - CPDF_ShadingObject* obj = new CPDF_ShadingObject; - obj->CopyData(this); - - obj->m_pShading = m_pShading; - if (obj->m_pShading && obj->m_pShading->document()) { - CPDF_DocPageData* pDocPageData = obj->m_pShading->document()->GetPageData(); - CPDF_Pattern* pattern = pDocPageData->GetPattern( - obj->m_pShading->GetShadingObject(), m_pShading->IsShadingObject(), - obj->m_pShading->parent_matrix()); - obj->m_pShading = pattern ? pattern->AsShadingPattern() : nullptr; - } - obj->m_Matrix = m_Matrix; - return obj; -} - CPDF_PageObject::Type CPDF_ShadingObject::GetType() const { return SHADING; } diff --git a/core/fpdfapi/page/cpdf_shadingobject.h b/core/fpdfapi/page/cpdf_shadingobject.h index ed5679a83b..ffd622379e 100644 --- a/core/fpdfapi/page/cpdf_shadingobject.h +++ b/core/fpdfapi/page/cpdf_shadingobject.h @@ -18,7 +18,6 @@ class CPDF_ShadingObject : public CPDF_PageObject { ~CPDF_ShadingObject() override; // CPDF_PageObject - CPDF_ShadingObject* Clone() const override; Type GetType() const override; void Transform(const CFX_Matrix& matrix) override; bool IsShading() const override; diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp index d5a2ea6d29..0979fcfb33 100644 --- a/core/fpdfapi/page/cpdf_textobject.cpp +++ b/core/fpdfapi/page/cpdf_textobject.cpp @@ -8,6 +8,7 @@ #include "core/fpdfapi/font/cpdf_cidfont.h" #include "core/fpdfapi/font/cpdf_font.h" +#include "third_party/base/ptr_util.h" CPDF_TextObject::CPDF_TextObject() : m_PosX(0), @@ -109,8 +110,8 @@ void CPDF_TextObject::GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const { } } -CPDF_TextObject* CPDF_TextObject::Clone() const { - CPDF_TextObject* obj = new CPDF_TextObject; +std::unique_ptr<CPDF_TextObject> CPDF_TextObject::Clone() const { + auto obj = pdfium::MakeUnique<CPDF_TextObject>(); obj->CopyData(this); obj->m_nChars = m_nChars; diff --git a/core/fpdfapi/page/cpdf_textobject.h b/core/fpdfapi/page/cpdf_textobject.h index 23da997aeb..b520e3ee92 100644 --- a/core/fpdfapi/page/cpdf_textobject.h +++ b/core/fpdfapi/page/cpdf_textobject.h @@ -7,6 +7,8 @@ #ifndef CORE_FPDFAPI_PAGE_CPDF_TEXTOBJECT_H_ #define CORE_FPDFAPI_PAGE_CPDF_TEXTOBJECT_H_ +#include <memory> + #include "core/fpdfapi/page/cpdf_pageobject.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" @@ -23,13 +25,13 @@ class CPDF_TextObject : public CPDF_PageObject { ~CPDF_TextObject() override; // CPDF_PageObject - CPDF_TextObject* Clone() const override; Type GetType() const override; void Transform(const CFX_Matrix& matrix) override; bool IsText() const override; CPDF_TextObject* AsText() override; const CPDF_TextObject* AsText() const override; + std::unique_ptr<CPDF_TextObject> Clone() const; int CountItems() const; void GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const; int CountChars() const; |