diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-02-24 13:46:52 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-02-24 15:49:15 +0000 |
commit | 58eac1105f8504bd5320911fc6fe967ccaa3d469 (patch) | |
tree | a71f1ba78135b13bedf7a20924db1bd2df18a94e /xmlsecurity/source/pdfio/pdfdocument.cxx | |
parent | 3cc3dc176e00062d8395d9f3d83b49ab24542a61 (diff) |
vcl: add initial CppunitTest_vcl_pdfexport
Invoke the PDF export filter and then use the PDF tokenizer from
xmlsecurity to assert the contents of created PDF file. The testcase
fails with commit 6db0f1feb1d9931d2726dd11a889c58815710ce0 (tdf#106059
PDF export: create a reference XObject for PDF images, 2017-02-22)
reverted.
Change-Id: I90526fef41d9560ae447f586df766bc50a491c43
Reviewed-on: https://gerrit.libreoffice.org/34609
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'xmlsecurity/source/pdfio/pdfdocument.cxx')
-rw-r--r-- | xmlsecurity/source/pdfio/pdfdocument.cxx | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/xmlsecurity/source/pdfio/pdfdocument.cxx b/xmlsecurity/source/pdfio/pdfdocument.cxx index 0d6c7e13e06e..50e00d79c067 100644 --- a/xmlsecurity/source/pdfio/pdfdocument.cxx +++ b/xmlsecurity/source/pdfio/pdfdocument.cxx @@ -7,7 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <pdfio/pdfdocument.hxx> +#include <xmlsecurity/pdfio/pdfdocument.hxx> #include <map> #include <memory> @@ -31,6 +31,8 @@ #include <xmloff/xmluconv.hxx> #include <o3tl/make_unique.hxx> +#include <sigstruct.hxx> + #ifdef XMLSEC_CRYPTO_NSS #include <cert.h> #include <cms.h> @@ -87,31 +89,6 @@ public: class PDFReferenceElement; -/// Dictionary object: a set key-value pairs. -class PDFDictionaryElement : public PDFElement -{ - /// Key-value pairs when the dictionary is a nested value. - std::map<OString, PDFElement*> m_aItems; - /// Offset after the '<<' token. - sal_uInt64 m_nLocation = 0; - /// Position after the '/' token. - std::map<OString, sal_uInt64> m_aDictionaryKeyOffset; - /// Length of the dictionary key and value, till (before) the next token. - std::map<OString, sal_uInt64> m_aDictionaryKeyValueLength; - -public: - PDFDictionaryElement(); - bool Read(SvStream& rStream) override; - - static size_t Parse(const std::vector< std::unique_ptr<PDFElement> >& rElements, PDFElement* pThis, std::map<OString, PDFElement*>& rDictionary); - static PDFElement* Lookup(const std::map<OString, PDFElement*>& rDictionary, const OString& rKey); - void SetKeyOffset(const OString& rKey, sal_uInt64 nOffset); - sal_uInt64 GetKeyOffset(const OString& rKey) const; - void SetKeyValueLength(const OString& rKey, sal_uInt64 nLength); - sal_uInt64 GetKeyValueLength(const OString& rKey) const; - const std::map<OString, PDFElement*>& GetItems() const; -}; - /// End of a dictionary: '>>'. class PDFEndDictionaryElement : public PDFElement { @@ -3182,6 +3159,18 @@ PDFElement* PDFDictionaryElement::Lookup(const std::map<OString, PDFElement*>& r return it->second; } +PDFObjectElement* PDFDictionaryElement::LookupObject(const OString& rDictionaryKey) +{ + auto pKey = dynamic_cast<PDFReferenceElement*>(PDFDictionaryElement::Lookup(m_aItems, rDictionaryKey)); + if (!pKey) + { + SAL_WARN("xmlsecurity.pdfio", "PDFDictionaryElement::LookupObject: no such key with reference value: " << rDictionaryKey); + return nullptr; + } + + return pKey->LookupObject(); +} + PDFElement* PDFObjectElement::Lookup(const OString& rDictionaryKey) { if (m_aDictionary.empty()) |