From 7415b71b7976319b0c04e670facabd20b30e3fe2 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 21 Mar 2017 18:03:21 +0100 Subject: vcl: move in PDF tokenizer from xmlsecurity The PDF code in xmlsecurity served two purposes: - a generic PDF tokenizer - signature verification The first purpose is useful to have in VCL, so the PDF export code can use it as well when it comes to PDF image handling. This commit just moves most of the PDF code to VCL, it does not touch the PDF export code yet. With this, also the somewhat odd xmlsecurity dependency of CppunitTest_vcl_pdfexport can be removed as well. Change-Id: I6fe8294ed5c4aa4d79f4b2ddef80a4d1c9d566cc Reviewed-on: https://gerrit.libreoffice.org/35513 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- vcl/qa/cppunit/pdfexport/pdfexport.cxx | 48 +++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'vcl/qa') diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index edd63e6fc351..4e80f08d9e45 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include using namespace ::com::sun::star; @@ -90,21 +90,21 @@ void PdfExportTest::testTdf106059() xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); // Parse the export result. - xmlsecurity::pdfio::PDFDocument aDocument; + vcl::filter::PDFDocument aDocument; SvFileStream aStream(aTempFile.GetURL(), StreamMode::READ); CPPUNIT_ASSERT(aDocument.Read(aStream)); // Assert that the XObject in the page resources dictionary is a reference XObject. - std::vector aPages = aDocument.GetPages(); + std::vector aPages = aDocument.GetPages(); // The document has one page. CPPUNIT_ASSERT_EQUAL(static_cast(1), aPages.size()); - xmlsecurity::pdfio::PDFObjectElement* pResources = aPages[0]->LookupObject("Resources"); + vcl::filter::PDFObjectElement* pResources = aPages[0]->LookupObject("Resources"); CPPUNIT_ASSERT(pResources); - auto pXObjects = dynamic_cast(pResources->Lookup("XObject")); + auto pXObjects = dynamic_cast(pResources->Lookup("XObject")); CPPUNIT_ASSERT(pXObjects); // The page has one image. CPPUNIT_ASSERT_EQUAL(static_cast(1), pXObjects->GetItems().size()); - xmlsecurity::pdfio::PDFObjectElement* pReferenceXObject = pXObjects->LookupObject(pXObjects->GetItems().begin()->first); + vcl::filter::PDFObjectElement* pReferenceXObject = pXObjects->LookupObject(pXObjects->GetItems().begin()->first); CPPUNIT_ASSERT(pReferenceXObject); // The image is a reference XObject. // This dictionary key was missing, so the XObject wasn't a reference one. @@ -126,18 +126,18 @@ void PdfExportTest::testTdf105461() xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); // Parse the export result. - xmlsecurity::pdfio::PDFDocument aDocument; + vcl::filter::PDFDocument aDocument; SvFileStream aStream(aTempFile.GetURL(), StreamMode::READ); CPPUNIT_ASSERT(aDocument.Read(aStream)); // The document has one page. - std::vector aPages = aDocument.GetPages(); + std::vector aPages = aDocument.GetPages(); CPPUNIT_ASSERT_EQUAL(static_cast(1), aPages.size()); // The page has a stream. - xmlsecurity::pdfio::PDFObjectElement* pContents = aPages[0]->LookupObject("Contents"); + vcl::filter::PDFObjectElement* pContents = aPages[0]->LookupObject("Contents"); CPPUNIT_ASSERT(pContents); - xmlsecurity::pdfio::PDFStreamElement* pStream = pContents->GetStream(); + vcl::filter::PDFStreamElement* pStream = pContents->GetStream(); CPPUNIT_ASSERT(pStream); SvMemoryStream& rObjectStream = pStream->GetMemory(); // Uncompress it. @@ -172,32 +172,32 @@ void PdfExportTest::testTdf105093() xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); // Parse the export result. - xmlsecurity::pdfio::PDFDocument aDocument; + vcl::filter::PDFDocument aDocument; SvFileStream aStream(aTempFile.GetURL(), StreamMode::READ); CPPUNIT_ASSERT(aDocument.Read(aStream)); // The document has one page. - std::vector aPages = aDocument.GetPages(); + std::vector aPages = aDocument.GetPages(); CPPUNIT_ASSERT_EQUAL(static_cast(1), aPages.size()); // Get page annotations. - auto pAnnots = dynamic_cast(aPages[0]->Lookup("Annots")); + auto pAnnots = dynamic_cast(aPages[0]->Lookup("Annots")); CPPUNIT_ASSERT(pAnnots); CPPUNIT_ASSERT_EQUAL(static_cast(1), pAnnots->GetElements().size()); - auto pAnnotReference = dynamic_cast(pAnnots->GetElements()[0]); + auto pAnnotReference = dynamic_cast(pAnnots->GetElements()[0]); CPPUNIT_ASSERT(pAnnotReference); - xmlsecurity::pdfio::PDFObjectElement* pAnnot = pAnnotReference->LookupObject(); + vcl::filter::PDFObjectElement* pAnnot = pAnnotReference->LookupObject(); CPPUNIT_ASSERT(pAnnot); - CPPUNIT_ASSERT_EQUAL(OString("Annot"), static_cast(pAnnot->Lookup("Type"))->GetValue()); + CPPUNIT_ASSERT_EQUAL(OString("Annot"), static_cast(pAnnot->Lookup("Type"))->GetValue()); // Get the Action -> Rendition -> MediaClip -> FileSpec. - auto pAction = dynamic_cast(pAnnot->Lookup("A")); + auto pAction = dynamic_cast(pAnnot->Lookup("A")); CPPUNIT_ASSERT(pAction); - auto pRendition = dynamic_cast(pAction->LookupElement("R")); + auto pRendition = dynamic_cast(pAction->LookupElement("R")); CPPUNIT_ASSERT(pRendition); - auto pMediaClip = dynamic_cast(pRendition->LookupElement("C")); + auto pMediaClip = dynamic_cast(pRendition->LookupElement("C")); CPPUNIT_ASSERT(pMediaClip); - auto pFileSpec = dynamic_cast(pMediaClip->LookupElement("D")); + auto pFileSpec = dynamic_cast(pMediaClip->LookupElement("D")); CPPUNIT_ASSERT(pFileSpec); // Make sure the filespec refers to an embedded file. // This key was missing, the embedded video was handled as a linked one. @@ -219,18 +219,18 @@ void PdfExportTest::testTdf106206() xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); // Parse the export result. - xmlsecurity::pdfio::PDFDocument aDocument; + vcl::filter::PDFDocument aDocument; SvFileStream aStream(aTempFile.GetURL(), StreamMode::READ); CPPUNIT_ASSERT(aDocument.Read(aStream)); // The document has one page. - std::vector aPages = aDocument.GetPages(); + std::vector aPages = aDocument.GetPages(); CPPUNIT_ASSERT_EQUAL(static_cast(1), aPages.size()); // The page has a stream. - xmlsecurity::pdfio::PDFObjectElement* pContents = aPages[0]->LookupObject("Contents"); + vcl::filter::PDFObjectElement* pContents = aPages[0]->LookupObject("Contents"); CPPUNIT_ASSERT(pContents); - xmlsecurity::pdfio::PDFStreamElement* pStream = pContents->GetStream(); + vcl::filter::PDFStreamElement* pStream = pContents->GetStream(); CPPUNIT_ASSERT(pStream); SvMemoryStream& rObjectStream = pStream->GetMemory(); // Uncompress it. -- cgit