summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-08-20 15:01:34 +0200
committerTamás Zolnai <tamas.zolnai@collabora.com>2019-08-20 19:08:13 +0200
commitd3c8973f54037f915e12cd038a6a76501d237ea4 (patch)
tree6e20ef56c96003ef2fabf72a3dbde8266812b97e /sw
parent1d4eb1be35cc393f98496883c2cb4ee89f4bcf0c (diff)
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@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/strings.hrc1
-rw-r--r--sw/source/ui/fldui/DropDownFormFieldDialog.cxx13
-rw-r--r--sw/source/uibase/inc/DropDownFormFieldDialog.hxx1
3 files changed, 15 insertions, 0 deletions
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 232e673fbd5e..010d7e662724 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -550,6 +550,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 177fd00bb961..7d703dee7122 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::Widget* 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"))
@@ -128,6 +132,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 ae1e1b51db62..e3cf8032b97f 100644
--- a/sw/source/uibase/inc/DropDownFormFieldDialog.hxx
+++ b/sw/source/uibase/inc/DropDownFormFieldDialog.hxx
@@ -26,6 +26,7 @@ namespace sw
class DropDownFormFieldDialog : public weld::GenericDialogController
{
private:
+ weld::Widget* const m_pParent;
mark::IFieldmark* m_pDropDownField;
bool m_bListHasChanged;