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