summaryrefslogtreecommitdiff
path: root/cui/source/dialogs
diff options
context:
space:
mode:
authorHeiko Tietze <tietze.heiko@gmail.com>2020-10-20 12:11:20 +0200
committerHeiko Tietze <heiko.tietze@documentfoundation.org>2020-10-22 11:50:39 +0200
commit31763e5af060f598c1699662adefe43f13d4db0e (patch)
treecda24c437ad2223cf90fc138090236e7226f289c /cui/source/dialogs
parentfe2b4e7dc6533535736a8f08496f316427386179 (diff)
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.kaganski@collabora.com> Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Diffstat (limited to 'cui/source/dialogs')
-rw-r--r--cui/source/dialogs/tipofthedaydlg.cxx48
1 files changed, 44 insertions, 4 deletions
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"))
{