summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-05-24 13:45:11 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-24 22:35:01 +0000
commitdc8a2b7606c2c6c12d5cfb280dfb49128c1a60ab (patch)
tree8808b5cc14ba97955c8b34db7317b9f35c819eea
parentedc1e4e5baac33c8f2799e82ff52fd556d3c5e02 (diff)
downloadpdfium-dc8a2b7606c2c6c12d5cfb280dfb49128c1a60ab.tar.xz
Convert to CFX_UnownedPtr, part 10
Change-Id: I4eab5e843580845753c5f80c05cf9490a85114b6 Reviewed-on: https://pdfium-review.googlesource.com/5890 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
-rw-r--r--core/fpdfdoc/cpdf_viewerpreferences.h3
-rw-r--r--fpdfsdk/formfiller/cba_fontmap.cpp16
-rw-r--r--fpdfsdk/formfiller/cba_fontmap.h10
-rw-r--r--fpdfsdk/fpdfppo.cpp11
-rw-r--r--xfa/fxfa/cxfa_ffdoc.cpp4
-rw-r--r--xfa/fxfa/cxfa_ffdoc.h17
6 files changed, 31 insertions, 30 deletions
diff --git a/core/fpdfdoc/cpdf_viewerpreferences.h b/core/fpdfdoc/cpdf_viewerpreferences.h
index c7e9112380..46428a238c 100644
--- a/core/fpdfdoc/cpdf_viewerpreferences.h
+++ b/core/fpdfdoc/cpdf_viewerpreferences.h
@@ -7,6 +7,7 @@
#ifndef CORE_FPDFDOC_CPDF_VIEWERPREFERENCES_H_
#define CORE_FPDFDOC_CPDF_VIEWERPREFERENCES_H_
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
@@ -33,7 +34,7 @@ class CPDF_ViewerPreferences {
private:
CPDF_Dictionary* GetViewerPreferences() const;
- CPDF_Document* const m_pDoc;
+ CFX_UnownedPtr<CPDF_Document> const m_pDoc;
};
#endif // CORE_FPDFDOC_CPDF_VIEWERPREFERENCES_H_
diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp
index 273317401d..8bef264085 100644
--- a/fpdfsdk/formfiller/cba_fontmap.cpp
+++ b/fpdfsdk/formfiller/cba_fontmap.cpp
@@ -58,8 +58,8 @@ void CBA_FontMap::Initialize() {
else
nCharset = FX_CHARSET_ANSI;
}
- AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset);
- AddFontToAnnotDict(m_pDefaultFont, m_sDefaultFontName);
+ AddFontData(m_pDefaultFont.Get(), m_sDefaultFontName, nCharset);
+ AddFontToAnnotDict(m_pDefaultFont.Get(), m_sDefaultFontName);
}
}
@@ -80,7 +80,7 @@ void CBA_FontMap::SetDefaultFont(CPDF_Font* pFont,
int32_t nCharset = FX_CHARSET_Default;
if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont())
nCharset = pSubstFont->m_Charset;
- AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset);
+ AddFontData(m_pDefaultFont.Get(), m_sDefaultFontName, nCharset);
}
CPDF_Font* CBA_FontMap::FindFontSameCharset(CFX_ByteString* sFontAlias,
@@ -105,7 +105,7 @@ CPDF_Font* CBA_FontMap::FindFontSameCharset(CFX_ByteString* sFontAlias,
}
CPDF_Document* CBA_FontMap::GetDocument() {
- return m_pDocument;
+ return m_pDocument.Get();
}
CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict,
@@ -167,7 +167,7 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
CPDF_Stream* pStream = pAPDict->GetStreamFor(m_sAPType);
if (!pStream) {
pStream = m_pDocument->NewIndirect<CPDF_Stream>();
- pAPDict->SetNewFor<CPDF_Reference>(m_sAPType, m_pDocument,
+ pAPDict->SetNewFor<CPDF_Reference>(m_sAPType, m_pDocument.Get(),
pStream->GetObjNum());
}
@@ -185,12 +185,12 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictFor("Font");
if (!pStreamResFontList) {
pStreamResFontList = m_pDocument->NewIndirect<CPDF_Dictionary>();
- pStreamResList->SetNewFor<CPDF_Reference>("Font", m_pDocument,
+ pStreamResList->SetNewFor<CPDF_Reference>("Font", m_pDocument.Get(),
pStreamResFontList->GetObjNum());
}
if (!pStreamResFontList->KeyExist(sAlias)) {
pStreamResFontList->SetNewFor<CPDF_Reference>(
- sAlias, m_pDocument, pFont->GetFontDict()->GetObjNum());
+ sAlias, m_pDocument.Get(), pFont->GetFontDict()->GetObjNum());
}
}
@@ -203,7 +203,7 @@ CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString* sAlias) {
}
CFX_ByteString sDA;
- CPDF_Object* pObj = FPDF_GetFieldAttr(m_pAnnotDict, "DA");
+ CPDF_Object* pObj = FPDF_GetFieldAttr(m_pAnnotDict.Get(), "DA");
if (pObj)
sDA = pObj->GetString();
diff --git a/fpdfsdk/formfiller/cba_fontmap.h b/fpdfsdk/formfiller/cba_fontmap.h
index 09a5a38116..14aabe4d2a 100644
--- a/fpdfsdk/formfiller/cba_fontmap.h
+++ b/fpdfsdk/formfiller/cba_fontmap.h
@@ -7,6 +7,7 @@
#ifndef FPDFSDK_FORMFILLER_CBA_FONTMAP_H_
#define FPDFSDK_FORMFILLER_CBA_FONTMAP_H_
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "fpdfsdk/pdfwindow/PWL_FontMap.h"
class CPDF_Dictionary;
@@ -17,9 +18,8 @@ class CBA_FontMap : public CPWL_FontMap {
CBA_FontMap(CPDFSDK_Annot* pAnnot, CFX_SystemHandler* pSystemHandler);
~CBA_FontMap() override;
- void SetDefaultFont(CPDF_Font* pFont, const CFX_ByteString& sFontName);
-
void Reset();
+ void SetDefaultFont(CPDF_Font* pFont, const CFX_ByteString& sFontName);
void SetAPType(const CFX_ByteString& sAPType);
private:
@@ -36,9 +36,9 @@ class CBA_FontMap : public CPWL_FontMap {
CPDF_Font* GetAnnotDefaultFont(CFX_ByteString* csNameTag);
void AddFontToAnnotDict(CPDF_Font* pFont, const CFX_ByteString& sAlias);
- CPDF_Document* m_pDocument;
- CPDF_Dictionary* m_pAnnotDict;
- CPDF_Font* m_pDefaultFont;
+ CFX_UnownedPtr<CPDF_Document> m_pDocument;
+ CFX_UnownedPtr<CPDF_Dictionary> m_pAnnotDict;
+ CFX_UnownedPtr<CPDF_Font> m_pDefaultFont;
CFX_ByteString m_sDefaultFontName;
CFX_ByteString m_sAPType;
};
diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp
index e2ef406b05..d05fab9c0b 100644
--- a/fpdfsdk/fpdfppo.cpp
+++ b/fpdfsdk/fpdfppo.cpp
@@ -18,6 +18,7 @@
#include "core/fpdfapi/parser/cpdf_reference.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_string.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "fpdfsdk/fsdk_define.h"
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
@@ -137,8 +138,8 @@ class CPDF_PageOrganizer {
bool UpdateReference(CPDF_Object* pObj, ObjectNumberMap* pObjNumberMap);
uint32_t GetNewObjId(ObjectNumberMap* pObjNumberMap, CPDF_Reference* pRef);
- CPDF_Document* m_pDestPDFDoc;
- CPDF_Document* m_pSrcPDFDoc;
+ CFX_UnownedPtr<CPDF_Document> m_pDestPDFDoc;
+ CFX_UnownedPtr<CPDF_Document> m_pSrcPDFDoc;
};
CPDF_PageOrganizer::CPDF_PageOrganizer(CPDF_Document* pDestPDFDoc,
@@ -170,7 +171,7 @@ bool CPDF_PageOrganizer::PDFDocInit() {
pElement ? ToDictionary(pElement->GetDirect()) : nullptr;
if (!pNewPages) {
pNewPages = m_pDestPDFDoc->NewIndirect<CPDF_Dictionary>();
- pNewRoot->SetNewFor<CPDF_Reference>("Pages", m_pDestPDFDoc,
+ pNewRoot->SetNewFor<CPDF_Reference>("Pages", m_pDestPDFDoc.Get(),
pNewPages->GetObjNum());
}
@@ -181,7 +182,7 @@ bool CPDF_PageOrganizer::PDFDocInit() {
if (!pNewPages->GetArrayFor("Kids")) {
pNewPages->SetNewFor<CPDF_Number>("Count", 0);
pNewPages->SetNewFor<CPDF_Reference>(
- "Kids", m_pDestPDFDoc,
+ "Kids", m_pDestPDFDoc.Get(),
m_pDestPDFDoc->NewIndirect<CPDF_Array>()->GetObjNum());
}
@@ -260,7 +261,7 @@ bool CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
uint32_t newobjnum = GetNewObjId(pObjNumberMap, pReference);
if (newobjnum == 0)
return false;
- pReference->SetRef(m_pDestPDFDoc, newobjnum);
+ pReference->SetRef(m_pDestPDFDoc.Get(), newobjnum);
break;
}
case CPDF_Object::DICTIONARY: {
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index f7bad38934..bde40ce11f 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -337,10 +337,6 @@ void CXFA_FFDoc::CloseDoc() {
m_pApp->ClearEventTargets();
}
-CPDF_Document* CXFA_FFDoc::GetPDFDoc() {
- return m_pPDFDoc;
-}
-
CFX_RetainPtr<CFX_DIBitmap> CXFA_FFDoc::GetPDFNamedImage(
const CFX_WideStringC& wsName,
int32_t& iImageXDpi,
diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h
index d40e7ba0c8..a43dae3caa 100644
--- a/xfa/fxfa/cxfa_ffdoc.h
+++ b/xfa/fxfa/cxfa_ffdoc.h
@@ -10,6 +10,7 @@
#include <map>
#include <memory>
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "xfa/fxfa/fxfa.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_document_parser.h"
@@ -49,7 +50,9 @@ class CXFA_FFDoc {
CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment);
~CXFA_FFDoc();
- IXFA_DocEnvironment* GetDocEnvironment() const { return m_pDocEnvironment; }
+ IXFA_DocEnvironment* GetDocEnvironment() const {
+ return m_pDocEnvironment.Get();
+ }
XFA_DocType GetDocType() const { return m_dwDocType; }
int32_t StartLoad();
@@ -62,11 +65,11 @@ class CXFA_FFDoc {
bool OpenDoc(CPDF_Document* pPDFDoc);
void CloseDoc();
- CXFA_Document* GetXFADoc() { return m_pDocumentParser->GetDocument(); }
- CXFA_FFApp* GetApp() { return m_pApp; }
+ CXFA_Document* GetXFADoc() const { return m_pDocumentParser->GetDocument(); }
+ CXFA_FFApp* GetApp() const { return m_pApp.Get(); }
+ CPDF_Document* GetPDFDoc() const { return m_pPDFDoc.Get(); }
CXFA_FFDocView* GetDocView(CXFA_LayoutProcessor* pLayout);
CXFA_FFDocView* GetDocView();
- CPDF_Document* GetPDFDoc();
CFX_RetainPtr<CFX_DIBitmap> GetPDFNamedImage(const CFX_WideStringC& wsName,
int32_t& iImageXDpi,
int32_t& iImageYDpi);
@@ -78,12 +81,12 @@ class CXFA_FFDoc {
bool bXDP = true);
private:
- IXFA_DocEnvironment* const m_pDocEnvironment;
+ CFX_UnownedPtr<IXFA_DocEnvironment> const m_pDocEnvironment;
std::unique_ptr<CXFA_DocumentParser> m_pDocumentParser;
CFX_RetainPtr<IFX_SeekableStream> m_pStream;
- CXFA_FFApp* m_pApp;
+ CFX_UnownedPtr<CXFA_FFApp> m_pApp;
std::unique_ptr<CXFA_FFNotify> m_pNotify;
- CPDF_Document* m_pPDFDoc;
+ CFX_UnownedPtr<CPDF_Document> m_pPDFDoc;
std::map<uint32_t, FX_IMAGEDIB_AND_DPI> m_HashToDibDpiMap;
std::unique_ptr<CXFA_FFDocView> m_DocView;
XFA_DocType m_dwDocType;