From 2ba9d58d5978c94352c4c6cf9c47aa3de79d05fe Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 27 Mar 2017 15:39:04 +0200 Subject: tdf#106693 vcl PDF export, norefxobj: handle multiple refs in copied dicts When copying font definitions the dictionary has multiple values where the type is a reference. Improve PDFWriterImpl::copyExternalResource(), so that multiple references are copied correctly as well. With this the bugdoc (from comment 5) text appears in the output. Change-Id: I2343e616d8b36e3cdcbd4e713bd3f7fa7bce6d3b Reviewed-on: https://gerrit.libreoffice.org/35760 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- vcl/source/filter/ipdf/pdfdocument.cxx | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'vcl/source/filter/ipdf/pdfdocument.cxx') diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx index 926ebb0500fd..1a85c4f3fd5e 100644 --- a/vcl/source/filter/ipdf/pdfdocument.cxx +++ b/vcl/source/filter/ipdf/pdfdocument.cxx @@ -1933,7 +1933,7 @@ bool PDFNumberElement::Read(SvStream& rStream) return false; } if (!rtl::isAsciiDigit(static_cast(ch)) && ch != '-' - && ch != '.') + && ch != '.') { rStream.SeekRel(-1); return false; @@ -1941,7 +1941,7 @@ bool PDFNumberElement::Read(SvStream& rStream) while (!rStream.IsEof()) { if (!rtl::isAsciiDigit(static_cast(ch)) && ch != '-' - && ch != '.') + && ch != '.') { rStream.SeekRel(-1); m_nLength = rStream.Tell() - m_nOffset; @@ -2446,8 +2446,10 @@ sal_uInt64 PDFObjectElement::GetArrayLength() return m_nArrayLength; } -PDFDictionaryElement* PDFObjectElement::GetDictionary() const +PDFDictionaryElement* PDFObjectElement::GetDictionary() { + if (m_aDictionary.empty()) + PDFDictionaryElement::Parse(m_rDoc.GetElements(), this, m_aDictionary); return m_pDictionaryElement; } @@ -2456,6 +2458,25 @@ void PDFObjectElement::SetDictionary(PDFDictionaryElement* pDictionaryElement) m_pDictionaryElement = pDictionaryElement; } +std::vector< std::pair > PDFObjectElement::GetDictionaryItemsByOffset() +{ + std::vector< std::pair > 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& a, const std::pair& b) -> bool + { + return pDictionary->GetKeyOffset(a.first) < pDictionary->GetKeyOffset(b.first); + }); + + return aRet; +} + const std::map& PDFObjectElement::GetDictionaryItems() const { return m_aDictionary; @@ -2841,7 +2862,7 @@ bool PDFNameElement::Read(SvStream& rStream) while (!rStream.IsEof()) { if (rtl::isAsciiWhiteSpace(static_cast(ch)) || ch == '/' - || ch == '[' || ch == ']' || ch == '<' || ch == '>' || ch == '(') + || ch == '[' || ch == ']' || ch == '<' || ch == '>' || ch == '(') { rStream.SeekRel(-1); m_aValue = aBuf.makeStringAndClear(); -- cgit v1.2.3