From 56b124c36cff09257d8373aaa6661a88cfb1926d Mon Sep 17 00:00:00 2001 From: Heiko Tietze Date: Thu, 7 Nov 2019 16:19:36 +0100 Subject: Resolves tdf#128521 - illegal char in a bookmark name Message box removed and warning label introduced Some alignment and accessibility issues solved too Change-Id: Icc88d489268403fa3da525aadc1c007c589fa019 Reviewed-on: https://gerrit.libreoffice.org/82231 Tested-by: Jenkins Reviewed-by: Heiko Tietze --- solenv/sanitizers/ui/modules/swriter.suppr | 1 + sw/inc/strings.hrc | 2 +- sw/source/ui/misc/bookmark.cxx | 20 +- sw/source/uibase/inc/bookmark.hxx | 2 +- sw/uiconfig/swriter/ui/insertbookmark.ui | 300 +++++++++++++++++------------ 5 files changed, 185 insertions(+), 140 deletions(-) diff --git a/solenv/sanitizers/ui/modules/swriter.suppr b/solenv/sanitizers/ui/modules/swriter.suppr index 97f6e239143f..43134e801be7 100644 --- a/solenv/sanitizers/ui/modules/swriter.suppr +++ b/solenv/sanitizers/ui/modules/swriter.suppr @@ -93,6 +93,7 @@ sw/uiconfig/swriter/ui/indexentry.ui://GtkButton[@id='next'] button-no-label sw/uiconfig/swriter/ui/indexentry.ui://GtkButton[@id='first'] button-no-label sw/uiconfig/swriter/ui/indexentry.ui://GtkButton[@id='last'] button-no-label sw/uiconfig/swriter/ui/insertbookmark.ui://GtkEntry[@id='name'] no-labelled-by +sw/uiconfig/swriter/ui/insertbookmark.ui://GtkLabel[@id='lbForbiddenChars'] orphan-label sw/uiconfig/swriter/ui/insertbreak.ui://GtkSpinButton[@id='pagenumsb'] missing-label-for sw/uiconfig/swriter/ui/insertcaption.ui://GtkEntry[@id='caption_edit'] no-labelled-by sw/uiconfig/swriter/ui/insertdbcolumnsdialog.ui://GtkButton[@id='allright'] button-no-label diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc index 47368c1e9dc5..8b2bd0073093 100644 --- a/sw/inc/strings.hrc +++ b/sw/inc/strings.hrc @@ -237,7 +237,6 @@ #define STR_LOAD_GLOBAL_DOC NC_("STR_LOAD_GLOBAL_DOC", "Name and Path of Master Document") #define STR_LOAD_HTML_DOC NC_("STR_LOAD_HTML_DOC", "Name and Path of the HTML Document") #define STR_JAVA_EDIT NC_("STR_JAVA_EDIT", "Edit Script") -#define STR_REMOVE_WARNING NC_("STR_REMOVE_WARNING", "The following characters are not valid and have been removed: ") #define STR_BOOKMARK_DEF_NAME NC_("STR_BOOKMARK_DEF_NAME", "Bookmark") #define STR_BOOKMARK_NAME NC_("STR_BOOKMARK_NAME", "Name") #define STR_BOOKMARK_TEXT NC_("STR_BOOKMARK_TEXT", "Text") @@ -245,6 +244,7 @@ #define STR_BOOKMARK_CONDITION NC_("STR_BOOKMARK_CONDITION", "Condition") #define STR_BOOKMARK_YES NC_("STR_BOOKMARK_YES", "Yes") #define STR_BOOKMARK_NO NC_("STR_BOOKMARK_NO", "No") +#define STR_BOOKMARK_FORBIDDENCHARS NC_("STR_BOOKMARK_FORBIDDENCHARS", "Forbidden chars:") #define SW_STR_NONE NC_("SW_STR_NONE", "[None]") #define STR_CAPTION_BEGINNING NC_("STR_CAPTION_BEGINNING", "Start") #define STR_CAPTION_END NC_("STR_CAPTION_END", "End") diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx index 5d6f08cf48fa..2fd11375504b 100644 --- a/sw/source/ui/misc/bookmark.cxx +++ b/sw/source/ui/misc/bookmark.cxx @@ -59,14 +59,12 @@ IMPL_LINK_NOARG(SwInsertBookmarkDlg, ModifyHdl, weld::Entry&, void) if (sTmp.getLength() != nTmpLen) sMsg += OUStringChar(BookmarkTable::aForbiddenChars[i]); } - if (sTmp.getLength() != nLen) - { - m_xEditBox->set_text(sTmp); - std::unique_ptr xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), - VclMessageType::Info, VclButtonsType::Ok, - sRemoveWarning + sMsg)); - xInfoBox->run(); - } + const bool bHasForbiddenChars = sTmp.getLength() != nLen; + m_xForbiddenChars->set_visible(bHasForbiddenChars); + if (bHasForbiddenChars) + m_xEditBox->set_message_type(weld::EntryMessageType::Error); + else + m_xEditBox->set_message_type(weld::EntryMessageType::Normal); sal_Int32 nSelectedEntries = 0; sal_Int32 nEntries = 0; @@ -83,7 +81,7 @@ IMPL_LINK_NOARG(SwInsertBookmarkDlg, ModifyHdl, weld::Entry&, void) } // allow to add new bookmark only if one name provided and it's not taken - m_xInsertBtn->set_sensitive(nEntries == 1 && nSelectedEntries == 0); + m_xInsertBtn->set_sensitive(nEntries == 1 && nSelectedEntries == 0 && !bHasForbiddenChars); // allow to delete only if all bookmarks are recognized m_xDeleteBtn->set_sensitive(nEntries > 0 && nSelectedEntries == nEntries); @@ -313,6 +311,7 @@ SwInsertBookmarkDlg::SwInsertBookmarkDlg(weld::Window* pParent, SwWrtShell& rS, , m_xConditionFT(m_xBuilder->weld_label("condlabel")) , m_xConditionED(new ConditionEdit(m_xBuilder->weld_entry("withcond"))) , m_xBookmarksBox(new BookmarkTable(m_xBuilder->weld_tree_view("bookmarks"))) + , m_xForbiddenChars(m_xBuilder->weld_label("lbForbiddenChars")) { m_xBookmarksBox->connect_changed(LINK(this, SwInsertBookmarkDlg, SelectionChangedHdl)); m_xBookmarksBox->connect_row_activated(LINK(this, SwInsertBookmarkDlg, DoubleClickHdl)); @@ -333,7 +332,8 @@ SwInsertBookmarkDlg::SwInsertBookmarkDlg(weld::Window* pParent, SwWrtShell& rS, m_xEditBox->set_text(m_xBookmarksBox->GetNameProposal()); m_xEditBox->set_position(-1); - sRemoveWarning = SwResId(STR_REMOVE_WARNING); + m_xForbiddenChars->set_label(SwResId(STR_BOOKMARK_FORBIDDENCHARS) + " " + BookmarkTable::aForbiddenChars); + m_xForbiddenChars->set_visible(false); } IMPL_LINK(SwInsertBookmarkDlg, HeaderBarClick, int, nColumn, void) diff --git a/sw/source/uibase/inc/bookmark.hxx b/sw/source/uibase/inc/bookmark.hxx index 1a126788ca15..7522dbe9bc12 100644 --- a/sw/source/uibase/inc/bookmark.hxx +++ b/sw/source/uibase/inc/bookmark.hxx @@ -64,7 +64,6 @@ public: class SwInsertBookmarkDlg : public SfxDialogController { - OUString sRemoveWarning; SwWrtShell& rSh; SfxRequest& rReq; std::vector> aTableBookmarks; @@ -80,6 +79,7 @@ class SwInsertBookmarkDlg : public SfxDialogController std::unique_ptr m_xConditionFT; std::unique_ptr m_xConditionED; std::unique_ptr m_xBookmarksBox; + std::unique_ptr m_xForbiddenChars; DECL_LINK(ModifyHdl, weld::Entry&, void); DECL_LINK(InsertHdl, weld::Button&, void); diff --git a/sw/uiconfig/swriter/ui/insertbookmark.ui b/sw/uiconfig/swriter/ui/insertbookmark.ui index bc9c3896f1d3..e5197049c16e 100644 --- a/sw/uiconfig/swriter/ui/insertbookmark.ui +++ b/sw/uiconfig/swriter/ui/insertbookmark.ui @@ -35,7 +35,7 @@ True True vertical - 12 + 6 False @@ -73,25 +73,41 @@ True True - 5 + 6 - + True False - 6 + True + 6 + 6 + + + False + end + start + True + Forbidden chars: + True + + + 1 + 1 + + True True + True True 0 - True - True - 0 + 1 + 0 @@ -104,52 +120,51 @@ True - False - False - end - 0 + 2 + 0 + + + + + True + False + start + Name: + True + name + + + 0 + 0 + + + + + H_ide + True + True + False + start + True + True + + + 1 + 2 - - - False - False - 0 - - - - - H_ide - True - True - False - start - True - True - - - False - True - 1 - - - - - True - False - 12 True False - _With condition + start + _Condition: True withcond - False - True - 0 + 0 + 3 @@ -159,115 +174,143 @@ True - True - True - 1 + 1 + 3 + 2 - - - False - True - 2 - - - - - True - True - True - True - in - + + True + False + start + start + True + _Bookmarks: + True + bookmarks + + + 0 + 4 + + + + True True - True True True - liststore1 - 0 - False - - - + in - - True - 6 - Page - True + + True + True + True + True + True + liststore1 + 0 + False + + + - - - 0 - + + True + 6 + Page + True + + + + 0 + + + - - - - - True - 6 - Name - True - - - 1 - + + True + 6 + Name + True + + + + 1 + + + - - - - - True - 6 - Text - True - - - 2 - + + True + 6 + Text + True + + + + 2 + + + - - - - - True - 6 - Hidden - True - - - 3 - + + True + 6 + Hidden + True + + + + 3 + + + - - - - - True - 6 - Condition - True - - - 4 - + + True + 6 + Condition + True + + + + 4 + + + + + 1 + 4 + 2 + + + + + + + + + + + + + - True + False True - 3 + 1 @@ -321,7 +364,7 @@ False False - 4 + 6 @@ -331,4 +374,5 @@ help + -- cgit