summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-03-23 11:36:21 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-03-24 12:48:04 +0100
commitfaa8f4ff3536f9328c6dcf11feff3a7c5fca0ea4 (patch)
tree749ec77ac90add7e4d8a8d73557e3e2d17228080 /sw/source/uibase
parentb6632bd41b56a2485dc6dd67a19d930c9654f835 (diff)
sw bibliography, refer to a page: add open hyperlink context menu
This brings bibliography entry fields with URLs closer to hyperlinks, which already had the same context menu. Change-Id: I8680a0fccb1f75c15cdcc52f86fabf1c57b5635e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112981 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/shells/textsh1.cxx28
1 files changed, 27 insertions, 1 deletions
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index 9535ceef1fa9..1b2cd56fb2f0 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -99,6 +99,7 @@
#include <xmloff/odffields.hxx>
#include <bookmrk.hxx>
#include <linguistic/misc.hxx>
+#include <authfld.hxx>
using namespace ::com::sun::star;
using namespace com::sun::star::beans;
@@ -1351,6 +1352,21 @@ void SwTextShell::Execute(SfxRequest &rReq)
else
rWrtSh.ClickToINetAttr(rINetFormat);
}
+ else
+ {
+ SwField* pField = rWrtSh.GetCurField();
+ if (pField && pField->GetTyp()->Which() == SwFieldIds::TableOfAuthorities)
+ {
+ const auto& rAuthorityField = *static_cast<const SwAuthorityField*>(pField);
+ if (rAuthorityField.HasURL())
+ {
+ // Bibliography entry with URL also provides a hyperlink.
+ const OUString& rURL
+ = rAuthorityField.GetAuthEntry()->GetAuthorField(AUTH_FIELD_URL);
+ ::LoadURL(rWrtSh, rURL, LoadUrlFlags::NewView, /*rTargetFrameName=*/OUString());
+ }
+ }
+ }
}
break;
case SID_OPEN_XML_FILTERSETTINGS:
@@ -1984,7 +2000,17 @@ void SwTextShell::GetState( SfxItemSet &rSet )
svl::Items<RES_TXTATR_INETFMT,
RES_TXTATR_INETFMT>{});
rSh.GetCurAttr(aSet);
- if(SfxItemState::SET > aSet.GetItemState( RES_TXTATR_INETFMT, false ))
+
+ bool bAuthorityFieldURL = false;
+ SwField* pField = rSh.GetCurField();
+ if (pField && pField->GetTyp()->Which() == SwFieldIds::TableOfAuthorities)
+ {
+ // Bibliography entry with URL also provides a hyperlink.
+ const auto& rAuthorityField = *static_cast<const SwAuthorityField*>(pField);
+ bAuthorityFieldURL = rAuthorityField.HasURL();
+ }
+ if (SfxItemState::SET > aSet.GetItemState(RES_TXTATR_INETFMT, false)
+ && !bAuthorityFieldURL)
rSet.DisableItem(nWhich);
}
break;