summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r--core/fpdfapi/parser/cfdf_document.cpp4
-rw-r--r--core/fpdfapi/parser/cfdf_document.h6
-rw-r--r--core/fpdfapi/parser/cpdf_document.cpp25
-rw-r--r--core/fpdfapi/parser/cpdf_document.h7
-rw-r--r--core/fpdfapi/parser/cpdf_indirect_object_holder.cpp8
-rw-r--r--core/fpdfapi/parser/cpdf_indirect_object_holder.h7
6 files changed, 27 insertions, 30 deletions
diff --git a/core/fpdfapi/parser/cfdf_document.cpp b/core/fpdfapi/parser/cfdf_document.cpp
index d76ae1e642..96ed4ae6eb 100644
--- a/core/fpdfapi/parser/cfdf_document.cpp
+++ b/core/fpdfapi/parser/cfdf_document.cpp
@@ -15,13 +15,11 @@ CFDF_Document::CFDF_Document()
: CPDF_IndirectObjectHolder(),
m_pRootDict(nullptr),
m_pFile(nullptr),
- m_bOwnFile(false),
- m_pByteStringPool(pdfium::MakeUnique<CFX_ByteStringPool>()) {}
+ m_bOwnFile(false) {}
CFDF_Document::~CFDF_Document() {
if (m_bOwnFile && m_pFile)
m_pFile->Release();
- m_pByteStringPool.DeleteObject(); // Make weak.
}
CFDF_Document* CFDF_Document::CreateNewDoc() {
diff --git a/core/fpdfapi/parser/cfdf_document.h b/core/fpdfapi/parser/cfdf_document.h
index 181c4697e2..075119376f 100644
--- a/core/fpdfapi/parser/cfdf_document.h
+++ b/core/fpdfapi/parser/cfdf_document.h
@@ -9,8 +9,6 @@
#include "core/fpdfapi/parser/cpdf_indirect_object_holder.h"
#include "core/fpdfapi/parser/cpdf_object.h"
-#include "core/fxcrt/cfx_string_pool_template.h"
-#include "core/fxcrt/cfx_weak_ptr.h"
#include "core/fxcrt/fx_basic.h"
class CPDF_Dictionary;
@@ -25,9 +23,6 @@ class CFDF_Document : public CPDF_IndirectObjectHolder {
bool WriteBuf(CFX_ByteTextBuf& buf) const;
CPDF_Dictionary* GetRoot() const { return m_pRootDict; }
- CFX_WeakPtr<CFX_ByteStringPool> GetByteStringPool() const {
- return m_pByteStringPool;
- }
protected:
CFDF_Document();
@@ -36,7 +31,6 @@ class CFDF_Document : public CPDF_IndirectObjectHolder {
CPDF_Dictionary* m_pRootDict;
IFX_SeekableReadStream* m_pFile;
bool m_bOwnFile;
- CFX_WeakPtr<CFX_ByteStringPool> m_pByteStringPool;
};
#endif // CORE_FPDFAPI_PARSER_CFDF_DOCUMENT_H_
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index 83123b27c6..9d1db26e30 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -343,8 +343,7 @@ CPDF_Document::CPDF_Document(std::unique_ptr<CPDF_Parser> pParser)
m_iFirstPageNo(0),
m_dwFirstPageObjNum(0),
m_pDocPage(new CPDF_DocPageData(this)),
- m_pDocRender(new CPDF_DocRenderData(this)),
- m_pByteStringPool(pdfium::MakeUnique<CFX_ByteStringPool>()) {
+ m_pDocRender(new CPDF_DocRenderData(this)) {
if (pParser)
SetLastObjNum(m_pParser->GetLastObjNum());
}
@@ -352,7 +351,6 @@ CPDF_Document::CPDF_Document(std::unique_ptr<CPDF_Parser> pParser)
CPDF_Document::~CPDF_Document() {
delete m_pDocPage;
CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this);
- m_pByteStringPool.DeleteObject(); // Make weak.
}
std::unique_ptr<CPDF_Object> CPDF_Document::ParseIndirectObject(
@@ -649,19 +647,19 @@ CPDF_Image* CPDF_Document::LoadImageFromPageData(uint32_t dwStreamObjNum) {
void CPDF_Document::CreateNewDoc() {
ASSERT(!m_pRootDict && !m_pInfoDict);
- m_pRootDict = NewIndirect<CPDF_Dictionary>(m_pByteStringPool);
+ m_pRootDict = NewIndirect<CPDF_Dictionary>(GetByteStringPool());
m_pRootDict->SetNameFor("Type", "Catalog");
- CPDF_Dictionary* pPages = NewIndirect<CPDF_Dictionary>(m_pByteStringPool);
+ CPDF_Dictionary* pPages = NewIndirect<CPDF_Dictionary>(GetByteStringPool());
pPages->SetNameFor("Type", "Pages");
pPages->SetNumberFor("Count", 0);
pPages->SetFor("Kids", new CPDF_Array);
m_pRootDict->SetReferenceFor("Pages", this, pPages);
- m_pInfoDict = NewIndirect<CPDF_Dictionary>(m_pByteStringPool);
+ m_pInfoDict = NewIndirect<CPDF_Dictionary>(GetByteStringPool());
}
CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) {
- CPDF_Dictionary* pDict = NewIndirect<CPDF_Dictionary>(m_pByteStringPool);
+ CPDF_Dictionary* pDict = NewIndirect<CPDF_Dictionary>(GetByteStringPool());
pDict->SetNameFor("Type", "Page");
uint32_t dwObjNum = pDict->GetObjNum();
if (!InsertNewPage(iPage, pDict)) {
@@ -781,7 +779,7 @@ size_t CPDF_Document::CalculateEncodingDict(int charset,
return i;
CPDF_Dictionary* pEncodingDict =
- NewIndirect<CPDF_Dictionary>(m_pByteStringPool);
+ NewIndirect<CPDF_Dictionary>(GetByteStringPool());
pEncodingDict->SetNameFor("BaseEncoding", "WinAnsiEncoding");
CPDF_Array* pArray = new CPDF_Array;
@@ -803,7 +801,8 @@ CPDF_Dictionary* CPDF_Document::ProcessbCJK(
bool bVert,
CFX_ByteString basefont,
std::function<void(FX_WCHAR, FX_WCHAR, CPDF_Array*)> Insert) {
- CPDF_Dictionary* pFontDict = NewIndirect<CPDF_Dictionary>(m_pByteStringPool);
+ CPDF_Dictionary* pFontDict =
+ NewIndirect<CPDF_Dictionary>(GetByteStringPool());
CFX_ByteString cmap;
CFX_ByteString ordering;
int supplement = 0;
@@ -853,7 +852,7 @@ CPDF_Dictionary* CPDF_Document::ProcessbCJK(
pFontDict->SetNameFor("Type", "Font");
pFontDict->SetNameFor("Subtype", "CIDFontType2");
pFontDict->SetNameFor("BaseFont", basefont);
- CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary(m_pByteStringPool);
+ CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary(GetByteStringPool());
pCIDSysInfo->SetStringFor("Registry", "Adobe");
pCIDSysInfo->SetStringFor("Ordering", ordering);
pCIDSysInfo->SetIntegerFor("Supplement", supplement);
@@ -878,7 +877,8 @@ CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, bool bVert) {
CalculateFlags(pFont->IsBold(), pFont->IsItalic(), pFont->IsFixedWidth(),
false, false, charset == FXFONT_SYMBOL_CHARSET);
- CPDF_Dictionary* pBaseDict = NewIndirect<CPDF_Dictionary>(m_pByteStringPool);
+ CPDF_Dictionary* pBaseDict =
+ NewIndirect<CPDF_Dictionary>(GetByteStringPool());
pBaseDict->SetNameFor("Type", "Font");
std::unique_ptr<CFX_UnicodeEncoding> pEncoding(
new CFX_UnicodeEncoding(pFont));
@@ -1008,7 +1008,8 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont,
ptm->otmrcFontBox.right, ptm->otmrcFontBox.top};
FX_Free(tm_buf);
basefont.Replace(" ", "");
- CPDF_Dictionary* pBaseDict = NewIndirect<CPDF_Dictionary>(m_pByteStringPool);
+ CPDF_Dictionary* pBaseDict =
+ NewIndirect<CPDF_Dictionary>(GetByteStringPool());
pBaseDict->SetNameFor("Type", "Font");
CPDF_Dictionary* pFontDict = pBaseDict;
if (!bCJK) {
diff --git a/core/fpdfapi/parser/cpdf_document.h b/core/fpdfapi/parser/cpdf_document.h
index 73c8666686..1fd13a1c8e 100644
--- a/core/fpdfapi/parser/cpdf_document.h
+++ b/core/fpdfapi/parser/cpdf_document.h
@@ -13,8 +13,6 @@
#include "core/fpdfapi/parser/cpdf_indirect_object_holder.h"
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fpdfdoc/cpdf_linklist.h"
-#include "core/fxcrt/cfx_string_pool_template.h"
-#include "core/fxcrt/cfx_weak_ptr.h"
#include "core/fxcrt/fx_basic.h"
class CFX_Font;
@@ -50,13 +48,9 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
CPDF_Parser* GetParser() const { return m_pParser.get(); }
CPDF_Dictionary* GetRoot() const { return m_pRootDict; }
CPDF_Dictionary* GetInfo() const { return m_pInfoDict; }
- CFX_WeakPtr<CFX_ByteStringPool> GetByteStringPool() const {
- return m_pByteStringPool;
- }
void DeletePage(int iPage);
int GetPageCount() const;
-
bool IsPageLoaded(int iPage) const;
CPDF_Dictionary* GetPage(int iPage);
int GetPageIndex(uint32_t objnum);
@@ -150,7 +144,6 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
std::unique_ptr<JBig2_DocumentContext> m_pCodecContext;
std::unique_ptr<CPDF_LinkList> m_pLinksContext;
CFX_ArrayTemplate<uint32_t> m_PageList;
- CFX_WeakPtr<CFX_ByteStringPool> m_pByteStringPool;
};
#endif // CORE_FPDFAPI_PARSER_CPDF_DOCUMENT_H_
diff --git a/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp b/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
index 12b1e9f089..d1183ebaf4 100644
--- a/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
+++ b/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
@@ -9,9 +9,13 @@
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fpdfapi/parser/cpdf_parser.h"
-CPDF_IndirectObjectHolder::CPDF_IndirectObjectHolder() : m_LastObjNum(0) {}
+CPDF_IndirectObjectHolder::CPDF_IndirectObjectHolder()
+ : m_LastObjNum(0),
+ m_pByteStringPool(pdfium::MakeUnique<CFX_ByteStringPool>()) {}
-CPDF_IndirectObjectHolder::~CPDF_IndirectObjectHolder() {}
+CPDF_IndirectObjectHolder::~CPDF_IndirectObjectHolder() {
+ m_pByteStringPool.DeleteObject(); // Make weak.
+}
CPDF_Object* CPDF_IndirectObjectHolder::GetIndirectObject(
uint32_t objnum) const {
diff --git a/core/fpdfapi/parser/cpdf_indirect_object_holder.h b/core/fpdfapi/parser/cpdf_indirect_object_holder.h
index 428bfa05ec..375010de93 100644
--- a/core/fpdfapi/parser/cpdf_indirect_object_holder.h
+++ b/core/fpdfapi/parser/cpdf_indirect_object_holder.h
@@ -10,6 +10,8 @@
#include <map>
#include <memory>
+#include "core/fxcrt/cfx_string_pool_template.h"
+#include "core/fxcrt/cfx_weak_ptr.h"
#include "core/fxcrt/fx_system.h"
#include "third_party/base/ptr_util.h"
@@ -45,6 +47,10 @@ class CPDF_IndirectObjectHolder {
uint32_t GetLastObjNum() const { return m_LastObjNum; }
void SetLastObjNum(uint32_t objnum) { m_LastObjNum = objnum; }
+ CFX_WeakPtr<CFX_ByteStringPool> GetByteStringPool() const {
+ return m_pByteStringPool;
+ }
+
const_iterator begin() const { return m_IndirectObjs.begin(); }
const_iterator end() const { return m_IndirectObjs.end(); }
@@ -54,6 +60,7 @@ class CPDF_IndirectObjectHolder {
private:
uint32_t m_LastObjNum;
std::map<uint32_t, std::unique_ptr<CPDF_Object>> m_IndirectObjs;
+ CFX_WeakPtr<CFX_ByteStringPool> m_pByteStringPool;
};
#endif // CORE_FPDFAPI_PARSER_CPDF_INDIRECT_OBJECT_HOLDER_H_