include/xmloff/odffields.hxx | 1 sw/qa/extras/ooxmlexport/data/tdf126792.odt |binary sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 30 ++++++++++++++++++++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 3 ++ 4 files changed, 34 insertions(+)
New commits: commit 92f527ef00fe7fa4f84e6577c7249de845be6479 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Wed Aug 21 10:30:31 2019 +0200 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sat Aug 24 22:36:51 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. Reviewed-on: https://gerrit.libreoffice.org/77844 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> (cherry picked from commit 8d84f32d55df06c2944da78e2b779de2dba21d50) Change-Id: I21fd63fd2b8d6c8fe76500e1cdd468d4692612c1 Reviewed-on: https://gerrit.libreoffice.org/77869 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/xmloff/odffields.hxx b/include/xmloff/odffields.hxx index 27525fb39374..fd1b6b4dabfe 100644 --- a/include/xmloff/odffields.hxx +++ b/include/xmloff/odffields.hxx @@ -32,6 +32,7 @@ #define ODF_FORMDROPDOWN "vnd.oasis.opendocument.field.FORMDROPDOWN" #define ODF_FORMDROPDOWN_LISTENTRY "Dropdown_ListEntry" #define ODF_FORMDROPDOWN_RESULT "Dropdown_Selected" +#define ODF_FORMDROPDOWN_ENTRY_COUNT_LIMIT 25 #define ODF_TOC "vnd.oasis.opendocument.field.TOC" 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 b5b6b6040216..1765a28fa64f 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -8,6 +8,9 @@ */ #include <swmodeltestbase.hxx> +#include <xmloff/odffields.hxx> +#include <IDocumentMarkAccess.hxx> +#include <IMark.hxx> class Test : public SwModelTestBase { @@ -664,6 +667,33 @@ DECLARE_OOXMLEXPORT_TEST( testTdf66401, "tdf66401.docx") } } +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 2bdbc30c7aa1..ff208c98ef22 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1840,6 +1840,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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits