[Libreoffice-commits] core.git: sw/qa sw/source

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Tue Aug 20 18:30:01 UTC 2019


 sw/qa/extras/ooxmlexport/data/tdf126792.odt   |binary
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx |   27 ++++++++++++++++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx  |    3 ++
 3 files changed, 30 insertions(+)

New commits:
commit 8d84f32d55df06c2944da78e2b779de2dba21d50
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Tue Aug 20 15:51:42 2019 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Aug 20 20:29:06 2019 +0200

    tdf#126792: DOCX legacy drop-downs are only supposed to hold 25 items, DOCX
    
    Truncate item list if the MSO limit is exceeded.
    
    Change-Id: I21fd63fd2b8d6c8fe76500e1cdd468d4692612c1
    Reviewed-on: https://gerrit.libreoffice.org/77844
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf126792.odt b/sw/qa/extras/ooxmlexport/data/tdf126792.odt
new file mode 100644
index 000000000000..7eb43e78a71c
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf126792.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index 9e5fc9ccb3d4..d716ad535f84 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -711,6 +711,33 @@ DECLARE_OOXMLEXPORT_TEST( testDateFieldAtEndOfParagraph, "date_field_at_end_of_p
     CPPUNIT_ASSERT_EQUAL(OUString("Click here to enter a date."), pFieldmark->GetContent());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testDropDownFieldEntryLimit, "tdf126792.odt" )
+{
+    // In MSO, there is a limit of 25 for the items in a drop-down form field.
+    // So we truncate the list of items to not exceed this limit.
+
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+    SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+    IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount());
+
+    ::sw::mark::IFieldmark* pFieldmark
+          = dynamic_cast<::sw::mark::IFieldmark*>(*pMarkAccess->getAllMarksBegin());
+    CPPUNIT_ASSERT(pFieldmark);
+    CPPUNIT_ASSERT_EQUAL(OUString(ODF_FORMDROPDOWN), pFieldmark->GetFieldname());
+
+    const sw::mark::IFieldmark::parameter_map_t* const pParameters = pFieldmark->GetParameters();
+    auto pListEntries = pParameters->find(ODF_FORMDROPDOWN_LISTENTRY);
+    CPPUNIT_ASSERT(bool(pListEntries != pParameters->end()));
+    css::uno::Sequence<OUString> vListEntries;
+    pListEntries->second >>= vListEntries;
+    if (!mbExported)
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(26), vListEntries.getLength());
+    else
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(25), vListEntries.getLength());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 8746deaa6397..4a087e8188a4 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1837,6 +1837,9 @@ void DocxAttributeOutput::WriteFFData(  const FieldInfos& rInfos )
         OUString sName, sSelected;
 
         params.extractParam( ODF_FORMDROPDOWN_LISTENTRY, vListEntries );
+        if (vListEntries.getLength() > ODF_FORMDROPDOWN_ENTRY_COUNT_LIMIT)
+            vListEntries = uno::Sequence< OUString>(vListEntries.getArray(), ODF_FORMDROPDOWN_ENTRY_COUNT_LIMIT);
+
         sName = params.getName();
         sal_Int32 nSelectedIndex = 0;
 


More information about the Libreoffice-commits mailing list