diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-03-28 12:10:03 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-03-28 12:49:24 +0000 |
commit | 3ea5e3401e567bfe956817fd5abd17530da664f5 (patch) | |
tree | 354212ac64928295fe97079306a0c6736adce92a /vcl | |
parent | 0cb5435dd35674b6e55e22922a0819d2a755fc10 (diff) |
tdf#106693 vcl PDF export, norefxobj: copy nested arrays correctly
When copying an array we're only interested in the start/end position of
the outermost array, otherwise only part of the array is copied.
Change-Id: I9f5cb5e3ed395142fd82db34e1153ddfdf9f0eb3
Reviewed-on: https://gerrit.libreoffice.org/35797
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/filter/ipdf/pdfdocument.cxx | 8 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 4 |
2 files changed, 10 insertions, 2 deletions
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx index 1a85c4f3fd5e..1c132353e0a6 100644 --- a/vcl/source/filter/ipdf/pdfdocument.cxx +++ b/vcl/source/filter/ipdf/pdfdocument.cxx @@ -876,6 +876,8 @@ bool PDFDocument::Tokenize(SvStream& rStream, TokenizeMode eMode, std::vector< s bool bInStartXRef = false; // Dictionary depth, so we know when we're outside any dictionaries. int nDictionaryDepth = 0; + // Array depth, only the offset/length of the toplevel array is tracked. + int nArrayDepth = 0; // Last seen array token that's outside any dictionaries. PDFArrayElement* pArray = nullptr; while (true) @@ -939,7 +941,7 @@ bool PDFDocument::Tokenize(SvStream& rStream, TokenizeMode eMode, std::vector< s { auto pArr = new PDFArrayElement(); rElements.push_back(std::unique_ptr<PDFElement>(pArr)); - if (nDictionaryDepth == 0) + if (nDictionaryDepth == 0 && nArrayDepth == 0) { // The array is attached directly, inform the object. pArray = pArr; @@ -949,6 +951,7 @@ bool PDFDocument::Tokenize(SvStream& rStream, TokenizeMode eMode, std::vector< s pObject->SetArrayOffset(rStream.Tell()); } } + ++nArrayDepth; rStream.SeekRel(-1); if (!rElements.back()->Read(rStream)) { @@ -962,7 +965,8 @@ bool PDFDocument::Tokenize(SvStream& rStream, TokenizeMode eMode, std::vector< s rElements.push_back(std::unique_ptr<PDFElement>(new PDFEndArrayElement())); pArray = nullptr; rStream.SeekRel(-1); - if (nDictionaryDepth == 0) + --nArrayDepth; + if (nDictionaryDepth == 0 && nArrayDepth == 0) { if (pObject) { diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 7d435e404837..000e2875d95b 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -11067,6 +11067,8 @@ void PDFWriterImpl::writeReferenceXObject(ReferenceXObjectEmit& rEmit) return; } + OString sColorSpaces = copyExternalResources(*pPage, "ColorSpace"); + OString sExtGStates = copyExternalResources(*pPage, "ExtGState"); OString sFonts = copyExternalResources(*pPage, "Font"); OString sXObjects = copyExternalResources(*pPage, "XObject"); @@ -11089,6 +11091,8 @@ void PDFWriterImpl::writeReferenceXObject(ReferenceXObjectEmit& rEmit) aLine.append("<< /Type /XObject"); aLine.append(" /Subtype /Form"); aLine.append(" /Resources <<"); + aLine.append(sColorSpaces); + aLine.append(sExtGStates); aLine.append(sFonts); aLine.append(sXObjects); aLine.append(">>"); |