summaryrefslogtreecommitdiff
path: root/sw/source/ui
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-04-12 17:54:35 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-04-12 19:17:50 +0200
commitc63b8d55bdb0a6a236cef856cbfc5d9fe45ac103 (patch)
treedb952bae2db04e1dfed5619b9025b92d3f8cf1a5 /sw/source/ui
parentfe23e35ba5705d7f51f69c3f4e7ccd6c5b575a6b (diff)
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 <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/ui')
-rw-r--r--sw/source/ui/index/swuiidxmrk.cxx50
1 files changed, 45 insertions, 5 deletions
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 <swuiidxmrk.hxx>
#include <hintids.hxx>
#include <helpids.h>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -49,6 +50,7 @@
#include <strings.hrc>
#include <svl/cjkoptions.hxx>
#include <comphelper/fileurl.hxx>
+#include <sfx2/filedlghelper.hxx>
#include <ndtxt.hxx>
#include <SwRewriter.hxx>
@@ -1015,6 +1017,7 @@ class SwCreateAuthEntryDlg_Impl : public weld::GenericDialogController
std::vector<std::unique_ptr<weld::Container>> m_aOrigContainers;
std::vector<std::unique_ptr<weld::Label>> m_aFixedTexts;
+ std::unique_ptr<weld::Box> m_pBoxes[AUTH_FIELD_END];
std::unique_ptr<weld::Entry> pEdits[AUTH_FIELD_END];
std::unique_ptr<weld::Button> m_xOKBT;
std::unique_ptr<weld::Container> m_xBox;
@@ -1022,10 +1025,12 @@ class SwCreateAuthEntryDlg_Impl : public weld::GenericDialogController
std::unique_ptr<weld::Container> m_xRight;
std::unique_ptr<weld::ComboBox> m_xTypeListBox;
std::unique_ptr<weld::ComboBox> m_xIdentifierBox;
+ std::unique_ptr<weld::Button> 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,