summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page
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 /core/fpdfapi/page
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 'core/fpdfapi/page')
-rw-r--r--core/fpdfapi/page/cpdf_image.cpp8
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp5
2 files changed, 5 insertions, 8 deletions
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp
index 8720342d35..a8b593682b 100644
--- a/core/fpdfapi/page/cpdf_image.cpp
+++ b/core/fpdfapi/page/cpdf_image.cpp
@@ -238,9 +238,8 @@ void CPDF_Image::SetImage(const RetainPtr<CFX_DIBitmap>& pBitmap) {
pdfium::MakeUnique<CPDF_Dictionary>(m_pDocument->GetByteStringPool());
CPDF_Stream* pCTS = m_pDocument->NewIndirect<CPDF_Stream>(
std::move(pColorTable), iPalette * 3, std::move(pNewDict));
- pCS->AddNew<CPDF_Reference>(m_pDocument.Get(), pCTS->GetObjNum());
- pDict->SetNewFor<CPDF_Reference>("ColorSpace", m_pDocument.Get(),
- pCS->GetObjNum());
+ pCS->Add(pCTS->MakeReference(m_pDocument.Get()));
+ pDict->SetFor("ColorSpace", pCS->MakeReference(m_pDocument.Get()));
} else {
pDict->SetNewFor<CPDF_Name>("ColorSpace", "DeviceGray");
}
@@ -281,8 +280,7 @@ void CPDF_Image::SetImage(const RetainPtr<CFX_DIBitmap>& pBitmap) {
pMaskDict->SetNewFor<CPDF_Number>("Length", mask_size);
CPDF_Stream* pNewStream = m_pDocument->NewIndirect<CPDF_Stream>(
std::move(mask_buf), mask_size, std::move(pMaskDict));
- pDict->SetNewFor<CPDF_Reference>("SMask", m_pDocument.Get(),
- pNewStream->GetObjNum());
+ pDict->SetFor("SMask", pNewStream->MakeReference(m_pDocument.Get()));
}
uint8_t* src_buf = pBitmap->GetBuffer();
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 7e7c337d96..7562fb37a6 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -630,9 +630,8 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
ByteString key(word.Right(word.GetLength() - 1));
auto pObj = m_pSyntax->ReadNextObject(false, false, 0);
if (!key.IsEmpty()) {
- uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0;
- if (dwObjNum)
- pDict->SetNewFor<CPDF_Reference>(key, m_pDocument.Get(), dwObjNum);
+ if (pObj && !pObj->IsInline())
+ pDict->SetFor(key, pObj->MakeReference(m_pDocument.Get()));
else
pDict->SetFor(key, std::move(pObj));
}