summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_flatten.cpp
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2018-06-11 18:19:57 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-11 18:19:57 +0000
commitfb72726e51bfd0c7bfc61c9b354e2b60f46adac5 (patch)
treeb2a763c74a07b081a4b176c18c42569e377d6fc8 /fpdfsdk/fpdf_flatten.cpp
parent5e873f5ce8e407c97e966b9708d2560e908112d3 (diff)
downloadpdfium-fb72726e51bfd0c7bfc61c9b354e2b60f46adac5.tar.xz
Implement CPDF_Object::MakeReference method.chromium/3456
Change-Id: I153747ef587a184eaef58ff09dbf8f214c9ddfb3 Reviewed-on: https://pdfium-review.googlesource.com/17230 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Diffstat (limited to 'fpdfsdk/fpdf_flatten.cpp')
-rw-r--r--fpdfsdk/fpdf_flatten.cpp29
1 files changed, 13 insertions, 16 deletions
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();