summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/formfiller/cba_fontmap.cpp11
-rw-r--r--fpdfsdk/fpdf_attachment.cpp11
-rw-r--r--fpdfsdk/fpdf_edittext.cpp20
-rw-r--r--fpdfsdk/fpdf_flatten.cpp29
-rw-r--r--fpdfsdk/fpdf_ppo.cpp11
-rw-r--r--fpdfsdk/fpdf_save.cpp6
-rw-r--r--fpdfsdk/fpdf_transformpage.cpp24
-rw-r--r--fpdfsdk/pwl/cpwl_appstream.cpp7
8 files changed, 52 insertions, 67 deletions
diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp
index 671ba92282..d8d7dffd69 100644
--- a/fpdfsdk/formfiller/cba_fontmap.cpp
+++ b/fpdfsdk/formfiller/cba_fontmap.cpp
@@ -166,8 +166,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.Get(),
- pStream->GetObjNum());
+ pAPDict->SetFor(m_sAPType, pStream->MakeReference(m_pDocument.Get()));
}
CPDF_Dictionary* pStreamDict = pStream->GetDict();
@@ -184,12 +183,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.Get(),
- pStreamResFontList->GetObjNum());
+ pStreamResList->SetFor(
+ "Font", pStreamResFontList->MakeReference(m_pDocument.Get()));
}
if (!pStreamResFontList->KeyExist(sAlias)) {
- pStreamResFontList->SetNewFor<CPDF_Reference>(
- sAlias, m_pDocument.Get(), pFont->GetFontDict()->GetObjNum());
+ pStreamResFontList->SetFor(
+ sAlias, pFont->GetFontDict()->MakeReference(m_pDocument.Get()));
}
}
diff --git a/fpdfsdk/fpdf_attachment.cpp b/fpdfsdk/fpdf_attachment.cpp
index f2ed684e40..6a4faf6c65 100644
--- a/fpdfsdk/fpdf_attachment.cpp
+++ b/fpdfsdk/fpdf_attachment.cpp
@@ -72,15 +72,14 @@ FPDFDoc_AddAttachment(FPDF_DOCUMENT document, FPDF_WIDESTRING name) {
CPDF_Dictionary* pNames = pRoot->GetDictFor("Names");
if (!pNames) {
pNames = pDoc->NewIndirect<CPDF_Dictionary>();
- pRoot->SetNewFor<CPDF_Reference>("Names", pDoc, pNames->GetObjNum());
+ pRoot->SetFor("Names", pNames->MakeReference(pDoc));
}
// Create the EmbeddedFiles dictionary if missing.
if (!pNames->GetDictFor("EmbeddedFiles")) {
CPDF_Dictionary* pFiles = pDoc->NewIndirect<CPDF_Dictionary>();
pFiles->SetNewFor<CPDF_Array>("Names");
- pNames->SetNewFor<CPDF_Reference>("EmbeddedFiles", pDoc,
- pFiles->GetObjNum());
+ pNames->SetFor("EmbeddedFiles", pFiles->MakeReference(pDoc));
}
// Set up the basic entries in the filespec dictionary.
@@ -91,9 +90,7 @@ FPDFDoc_AddAttachment(FPDF_DOCUMENT document, FPDF_WIDESTRING name) {
// Add the new attachment name and filespec into the document's EmbeddedFiles.
CPDF_NameTree nameTree(pDoc, "EmbeddedFiles");
- if (!nameTree.AddValueAndName(
- pdfium::MakeUnique<CPDF_Reference>(pDoc, pFile->GetObjNum()),
- wsName)) {
+ if (!nameTree.AddValueAndName(pFile->MakeReference(pDoc), wsName)) {
return nullptr;
}
@@ -254,7 +251,7 @@ FPDFAttachment_SetFile(FPDF_ATTACHMENT attachment,
std::move(stream), len, std::move(pFileStreamDict));
CPDF_Dictionary* pEFDict =
pFile->AsDictionary()->SetNewFor<CPDF_Dictionary>("EF");
- pEFDict->SetNewFor<CPDF_Reference>("F", pDoc, pFileStream->GetObjNum());
+ pEFDict->SetFor("F", pFileStream->MakeReference(pDoc));
return true;
}
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
index 2996a505ee..2ead789204 100644
--- a/fpdfsdk/fpdf_edittext.cpp
+++ b/fpdfsdk/fpdf_edittext.cpp
@@ -74,7 +74,7 @@ CPDF_Dictionary* LoadFontDesc(CPDF_Document* pDoc,
static_cast<int>(size));
}
ByteString fontFile = font_type == FPDF_FONT_TYPE1 ? "FontFile" : "FontFile2";
- pFontDesc->SetNewFor<CPDF_Reference>(fontFile, pDoc, pStream->GetObjNum());
+ pFontDesc->SetFor(fontFile, pStream->MakeReference(pDoc));
return pFontDesc;
}
@@ -270,12 +270,11 @@ CPDF_Font* LoadSimpleFont(CPDF_Document* pDoc,
currentChar = nextChar;
}
fontDict->SetNewFor<CPDF_Number>("LastChar", static_cast<int>(currentChar));
- fontDict->SetNewFor<CPDF_Reference>("Widths", pDoc, widthsArray->GetObjNum());
+ fontDict->SetFor("Widths", widthsArray->MakeReference(pDoc));
CPDF_Dictionary* pFontDesc =
LoadFontDesc(pDoc, name, pFont.get(), data, size, font_type);
- fontDict->SetNewFor<CPDF_Reference>("FontDescriptor", pDoc,
- pFontDesc->GetObjNum());
+ fontDict->SetFor("FontDescriptor", pFontDesc->MakeReference(pDoc));
return pDoc->LoadFont(fontDict);
}
@@ -311,13 +310,11 @@ CPDF_Font* LoadCompositeFont(CPDF_Document* pDoc,
pCIDSystemInfo->SetNewFor<CPDF_Name>("Registry", "Adobe");
pCIDSystemInfo->SetNewFor<CPDF_Name>("Ordering", "Identity");
pCIDSystemInfo->SetNewFor<CPDF_Number>("Supplement", 0);
- pCIDFont->SetNewFor<CPDF_Reference>("CIDSystemInfo", pDoc,
- pCIDSystemInfo->GetObjNum());
+ pCIDFont->SetFor("CIDSystemInfo", pCIDSystemInfo->MakeReference(pDoc));
CPDF_Dictionary* pFontDesc =
LoadFontDesc(pDoc, name, pFont.get(), data, size, font_type);
- pCIDFont->SetNewFor<CPDF_Reference>("FontDescriptor", pDoc,
- pFontDesc->GetObjNum());
+ pCIDFont->SetFor("FontDescriptor", pFontDesc->MakeReference(pDoc));
uint32_t glyphIndex;
uint32_t currentChar = FXFT_Get_First_Char(pFont->GetFace(), &glyphIndex);
@@ -386,15 +383,14 @@ CPDF_Font* LoadCompositeFont(CPDF_Document* pDoc,
}
widthsArray->Add(std::move(curWidthArray));
}
- pCIDFont->SetNewFor<CPDF_Reference>("W", pDoc, widthsArray->GetObjNum());
+ pCIDFont->SetFor("W", widthsArray->MakeReference(pDoc));
// TODO(npm): Support vertical writing
auto pDescendant = pdfium::MakeUnique<CPDF_Array>();
- pDescendant->AddNew<CPDF_Reference>(pDoc, pCIDFont->GetObjNum());
+ pDescendant->Add(pCIDFont->MakeReference(pDoc));
fontDict->SetFor("DescendantFonts", std::move(pDescendant));
CPDF_Stream* toUnicodeStream = LoadUnicode(pDoc, to_unicode);
- fontDict->SetNewFor<CPDF_Reference>("ToUnicode", pDoc,
- toUnicodeStream->GetObjNum());
+ fontDict->SetFor("ToUnicode", toUnicodeStream->MakeReference(pDoc));
return pDoc->LoadFont(fontDict);
}
diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp
index d35cfe370d..4b9e1f8a9d 100644
--- a/fpdfsdk/fpdf_flatten.cpp
+++ b/fpdfsdk/fpdf_flatten.cpp
@@ -169,15 +169,15 @@ CFX_FloatRect CalculateRect(std::vector<CFX_FloatRect>* pRectArray) {
return rcRet;
}
-uint32_t NewIndirectContentsStream(const ByteString& key,
- CPDF_Document* pDocument) {
+CPDF_Object* NewIndirectContentsStream(const ByteString& key,
+ CPDF_Document* pDocument) {
CPDF_Stream* pNewContents = pDocument->NewIndirect<CPDF_Stream>(
nullptr, 0,
pdfium::MakeUnique<CPDF_Dictionary>(pDocument->GetByteStringPool()));
ByteString sStream =
ByteString::Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str());
pNewContents->SetData(sStream.raw_str(), sStream.GetLength());
- return pNewContents->GetObjNum();
+ return pNewContents;
}
void SetPageContents(const ByteString& key,
@@ -190,9 +190,9 @@ void SetPageContents(const ByteString& key,
pContentsArray = pPage->GetArrayFor(pdfium::page_object::kContents);
if (!pContentsArray) {
if (!key.IsEmpty()) {
- pPage->SetNewFor<CPDF_Reference>(
- pdfium::page_object::kContents, pDocument,
- NewIndirectContentsStream(key, pDocument));
+ pPage->SetFor(pdfium::page_object::kContents,
+ NewIndirectContentsStream(key, pDocument)
+ ->MakeReference(pDocument));
}
return;
}
@@ -207,14 +207,13 @@ void SetPageContents(const ByteString& key,
sStream = sStream + sBody + "\nQ";
pContentsStream->SetDataAndRemoveFilter(sStream.raw_str(),
sStream.GetLength());
- pContentsArray->AddNew<CPDF_Reference>(pDocument,
- pContentsStream->GetObjNum());
- pPage->SetNewFor<CPDF_Reference>(pdfium::page_object::kContents, pDocument,
- pContentsArray->GetObjNum());
+ pContentsArray->Add(pContentsStream->MakeReference(pDocument));
+ pPage->SetFor(pdfium::page_object::kContents,
+ pContentsArray->MakeReference(pDocument));
}
if (!key.IsEmpty()) {
- pContentsArray->AddNew<CPDF_Reference>(
- pDocument, NewIndirectContentsStream(key, pDocument));
+ pContentsArray->Add(
+ NewIndirectContentsStream(key, pDocument)->MakeReference(pDocument));
}
}
@@ -290,7 +289,6 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
nullptr, 0,
pdfium::MakeUnique<CPDF_Dictionary>(pDocument->GetByteStringPool()));
- uint32_t dwObjNum = pNewXObject->GetObjNum();
CPDF_Dictionary* pPageXObject = pRes->GetDictFor("XObject");
if (!pPageXObject)
pPageXObject = pRes->SetNewFor<CPDF_Dictionary>("XObject");
@@ -312,7 +310,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
CPDF_Dictionary* pNewXORes = nullptr;
if (!key.IsEmpty()) {
- pPageXObject->SetNewFor<CPDF_Reference>(key, pDocument, dwObjNum);
+ pPageXObject->SetFor(key, pNewXObject->MakeReference(pDocument));
CPDF_Dictionary* pNewOXbjectDic = pNewXObject->GetDict();
pNewXORes = pNewOXbjectDic->SetNewFor<CPDF_Dictionary>("Resources");
pNewOXbjectDic->SetNewFor<CPDF_Name>("Type", "XObject");
@@ -387,8 +385,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
pXObject = pNewXORes->SetNewFor<CPDF_Dictionary>("XObject");
ByteString sFormName = ByteString::Format("F%d", i);
- pXObject->SetNewFor<CPDF_Reference>(sFormName, pDocument,
- pObj->GetObjNum());
+ pXObject->SetFor(sFormName, pObj->MakeReference(pDocument));
auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pNewXObject);
pAcc->LoadAllDataFiltered();
diff --git a/fpdfsdk/fpdf_ppo.cpp b/fpdfsdk/fpdf_ppo.cpp
index c4bd51e603..8bbae7258d 100644
--- a/fpdfsdk/fpdf_ppo.cpp
+++ b/fpdfsdk/fpdf_ppo.cpp
@@ -337,8 +337,7 @@ bool CPDF_PageOrganizer::PDFDocInit() {
pElement ? ToDictionary(pElement->GetDirect()) : nullptr;
if (!pNewPages) {
pNewPages = dest()->NewIndirect<CPDF_Dictionary>();
- pNewRoot->SetNewFor<CPDF_Reference>("Pages", dest(),
- pNewPages->GetObjNum());
+ pNewRoot->SetFor("Pages", pNewPages->MakeReference(dest()));
}
ByteString cbPageType = pNewPages->GetStringFor("Type", "");
@@ -347,8 +346,8 @@ bool CPDF_PageOrganizer::PDFDocInit() {
if (!pNewPages->GetArrayFor("Kids")) {
pNewPages->SetNewFor<CPDF_Number>("Count", 0);
- pNewPages->SetNewFor<CPDF_Reference>(
- "Kids", dest(), dest()->NewIndirect<CPDF_Array>()->GetObjNum());
+ pNewPages->SetFor("Kids",
+ dest()->NewIndirect<CPDF_Array>()->MakeReference(dest()));
}
return true;
@@ -754,8 +753,8 @@ void CPDF_NPageToOneExporter::FinishPage(
CPDF_Stream* pStream =
dest()->NewIndirect<CPDF_Stream>(nullptr, 0, std::move(pDict));
pStream->SetData(bsContent.raw_str(), bsContent.GetLength());
- pDestPageDict->SetNewFor<CPDF_Reference>(pdfium::page_object::kContents,
- dest(), pStream->GetObjNum());
+ pDestPageDict->SetFor(pdfium::page_object::kContents,
+ pStream->MakeReference(dest()));
}
} // namespace
diff --git a/fpdfsdk/fpdf_save.cpp b/fpdfsdk/fpdf_save.cpp
index 6064a73629..52b87264e7 100644
--- a/fpdfsdk/fpdf_save.cpp
+++ b/fpdfsdk/fpdf_save.cpp
@@ -138,8 +138,7 @@ bool SaveXFADocumentData(CPDFXFA_Context* pContext,
pData->InitStreamFromFile(pDsfileWrite, std::move(pDataDict));
iLast = pArray->GetCount() - 2;
pArray->InsertNewAt<CPDF_String>(iLast, "datasets", false);
- pArray->InsertNewAt<CPDF_Reference>(iLast + 1, pPDFDocument,
- pData->GetObjNum());
+ pArray->InsertAt(iLast + 1, pData->MakeReference(pPDFDocument));
}
fileList->push_back(std::move(pDsfileWrite));
}
@@ -164,8 +163,7 @@ bool SaveXFADocumentData(CPDFXFA_Context* pContext,
pData->InitStreamFromFile(pfileWrite, std::move(pDataDict));
iLast = pArray->GetCount() - 2;
pArray->InsertNewAt<CPDF_String>(iLast, "form", false);
- pArray->InsertNewAt<CPDF_Reference>(iLast + 1, pPDFDocument,
- pData->GetObjNum());
+ pArray->InsertAt(iLast + 1, pData->MakeReference(pPDFDocument));
}
fileList->push_back(std::move(pfileWrite));
}
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index 267b582a47..d20b28fe81 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -144,15 +144,15 @@ FPDFPage_TransFormWithClip(FPDF_PAGE page,
pEndStream->SetData((const uint8_t*)" Q", 2);
if (CPDF_Array* pContentArray = ToArray(pContentObj)) {
- pContentArray->InsertNewAt<CPDF_Reference>(0, pDoc, pStream->GetObjNum());
- pContentArray->AddNew<CPDF_Reference>(pDoc, pEndStream->GetObjNum());
+ pContentArray->InsertAt(0, pStream->MakeReference(pDoc));
+ pContentArray->Add(pEndStream->MakeReference(pDoc));
} else if (pContentObj->IsStream() && !pContentObj->IsInline()) {
CPDF_Array* pContentArray = pDoc->NewIndirect<CPDF_Array>();
- pContentArray->AddNew<CPDF_Reference>(pDoc, pStream->GetObjNum());
- pContentArray->AddNew<CPDF_Reference>(pDoc, pContentObj->GetObjNum());
- pContentArray->AddNew<CPDF_Reference>(pDoc, pEndStream->GetObjNum());
- pPageDict->SetNewFor<CPDF_Reference>(pdfium::page_object::kContents, pDoc,
- pContentArray->GetObjNum());
+ pContentArray->Add(pStream->MakeReference(pDoc));
+ pContentArray->Add(pContentObj->MakeReference(pDoc));
+ pContentArray->Add(pEndStream->MakeReference(pDoc));
+ pPageDict->SetFor(pdfium::page_object::kContents,
+ pContentArray->MakeReference(pDoc));
}
// Need to transform the patterns as well.
@@ -298,12 +298,12 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertClipPath(FPDF_PAGE page,
pStream->SetData(&strClip);
if (CPDF_Array* pArray = ToArray(pContentObj)) {
- pArray->InsertNewAt<CPDF_Reference>(0, pDoc, pStream->GetObjNum());
+ pArray->InsertAt(0, pStream->MakeReference(pDoc));
} else if (pContentObj->IsStream() && !pContentObj->IsInline()) {
CPDF_Array* pContentArray = pDoc->NewIndirect<CPDF_Array>();
- pContentArray->AddNew<CPDF_Reference>(pDoc, pStream->GetObjNum());
- pContentArray->AddNew<CPDF_Reference>(pDoc, pContentObj->GetObjNum());
- pPageDict->SetNewFor<CPDF_Reference>(pdfium::page_object::kContents, pDoc,
- pContentArray->GetObjNum());
+ pContentArray->Add(pStream->MakeReference(pDoc));
+ pContentArray->Add(pContentObj->MakeReference(pDoc));
+ pPageDict->SetFor(pdfium::page_object::kContents,
+ pContentArray->MakeReference(pDoc));
}
}
diff --git a/fpdfsdk/pwl/cpwl_appstream.cpp b/fpdfsdk/pwl/cpwl_appstream.cpp
index cbe6501a32..01ef48a298 100644
--- a/fpdfsdk/pwl/cpwl_appstream.cpp
+++ b/fpdfsdk/pwl/cpwl_appstream.cpp
@@ -1910,9 +1910,8 @@ void CPWL_AppStream::AddImage(const ByteString& sAPType, CPDF_Stream* pImage) {
CPDF_Dictionary* pXObject =
pStreamResList->SetNewFor<CPDF_Dictionary>("XObject");
- pXObject->SetNewFor<CPDF_Reference>(sImageAlias,
- widget_->GetPageView()->GetPDFDocument(),
- pImage->GetObjNum());
+ pXObject->SetFor(sImageAlias, pImage->MakeReference(
+ widget_->GetPageView()->GetPDFDocument()));
}
void CPWL_AppStream::Write(const ByteString& sAPType,
@@ -1935,7 +1934,7 @@ void CPWL_AppStream::Write(const ByteString& sAPType,
if (!pStream) {
CPDF_Document* doc = widget_->GetPageView()->GetPDFDocument();
pStream = doc->NewIndirect<CPDF_Stream>();
- pParentDict->SetNewFor<CPDF_Reference>(sAPType, doc, pStream->GetObjNum());
+ pParentDict->SetFor(sAPType, pStream->MakeReference(doc));
}
CPDF_Dictionary* pStreamDict = pStream->GetDict();