summaryrefslogtreecommitdiff
path: root/core/fpdfdoc
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r--core/fpdfdoc/cpdf_aaction.cpp8
-rw-r--r--core/fpdfdoc/cpdf_aaction.h10
-rw-r--r--core/fpdfdoc/cpdf_action.cpp8
-rw-r--r--core/fpdfdoc/cpdf_action.h10
-rw-r--r--core/fpdfdoc/cpdf_actionfields.cpp5
-rw-r--r--core/fpdfdoc/cpdf_actionfields.h7
-rw-r--r--core/fpdfdoc/cpdf_annot.cpp20
-rw-r--r--core/fpdfdoc/cpdf_annot.h4
-rw-r--r--core/fpdfdoc/cpdf_apsettings.cpp4
-rw-r--r--core/fpdfdoc/cpdf_apsettings.h5
-rw-r--r--core/fpdfdoc/cpdf_formcontrol.cpp8
-rw-r--r--core/fpdfdoc/cpdf_formcontrol.h9
-rw-r--r--core/fpdfdoc/cpdf_formfield.cpp2
-rw-r--r--core/fpdfdoc/cpdf_iconfit.cpp6
-rw-r--r--core/fpdfdoc/cpdf_iconfit.h9
-rw-r--r--core/fpdfdoc/cpdf_interform.cpp2
-rw-r--r--core/fpdfdoc/cpdf_interform.h2
-rw-r--r--core/fpdfdoc/cpdf_numbertree.cpp6
-rw-r--r--core/fpdfdoc/cpdf_numbertree.h7
-rw-r--r--core/fpdfdoc/cpdf_occontext.cpp2
-rw-r--r--core/fpdfdoc/cpdf_occontext.h2
-rw-r--r--core/fpdfdoc/cpdf_pagelabel.cpp2
-rw-r--r--core/fpdfdoc/cpdf_pagelabel.h3
-rw-r--r--core/fpdfdoc/cpdf_structelement.cpp2
-rw-r--r--core/fpdfdoc/cpdf_structelement.h8
-rw-r--r--core/fpdfdoc/cpdf_variabletext.h2
-rw-r--r--core/fpdfdoc/csection.h2
-rw-r--r--core/fpdfdoc/ctypeset.h2
28 files changed, 107 insertions, 50 deletions
diff --git a/core/fpdfdoc/cpdf_aaction.cpp b/core/fpdfdoc/cpdf_aaction.cpp
index 7dc42828f4..033bf03a6a 100644
--- a/core/fpdfdoc/cpdf_aaction.cpp
+++ b/core/fpdfdoc/cpdf_aaction.cpp
@@ -14,6 +14,14 @@ const char* g_sAATypes[] = {"E", "X", "D", "U", "Fo", "Bl", "PO", "PC",
} // namespace
+CPDF_AAction::CPDF_AAction() {}
+
+CPDF_AAction::CPDF_AAction(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
+
+CPDF_AAction::CPDF_AAction(const CPDF_AAction& that) = default;
+
+CPDF_AAction::~CPDF_AAction() {}
+
bool CPDF_AAction::ActionExist(AActionType eType) const {
return m_pDict && m_pDict->KeyExist(g_sAATypes[eType]);
}
diff --git a/core/fpdfdoc/cpdf_aaction.h b/core/fpdfdoc/cpdf_aaction.h
index d615915ee3..b2b691fc26 100644
--- a/core/fpdfdoc/cpdf_aaction.h
+++ b/core/fpdfdoc/cpdf_aaction.h
@@ -37,15 +37,17 @@ class CPDF_AAction {
DocumentPrinted
};
- CPDF_AAction() : m_pDict(nullptr) {}
- explicit CPDF_AAction(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
+ CPDF_AAction();
+ explicit CPDF_AAction(CPDF_Dictionary* pDict);
+ CPDF_AAction(const CPDF_AAction& that);
+ ~CPDF_AAction();
bool ActionExist(AActionType eType) const;
CPDF_Action GetAction(AActionType eType) const;
- CPDF_Dictionary* GetDict() const { return m_pDict; }
+ CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
private:
- CPDF_Dictionary* const m_pDict;
+ CFX_UnownedPtr<CPDF_Dictionary> const m_pDict;
};
#endif // CORE_FPDFDOC_CPDF_AACTION_H_
diff --git a/core/fpdfdoc/cpdf_action.cpp b/core/fpdfdoc/cpdf_action.cpp
index f523f86b37..b40fdcd225 100644
--- a/core/fpdfdoc/cpdf_action.cpp
+++ b/core/fpdfdoc/cpdf_action.cpp
@@ -21,6 +21,14 @@ const char* const g_sATypes[] = {
} // namespace
+CPDF_Action::CPDF_Action() {}
+
+CPDF_Action::CPDF_Action(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
+
+CPDF_Action::CPDF_Action(const CPDF_Action& that) = default;
+
+CPDF_Action::~CPDF_Action() {}
+
CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const {
if (!m_pDict)
return CPDF_Dest();
diff --git a/core/fpdfdoc/cpdf_action.h b/core/fpdfdoc/cpdf_action.h
index 426edb12e9..bd1ce58ec6 100644
--- a/core/fpdfdoc/cpdf_action.h
+++ b/core/fpdfdoc/cpdf_action.h
@@ -37,10 +37,12 @@ class CPDF_Action {
GoTo3DView
};
- CPDF_Action() : m_pDict(nullptr) {}
- explicit CPDF_Action(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
+ CPDF_Action();
+ explicit CPDF_Action(CPDF_Dictionary* pDict);
+ CPDF_Action(const CPDF_Action& that);
+ ~CPDF_Action();
- CPDF_Dictionary* GetDict() const { return m_pDict; }
+ CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
ActionType GetType() const;
CPDF_Dest GetDest(CPDF_Document* pDoc) const;
CFX_WideString GetFilePath() const;
@@ -53,7 +55,7 @@ class CPDF_Action {
CPDF_Action GetSubAction(size_t iIndex) const;
private:
- CPDF_Dictionary* const m_pDict;
+ CFX_UnownedPtr<CPDF_Dictionary> const m_pDict;
};
#endif // CORE_FPDFDOC_CPDF_ACTION_H_
diff --git a/core/fpdfdoc/cpdf_actionfields.cpp b/core/fpdfdoc/cpdf_actionfields.cpp
index 35ec92c1b8..f3c3f5ed25 100644
--- a/core/fpdfdoc/cpdf_actionfields.cpp
+++ b/core/fpdfdoc/cpdf_actionfields.cpp
@@ -10,6 +10,11 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfdoc/cpdf_action.h"
+CPDF_ActionFields::CPDF_ActionFields(const CPDF_Action* pAction)
+ : m_pAction(pAction) {}
+
+CPDF_ActionFields::~CPDF_ActionFields() {}
+
size_t CPDF_ActionFields::GetFieldsCount() const {
if (!m_pAction)
return 0;
diff --git a/core/fpdfdoc/cpdf_actionfields.h b/core/fpdfdoc/cpdf_actionfields.h
index 9e0664cadb..71b42475a7 100644
--- a/core/fpdfdoc/cpdf_actionfields.h
+++ b/core/fpdfdoc/cpdf_actionfields.h
@@ -11,19 +11,22 @@
#include <vector>
+#include "core/fxcrt/cfx_unowned_ptr.h"
+
class CPDF_Action;
class CPDF_Object;
class CPDF_ActionFields {
public:
- explicit CPDF_ActionFields(const CPDF_Action* pAction) : m_pAction(pAction) {}
+ explicit CPDF_ActionFields(const CPDF_Action* pAction);
+ ~CPDF_ActionFields();
size_t GetFieldsCount() const;
std::vector<CPDF_Object*> GetAllFields() const;
CPDF_Object* GetField(size_t iIndex) const;
private:
- const CPDF_Action* const m_pAction;
+ CFX_UnownedPtr<const CPDF_Action> const m_pAction;
};
#endif // CORE_FPDFDOC_CPDF_ACTIONFIELDS_H_
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index 146c863cf3..eab6cd0145 100644
--- a/core/fpdfdoc/cpdf_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -90,23 +90,23 @@ void CPDF_Annot::GenerateAPIfNeeded() {
CPDF_Dictionary* pDict = m_pAnnotDict.Get();
bool result = false;
if (m_nSubtype == CPDF_Annot::Subtype::CIRCLE)
- result = CPVT_GenerateAP::GenerateCircleAP(m_pDocument, pDict);
+ result = CPVT_GenerateAP::GenerateCircleAP(m_pDocument.Get(), pDict);
else if (m_nSubtype == CPDF_Annot::Subtype::HIGHLIGHT)
- result = CPVT_GenerateAP::GenerateHighlightAP(m_pDocument, pDict);
+ result = CPVT_GenerateAP::GenerateHighlightAP(m_pDocument.Get(), pDict);
else if (m_nSubtype == CPDF_Annot::Subtype::INK)
- result = CPVT_GenerateAP::GenerateInkAP(m_pDocument, pDict);
+ result = CPVT_GenerateAP::GenerateInkAP(m_pDocument.Get(), pDict);
else if (m_nSubtype == CPDF_Annot::Subtype::POPUP)
- result = CPVT_GenerateAP::GeneratePopupAP(m_pDocument, pDict);
+ result = CPVT_GenerateAP::GeneratePopupAP(m_pDocument.Get(), pDict);
else if (m_nSubtype == CPDF_Annot::Subtype::SQUARE)
- result = CPVT_GenerateAP::GenerateSquareAP(m_pDocument, pDict);
+ result = CPVT_GenerateAP::GenerateSquareAP(m_pDocument.Get(), pDict);
else if (m_nSubtype == CPDF_Annot::Subtype::SQUIGGLY)
- result = CPVT_GenerateAP::GenerateSquigglyAP(m_pDocument, pDict);
+ result = CPVT_GenerateAP::GenerateSquigglyAP(m_pDocument.Get(), pDict);
else if (m_nSubtype == CPDF_Annot::Subtype::STRIKEOUT)
- result = CPVT_GenerateAP::GenerateStrikeOutAP(m_pDocument, pDict);
+ result = CPVT_GenerateAP::GenerateStrikeOutAP(m_pDocument.Get(), pDict);
else if (m_nSubtype == CPDF_Annot::Subtype::TEXT)
- result = CPVT_GenerateAP::GenerateTextAP(m_pDocument, pDict);
+ result = CPVT_GenerateAP::GenerateTextAP(m_pDocument.Get(), pDict);
else if (m_nSubtype == CPDF_Annot::Subtype::UNDERLINE)
- result = CPVT_GenerateAP::GenerateUnderlineAP(m_pDocument, pDict);
+ result = CPVT_GenerateAP::GenerateUnderlineAP(m_pDocument.Get(), pDict);
if (result) {
m_pAnnotDict->SetNewFor<CPDF_Boolean>(kPDFiumKey_HasGeneratedAP, result);
@@ -205,7 +205,7 @@ CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) {
return it->second.get();
auto pNewForm = pdfium::MakeUnique<CPDF_Form>(
- m_pDocument, pPage->m_pResources.Get(), pStream);
+ m_pDocument.Get(), pPage->m_pResources.Get(), pStream);
pNewForm->ParseContent(nullptr, nullptr, nullptr);
CPDF_Form* pResult = pNewForm.get();
diff --git a/core/fpdfdoc/cpdf_annot.h b/core/fpdfdoc/cpdf_annot.h
index 188106acdf..85a205345e 100644
--- a/core/fpdfdoc/cpdf_annot.h
+++ b/core/fpdfdoc/cpdf_annot.h
@@ -82,7 +82,7 @@ class CPDF_Annot {
CPDF_Annot::Subtype GetSubtype() const;
uint32_t GetFlags() const;
CFX_FloatRect GetRect() const;
- CPDF_Document* GetDocument() const { return m_pDocument; }
+ CPDF_Document* GetDocument() const { return m_pDocument.Get(); }
CPDF_Dictionary* GetAnnotDict() const { return m_pAnnotDict.Get(); }
bool DrawAppearance(CPDF_Page* pPage,
@@ -112,7 +112,7 @@ class CPDF_Annot {
CFX_FloatRect RectForDrawing() const;
CFX_MaybeOwned<CPDF_Dictionary> m_pAnnotDict;
- CPDF_Document* const m_pDocument;
+ CFX_UnownedPtr<CPDF_Document> const m_pDocument;
CPDF_Annot::Subtype m_nSubtype;
std::map<CPDF_Stream*, std::unique_ptr<CPDF_Form>> m_APMap;
// |m_bOpenState| is only set for popup annotations.
diff --git a/core/fpdfdoc/cpdf_apsettings.cpp b/core/fpdfdoc/cpdf_apsettings.cpp
index 4c44f5a13e..ee205e01dc 100644
--- a/core/fpdfdoc/cpdf_apsettings.cpp
+++ b/core/fpdfdoc/cpdf_apsettings.cpp
@@ -14,6 +14,10 @@
CPDF_ApSettings::CPDF_ApSettings(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
+CPDF_ApSettings::CPDF_ApSettings(const CPDF_ApSettings& that) = default;
+
+CPDF_ApSettings::~CPDF_ApSettings() {}
+
bool CPDF_ApSettings::HasMKEntry(const CFX_ByteString& csEntry) const {
return m_pDict && m_pDict->KeyExist(csEntry);
}
diff --git a/core/fpdfdoc/cpdf_apsettings.h b/core/fpdfdoc/cpdf_apsettings.h
index ba0b05bd2b..2f8f9e49d9 100644
--- a/core/fpdfdoc/cpdf_apsettings.h
+++ b/core/fpdfdoc/cpdf_apsettings.h
@@ -8,6 +8,7 @@
#define CORE_FPDFDOC_CPDF_APSETTINGS_H_
#include "core/fpdfdoc/cpdf_iconfit.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxge/fx_dib.h"
@@ -19,6 +20,8 @@ class CPDF_Stream;
class CPDF_ApSettings {
public:
explicit CPDF_ApSettings(CPDF_Dictionary* pDict);
+ CPDF_ApSettings(const CPDF_ApSettings& that);
+ ~CPDF_ApSettings();
bool HasMKEntry(const CFX_ByteString& csEntry) const;
int GetRotation() const;
@@ -68,7 +71,7 @@ class CPDF_ApSettings {
CFX_WideString GetCaption(const CFX_ByteString& csEntry) const;
CPDF_Stream* GetIcon(const CFX_ByteString& csEntry) const;
- CPDF_Dictionary* const m_pDict;
+ CFX_UnownedPtr<CPDF_Dictionary> const m_pDict;
};
#endif // CORE_FPDFDOC_CPDF_APSETTINGS_H_
diff --git a/core/fpdfdoc/cpdf_formcontrol.cpp b/core/fpdfdoc/cpdf_formcontrol.cpp
index d9740f7c99..54524a64e2 100644
--- a/core/fpdfdoc/cpdf_formcontrol.cpp
+++ b/core/fpdfdoc/cpdf_formcontrol.cpp
@@ -32,6 +32,8 @@ CPDF_FormControl::CPDF_FormControl(CPDF_FormField* pField,
m_pWidgetDict(pWidgetDict),
m_pForm(m_pField->GetForm()) {}
+CPDF_FormControl::~CPDF_FormControl() {}
+
CFX_ByteString CPDF_FormControl::GetOnStateName() const {
ASSERT(GetType() == CPDF_FormField::CheckBox ||
GetType() == CPDF_FormField::RadioButton);
@@ -167,7 +169,7 @@ void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice,
if (m_pWidgetDict->GetIntegerFor("F") & ANNOTFLAG_HIDDEN)
return;
- CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pWidgetDict, mode);
+ CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pWidgetDict.Get(), mode);
if (!pStream)
return;
@@ -178,7 +180,7 @@ void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice,
CFX_Matrix matrix;
matrix.MatchRect(arect, form_bbox);
matrix.Concat(*pMatrix);
- CPDF_Form form(m_pField->GetForm()->m_pDocument,
+ CPDF_Form form(m_pField->GetForm()->m_pDocument.Get(),
m_pField->GetForm()->m_pFormDict->GetDictFor("DR"), pStream);
form.ParseContent(nullptr, nullptr, nullptr);
CPDF_RenderContext context(pPage);
@@ -286,7 +288,7 @@ CPDF_Font* CPDF_FormControl::GetDefaultControlFont() {
if (csFontNameTag.IsEmpty())
return nullptr;
- CPDF_Object* pObj = FPDF_GetFieldAttr(m_pWidgetDict, "DR");
+ CPDF_Object* pObj = FPDF_GetFieldAttr(m_pWidgetDict.Get(), "DR");
if (CPDF_Dictionary* pDict = ToDictionary(pObj)) {
CPDF_Dictionary* pFonts = pDict->GetDictFor("Font");
if (pFonts) {
diff --git a/core/fpdfdoc/cpdf_formcontrol.h b/core/fpdfdoc/cpdf_formcontrol.h
index 154d592f32..eb63b5b6f0 100644
--- a/core/fpdfdoc/cpdf_formcontrol.h
+++ b/core/fpdfdoc/cpdf_formcontrol.h
@@ -47,11 +47,12 @@ class CPDF_FormControl {
enum HighlightingMode { None = 0, Invert, Outline, Push, Toggle };
CPDF_FormControl(CPDF_FormField* pField, CPDF_Dictionary* pWidgetDict);
+ ~CPDF_FormControl();
CPDF_FormField::Type GetType() const { return m_pField->GetType(); }
- const CPDF_InterForm* GetInterForm() const { return m_pForm; }
+ const CPDF_InterForm* GetInterForm() const { return m_pForm.Get(); }
CPDF_FormField* GetField() const { return m_pField; }
- CPDF_Dictionary* GetWidget() const { return m_pWidgetDict; }
+ CPDF_Dictionary* GetWidget() const { return m_pWidgetDict.Get(); }
CFX_FloatRect GetRect() const { return m_pWidgetDict->GetRectFor("Rect"); }
void DrawControl(CFX_RenderDevice* pDevice,
@@ -127,8 +128,8 @@ class CPDF_FormControl {
CPDF_ApSettings GetMK() const;
CPDF_FormField* const m_pField;
- CPDF_Dictionary* const m_pWidgetDict;
- const CPDF_InterForm* const m_pForm;
+ CFX_UnownedPtr<CPDF_Dictionary> const m_pWidgetDict;
+ CFX_UnownedPtr<const CPDF_InterForm> const m_pForm;
};
#endif // CORE_FPDFDOC_CPDF_FORMCONTROL_H_
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index 7a48826cbd..97ea052436 100644
--- a/core/fpdfdoc/cpdf_formfield.cpp
+++ b/core/fpdfdoc/cpdf_formfield.cpp
@@ -408,7 +408,7 @@ int CPDF_FormField::GetMaxLen() const {
for (auto& pControl : m_ControlList) {
if (!pControl)
continue;
- CPDF_Dictionary* pWidgetDict = pControl->m_pWidgetDict;
+ CPDF_Dictionary* pWidgetDict = pControl->m_pWidgetDict.Get();
if (pWidgetDict->KeyExist("MaxLen"))
return pWidgetDict->GetIntegerFor("MaxLen");
}
diff --git a/core/fpdfdoc/cpdf_iconfit.cpp b/core/fpdfdoc/cpdf_iconfit.cpp
index 0f05d7de35..a28f3bc430 100644
--- a/core/fpdfdoc/cpdf_iconfit.cpp
+++ b/core/fpdfdoc/cpdf_iconfit.cpp
@@ -10,6 +10,12 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fxcrt/fx_string.h"
+CPDF_IconFit::CPDF_IconFit(const CPDF_Dictionary* pDict) : m_pDict(pDict) {}
+
+CPDF_IconFit::CPDF_IconFit(const CPDF_IconFit& that) = default;
+
+CPDF_IconFit::~CPDF_IconFit() {}
+
CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() {
if (!m_pDict)
return Always;
diff --git a/core/fpdfdoc/cpdf_iconfit.h b/core/fpdfdoc/cpdf_iconfit.h
index 6e3b8cf50a..0fa8d37e24 100644
--- a/core/fpdfdoc/cpdf_iconfit.h
+++ b/core/fpdfdoc/cpdf_iconfit.h
@@ -7,6 +7,7 @@
#ifndef CORE_FPDFDOC_CPDF_ICONFIT_H_
#define CORE_FPDFDOC_CPDF_ICONFIT_H_
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_system.h"
class CPDF_Dictionary;
@@ -15,16 +16,18 @@ class CPDF_IconFit {
public:
enum ScaleMethod { Always = 0, Bigger, Smaller, Never };
- explicit CPDF_IconFit(const CPDF_Dictionary* pDict) : m_pDict(pDict) {}
+ explicit CPDF_IconFit(const CPDF_Dictionary* pDict);
+ CPDF_IconFit(const CPDF_IconFit& that);
+ ~CPDF_IconFit();
ScaleMethod GetScaleMethod();
bool IsProportionalScale();
void GetIconPosition(float& fLeft, float& fBottom);
bool GetFittingBounds();
- const CPDF_Dictionary* GetDict() const { return m_pDict; }
+ const CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
private:
- const CPDF_Dictionary* const m_pDict;
+ CFX_UnownedPtr<const CPDF_Dictionary> const m_pDict;
};
#endif // CORE_FPDFDOC_CPDF_ICONFIT_H_
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp
index 455158b74d..de99a5de0f 100644
--- a/core/fpdfdoc/cpdf_interform.cpp
+++ b/core/fpdfdoc/cpdf_interform.cpp
@@ -961,7 +961,7 @@ int CPDF_InterForm::FindFieldInCalculationOrder(const CPDF_FormField* pField) {
}
CPDF_Font* CPDF_InterForm::GetFormFont(CFX_ByteString csNameTag) const {
- return GetFont(m_pFormDict, m_pDocument, csNameTag);
+ return GetFont(m_pFormDict, m_pDocument.Get(), csNameTag);
}
CPDF_DefaultAppearance CPDF_InterForm::GetDefaultAppearance() const {
diff --git a/core/fpdfdoc/cpdf_interform.h b/core/fpdfdoc/cpdf_interform.h
index 23530e57b2..0a9b3e0e4a 100644
--- a/core/fpdfdoc/cpdf_interform.h
+++ b/core/fpdfdoc/cpdf_interform.h
@@ -108,7 +108,7 @@ class CPDF_InterForm {
static bool s_bUpdateAP;
- CPDF_Document* const m_pDocument;
+ CFX_UnownedPtr<CPDF_Document> const m_pDocument;
CPDF_Dictionary* m_pFormDict;
std::map<const CPDF_Dictionary*, std::unique_ptr<CPDF_FormControl>>
m_ControlMap;
diff --git a/core/fpdfdoc/cpdf_numbertree.cpp b/core/fpdfdoc/cpdf_numbertree.cpp
index 5f2bc06666..952fb4ef1d 100644
--- a/core/fpdfdoc/cpdf_numbertree.cpp
+++ b/core/fpdfdoc/cpdf_numbertree.cpp
@@ -47,6 +47,10 @@ CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) {
} // namespace
+CPDF_NumberTree::CPDF_NumberTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {}
+
+CPDF_NumberTree::~CPDF_NumberTree() {}
+
CPDF_Object* CPDF_NumberTree::LookupValue(int num) const {
- return SearchNumberNode(m_pRoot, num);
+ return SearchNumberNode(m_pRoot.Get(), num);
}
diff --git a/core/fpdfdoc/cpdf_numbertree.h b/core/fpdfdoc/cpdf_numbertree.h
index bfe44fddb9..843e186208 100644
--- a/core/fpdfdoc/cpdf_numbertree.h
+++ b/core/fpdfdoc/cpdf_numbertree.h
@@ -7,17 +7,20 @@
#ifndef CORE_FPDFDOC_CPDF_NUMBERTREE_H_
#define CORE_FPDFDOC_CPDF_NUMBERTREE_H_
+#include "core/fxcrt/cfx_unowned_ptr.h"
+
class CPDF_Dictionary;
class CPDF_Object;
class CPDF_NumberTree {
public:
- explicit CPDF_NumberTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {}
+ explicit CPDF_NumberTree(CPDF_Dictionary* pRoot);
+ ~CPDF_NumberTree();
CPDF_Object* LookupValue(int num) const;
protected:
- CPDF_Dictionary* const m_pRoot;
+ CFX_UnownedPtr<CPDF_Dictionary> const m_pRoot;
};
#endif // CORE_FPDFDOC_CPDF_NUMBERTREE_H_
diff --git a/core/fpdfdoc/cpdf_occontext.cpp b/core/fpdfdoc/cpdf_occontext.cpp
index c4272f4897..66950c9406 100644
--- a/core/fpdfdoc/cpdf_occontext.cpp
+++ b/core/fpdfdoc/cpdf_occontext.cpp
@@ -101,7 +101,7 @@ CPDF_OCContext::~CPDF_OCContext() {}
bool CPDF_OCContext::LoadOCGStateFromConfig(
const CFX_ByteString& csConfig,
const CPDF_Dictionary* pOCGDict) const {
- CPDF_Dictionary* pConfig = GetConfig(m_pDocument, pOCGDict);
+ CPDF_Dictionary* pConfig = GetConfig(m_pDocument.Get(), pOCGDict);
if (!pConfig)
return true;
diff --git a/core/fpdfdoc/cpdf_occontext.h b/core/fpdfdoc/cpdf_occontext.h
index 753aa5c176..ea8eea2489 100644
--- a/core/fpdfdoc/cpdf_occontext.h
+++ b/core/fpdfdoc/cpdf_occontext.h
@@ -38,7 +38,7 @@ class CPDF_OCContext : public CFX_Retainable {
bool GetOCGVE(CPDF_Array* pExpression, int nLevel);
bool LoadOCMDState(const CPDF_Dictionary* pOCMDDict);
- CPDF_Document* const m_pDocument;
+ CFX_UnownedPtr<CPDF_Document> const m_pDocument;
const UsageType m_eUsageType;
std::map<const CPDF_Dictionary*, bool> m_OCGStates;
};
diff --git a/core/fpdfdoc/cpdf_pagelabel.cpp b/core/fpdfdoc/cpdf_pagelabel.cpp
index 4200a28f64..3892abad5e 100644
--- a/core/fpdfdoc/cpdf_pagelabel.cpp
+++ b/core/fpdfdoc/cpdf_pagelabel.cpp
@@ -75,6 +75,8 @@ CFX_WideString GetLabelNumPortion(int num, const CFX_ByteString& bsStyle) {
CPDF_PageLabel::CPDF_PageLabel(CPDF_Document* pDocument)
: m_pDocument(pDocument) {}
+CPDF_PageLabel::~CPDF_PageLabel() {}
+
bool CPDF_PageLabel::GetLabel(int nPage, CFX_WideString* wsLabel) const {
if (!m_pDocument)
return false;
diff --git a/core/fpdfdoc/cpdf_pagelabel.h b/core/fpdfdoc/cpdf_pagelabel.h
index 0f91f614d9..66324f87c6 100644
--- a/core/fpdfdoc/cpdf_pagelabel.h
+++ b/core/fpdfdoc/cpdf_pagelabel.h
@@ -14,13 +14,14 @@ class CPDF_Document;
class CPDF_PageLabel {
public:
explicit CPDF_PageLabel(CPDF_Document* pDocument);
+ ~CPDF_PageLabel();
bool GetLabel(int nPage, CFX_WideString* wsLabel) const;
int32_t GetPageByLabel(const CFX_ByteStringC& bsLabel) const;
int32_t GetPageByLabel(const CFX_WideStringC& wsLabel) const;
private:
- CPDF_Document* const m_pDocument;
+ CFX_UnownedPtr<CPDF_Document> const m_pDocument;
};
#endif // CORE_FPDFDOC_CPDF_PAGELABEL_H_
diff --git a/core/fpdfdoc/cpdf_structelement.cpp b/core/fpdfdoc/cpdf_structelement.cpp
index c85ae0dd42..c5f2b6bd79 100644
--- a/core/fpdfdoc/cpdf_structelement.cpp
+++ b/core/fpdfdoc/cpdf_structelement.cpp
@@ -133,5 +133,5 @@ void CPDF_StructElement::LoadKid(uint32_t PageObjNum,
}
pKid->m_pElement =
- pdfium::MakeRetain<CPDF_StructElement>(m_pTree, this, pKidDict);
+ pdfium::MakeRetain<CPDF_StructElement>(m_pTree.Get(), this, pKidDict);
}
diff --git a/core/fpdfdoc/cpdf_structelement.h b/core/fpdfdoc/cpdf_structelement.h
index d8820a141c..8fe73e51c8 100644
--- a/core/fpdfdoc/cpdf_structelement.h
+++ b/core/fpdfdoc/cpdf_structelement.h
@@ -41,7 +41,7 @@ class CPDF_StructElement : public CFX_Retainable {
const CFX_ByteString& GetType() const { return m_Type; }
const CFX_ByteString& GetTitle() const { return m_Title; }
- CPDF_Dictionary* GetDict() const { return m_pDict; }
+ CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
int CountKids() const;
CPDF_StructElement* GetKidIfElement(int index) const;
@@ -56,9 +56,9 @@ class CPDF_StructElement : public CFX_Retainable {
void LoadKids(CPDF_Dictionary* pDict);
void LoadKid(uint32_t PageObjNum, CPDF_Object* pObj, CPDF_StructKid* pKid);
- CPDF_StructTree* const m_pTree;
- CPDF_StructElement* const m_pParent;
- CPDF_Dictionary* const m_pDict;
+ CFX_UnownedPtr<CPDF_StructTree> const m_pTree;
+ CFX_UnownedPtr<CPDF_StructElement> const m_pParent;
+ CFX_UnownedPtr<CPDF_Dictionary> const m_pDict;
CFX_ByteString m_Type;
CFX_ByteString m_Title;
std::vector<CPDF_StructKid> m_Kids;
diff --git a/core/fpdfdoc/cpdf_variabletext.h b/core/fpdfdoc/cpdf_variabletext.h
index 2e6caf63d6..a226350006 100644
--- a/core/fpdfdoc/cpdf_variabletext.h
+++ b/core/fpdfdoc/cpdf_variabletext.h
@@ -58,7 +58,7 @@ class CPDF_VariableText {
private:
CPVT_WordPlace m_CurPos;
- CPDF_VariableText* const m_pVT;
+ CFX_UnownedPtr<CPDF_VariableText> const m_pVT;
};
class Provider {
diff --git a/core/fpdfdoc/csection.h b/core/fpdfdoc/csection.h
index b465d1d63d..aefdcaf7b2 100644
--- a/core/fpdfdoc/csection.h
+++ b/core/fpdfdoc/csection.h
@@ -57,7 +57,7 @@ class CSection final {
void ClearRightWords(int32_t nWordIndex);
void ClearMidWords(int32_t nBeginIndex, int32_t nEndIndex);
- CPDF_VariableText* const m_pVT;
+ CFX_UnownedPtr<CPDF_VariableText> const m_pVT;
};
#endif // CORE_FPDFDOC_CSECTION_H_
diff --git a/core/fpdfdoc/ctypeset.h b/core/fpdfdoc/ctypeset.h
index f769fe1311..1b016ea562 100644
--- a/core/fpdfdoc/ctypeset.h
+++ b/core/fpdfdoc/ctypeset.h
@@ -27,7 +27,7 @@ class CTypeset final {
void OutputLines();
CPVT_FloatRect m_rcRet;
- CPDF_VariableText* const m_pVT;
+ CFX_UnownedPtr<CPDF_VariableText> const m_pVT;
CSection* const m_pSection;
};