From 31763e5af060f598c1699662adefe43f13d4db0e Mon Sep 17 00:00:00 2001 From: Heiko Tietze Date: Tue, 20 Oct 2020 12:11:20 +0200 Subject: [PATCH] Resolves tdf#137607 and tdf#137500 - Improvements to TotD Shows tooltip for UNO commands Check if the UNO command is available in the current module Don't show the menu entry on the start center Change-Id: I5c67ec3f8543b5442a6e2c2a478bfeb4ec0e1f3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104558 Tested-by: Jenkins Reviewed-by: Mike Kaganski Reviewed-by: Heiko Tietze --- cui/inc/tipoftheday.hrc | 1 + cui/source/dialogs/tipofthedaydlg.cxx | 48 +++++++++++++++++-- .../uiconfig/startmodule/menubar/menubar.xml | 1 - .../openoffice/Office/UI/GenericCommands.xcu | 3 ++ 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/cui/inc/tipoftheday.hrc b/cui/inc/tipoftheday.hrc index 33b551ecc2fc..e78d4aaa019d 100644 --- a/cui/inc/tipoftheday.hrc +++ b/cui/inc/tipoftheday.hrc @@ -32,6 +32,7 @@ * uri: * if uri is empty, do not show any link * if uri starts with "http", show the link directly in the browser + * if uri starts with ".uno:", run the command if available in the current module * all other strings are converted to a link for the offline help * to find the right uri, look in instdir/help/hid2file.js after building --with-help=html * structure of hid2file.js 'uri' : 'rest of URL' (that starts: https://help.libreoffice.org/latest/en-US/) diff --git a/cui/source/dialogs/tipofthedaydlg.cxx b/cui/source/dialogs/tipofthedaydlg.cxx index 88b61a8d0b2b..beed468ba5b6 100644 --- a/cui/source/dialogs/tipofthedaydlg.cxx +++ b/cui/source/dialogs/tipofthedaydlg.cxx @@ -21,11 +21,19 @@ #include #include +#include +#include #include #include #include #include +#include +#include +#include +#include +#include + #include #include #include @@ -105,10 +113,42 @@ void TipOfTheDayDialog::UpdateTip() } else if (sLink.startsWith(".uno:")) { - m_pLink->set_uri(sLink); - m_pLink->set_label(CuiResId(STR_UNO_LINK)); - m_pLink->set_visible(true); - m_pLink->connect_activate_link(LINK(this, TipOfTheDayDialog, OnLinkClick)); + m_pLink->set_visible(false); + //show the link only if the UNO command is available in the current module + SfxViewFrame* pViewFrame = SfxViewFrame::Current(); + if (pViewFrame) + { + const auto xFrame = pViewFrame->GetFrame().GetFrameInterface(); + const css::uno::Reference xDispatchProvider( + xFrame, css::uno::UNO_QUERY); + if (xDispatchProvider.is()) + { + css::util::URL aCommandURL; + aCommandURL.Complete = sLink; + const css::uno::Reference xContext + = comphelper::getProcessComponentContext(); + const css::uno::Reference xParser + = css::util::URLTransformer::create(xContext); + xParser->parseStrict(aCommandURL); + const css::uno::Reference xDisp + = xDispatchProvider->queryDispatch(aCommandURL, OUString(), 0); + if (xDisp.is()) + { + m_pLink->set_label(CuiResId(STR_UNO_LINK)); + m_pLink->set_uri(sLink); + + const OUString aModuleName( + vcl::CommandInfoProvider::GetModuleIdentifier(xFrame)); + const auto aProperties + = vcl::CommandInfoProvider::GetCommandProperties(sLink, aModuleName); + m_pLink->set_tooltip_text( + vcl::CommandInfoProvider::GetTooltipForCommand(sLink, aProperties, xFrame)); + + m_pLink->set_visible(true); + m_pLink->connect_activate_link(LINK(this, TipOfTheDayDialog, OnLinkClick)); + } + } + } } else if (sLink.startsWith("http")) { diff --git a/framework/uiconfig/startmodule/menubar/menubar.xml b/framework/uiconfig/startmodule/menubar/menubar.xml index eb0532080155..96ac15d10f81 100644 --- a/framework/uiconfig/startmodule/menubar/menubar.xml +++ b/framework/uiconfig/startmodule/menubar/menubar.xml @@ -61,7 +61,6 @@ - diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index 240a86d8487e..d7e9837838ad 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -6233,6 +6233,9 @@ User ~Interface... + + Shows a dialog to select the user interface + 1