From 663fd49286f67d1bbb7fcccc6672ba7f11401ace Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Thu, 14 Nov 2013 19:06:16 +0100 Subject: startcenter: Make the Help and Extensions button work. Change-Id: I9017dd830c44f642f7d4821345f3831c9031ff9f --- sfx2/source/dialog/backingwindow.cxx | 56 +++++++++++++++++++++++++++++++++--- sfx2/source/dialog/backingwindow.hxx | 5 ++-- 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx index fa4943bd7e2f..31d399e27831 100644 --- a/sfx2/source/dialog/backingwindow.cxx +++ b/sfx2/source/dialog/backingwindow.cxx @@ -25,18 +25,21 @@ #include #include #include +#include #include #include #include +#include +#include #include #include #include #include -#include -#include +#include +#include #include #include @@ -141,6 +144,9 @@ BackingWindow::BackingWindow( Window* i_pParent ) : mpDBAllButton->SetHelpId( ".HelpId:StartCenter:DBButton" ); mpMathAllButton->SetHelpId( ".HelpId:StartCenter:MathButton" ); + mpHelpButton->SetHelpId(".HelpId:StartCenter:Info"); + mpExtensionsButton->SetHelpId(".HelpId:StartCenter:Extensions"); + // init background SetBackground(); } @@ -216,8 +222,6 @@ void BackingWindow::initControls() setupButton( mpOpenButton ); setupButton( mpTemplateButton ); - mpCreateLabel->SetControlForeground(aButtonsText); - setupButton( mpWriterAllButton ); setupButton( mpDrawAllButton ); setupButton( mpCalcAllButton ); @@ -225,6 +229,12 @@ void BackingWindow::initControls() setupButton( mpImpressAllButton ); setupButton( mpMathAllButton ); + mpHelpButton->SetClickHdl(LINK(this, BackingWindow, ExtLinkClickHdl)); + mpExtensionsButton->SetClickHdl(LINK(this, BackingWindow, ExtLinkClickHdl)); + + // setup nice colors + mpCreateLabel->SetControlForeground(aButtonsText); + mpHelpButton->SetControlForeground(aButtonsText); mpExtensionsButton->SetControlForeground(aButtonsText); @@ -340,6 +350,44 @@ void BackingWindow::Resize() Invalidate(); } +IMPL_LINK(BackingWindow, ExtLinkClickHdl, Button*, pButton) +{ + OUString aNode; + + if (pButton == mpExtensionsButton) + aNode = "AddFeatureURL"; + else if (pButton == mpHelpButton) + aNode = "InfoURL"; + + if (!aNode.isEmpty()) + { + try + { + Sequence args(1); + PropertyValue val("nodepath", 0, Any(OUString("/org.openoffice.Office.Common/Help/StartCenter")), PropertyState_DIRECT_VALUE); + args.getArray()[0] <<= val; + + Reference xConfig = configuration::theDefaultProvider::get( comphelper::getProcessComponentContext() ); + Reference xNameAccess(xConfig->createInstanceWithArguments(SERVICENAME_CFGREADACCESS, args), UNO_QUERY); + if (xNameAccess.is()) + { + OUString sURL; + Any value(xNameAccess->getByName(aNode)); + + sURL = value.get(); + localizeWebserviceURI(sURL); + + Reference xSystemShellExecute(system::SystemShellExecute::create(comphelper::getProcessComponentContext())); + xSystemShellExecute->execute(sURL, OUString(), com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY); + } + } + catch (const Exception&) + { + } + } + return 0; +} + IMPL_LINK( BackingWindow, ClickHdl, Button*, pButton ) { // dispatch the appropriate URL and end the dialog diff --git a/sfx2/source/dialog/backingwindow.hxx b/sfx2/source/dialog/backingwindow.hxx index 725823f11f16..8afb203ba3ea 100644 --- a/sfx2/source/dialog/backingwindow.hxx +++ b/sfx2/source/dialog/backingwindow.hxx @@ -95,8 +95,9 @@ class BackingWindow const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& = com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >() ); - DECL_LINK( ClickHdl, Button* ); - DECL_LINK( OpenTemplateHdl, ThumbnailViewItem* ); + DECL_LINK(ClickHdl, Button*); + DECL_LINK(ExtLinkClickHdl, Button*); + DECL_LINK(OpenTemplateHdl, ThumbnailViewItem*); void initControls(); -- cgit