summaryrefslogtreecommitdiff
path: root/vcl/source/filter/ipdf/pdfdocument.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-04-07 18:19:41 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-04-07 21:07:52 +0000
commitee73747ab58fbbd5039823767693431223c347d3 (patch)
tree06c1b899b6a13074426b99ac7a997a92650e648a /vcl/source/filter/ipdf/pdfdocument.cxx
parent69b7204164945cfed385d58e64592ce1b17937d7 (diff)
tdf#107018 PDF export of PDF images: handle references in nested dictionaries
Also get rid of the GetKeyOffset() and GetKeyValueLength() calls when copying dictionaries: the reference already knows its offset and length, so no need to call them. This makes the dictionary and the array handling more similar. Change-Id: I65936acfaf857636a8d83da3a4cec69289eb89d8 Reviewed-on: https://gerrit.libreoffice.org/36282 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'vcl/source/filter/ipdf/pdfdocument.cxx')
-rw-r--r--vcl/source/filter/ipdf/pdfdocument.cxx27
1 files changed, 11 insertions, 16 deletions
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx
index 43d4248cc8ad..b0bb8be6c93e 100644
--- a/vcl/source/filter/ipdf/pdfdocument.cxx
+++ b/vcl/source/filter/ipdf/pdfdocument.cxx
@@ -1071,10 +1071,14 @@ bool PDFDocument::Tokenize(SvStream& rStream, TokenizeMode eMode, std::vector< s
}
else
{
- rElements.push_back(std::unique_ptr<PDFElement>(new PDFReferenceElement(*this, *pObjectNumber, *pGenerationNumber)));
+ auto pReference = new PDFReferenceElement(*this, *pObjectNumber, *pGenerationNumber);
+ rElements.push_back(std::unique_ptr<PDFElement>(pReference));
if (pArray)
// Reference is part of a direct (non-dictionary) array, inform the array.
pArray->PushBack(rElements.back().get());
+ if (bInObject && nDictionaryDepth > 0 && pObject)
+ // Inform the object about a new in-dictionary reference.
+ pObject->AddDictionaryReference(pReference);
}
if (!rElements.back()->Read(rStream))
{
@@ -2512,23 +2516,14 @@ PDFNumberElement* PDFObjectElement::GetNumberElement() const
return m_pNumberElement;
}
-std::vector< std::pair<OString, PDFElement*> > PDFObjectElement::GetDictionaryItemsByOffset()
+const std::vector<PDFReferenceElement*>& PDFObjectElement::GetDictionaryReferences() const
{
- std::vector< std::pair<OString, PDFElement*> > aRet;
-
- for (const auto& rItem : m_aDictionary)
- aRet.push_back(rItem);
-
- PDFDictionaryElement* pDictionary = GetDictionary();
- if (!pDictionary)
- return aRet;
-
- std::sort(aRet.begin(), aRet.end(), [pDictionary](const std::pair<OString, PDFElement*>& a, const std::pair<OString, PDFElement*>& b) -> bool
- {
- return pDictionary->GetKeyOffset(a.first) < pDictionary->GetKeyOffset(b.first);
- });
+ return m_aDictionaryReferences;
+}
- return aRet;
+void PDFObjectElement::AddDictionaryReference(PDFReferenceElement* pReference)
+{
+ m_aDictionaryReferences.push_back(pReference);
}
const std::map<OString, PDFElement*>& PDFObjectElement::GetDictionaryItems()