sw/qa/core/text/data/tdf159336.odt |binary
 sw/qa/core/text/text.cxx           |   35 +++++++++++++++++++++++++++++++++++
 sw/source/core/text/itrform2.cxx   |    2 ++
 3 files changed, 37 insertions(+)

New commits:
commit 22db6d7a8b1638550a53af57c7c832c3fff230e2
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Jan 23 15:28:26 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon Jan 29 11:48:46 2024 +0100

    tdf#159336: export EditWidget with multiline enabled
    
    How to reproduce it from scratch:
    1. Open writer
    2. Form - Content Controls - Rich Text/Plain Text
    3. Split the control intro different lines
    4. Export to PDF
    
    -> The content control is displayed in one line
    
    Change-Id: Ia8666c8a6520e94ae06693ea8767c1d79aa5d3a0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162446
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Tested-by: Jenkins
    (cherry picked from commit 8a6c9e246c746792fa0ab9d47a0fd5928b77d91d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162532
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162533

diff --git a/sw/qa/core/text/data/tdf159336.odt 
b/sw/qa/core/text/data/tdf159336.odt
new file mode 100644
index 000000000000..4f396e4f2abb
Binary files /dev/null and b/sw/qa/core/text/data/tdf159336.odt differ
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx
index 73d212935f01..0e4b2b56f13b 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -20,6 +20,7 @@
 #include <vcl/gdimtf.hxx>
 #include <vcl/metaact.hxx>
 #include <vcl/filter/PDFiumLibrary.hxx>
+#include <vcl/filter/pdfdocument.hxx>
 #include <comphelper/propertyvalue.hxx>
 #include <editeng/fhgtitem.hxx>
 #include <editeng/wghtitem.hxx>
@@ -115,6 +116,40 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, 
testLastBibliographyPdfExport)
     CPPUNIT_ASSERT(true);
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf159336)
+{
+    createSwDoc("tdf159336.odt");
+    save("writer_pdf_Export");
+
+    vcl::filter::PDFDocument aDocument;
+    SvFileStream aStream(maTempFile.GetURL(), StreamMode::READ);
+    CPPUNIT_ASSERT(aDocument.Read(aStream));
+
+    // The document has one page.
+    std::vector<vcl::filter::PDFObjectElement*> aPages = aDocument.GetPages();
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aPages.size());
+
+    auto pAnnots = 
dynamic_cast<vcl::filter::PDFArrayElement*>(aPages[0]->Lookup("Annots"));
+    CPPUNIT_ASSERT(pAnnots);
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), 
pAnnots->GetElements().size());
+    auto pAnnotReference
+        = 
dynamic_cast<vcl::filter::PDFReferenceElement*>(pAnnots->GetElements()[0]);
+    CPPUNIT_ASSERT(pAnnotReference);
+    vcl::filter::PDFObjectElement* pAnnot = pAnnotReference->LookupObject();
+    CPPUNIT_ASSERT(pAnnot);
+    CPPUNIT_ASSERT_EQUAL(
+        OString("Annot"),
+        
static_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Type"))->GetValue());
+    CPPUNIT_ASSERT_EQUAL(
+        OString("Widget"),
+        
static_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Subtype"))->GetValue());
+    // Ff = multiline
+    auto pFf = 
dynamic_cast<vcl::filter::PDFNumberElement*>(pAnnot->Lookup("Ff"));
+    CPPUNIT_ASSERT(pFf);
+    CPPUNIT_ASSERT_EQUAL(4096.0, pFf->GetValue());
+}
+
 CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testBibliographyUrlPdfExport)
 {
     // Given a document with a bibliography entry field:
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index e88e679e1d5b..b46505e226c2 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -1009,6 +1009,8 @@ bool SwContentControlPortion::DescribePDFControl(const 
SwTextPaintInfo& rInf) co
         case SwContentControlType::PLAIN_TEXT:
         {
             pDescriptor = std::make_unique<vcl::PDFWriter::EditWidget>();
+            auto pEditWidget = 
static_cast<vcl::PDFWriter::EditWidget*>(pDescriptor.get());
+            pEditWidget->MultiLine = true;
             break;
         }
         case SwContentControlType::CHECKBOX:

Reply via email to