[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - 2 commits - include/xmloff sw/inc sw/qa sw/source

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 21 12:32:10 UTC 2019


 include/xmloff/odffields.hxx                   |    1 
 sw/inc/strings.hrc                             |    1 
 sw/qa/extras/ooxmlexport/data/tdf126792.odt    |binary
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx  |   27 +++++++++++++++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx   |    3 ++
 sw/source/ui/fldui/DropDownFormFieldDialog.cxx |   12 +++++++++++
 6 files changed, 44 insertions(+)

New commits:
commit edfd8e9afb965832969701aadaca106da44cb53b
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: Wed Aug 21 14:31:23 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.zolnai at collabora.com>
    (cherry picked from commit 8d84f32d55df06c2944da78e2b779de2dba21d50)
    
    Change-Id: I21fd63fd2b8d6c8fe76500e1cdd468d4692612c1
    Reviewed-on: https://gerrit.libreoffice.org/77875
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    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 4857385692e1..299e7edbf00c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -752,6 +752,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()->get());
+    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 91127dcc333a..bc96cfb6a4a1 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1626,6 +1626,9 @@ void DocxAttributeOutput::WriteFFData(  const FieldInfos& rInfos )
 
         FieldMarkParamsHelper params( rFieldmark );
         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;
 
commit 7d948a25e961e4c26ff98a96255f96477e536571
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Aug 21 12:05:03 2019 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Aug 21 14:31:13 2019 +0200

    tdf#126792: DOCX legacy drop-downs are only supposed to hold 25 items, GUI
    
    Implement GUI part. Do not allow to add more items to the drop-down
    field if the count of items reached the 25 limit.
    
    Reviewed-on: https://gerrit.libreoffice.org/77843
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit d3c8973f54037f915e12cd038a6a76501d237ea4)
    
    Change-Id: I126edc500bc18e2f0f4b6864775f89be6801f887
    Reviewed-on: https://gerrit.libreoffice.org/77874
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/include/xmloff/odffields.hxx b/include/xmloff/odffields.hxx
index 8b5fc6dc7bcb..c37631f07d46 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_FORMDATE "vnd.oasis.opendocument.field.FORMDATE"
 #define ODF_FORMDATE_DATEFORMAT "DateField_DateFormat" // e.g. "MM.DD.YY"
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 8c1cc47a85e8..23e38d90450b 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -523,6 +523,7 @@
 #define STR_UNDO_TBLSTYLE_UPDATE                NC_("STR_UNDO_TBLSTYLE_UPDATE", "Update table style: $1")
 #define STR_UNDO_TABLE_DELETE                   NC_("STR_UNDO_TABLE_DELETE", "Delete table")
 #define STR_UNDO_INSERT_FORM_FIELD              NC_("STR_UNDO_INSERT_FORM_FIELD", "Insert form field")
+#define STR_DROP_DOWN_FIELD_ITEM_LIMIT          NC_("STR_DROP_DOWN_FIELD_ITEM_LIMIT", "You can specify maximum of 25 items for a drop-down form field.")
 
 #define STR_ACCESS_DOC_NAME                     NC_("STR_ACCESS_DOC_NAME", "Document view")
 #define STR_ACCESS_DOC_DESC                     NC_("STR_ACCESS_DOC_DESC", "Document view")
diff --git a/sw/source/ui/fldui/DropDownFormFieldDialog.cxx b/sw/source/ui/fldui/DropDownFormFieldDialog.cxx
index 079aeaad4739..1b9845c983ad 100644
--- a/sw/source/ui/fldui/DropDownFormFieldDialog.cxx
+++ b/sw/source/ui/fldui/DropDownFormFieldDialog.cxx
@@ -11,6 +11,10 @@
 #include <vcl/event.hxx>
 #include <IMark.hxx>
 #include <xmloff/odffields.hxx>
+#include <vcl/svapp.hxx>
+#include <strings.hrc>
+#include <swtypes.hxx>
+#include <vcl/layout.hxx>
 
 namespace sw
 {
@@ -125,6 +129,14 @@ void DropDownFormFieldDialog::AppendItemToList()
 {
     if (m_xListAddButton->IsEnabled())
     {
+        if (m_xListItemsTreeView->GetEntryCount() >= ODF_FORMDROPDOWN_ENTRY_COUNT_LIMIT)
+        {
+            ScopedVclPtrInstance<MessageDialog>(this, SwResId(STR_DROP_DOWN_FIELD_ITEM_LIMIT),
+                                                VclMessageType::Info)
+                ->Execute();
+            return;
+        }
+
         const OUString sEntry(m_xListItemEntry->GetText());
         if (!sEntry.isEmpty())
         {


More information about the Libreoffice-commits mailing list