summaryrefslogtreecommitdiff
path: root/sw/source/uibase/shells/textsh1.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-07-22 14:23:07 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-07-22 16:21:49 +0200
commitb85becd0d427c7375f1d8e6309f348304b6ebbac (patch)
tree3fe265fa9c727e6c54de08bb99b8d792a77dd0c4 /sw/source/uibase/shells/textsh1.cxx
parent8ea426bfa978d338683bf4c715d358187a527ccd (diff)
sw bibliography, local copy: add context menu
This way in case a bibliography entry (field) has both a URL and a LocalURL, it is possible to choose which one should be opened when the context menu is used on the field. This is meant to be the primary way the user consumes this information. Change-Id: I21b72505f8387943424665bff70905f774771d4a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119373 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/uibase/shells/textsh1.cxx')
-rw-r--r--sw/source/uibase/shells/textsh1.cxx41
1 files changed, 41 insertions, 0 deletions
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index ed5bc5a1b91e..0114119d1fc7 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -351,6 +351,30 @@ void InsertBreak(SwWrtShell& rWrtSh,
}
}
+OUString GetLocalURL(SwWrtShell& rSh)
+{
+ SwField* pField = rSh.GetCurField();
+ if (!pField)
+ {
+ return OUString();
+ }
+
+ if (pField->GetTyp()->Which() != SwFieldIds::TableOfAuthorities)
+ {
+ return OUString();
+ }
+
+ const auto& rAuthorityField = *static_cast<const SwAuthorityField*>(pField);
+ SwAuthEntry* pAuthEntry = rAuthorityField.GetAuthEntry();
+ if (!pAuthEntry)
+ {
+ return OUString();
+ }
+
+ const OUString& rLocalURL = pAuthEntry->GetAuthorField(AUTH_FIELD_LOCAL_URL);
+ return rLocalURL;
+}
+
}
void SwTextShell::Execute(SfxRequest &rReq)
@@ -1388,6 +1412,15 @@ void SwTextShell::Execute(SfxRequest &rReq)
}
}
break;
+ case FN_OPEN_LOCAL_URL:
+ {
+ OUString aLocalURL = GetLocalURL(rWrtSh);
+ if (!aLocalURL.isEmpty())
+ {
+ ::LoadURL(rWrtSh, aLocalURL, LoadUrlFlags::NewView, /*rTargetFrameName=*/OUString());
+ }
+ }
+ break;
case SID_OPEN_XML_FILTERSETTINGS:
{
HandleOpenXmlFilterSettings(rReq);
@@ -2033,6 +2066,14 @@ void SwTextShell::GetState( SfxItemSet &rSet )
rSet.DisableItem(nWhich);
}
break;
+ case FN_OPEN_LOCAL_URL:
+ {
+ if (GetLocalURL(rSh).isEmpty())
+ {
+ rSet.DisableItem(nWhich);
+ }
+ }
+ break;
case SID_OPEN_SMARTTAGMENU:
{
std::vector< OUString > aSmartTagTypes;