diff options
Diffstat (limited to 'core/fpdfapi/edit')
-rw-r--r-- | core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 26 | ||||
-rw-r--r-- | core/fpdfapi/edit/cpdf_pagecontentgenerator.h | 2 |
2 files changed, 17 insertions, 11 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index 20b4ea6eaf..c27ca044e6 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp @@ -59,8 +59,9 @@ void CPDF_PageContentGenerator::GenerateContent() { } CFX_ByteString CPDF_PageContentGenerator::RealizeResource( - CPDF_Object* pResourceObj, + uint32_t dwResourceObjNum, const CFX_ByteString& bsType) { + ASSERT(dwResourceObjNum); if (!m_pPage->m_pResources) { m_pPage->m_pResources = new CPDF_Dictionary(m_pDocument->GetByteStringPool()); @@ -82,8 +83,7 @@ CFX_ByteString CPDF_PageContentGenerator::RealizeResource( } idnum++; } - pResList->SetReferenceFor(name, m_pDocument, - m_pDocument->AddIndirectObject(pResourceObj)); + pResList->SetReferenceFor(name, m_pDocument, dwResourceObjNum); return name; } @@ -104,9 +104,13 @@ void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf, return; bool bWasInline = pStream->IsInline(); - CFX_ByteString name = RealizeResource(pStream, "XObject"); if (bWasInline) - pImageObj->SetUnownedImage(m_pDocument->GetPageData()->GetImage(pStream)); + pImage->ConvertStreamToIndirectObject(); + + uint32_t dwObjNum = pStream->GetObjNum(); + CFX_ByteString name = RealizeResource(dwObjNum, "XObject"); + if (bWasInline) + pImageObj->SetUnownedImage(m_pDocument->GetPageData()->GetImage(dwObjNum)); buf << "/" << PDF_NameEncode(name) << " Do Q\n"; } @@ -118,20 +122,22 @@ void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, if (!data || !size) return; + buf << "q " << matrix << " cm "; + + CFX_FloatRect bbox = m_pPage->GetPageBBox(); + matrix.TransformRect(bbox); + CPDF_Dictionary* pFormDict = new CPDF_Dictionary(m_pDocument->GetByteStringPool()); pFormDict->SetNameFor("Type", "XObject"); pFormDict->SetNameFor("Subtype", "Form"); - - CFX_FloatRect bbox = m_pPage->GetPageBBox(); - matrix.TransformRect(bbox); pFormDict->SetRectFor("BBox", bbox); CPDF_Stream* pStream = new CPDF_Stream; pStream->InitStream(data, size, pFormDict); - buf << "q " << matrix << " cm "; - CFX_ByteString name = RealizeResource(pStream, "XObject"); + CFX_ByteString name = + RealizeResource(m_pDocument->AddIndirectObject(pStream), "XObject"); buf << "/" << PDF_NameEncode(name) << " Do Q\n"; } diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.h b/core/fpdfapi/edit/cpdf_pagecontentgenerator.h index ce605f0dfe..df8d3b0f8e 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.h +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.h @@ -34,7 +34,7 @@ class CPDF_PageContentGenerator { const uint8_t* data, uint32_t size, CFX_Matrix& matrix); - CFX_ByteString RealizeResource(CPDF_Object* pResourceObj, + CFX_ByteString RealizeResource(uint32_t dwResourceObjNum, const CFX_ByteString& bsType); CPDF_Page* m_pPage; |