sw/qa/core/text/data/tdf153040.docx |binary
 sw/qa/core/text/text.cxx            |   24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+)

New commits:
commit 026924b192031769449814b9166a7b8d37c869f8
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Mon Jun 5 12:35:22 2023 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Tue Jun 6 01:17:25 2023 +0200

    tdf#153040: unit test
    
    make CppunitTest_sw_core_text \
        CPPUNIT_TEST_NAME=testDropdownContentControlPDF2
    
    Still wrong/poor with this unit test:
    -wrong font for rich/plain text content
    -slightly offset (shifted right/shifted down) placement
     (tested in Linux Evince anyway).
    
    Change-Id: I586d46eaf5cdf9fbf44a6913f295c440240d180a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152634
    Reviewed-by: Justin Luth <jl...@mail.com>
    Tested-by: Jenkins

diff --git a/sw/qa/core/text/data/tdf153040.docx 
b/sw/qa/core/text/data/tdf153040.docx
new file mode 100644
index 000000000000..27dc07601ab0
Binary files /dev/null and b/sw/qa/core/text/data/tdf153040.docx differ
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx
index 36332102e3b0..f321a01c3aa5 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -1016,6 +1016,30 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, 
testDropdownContentControlPDF)
                          pAnnotation->getFormFieldType(pPdfDocument.get()));
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testDropdownContentControlPDF2)
+{
+    std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get();
+    if (!pPDFium)
+        return;
+
+    createSwDoc("tdf153040.docx");
+
+    save("writer_pdf_Export");
+
+    // Make sure that a dropdown form widget is emitted:
+    std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
+    std::unique_ptr<vcl::pdf::PDFiumPage> pPage = pPdfDocument->openPage(0);
+
+    CPPUNIT_ASSERT_EQUAL(4, pPage->getAnnotationCount());
+    std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnotation = 
pPage->getAnnotation(0);
+    CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFAnnotationSubType::Widget, 
pAnnotation->getSubType());
+    // Also check the form widget type (our dropdown is called combo in PDF 
terms):
+    CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFFormFieldType::ComboBox,
+                         pAnnotation->getFormFieldType(pPdfDocument.get()));
+    // Without tdf#153040's fix, this would have been the empty OUString()
+    CPPUNIT_ASSERT_EQUAL(OUString("Apfel"), 
pAnnotation->getFormFieldValue(pPdfDocument.get()));
+}
+
 CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testDateContentControlPDF)
 {
     std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get();

Reply via email to