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

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 21 12:31:29 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   |   13 +++++++++++
 sw/source/uibase/inc/DropDownFormFieldDialog.hxx |    1 
 7 files changed, 46 insertions(+)

New commits:
commit 79d8123d406388f97413ca4b515c1b9f55e6c82c
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:30:44 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/77872
    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 a4c811695412..8f2e9c4d266c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -751,6 +751,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 cfc98d6e9391..2b3096b68948 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1878,6 +1878,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;
 
commit 14f05d1bcd9874b9e0b4e952fc5dd486e2396013
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Tue Aug 20 15:01:34 2019 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Aug 21 14:30:29 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.
    
    Change-Id: I126edc500bc18e2f0f4b6864775f89be6801f887
    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)
    Reviewed-on: https://gerrit.libreoffice.org/77871
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.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 b16f0051d182..1bb9b35a7c1a 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -540,6 +540,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 dd187704aa7a..e67f9a99a5b2 100644
--- a/sw/source/ui/fldui/DropDownFormFieldDialog.cxx
+++ b/sw/source/ui/fldui/DropDownFormFieldDialog.cxx
@@ -11,6 +11,9 @@
 #include <vcl/event.hxx>
 #include <IMark.hxx>
 #include <xmloff/odffields.hxx>
+#include <vcl/svapp.hxx>
+#include <strings.hrc>
+#include <swtypes.hxx>
 
 namespace sw
 {
@@ -18,6 +21,7 @@ DropDownFormFieldDialog::DropDownFormFieldDialog(weld::Window* pParent,
                                                  mark::IFieldmark* pDropDownField)
     : GenericDialogController(pParent, "modules/swriter/ui/dropdownformfielddialog.ui",
                               "DropDownFormFieldDialog")
+    , m_pParent(pParent)
     , m_pDropDownField(pDropDownField)
     , m_bListHasChanged(false)
     , m_xListItemEntry(m_xBuilder->weld_entry("item_entry"))
@@ -131,6 +135,15 @@ void DropDownFormFieldDialog::AppendItemToList()
 {
     if (m_xListAddButton->get_sensitive())
     {
+        if (m_xListItemsTreeView->n_children() >= ODF_FORMDROPDOWN_ENTRY_COUNT_LIMIT)
+        {
+            std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(
+                m_pParent, VclMessageType::Info, VclButtonsType::Ok,
+                SwResId(STR_DROP_DOWN_FIELD_ITEM_LIMIT)));
+            xInfoBox->run();
+            return;
+        }
+
         const OUString sEntry(m_xListItemEntry->get_text());
         if (!sEntry.isEmpty())
         {
diff --git a/sw/source/uibase/inc/DropDownFormFieldDialog.hxx b/sw/source/uibase/inc/DropDownFormFieldDialog.hxx
index 3fbb59db0ebc..fbd37f401e48 100644
--- a/sw/source/uibase/inc/DropDownFormFieldDialog.hxx
+++ b/sw/source/uibase/inc/DropDownFormFieldDialog.hxx
@@ -27,6 +27,7 @@ namespace sw
 class DropDownFormFieldDialog : public weld::GenericDialogController
 {
 private:
+    weld::Widget* const m_pParent;
     mark::IFieldmark* m_pDropDownField;
     bool m_bListHasChanged;
 


More information about the Libreoffice-commits mailing list