[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - vcl/qa vcl/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Thu Nov 12 11:36:24 UTC 2020


 vcl/qa/cppunit/filter/ipdf/data/dict-array-dict.pdf |   55 ++++++++++++++++++++
 vcl/qa/cppunit/filter/ipdf/ipdf.cxx                 |   21 +++++++
 vcl/source/filter/ipdf/pdfdocument.cxx              |   13 ++++
 3 files changed, 87 insertions(+), 2 deletions(-)

New commits:
commit c10a3586f10a9129135275c3c33cf3c7cfe8b42d
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Oct 16 18:15:21 2020 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Nov 12 12:35:50 2020 +0100

    vcl pdf tokenizer: fix handling of dict -> array -> dict tokens
    
    Needed to be able to parse the /Reference key of signatures.
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104443
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit 056c1284d6a68525002c54bef10834cc135385db)
    
    Change-Id: I6b81089a3f58a2de461ad92ca5a891c284f8686a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105635
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/vcl/qa/cppunit/filter/ipdf/data/dict-array-dict.pdf b/vcl/qa/cppunit/filter/ipdf/data/dict-array-dict.pdf
new file mode 100644
index 000000000000..73de3117b9a6
--- /dev/null
+++ b/vcl/qa/cppunit/filter/ipdf/data/dict-array-dict.pdf
@@ -0,0 +1,55 @@
+%PDF-1.7
+% ò¤ô
+1 0 obj <<
+  /Type /Catalog
+  /Pages 2 0 R
+>>
+endobj
+2 0 obj <<
+  /Type /Pages
+  /MediaBox [0 0 200 300]
+  /Count 1
+  /Kids [3 0 R]
+>>
+endobj
+3 0 obj <<
+  /Type /Page
+  /Parent 2 0 R
+  /Contents 4 0 R
+  /Key[<</InnerKey 42>>]
+>>
+endobj
+4 0 obj <<
+  /Length 188
+>>
+stream
+q
+0 0 0 rg
+0 290 10 10 re B*
+10 150 50 30 re B*
+0 0 1 rg
+190 290 10 10 re B*
+70 232 50 30 re B*
+0 1 0 rg
+190 0 10 10 re B*
+130 150 50 30 re B*
+1 0 0 rg
+0 0 10 10 re B*
+70 67 50 30 re B*
+Q
+endstream
+endobj
+xref
+0 5
+0000000000 65535 f 
+0000000015 00000 n 
+0000000068 00000 n 
+0000000157 00000 n 
+0000000251 00000 n 
+trailer <<
+  /Root 1 0 R
+  /Size 5
+>>
+startxref
+491
+%%EOF
diff --git a/vcl/qa/cppunit/filter/ipdf/ipdf.cxx b/vcl/qa/cppunit/filter/ipdf/ipdf.cxx
index 362aa9b8ec4c..5055e36a922e 100644
--- a/vcl/qa/cppunit/filter/ipdf/ipdf.cxx
+++ b/vcl/qa/cppunit/filter/ipdf/ipdf.cxx
@@ -31,6 +31,7 @@
 #include <sfx2/objsh.hxx>
 #include <vcl/filter/PDFiumLibrary.hxx>
 #include <comphelper/processfactory.hxx>
+#include <vcl/filter/pdfdocument.hxx>
 
 using namespace ::com::sun::star;
 
@@ -147,6 +148,26 @@ CPPUNIT_TEST_FIXTURE(VclFilterIpdfTest, testPDFAddVisibleSignatureLastPage)
     CPPUNIT_ASSERT_EQUAL(4, FPDFAnnot_GetObjectCount(pAnnot.get()));
 }
 
+CPPUNIT_TEST_FIXTURE(VclFilterIpdfTest, testDictArrayDict)
+{
+    // Load a file that has markup like this:
+    // 3 0 obj <<
+    //   /Key[<</InnerKey 42>>]
+    // >>
+    OUString aSourceURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "dict-array-dict.pdf";
+    SvFileStream aFile(aSourceURL, StreamMode::READ);
+    vcl::filter::PDFDocument aDocument;
+    CPPUNIT_ASSERT(aDocument.Read(aFile));
+    std::vector<vcl::filter::PDFObjectElement*> aPages = aDocument.GetPages();
+    CPPUNIT_ASSERT(!aPages.empty());
+    vcl::filter::PDFObjectElement* pPage = aPages[0];
+    auto pKey = dynamic_cast<vcl::filter::PDFArrayElement*>(pPage->Lookup("Key"));
+
+    // Without the accompanying fix in place, this test would have failed, because the value of Key
+    // was a dictionary element, not an array element.
+    CPPUNIT_ASSERT(pKey);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx
index 7d1305fa364c..690e2daf1263 100644
--- a/vcl/source/filter/ipdf/pdfdocument.cxx
+++ b/vcl/source/filter/ipdf/pdfdocument.cxx
@@ -2401,8 +2401,17 @@ size_t PDFDictionaryElement::Parse(const std::vector<std::unique_ptr<PDFElement>
                 if (nexti >= i) // ensure we go forwards and not endlessly loop
                 {
                     i = nexti;
-                    rDictionary[aName] = pDictionary;
-                    aName.clear();
+                    if (pArray)
+                    {
+                        // Dictionary value inside an array.
+                        pArray->PushBack(pDictionary);
+                    }
+                    else
+                    {
+                        // Dictionary toplevel value.
+                        rDictionary[aName] = pDictionary;
+                        aName.clear();
+                    }
                 }
             }
         }


More information about the Libreoffice-commits mailing list