summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/page/cpdf_contentmarkitem.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_contentmarkitem.h3
-rw-r--r--core/fpdfapi/parser/cpdf_parser.cpp15
-rw-r--r--core/fpdfapi/parser/cpdf_parser.h3
-rw-r--r--core/fpdfapi/render/cpdf_docrenderdata.cpp2
-rw-r--r--core/fpdfapi/render/cpdf_docrenderdata.h4
6 files changed, 16 insertions, 13 deletions
diff --git a/core/fpdfapi/page/cpdf_contentmarkitem.cpp b/core/fpdfapi/page/cpdf_contentmarkitem.cpp
index 2c370141e2..de720b39fc 100644
--- a/core/fpdfapi/page/cpdf_contentmarkitem.cpp
+++ b/core/fpdfapi/page/cpdf_contentmarkitem.cpp
@@ -26,7 +26,7 @@ CPDF_ContentMarkItem::~CPDF_ContentMarkItem() {}
CPDF_Dictionary* CPDF_ContentMarkItem::GetParam() const {
switch (m_ParamType) {
case PropertiesDict:
- return m_pPropertiesDict;
+ return m_pPropertiesDict.Get();
case DirectDict:
return m_pDirectDict.get();
case None:
diff --git a/core/fpdfapi/page/cpdf_contentmarkitem.h b/core/fpdfapi/page/cpdf_contentmarkitem.h
index ed2737111b..afd2833691 100644
--- a/core/fpdfapi/page/cpdf_contentmarkitem.h
+++ b/core/fpdfapi/page/cpdf_contentmarkitem.h
@@ -9,6 +9,7 @@
#include <memory>
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_memory.h"
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
@@ -37,7 +38,7 @@ class CPDF_ContentMarkItem {
private:
CFX_ByteString m_MarkName;
ParamType m_ParamType;
- CPDF_Dictionary* m_pPropertiesDict; // not owned.
+ CFX_UnownedPtr<CPDF_Dictionary> m_pPropertiesDict;
std::unique_ptr<CPDF_Dictionary> m_pDirectDict;
};
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index a3e5dba40a..54b8ea0aa3 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -52,8 +52,7 @@ int32_t GetStreamFirst(const CFX_RetainPtr<CPDF_StreamAcc>& pObjStream) {
} // namespace
CPDF_Parser::CPDF_Parser()
- : m_pDocument(nullptr),
- m_bHasParsed(false),
+ : m_bHasParsed(false),
m_bXRefStream(false),
m_bVersionUpdated(false),
m_FileVersion(0),
@@ -719,8 +718,8 @@ bool CPDF_Parser::RebuildCrossRef() {
last_obj = start_pos;
FX_FILESIZE obj_end = 0;
std::unique_ptr<CPDF_Object> pObject =
- ParseIndirectObjectAtByStrict(m_pDocument, obj_pos, objnum,
- &obj_end);
+ ParseIndirectObjectAtByStrict(m_pDocument.Get(), obj_pos,
+ objnum, &obj_end);
if (CPDF_Stream* pStream = ToStream(pObject.get())) {
if (CPDF_Dictionary* pDict = pStream->GetDict()) {
if ((pDict->KeyExist("Type")) &&
@@ -779,7 +778,7 @@ bool CPDF_Parser::RebuildCrossRef() {
m_pSyntax->SetPos(pos + i - m_pSyntax->m_HeaderOffset);
std::unique_ptr<CPDF_Object> pObj =
- m_pSyntax->GetObject(m_pDocument, 0, 0, true);
+ m_pSyntax->GetObject(m_pDocument.Get(), 0, 0, true);
if (pObj) {
if (pObj->IsDictionary() || pObj->AsStream()) {
CPDF_Stream* pStream = pObj->AsStream();
@@ -800,7 +799,7 @@ bool CPDF_Parser::RebuildCrossRef() {
pElement ? pElement->GetObjNum() : 0;
if (dwObjNum) {
m_pTrailer->SetNewFor<CPDF_Reference>(
- key, m_pDocument, dwObjNum);
+ key, m_pDocument.Get(), dwObjNum);
} else {
m_pTrailer->SetFor(key, pElement->Clone());
}
@@ -920,7 +919,7 @@ bool CPDF_Parser::RebuildCrossRef() {
bool CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, bool bMainXRef) {
std::unique_ptr<CPDF_Object> pObject(
- ParseIndirectObjectAt(m_pDocument, *pos, 0));
+ ParseIndirectObjectAt(m_pDocument.Get(), *pos, 0));
if (!pObject)
return false;
@@ -1397,7 +1396,7 @@ std::unique_ptr<CPDF_Dictionary> CPDF_Parser::LoadTrailerV4() {
if (m_pSyntax->GetKeyword() != "trailer")
return nullptr;
- return ToDictionary(m_pSyntax->GetObject(m_pDocument, 0, 0, true));
+ return ToDictionary(m_pSyntax->GetObject(m_pDocument.Get(), 0, 0, true));
}
uint32_t CPDF_Parser::GetPermissions() const {
diff --git a/core/fpdfapi/parser/cpdf_parser.h b/core/fpdfapi/parser/cpdf_parser.h
index 7ae2d4627e..c444c99f28 100644
--- a/core/fpdfapi/parser/cpdf_parser.h
+++ b/core/fpdfapi/parser/cpdf_parser.h
@@ -12,6 +12,7 @@
#include <set>
#include <vector>
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_basic.h"
class CPDF_Array;
@@ -150,7 +151,7 @@ class CPDF_Parser {
// the objects.
bool VerifyCrossRefV4();
- CPDF_Document* m_pDocument; // not owned
+ CFX_UnownedPtr<CPDF_Document> m_pDocument;
bool m_bHasParsed;
bool m_bXRefStream;
bool m_bVersionUpdated;
diff --git a/core/fpdfapi/render/cpdf_docrenderdata.cpp b/core/fpdfapi/render/cpdf_docrenderdata.cpp
index 2d0bca4497..d03824b59e 100644
--- a/core/fpdfapi/render/cpdf_docrenderdata.cpp
+++ b/core/fpdfapi/render/cpdf_docrenderdata.cpp
@@ -88,7 +88,7 @@ CFX_RetainPtr<CPDF_TransferFunc> CPDF_DocRenderData::GetTransferFunc(
if (!pFuncs[0])
return nullptr;
}
- auto pTransfer = pdfium::MakeRetain<CPDF_TransferFunc>(m_pPDFDoc);
+ auto pTransfer = pdfium::MakeRetain<CPDF_TransferFunc>(m_pPDFDoc.Get());
m_TransferFuncMap[pObj] = pTransfer;
float input;
diff --git a/core/fpdfapi/render/cpdf_docrenderdata.h b/core/fpdfapi/render/cpdf_docrenderdata.h
index 7952f95991..949a079126 100644
--- a/core/fpdfapi/render/cpdf_docrenderdata.h
+++ b/core/fpdfapi/render/cpdf_docrenderdata.h
@@ -11,6 +11,8 @@
#include "core/fpdfapi/page/cpdf_countedobject.h"
#include "core/fpdfapi/render/cpdf_transferfunc.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
+#include "core/fxcrt/fx_system.h"
class CPDF_Document;
class CPDF_Font;
@@ -32,7 +34,7 @@ class CPDF_DocRenderData {
void Clear(bool bRelease);
private:
- CPDF_Document* m_pPDFDoc; // Not Owned
+ CFX_UnownedPtr<CPDF_Document> m_pPDFDoc;
std::map<CPDF_Font*, CFX_RetainPtr<CPDF_Type3Cache>> m_Type3FaceMap;
std::map<CPDF_Object*, CFX_RetainPtr<CPDF_TransferFunc>> m_TransferFuncMap;
};