summaryrefslogtreecommitdiff
path: root/core/fpdfdoc
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r--core/fpdfdoc/cpdf_formfield_unittest.cpp13
-rw-r--r--core/fpdfdoc/cpdf_interform.cpp9
-rw-r--r--core/fpdfdoc/cpvt_fontmap.cpp7
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp25
4 files changed, 23 insertions, 31 deletions
diff --git a/core/fpdfdoc/cpdf_formfield_unittest.cpp b/core/fpdfdoc/cpdf_formfield_unittest.cpp
index 11cccf19b8..a9d3d2403a 100644
--- a/core/fpdfdoc/cpdf_formfield_unittest.cpp
+++ b/core/fpdfdoc/cpdf_formfield_unittest.cpp
@@ -12,15 +12,13 @@ TEST(cpdf_formfield, FPDF_GetFullName) {
EXPECT_TRUE(name.IsEmpty());
CPDF_IndirectObjectHolder obj_holder;
- CPDF_Dictionary* root = new CPDF_Dictionary();
- obj_holder.AddIndirectObject(root);
+ CPDF_Dictionary* root = obj_holder.AddIndirectDictionary();
root->SetNameFor("T", "foo");
name = FPDF_GetFullName(root);
EXPECT_STREQ("foo", name.UTF8Encode().c_str());
- CPDF_Dictionary* dict1 = new CPDF_Dictionary();
- root->SetReferenceFor("Parent", &obj_holder,
- obj_holder.AddIndirectObject(dict1));
+ CPDF_Dictionary* dict1 = obj_holder.AddIndirectDictionary();
+ root->SetReferenceFor("Parent", &obj_holder, dict1);
dict1->SetNameFor("T", "bar");
name = FPDF_GetFullName(root);
EXPECT_STREQ("bar.foo", name.UTF8Encode().c_str());
@@ -30,9 +28,8 @@ TEST(cpdf_formfield, FPDF_GetFullName) {
name = FPDF_GetFullName(root);
EXPECT_STREQ("bar.foo", name.UTF8Encode().c_str());
- CPDF_Dictionary* dict3 = new CPDF_Dictionary();
- dict2->SetReferenceFor("Parent", &obj_holder,
- obj_holder.AddIndirectObject(dict3));
+ CPDF_Dictionary* dict3 = obj_holder.AddIndirectDictionary();
+ dict2->SetReferenceFor("Parent", &obj_holder, dict3);
dict3->SetNameFor("T", "qux");
name = FPDF_GetFullName(root);
EXPECT_STREQ("qux.bar.foo", name.UTF8Encode().c_str());
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp
index 3bef85ef9c..cafc912569 100644
--- a/core/fpdfdoc/cpdf_interform.cpp
+++ b/core/fpdfdoc/cpdf_interform.cpp
@@ -59,9 +59,9 @@ void InitDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) {
return;
if (!pFormDict) {
- pFormDict = new CPDF_Dictionary(pDocument->GetByteStringPool());
- pDocument->GetRoot()->SetReferenceFor(
- "AcroForm", pDocument, pDocument->AddIndirectObject(pFormDict));
+ pFormDict =
+ pDocument->AddIndirectDictionary(pDocument->GetByteStringPool());
+ pDocument->GetRoot()->SetReferenceFor("AcroForm", pDocument, pFormDict);
}
CFX_ByteString csDA;
@@ -274,8 +274,7 @@ void AddFont(CPDF_Dictionary*& pFormDict,
csNameTag.Remove(' ');
csNameTag = CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4,
csNameTag.c_str());
- pFonts->SetReferenceFor(csNameTag, pDocument,
- pFont->GetFontDict()->GetObjNum());
+ pFonts->SetReferenceFor(csNameTag, pDocument, pFont->GetFontDict());
}
CPDF_Font* AddNativeFont(CPDF_Dictionary*& pFormDict,
diff --git a/core/fpdfdoc/cpvt_fontmap.cpp b/core/fpdfdoc/cpvt_fontmap.cpp
index a47595a6ac..5960fc1215 100644
--- a/core/fpdfdoc/cpvt_fontmap.cpp
+++ b/core/fpdfdoc/cpvt_fontmap.cpp
@@ -38,10 +38,9 @@ void CPVT_FontMap::GetAnnotSysPDFFont(CPDF_Document* pDoc,
return;
CPDF_Dictionary* pFontList = pResDict->GetDictFor("Font");
- if (pFontList && !pFontList->KeyExist(sSysFontAlias)) {
- pFontList->SetReferenceFor(sSysFontAlias, pDoc,
- pPDFFont->GetFontDict()->GetObjNum());
- }
+ if (pFontList && !pFontList->KeyExist(sSysFontAlias))
+ pFontList->SetReferenceFor(sSysFontAlias, pDoc, pPDFFont->GetFontDict());
+
pSysFont = pPDFFont;
}
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index 28b436a05c..24827e3f22 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -58,13 +58,12 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
CPDF_Dictionary* pFontDict = pDRFontDict->GetDictFor(sFontName.Mid(1));
if (!pFontDict) {
- pFontDict = new CPDF_Dictionary(pDoc->GetByteStringPool());
+ pFontDict = pDoc->AddIndirectDictionary(pDoc->GetByteStringPool());
pFontDict->SetNameFor("Type", "Font");
pFontDict->SetNameFor("Subtype", "Type1");
pFontDict->SetNameFor("BaseFont", "Helvetica");
pFontDict->SetNameFor("Encoding", "WinAnsiEncoding");
- pDRFontDict->SetReferenceFor(sFontName.Mid(1), pDoc,
- pDoc->AddIndirectObject(pFontDict));
+ pDRFontDict->SetReferenceFor(sFontName.Mid(1), pDoc, pFontDict);
}
CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict);
if (!pDefFont)
@@ -168,8 +167,8 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
}
CPDF_Stream* pNormalStream = pAPDict->GetStreamFor("N");
if (!pNormalStream) {
- pNormalStream = new CPDF_Stream;
- pAPDict->SetReferenceFor("N", pDoc, pDoc->AddIndirectObject(pNormalStream));
+ pNormalStream = pDoc->AddIndirectStream();
+ pAPDict->SetReferenceFor("N", pDoc, pNormalStream);
}
CPDF_Dictionary* pStreamDict = pNormalStream->GetDict();
if (pStreamDict) {
@@ -183,8 +182,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
pStreamResList->SetFor("Font", pStreamResFontList);
}
if (!pStreamResFontList->KeyExist(sFontName))
- pStreamResFontList->SetReferenceFor(sFontName, pDoc,
- pFontDict->GetObjNum());
+ pStreamResFontList->SetReferenceFor(sFontName, pDoc, pFontDict);
} else {
pStreamDict->SetFor("Resources", pFormDict->GetDictFor("DR")->Clone());
pStreamResList = pStreamDict->GetDictFor("Resources");
@@ -434,8 +432,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc,
pStreamResList->SetFor("Font", pStreamResFontList);
}
if (!pStreamResFontList->KeyExist(sFontName))
- pStreamResFontList->SetReferenceFor(sFontName, pDoc,
- pFontDict->GetObjNum());
+ pStreamResFontList->SetReferenceFor(sFontName, pDoc, pFontDict);
} else {
pStreamDict->SetFor("Resources", pFormDict->GetDictFor("DR")->Clone());
pStreamResList = pStreamDict->GetDictFor("Resources");
@@ -559,7 +556,8 @@ CPDF_Dictionary* GenerateExtGStateDict(const CPDF_Dictionary& pAnnotDict,
CPDF_Dictionary* GenerateResourceFontDict(CPDF_Document* pDoc,
const CFX_ByteString& sFontDictName) {
- CPDF_Dictionary* pFontDict = new CPDF_Dictionary(pDoc->GetByteStringPool());
+ CPDF_Dictionary* pFontDict =
+ pDoc->AddIndirectDictionary(pDoc->GetByteStringPool());
pFontDict->SetNameFor("Type", "Font");
pFontDict->SetNameFor("Subtype", "Type1");
pFontDict->SetNameFor("BaseFont", "Helvetica");
@@ -567,8 +565,7 @@ CPDF_Dictionary* GenerateResourceFontDict(CPDF_Document* pDoc,
CPDF_Dictionary* pResourceFontDict =
new CPDF_Dictionary(pDoc->GetByteStringPool());
- pResourceFontDict->SetReferenceFor(sFontDictName, pDoc,
- pDoc->AddIndirectObject(pFontDict));
+ pResourceFontDict->SetReferenceFor(sFontDictName, pDoc, pFontDict);
return pResourceFontDict;
}
@@ -596,9 +593,9 @@ void GenerateAndSetAPDict(CPDF_Document* pDoc,
CPDF_Dictionary* pAPDict = new CPDF_Dictionary(pDoc->GetByteStringPool());
pAnnotDict->SetFor("AP", pAPDict);
- CPDF_Stream* pNormalStream = new CPDF_Stream;
+ CPDF_Stream* pNormalStream = pDoc->AddIndirectStream();
pNormalStream->SetData(sAppStream.GetBuffer(), sAppStream.GetSize());
- pAPDict->SetReferenceFor("N", pDoc, pDoc->AddIndirectObject(pNormalStream));
+ pAPDict->SetReferenceFor("N", pDoc, pNormalStream);
CPDF_Dictionary* pStreamDict = pNormalStream->GetDict();
pStreamDict->SetIntegerFor("FormType", 1);