cui/inc/tipoftheday.hrc | 1 cui/source/dialogs/tipofthedaydlg.cxx | 48 +++++++++- framework/uiconfig/startmodule/menubar/menubar.xml | 1 officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu | 3 4 files changed, 48 insertions(+), 5 deletions(-)
New commits: commit 31763e5af060f598c1699662adefe43f13d4db0e Author: Heiko Tietze <tietze.he...@gmail.com> AuthorDate: Tue Oct 20 12:11:20 2020 +0200 Commit: Heiko Tietze <heiko.tie...@documentfoundation.org> CommitDate: Thu Oct 22 11:50:39 2020 +0200 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 <mike.kagan...@collabora.com> Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org> 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 <tipofthedaydlg.hxx> #include <tipoftheday.hrc> +#include <sfx2/viewfrm.hxx> +#include <vcl/commandinfoprovider.hxx> #include <vcl/graphicfilter.hxx> #include <vcl/help.hxx> #include <vcl/virdev.hxx> #include <vcl/svapp.hxx> +#include <com/sun/star/frame/XDesktop2.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/util/URLTransformer.hpp> + #include <comphelper/dispatchcommand.hxx> #include <comphelper/propertysequence.hxx> #include <dialmgr.hxx> @@ -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<css::frame::XDispatchProvider> xDispatchProvider( + xFrame, css::uno::UNO_QUERY); + if (xDispatchProvider.is()) + { + css::util::URL aCommandURL; + aCommandURL.Complete = sLink; + const css::uno::Reference<css::uno::XComponentContext> xContext + = comphelper::getProcessComponentContext(); + const css::uno::Reference<css::util::XURLTransformer> xParser + = css::util::URLTransformer::create(xContext); + xParser->parseStrict(aCommandURL); + const css::uno::Reference<css::frame::XDispatch> 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 @@ <menu:menuitem menu:id=".uno:HelpIndex"/> <menu:menuitem menu:id=".uno:ExtendedHelp"/> <menu:menuitem menu:id=".uno:Documentation"/> - <menu:menuitem menu:id=".uno:TipOfTheDay"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:QuestionAnswers"/> <menu:menuitem menu:id=".uno:SendFeedback"/> 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 @@ <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">User ~Interface...</value> </prop> + <prop oor:name="TooltipLabel" oor:type="xs:string"> + <value xml:lang="en-US">Shows a dialog to select the user interface</value> + </prop> <prop oor:name="Properties" oor:type="xs:int"> <value>1</value> </prop> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits