summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-10-20 10:49:24 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-10-20 12:48:43 +0200
commitf0006e79c4112b06b65c098722729b9a3f3301c7 (patch)
treeac7dcac47f7c8da208484f91c55a1abc11b742be
parent168463ed0537a5a9737aa5226657af1e263d0036 (diff)
Handle link click directly in FixedHyperlink
Change-Id: I5b5f0648b6e6432b0928351a17d285df8c9da811
-rw-r--r--cui/source/dialogs/SpellDialog.cxx28
-rw-r--r--cui/source/inc/SpellDialog.hxx1
-rw-r--r--cui/source/inc/optlingu.hxx2
-rw-r--r--cui/source/options/optlingu.cxx54
-rw-r--r--desktop/source/deployment/gui/dp_gui_dialog2.cxx18
-rw-r--r--desktop/source/deployment/gui/dp_gui_dialog2.hxx2
-rw-r--r--desktop/source/deployment/gui/dp_gui_extlistbox.cxx3
-rw-r--r--desktop/source/deployment/gui/dp_gui_extlistbox.hxx3
-rw-r--r--desktop/source/deployment/gui/dp_gui_updatedialog.cxx24
-rw-r--r--desktop/source/deployment/gui/dp_gui_updatedialog.hxx1
-rw-r--r--include/vcl/fixedhyper.hxx2
-rw-r--r--svx/source/dialog/SafeModeDialog.cxx31
-rw-r--r--svx/source/dialog/SafeModeDialog.hxx1
-rw-r--r--vcl/source/control/fixedhyper.cxx35
14 files changed, 40 insertions, 165 deletions
diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx
index a08ec7546344..7d76879a1dec 100644
--- a/cui/source/dialogs/SpellDialog.cxx
+++ b/cui/source/dialogs/SpellDialog.cxx
@@ -39,8 +39,6 @@
#include <com/sun/star/lang/XServiceDisplayName.hpp>
#include <com/sun/star/linguistic2/SpellFailure.hpp>
#include <com/sun/star/frame/XStorable.hpp>
-#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
-#include <com/sun/star/system/SystemShellExecute.hpp>
#include <sfx2/app.hxx>
#include <vcl/help.hxx>
#include <vcl/graph.hxx>
@@ -308,8 +306,6 @@ void SpellDialog::Init_Impl()
m_pLanguageLB->SetSelectHdl(LINK( this, SpellDialog, LanguageSelectHdl ) );
- m_pExplainLink->SetClickHdl( LINK( this, SpellDialog, HandleHyperlink ) );
-
// initialize language ListBox
m_pLanguageLB->SetLanguageList( SvxLanguageListFlags::SPELL_USED, false, false, true );
@@ -2053,28 +2049,4 @@ void SentenceEditWindow_Impl::SetUndoEditMode(bool bSet)
pSpellDialog->m_pChangePB->Enable();
}
-IMPL_LINK( SpellDialog, HandleHyperlink, FixedHyperlink&, rHyperlink, void )
-{
- OUString sURL=rHyperlink.GetURL();
- OUString sTitle=GetText();
-
- if ( sURL.isEmpty() ) // Nothing to do, when the URL is empty
- return;
- try
- {
- uno::Reference< css::system::XSystemShellExecute > xSystemShellExecute(
- css::system::SystemShellExecute::create(::comphelper::getProcessComponentContext()) );
- xSystemShellExecute->execute( sURL, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY );
- }
- catch ( uno::Exception& )
- {
- uno::Any exc( ::cppu::getCaughtException() );
- OUString msg( ::comphelper::anyToString( exc ) );
- const SolarMutexGuard guard;
- ScopedVclPtrInstance< MessageDialog > aErrorBox(nullptr, msg);
- aErrorBox->SetText(sTitle);
- aErrorBox->Execute();
- }
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/inc/SpellDialog.hxx b/cui/source/inc/SpellDialog.hxx
index 0dc32c1b1888..b2687063259a 100644
--- a/cui/source/inc/SpellDialog.hxx
+++ b/cui/source/inc/SpellDialog.hxx
@@ -192,7 +192,6 @@ private:
DECL_LINK( AddToDictClickHdl, Button*, void );
DECL_LINK( LanguageSelectHdl, ListBox&, void );
DECL_LINK( DialogUndoHdl, SpellUndoAction_Impl&, void );
- DECL_LINK( HandleHyperlink, FixedHyperlink&, void );
DECL_LINK( InitHdl, void*, void );
diff --git a/cui/source/inc/optlingu.hxx b/cui/source/inc/optlingu.hxx
index 3742d5291996..e192d36f1c31 100644
--- a/cui/source/inc/optlingu.hxx
+++ b/cui/source/inc/optlingu.hxx
@@ -81,7 +81,6 @@ class SvxEditModulesDlg : public ModalDialog
DECL_LINK( LangSelectListBoxHdl_Impl, ListBox&, void );
DECL_LINK( BoxCheckButtonHdl_Impl2, SvLBoxButtonData*, void );
DECL_LINK( BoxCheckButtonHdl_Impl, SvTreeListBox*, void );
- DECL_LINK( OpenURLHdl_Impl, FixedHyperlink&, void );
void LangSelectHdl_Impl(ListBox*);
public:
@@ -143,7 +142,6 @@ private:
DECL_LINK( BoxDoubleClickHdl_Impl, SvTreeListBox*, bool );
DECL_LINK( BoxCheckButtonHdl_Impl, SvTreeListBox*, void );
DECL_LINK( PostDblClickHdl_Impl, void *, void);
- DECL_LINK( OpenURLHdl_Impl, FixedHyperlink&, void );
void UpdateModulesBox_Impl();
void UpdateDicBox_Impl();
diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx
index 1901cc60bdb5..2b374b136cbc 100644
--- a/cui/source/options/optlingu.cxx
+++ b/cui/source/options/optlingu.cxx
@@ -46,8 +46,6 @@
#include <com/sun/star/linguistic2/XDictionaryList.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/ucb/CommandAbortedException.hpp>
-#include <com/sun/star/system/SystemShellExecute.hpp>
-#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
#include <unotools/extendedsecurityoptions.hxx>
#include <svtools/treelistbox.hxx>
#include "svtools/treelistentry.hxx"
@@ -128,28 +126,6 @@ static sal_Int32 lcl_SeqGetEntryPos(
return i < nLen ? i : -1;
}
-static void lcl_OpenURL( const OUString& _sURL )
-{
- if ( !_sURL.isEmpty() )
- {
- OUString sURL = _sURL;
- localizeWebserviceURI(sURL);
- try
- {
- uno::Reference< uno::XComponentContext > xContext =
- ::comphelper::getProcessComponentContext();
- uno::Reference< css::system::XSystemShellExecute > xSystemShell(
- css::system::SystemShellExecute::create(xContext) );
- xSystemShell->execute( sURL, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY );
- }
- catch( const uno::Exception& e )
- {
- OSL_TRACE( "Caught exception: %s\n thread terminated.\n",
- OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
- }
- }
-}
-
bool KillFile_Impl( const OUString& rURL )
{
bool bRet = true;
@@ -1073,12 +1049,7 @@ SvxLinguTabPage::SvxLinguTabPage( vcl::Window* pParent, const SfxItemSet& rSet )
m_pLinguOptionsCLB->SetSelectHdl( LINK( this, SvxLinguTabPage, SelectHdl_Impl ));
m_pLinguOptionsCLB->SetDoubleClickHdl(LINK(this, SvxLinguTabPage, BoxDoubleClickHdl_Impl));
- if ( SvtExtendedSecurityOptions().GetOpenHyperlinkMode()
- != SvtExtendedSecurityOptions::OPEN_NEVER )
- {
- m_pMoreDictsLink->SetClickHdl( LINK( this, SvxLinguTabPage, OpenURLHdl_Impl ) );
- }
- else
+ if ( SvtExtendedSecurityOptions().GetOpenHyperlinkMode() == SvtExtendedSecurityOptions::OPEN_NEVER )
m_pMoreDictsLink->Hide();
xProp = LinguMgr::GetLinguPropertySet();
@@ -1513,13 +1484,6 @@ IMPL_LINK_NOARG(SvxLinguTabPage, PostDblClickHdl_Impl, void*, void)
}
-IMPL_LINK_NOARG(SvxLinguTabPage, OpenURLHdl_Impl, FixedHyperlink&, void)
-{
- OUString sURL( m_pMoreDictsLink->GetURL() );
- lcl_OpenURL( sURL );
-}
-
-
IMPL_LINK( SvxLinguTabPage, BoxCheckButtonHdl_Impl, SvTreeListBox *, pBox, void )
{
if (pBox == m_pLinguModulesCLB)
@@ -1832,15 +1796,8 @@ SvxEditModulesDlg::SvxEditModulesDlg(vcl::Window* pParent, SvxLinguData_Impl& rD
m_pPrioUpPB->Enable( false );
m_pPrioDownPB->Enable( false );
- if ( SvtExtendedSecurityOptions().GetOpenHyperlinkMode()
- != SvtExtendedSecurityOptions::OPEN_NEVER )
- {
- m_pMoreDictsLink->SetClickHdl( LINK( this, SvxEditModulesDlg, OpenURLHdl_Impl ) );
- }
- else
- {
+ if ( SvtExtendedSecurityOptions().GetOpenHyperlinkMode() == SvtExtendedSecurityOptions::OPEN_NEVER )
m_pMoreDictsLink->Hide();
- }
//fill language box
Sequence< sal_Int16 > aAvailLang;
@@ -2272,11 +2229,4 @@ IMPL_LINK_NOARG(SvxEditModulesDlg, BackHdl_Impl, Button*, void)
LangSelectHdl_Impl(nullptr);
}
-
-IMPL_LINK_NOARG(SvxEditModulesDlg, OpenURLHdl_Impl, FixedHyperlink&, void)
-{
- OUString sURL( m_pMoreDictsLink->GetURL() );
- lcl_OpenURL( sURL );
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
index c7530159e248..a2b7988d390c 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
@@ -636,6 +636,7 @@ void DialogHelper::openWebBrowser( const OUString & sURL, const OUString &sTitle
}
}
+
bool DialogHelper::installExtensionWarn( const OUString &rExtensionName ) const
{
const SolarMutexGuard guard;
@@ -700,12 +701,10 @@ ExtMgrDialog::ExtMgrDialog(vcl::Window *pParent, TheExtensionManager *pManager,
get(m_pCancelBtn, "cancel");
m_pExtensionBox->InitFromDialog(this);
- m_pExtensionBox->SetHyperlinkHdl( LINK( this, ExtMgrDialog, HandleHyperlink ) );
m_pAddBtn->SetClickHdl( LINK( this, ExtMgrDialog, HandleAddBtn ) );
m_pCloseBtn->SetClickHdl( LINK( this, ExtMgrDialog, HandleCloseBtn ) );
- m_pGetExtensions->SetClickHdl( LINK( this, ExtMgrDialog, HandleHyperlink ) );
m_pCancelBtn->SetClickHdl( LINK( this, ExtMgrDialog, HandleCancelBtn ) );
m_pBundledCbx->SetClickHdl( LINK( this, ExtMgrDialog, HandleExtTypeCbx ) );
@@ -1073,13 +1072,6 @@ IMPL_LINK_NOARG(ExtMgrDialog, HandleUpdateBtn, Button*, void)
#endif
}
-
-IMPL_LINK( ExtMgrDialog, HandleHyperlink, FixedHyperlink&, rHyperlink, void )
-{
- openWebBrowser( rHyperlink.GetURL(), GetText() );
-}
-
-
IMPL_LINK_NOARG(ExtMgrDialog, TimeOutHdl, Idle *, void)
{
if ( m_bStopProgress )
@@ -1199,8 +1191,6 @@ UpdateRequiredDialog::UpdateRequiredDialog(vcl::Window *pParent, TheExtensionMan
get(m_pProgressText, "progresslabel");
get(m_pProgressBar, "progress");
- m_pExtensionBox->SetHyperlinkHdl( LINK( this, UpdateRequiredDialog, HandleHyperlink ) );
-
m_pUpdateBtn->SetClickHdl( LINK( this, UpdateRequiredDialog, HandleUpdateBtn ) );
m_pCloseBtn->SetClickHdl( LINK( this, UpdateRequiredDialog, HandleCloseBtn ) );
m_pCancelBtn->SetClickHdl( LINK( this, UpdateRequiredDialog, HandleCancelBtn ) );
@@ -1414,12 +1404,6 @@ IMPL_LINK_NOARG(UpdateRequiredDialog, HandleCloseBtn, Button*, void)
}
-IMPL_LINK( UpdateRequiredDialog, HandleHyperlink, FixedHyperlink&, rHyperlink, void )
-{
- openWebBrowser( rHyperlink.GetURL(), GetText() );
-}
-
-
IMPL_LINK_NOARG(UpdateRequiredDialog, TimeOutHdl, Idle *, void)
{
if ( m_bStopProgress )
diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx b/desktop/source/deployment/gui/dp_gui_dialog2.hxx
index 39c406522c4f..fdd23d8255e8 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx
@@ -137,7 +137,6 @@ class ExtMgrDialog : public ModelessDialog,
DECL_LINK( HandleCancelBtn, Button*, void );
DECL_LINK( HandleCloseBtn, Button*, void );
DECL_LINK( HandleExtTypeCbx, Button*, void );
- DECL_LINK( HandleHyperlink, FixedHyperlink&, void );
DECL_LINK(TimeOutHdl, Idle *, void);
DECL_LINK( startProgress, void *, void );
DECL_STATIC_LINK( ExtMgrDialog, Restart, void *, void );
@@ -204,7 +203,6 @@ class UpdateRequiredDialog : public ModalDialog,
DECL_LINK( HandleCancelBtn, Button*, void );
DECL_LINK(TimeOutHdl, Idle *, void);
DECL_LINK( startProgress, void *, void );
- DECL_LINK( HandleHyperlink, FixedHyperlink&, void );
static bool isEnabled( const css::uno::Reference< css::deployment::XPackage > &xPackage );
static bool checkDependencies( const css::uno::Reference< css::deployment::XPackage > &xPackage );
diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
index 2eaef2913346..df198dc16115 100644
--- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
+++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
@@ -481,9 +481,6 @@ void ExtensionBox_Impl::DrawRow(vcl::RenderContext& rRenderContext, const Rectan
rEntry->m_pPublisher->SetText(rEntry->m_sPublisher);
Size aSize = FixedText::CalcMinimumTextSize(rEntry->m_pPublisher);
rEntry->m_pPublisher->SetSizePixel(aSize);
-
- if (m_aClickHdl.IsSet())
- rEntry->m_pPublisher->SetClickHdl( m_aClickHdl );
}
// Get max title width
diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx
index 403311fb5073..7543ad20761d 100644
--- a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx
+++ b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx
@@ -126,8 +126,6 @@ class ExtensionBox_Impl : public ::svt::IExtensionListBox
Image m_aWarningImage;
Image m_aDefaultImage;
- Link<FixedHyperlink&,void> m_aClickHdl;
-
VclPtr<ScrollBar> m_pScrollBar;
rtl::Reference<ExtensionRemovedListener> m_xRemoveListener;
@@ -185,7 +183,6 @@ public:
long PointToPos( const Point& rPos );
void SetScrollHdl( const Link<ScrollBar*,void>& rLink );
void DoScroll( long nDelta );
- void SetHyperlinkHdl( const Link<FixedHyperlink&,void>& rLink ){ m_aClickHdl = rLink; }
virtual void RecalcAll();
void RemoveUnlocked();
diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
index 85ae2a080748..cedfdbe7e504 100644
--- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
+++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
@@ -54,8 +54,6 @@
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/lang/XMultiComponentFactory.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
-#include <com/sun/star/system/SystemShellExecute.hpp>
#include <com/sun/star/task/InteractionHandler.hpp>
#include <com/sun/star/task/XAbortChannel.hpp>
#include <com/sun/star/task/XJob.hpp>
@@ -911,10 +909,6 @@ void UpdateDialog::initDescription()
m_pPublisherLink->Hide();
m_pReleaseNotesLabel->Hide();
m_pReleaseNotesLink->Hide();
-
- Link<FixedHyperlink&,void> aLink = LINK( this, UpdateDialog, hyperlink_clicked );
- m_pPublisherLink->SetClickHdl( aLink );
- m_pReleaseNotesLink->SetClickHdl( aLink );
}
void UpdateDialog::clearDescription()
@@ -1308,22 +1302,4 @@ IMPL_LINK_NOARG(UpdateDialog, closeHandler, Button*, void)
EndDialog();
}
-IMPL_LINK( UpdateDialog, hyperlink_clicked, FixedHyperlink&, rHyperlink, void )
-{
- OUString sURL = rHyperlink.GetURL();
- if ( sURL.isEmpty() )
- return;
-
- try
- {
- uno::Reference< css::system::XSystemShellExecute > xSystemShellExecute(
- css::system::SystemShellExecute::create(m_context) );
- //throws lang::IllegalArgumentException, system::SystemShellExecuteException
- xSystemShellExecute->execute( sURL, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY);
- }
- catch ( const uno::Exception& )
- {
- }
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx
index 2662a41beb11..96bb6450cfb3 100644
--- a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx
+++ b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx
@@ -163,7 +163,6 @@ private:
DECL_LINK(allHandler, CheckBox&, void);
DECL_LINK(okHandler, Button*, void);
DECL_LINK(closeHandler, Button*, void);
- DECL_LINK(hyperlink_clicked, FixedHyperlink&, void);
css::uno::Reference< css::uno::XComponentContext > m_context;
VclPtr<FixedText> m_pchecking;
diff --git a/include/vcl/fixedhyper.hxx b/include/vcl/fixedhyper.hxx
index d98343ca7b97..98b5e159e3bb 100644
--- a/include/vcl/fixedhyper.hxx
+++ b/include/vcl/fixedhyper.hxx
@@ -40,6 +40,8 @@ class VCL_DLLPUBLIC FixedHyperlink : public FixedText
/** is position X position hitting text */
SAL_DLLPRIVATE bool ImplIsOverText(Point rPosition);
+ DECL_LINK(HandleClick, FixedHyperlink&, void);
+
protected:
/** overwrites Window::MouseMove().
diff --git a/svx/source/dialog/SafeModeDialog.cxx b/svx/source/dialog/SafeModeDialog.cxx
index b0f6ebeb2bbb..ef97afb9b833 100644
--- a/svx/source/dialog/SafeModeDialog.cxx
+++ b/svx/source/dialog/SafeModeDialog.cxx
@@ -67,8 +67,6 @@ SafeModeDialog::SafeModeDialog(vcl::Window* pParent)
mpCBResetCustomizations->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
mpCBResetWholeUserProfile->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
- mpBugLink->SetClickHdl(LINK(this, SafeModeDialog, HandleHyperlink));
-
// Disable restart btn until some checkbox is active
mpBtnRestart->Disable();
@@ -167,30 +165,6 @@ void SafeModeDialog::applyChanges()
css::uno::Reference< css::task::XInteractionHandler >());
}
-void SafeModeDialog::openWebBrowser(const OUString & sURL, const OUString &sTitle)
-{
- if ( sURL.isEmpty() ) // Nothing to do, when the URL is empty
- return;
-
- try
- {
- uno::Reference< system::XSystemShellExecute > xSystemShellExecute(
- system::SystemShellExecute::create(comphelper::getProcessComponentContext()));
- //throws css::lang::IllegalArgumentException, css::system::SystemShellExecuteException
- xSystemShellExecute->execute( sURL, OUString(), system::SystemShellExecuteFlags::URIS_ONLY );
- }
- catch ( const uno::Exception& )
- {
- uno::Any exc(cppu::getCaughtException());
- OUString msg(comphelper::anyToString(exc));
- const SolarMutexGuard guard;
- ScopedVclPtrInstance< MessageDialog > aErrorBox(nullptr, msg);
- aErrorBox->SetText( sTitle );
- aErrorBox->Execute();
- }
-}
-
-
IMPL_LINK(SafeModeDialog, BtnHdl, Button*, pBtn, void)
{
if (pBtn == mpBtnContinue.get())
@@ -221,9 +195,4 @@ IMPL_LINK(SafeModeDialog, CheckBoxHdl, CheckBox&, /*pCheckBox*/, void)
mpBtnRestart->Enable(bEnable);
}
-IMPL_LINK( SafeModeDialog, HandleHyperlink, FixedHyperlink&, rHyperlink, void )
-{
- SafeModeDialog::openWebBrowser( rHyperlink.GetURL(), GetText() );
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/SafeModeDialog.hxx b/svx/source/dialog/SafeModeDialog.hxx
index 815cb1190a48..f385fc44faaa 100644
--- a/svx/source/dialog/SafeModeDialog.hxx
+++ b/svx/source/dialog/SafeModeDialog.hxx
@@ -52,7 +52,6 @@ private:
DECL_LINK(CheckBoxHdl, CheckBox&, void);
DECL_LINK(BtnHdl, Button*, void);
- DECL_LINK(HandleHyperlink, FixedHyperlink&, void);
};
#endif
diff --git a/vcl/source/control/fixedhyper.cxx b/vcl/source/control/fixedhyper.cxx
index 7f940dd203cb..51a12f661cf9 100644
--- a/vcl/source/control/fixedhyper.cxx
+++ b/vcl/source/control/fixedhyper.cxx
@@ -19,6 +19,16 @@
#include <vcl/fixedhyper.hxx>
#include <vcl/svapp.hxx>
+#include <vcl/layout.hxx>
+#include <comphelper/anytostring.hxx>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+
+#include <com/sun/star/system/XSystemShellExecute.hpp>
+#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
+#include <com/sun/star/system/SystemShellExecute.hpp>
+
+using namespace css;
FixedHyperlink::FixedHyperlink(vcl::Window* pParent, WinBits nWinStyle)
: FixedText(pParent, nWinStyle)
@@ -40,6 +50,8 @@ void FixedHyperlink::Initialize()
SetControlForeground( Application::GetSettings().GetStyleSettings().GetLinkColor() );
// calculates text len
m_nTextLen = GetCtrlTextWidth( GetText() );
+
+ SetClickHdl(LINK(this, FixedHyperlink, HandleClick));
}
bool FixedHyperlink::ImplIsOverText(Point aPosition)
@@ -137,4 +149,27 @@ bool FixedHyperlink::set_property(const OString &rKey, const OString &rValue)
return true;
}
+IMPL_LINK(FixedHyperlink, HandleClick, FixedHyperlink&, rHyperlink, void)
+{
+ if ( rHyperlink.m_sURL.isEmpty() ) // Nothing to do, when the URL is empty
+ return;
+
+ try
+ {
+ uno::Reference< system::XSystemShellExecute > xSystemShellExecute(
+ system::SystemShellExecute::create(comphelper::getProcessComponentContext()));
+ //throws css::lang::IllegalArgumentException, css::system::SystemShellExecuteException
+ xSystemShellExecute->execute( rHyperlink.m_sURL, OUString(), system::SystemShellExecuteFlags::URIS_ONLY );
+ }
+ catch ( const uno::Exception& )
+ {
+ uno::Any exc(cppu::getCaughtException());
+ OUString msg(comphelper::anyToString(exc));
+ const SolarMutexGuard guard;
+ ScopedVclPtrInstance< MessageDialog > aErrorBox(nullptr, msg);
+ aErrorBox->SetText( rHyperlink.GetText() );
+ aErrorBox->Execute();
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */