From c63b8d55bdb0a6a236cef856cbfc5d9fe45ac103 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 12 Apr 2021 17:54:35 +0200 Subject: sw define bibliography entry dialog: add browse button for file:// URLs - wrap "entry" in the biblio fragment into a "hbox" - audit uses of "entry" and work with "hbox" instead, depending on if the context is a child widget (want hbox) or indeed an entry (want entry) - add a hidden-by-default browse button to that box - add a handler which can edit the AUTH_FIELD_URL entry Change-Id: Ifecc6f1a86be1f609d470535f103c630e45d04cf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114013 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- sw/source/ui/index/swuiidxmrk.cxx | 50 ++++++++++++++++++++++++++++---- sw/uiconfig/swriter/ui/bibliofragment.ui | 37 ++++++++++++++++++----- 2 files changed, 75 insertions(+), 12 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx index 13bc59d038e8..ee5ea01bd037 100644 --- a/sw/source/ui/index/swuiidxmrk.cxx +++ b/sw/source/ui/index/swuiidxmrk.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,7 @@ #include #include #include +#include #include #include @@ -1015,6 +1017,7 @@ class SwCreateAuthEntryDlg_Impl : public weld::GenericDialogController std::vector> m_aOrigContainers; std::vector> m_aFixedTexts; + std::unique_ptr m_pBoxes[AUTH_FIELD_END]; std::unique_ptr pEdits[AUTH_FIELD_END]; std::unique_ptr m_xOKBT; std::unique_ptr m_xBox; @@ -1022,10 +1025,12 @@ class SwCreateAuthEntryDlg_Impl : public weld::GenericDialogController std::unique_ptr m_xRight; std::unique_ptr m_xTypeListBox; std::unique_ptr m_xIdentifierBox; + std::unique_ptr m_xBrowseButton; DECL_LINK(IdentifierHdl, weld::ComboBox&, void); DECL_LINK(ShortNameHdl, weld::Entry&, void); DECL_LINK(EnableHdl, weld::ComboBox&, void); + DECL_LINK(BrowseHdl, weld::Button&, void); public: SwCreateAuthEntryDlg_Impl(weld::Window* pParent, @@ -1593,15 +1598,16 @@ SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(weld::Window* pParent, } else { + m_pBoxes[nIndex] = m_aBuilders.back()->weld_box("hbox"); pEdits[nIndex] = m_aBuilders.back()->weld_entry("entry"); if (bLeft) - m_aOrigContainers.back()->move(pEdits[nIndex].get(), m_xLeft.get()); + m_aOrigContainers.back()->move(m_pBoxes[nIndex].get(), m_xLeft.get()); else - m_aOrigContainers.back()->move(pEdits[nIndex].get(), m_xRight.get()); + m_aOrigContainers.back()->move(m_pBoxes[nIndex].get(), m_xRight.get()); - pEdits[nIndex]->set_grid_left_attach(1); - pEdits[nIndex]->set_grid_top_attach(bLeft ? nLeftRow : nRightRow); - pEdits[nIndex]->set_hexpand(true); + m_pBoxes[nIndex]->set_grid_left_attach(1); + m_pBoxes[nIndex]->set_grid_top_attach(bLeft ? nLeftRow : nRightRow); + m_pBoxes[nIndex]->set_hexpand(true); pEdits[nIndex]->set_text(pFields[aCurInfo.nToxField]); pEdits[nIndex]->show(); pEdits[nIndex]->set_help_id(aCurInfo.pHelpId); @@ -1615,6 +1621,14 @@ SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(weld::Window* pParent, pEdits[nIndex]->set_sensitive(false); } } + else if (aCurInfo.nToxField == AUTH_FIELD_URL + && comphelper::isFileUrl(pFields[aCurInfo.nToxField])) + { + m_xBrowseButton = m_aBuilders.back()->weld_button("browse"); + m_xBrowseButton->connect_clicked(LINK(this, SwCreateAuthEntryDlg_Impl, BrowseHdl)); + m_xBrowseButton->show(); + } + m_aFixedTexts.back()->set_mnemonic_widget(pEdits[nIndex].get()); } if(bLeft) @@ -1699,6 +1713,32 @@ IMPL_LINK(SwCreateAuthEntryDlg_Impl, EnableHdl, weld::ComboBox&, rBox, void) m_xOKBT->set_sensitive(m_bNameAllowed && rBox.get_active() != -1); }; +IMPL_LINK_NOARG(SwCreateAuthEntryDlg_Impl, BrowseHdl, weld::Button&, void) +{ + sfx2::FileDialogHelper aFileDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, + FileDialogFlags::NONE, getDialog()); + OUString aPath = GetEntryText(AUTH_FIELD_URL); + if (!aPath.isEmpty()) + { + aFileDlg.SetDisplayDirectory(aPath); + } + + if (aFileDlg.Execute() != ERRCODE_NONE) + { + return; + } + + for (int nIndex = 0; nIndex < AUTH_FIELD_END; nIndex++) + { + const TextInfo& rCurInfo = aTextInfoArr[nIndex]; + if (rCurInfo.nToxField == AUTH_FIELD_URL) + { + pEdits[nIndex]->set_text(aFileDlg.GetPath()); + break; + } + } +}; + SwAuthMarkFloatDlg::SwAuthMarkFloatDlg(SfxBindings* _pBindings, SfxChildWindow* pChild, weld::Window *pParent, diff --git a/sw/uiconfig/swriter/ui/bibliofragment.ui b/sw/uiconfig/swriter/ui/bibliofragment.ui index 6352bc9a9cfa..d800d0b7d8c7 100644 --- a/sw/uiconfig/swriter/ui/bibliofragment.ui +++ b/sw/uiconfig/swriter/ui/bibliofragment.ui @@ -11,14 +11,37 @@ True 6 - + True - True - True - False - True - True - 14 + False + + + True + True + True + False + True + 14 + True + + + False + True + 0 + + + + + Browse... + True + True + + + False + True + 1 + + 1 -- cgit