include/xmloff/odffields.hxx | 1 + sw/inc/strings.hrc | 1 + sw/source/ui/fldui/DropDownFormFieldDialog.cxx | 13 +++++++++++++ sw/source/uibase/inc/DropDownFormFieldDialog.hxx | 1 + 4 files changed, 16 insertions(+)
New commits: commit d3c8973f54037f915e12cd038a6a76501d237ea4 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Tue Aug 20 15:01:34 2019 +0200 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Tue Aug 20 19:08: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. Change-Id: I126edc500bc18e2f0f4b6864775f89be6801f887 Reviewed-on: https://gerrit.libreoffice.org/77843 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zol...@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 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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits