sdext/source/pdfimport/misc/pwdinteract.cxx                         |    6 +--
 sw/qa/extras/pdf/HybridPdfTest.cxx                                  |   18 
++++++++++
 sw/qa/extras/pdf/data/Hybrid_EmbeddedFileOnlyPDF20UAPasswordpop.pdf |binary
 3 files changed, 21 insertions(+), 3 deletions(-)

New commits:
commit 9840136fc91f73b237a81ccbad31721ecba5c689
Author:     Dr. David Alan Gilbert <d...@treblig.org>
AuthorDate: Fri Apr 11 02:12:24 2025 +0100
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Tue Apr 22 04:40:03 2025 +0200

    sdext,pdfimport: Add passworded, PDF 2, UA, hybrid test
    
    When LO exports PDF/UA files it doesn't add the old
    AdditionalStreams trailer hack, just using the standard
    EmbeddedFiles mechanism.
    Add a test of a hybrid in that format, with a password
    in PDF2 format (which uses the newer encryption format).
    
    Change-Id: I268784a370ef6223a3b91c38d14b0484fd984b73
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184082
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/pdf/HybridPdfTest.cxx 
b/sw/qa/extras/pdf/HybridPdfTest.cxx
index 5302f5494a8e..e6b102567a5a 100644
--- a/sw/qa/extras/pdf/HybridPdfTest.cxx
+++ b/sw/qa/extras/pdf/HybridPdfTest.cxx
@@ -25,11 +25,13 @@ public:
     void testNoHybridDataInPDF();
     void testHybridWithAdditionalStreams();
     void testHybridWithAdditionalStreamsAndAttachedFile();
+    void testHybridWithAttachedFileAndPass();
 
     CPPUNIT_TEST_SUITE(HybridPdfTest);
     CPPUNIT_TEST(testNoHybridDataInPDF);
     CPPUNIT_TEST(testHybridWithAdditionalStreams);
     CPPUNIT_TEST(testHybridWithAdditionalStreamsAndAttachedFile);
+    CPPUNIT_TEST(testHybridWithAttachedFileAndPass);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -73,6 +75,22 @@ void 
HybridPdfTest::testHybridWithAdditionalStreamsAndAttachedFile()
 #endif
 }
 
+void HybridPdfTest::testHybridWithAttachedFileAndPass()
+{
+#if ENABLE_PDFIMPORT
+    // Load PDF document with an embedded ODT document
+    // The ODT document is embedded using an attached file conforming to the 
PDF specs
+    // it doesn't have the "/AdditionalStreams"
+    // The file is encrypted
+    createSwDoc("Hybrid_EmbeddedFileOnlyPDF20UAPasswordpop.pdf", "pop");
+
+    // We can access the document text in a single paragraph that spans 
multiple rows
+    // This wouldn't be possible with a PDF, so the opened document has to be 
ODT
+    CPPUNIT_ASSERT_EQUAL(u"He heard quiet steps behind him. 
That didn't bode well."_ustr,
+                         getParagraph(1)->getString());
+#endif
+}
+
 } // end of anonymous namespace
 CPPUNIT_TEST_SUITE_REGISTRATION(HybridPdfTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git 
a/sw/qa/extras/pdf/data/Hybrid_EmbeddedFileOnlyPDF20UAPasswordpop.pdf 
b/sw/qa/extras/pdf/data/Hybrid_EmbeddedFileOnlyPDF20UAPasswordpop.pdf
new file mode 100644
index 000000000000..194bb066fe08
Binary files /dev/null and 
b/sw/qa/extras/pdf/data/Hybrid_EmbeddedFileOnlyPDF20UAPasswordpop.pdf differ
commit 6acfaaca9741e854db161e0afed029ff6c647dd0
Author:     Dr. David Alan Gilbert <d...@treblig.org>
AuthorDate: Fri Apr 11 21:42:24 2025 +0100
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Tue Apr 22 04:39:51 2025 +0200

    sdext,pdfimport: Update password helper to use DocumentPasswordRequest2
    
    PDFPasswordRequest currently uses task::DocumentPasswordRequest
    but the test harnesses TestInteractionHandler only
    supports DocumentPasswordRequest2.
    So update to use '2', the only difference seems to be a flag to
    say whether we're opening or modifying a file, in the PDF import
    it's always a case of opening.
    
    Change-Id: I9822179db344fff3743e8c25a0c222338c1ad49e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184081
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    Tested-by: Jenkins

diff --git a/sdext/source/pdfimport/misc/pwdinteract.cxx 
b/sdext/source/pdfimport/misc/pwdinteract.cxx
index c289acc98e50..44214ac70ac3 100644
--- a/sdext/source/pdfimport/misc/pwdinteract.cxx
+++ b/sdext/source/pdfimport/misc/pwdinteract.cxx
@@ -28,7 +28,7 @@
 #include <com/sun/star/task/XInteractionHandler.hpp>
 #include <com/sun/star/task/XInteractionRequest.hpp>
 #include <com/sun/star/task/XInteractionPassword.hpp>
-#include <com/sun/star/task/DocumentPasswordRequest.hpp>
+#include <com/sun/star/task/DocumentPasswordRequest2.hpp>
 
 #include <cppuhelper/implbase.hxx>
 #include <rtl/ref.hxx>
@@ -74,13 +74,13 @@ private:
 PDFPasswordRequest::PDFPasswordRequest( bool bFirstTry, const OUString& rName 
) :
     m_aRequest(
         uno::Any(
-            task::DocumentPasswordRequest(
+            task::DocumentPasswordRequest2(
                 OUString(), uno::Reference< uno::XInterface >(),
                 task::InteractionClassification_QUERY,
                 (bFirstTry
                  ? task::PasswordRequestMode_PASSWORD_ENTER
                  : task::PasswordRequestMode_PASSWORD_REENTER),
-                rName))),
+                rName, false))),
     m_bSelected(false)
 {}
 

Reply via email to