30#include <com/sun/star/system/XSystemShellExecute.hpp>
31#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
32#include <com/sun/star/system/SystemShellExecute.hpp>
44void FixedHyperlink::Initialize()
47 m_aOldPointer = GetPointer();
52 SetControlFont( aFont );
56 m_nTextLen = GetOutDev()->GetCtrlTextWidth( GetText() );
58 SetClickHdl(
LINK(
this, FixedHyperlink, HandleClick));
61bool FixedHyperlink::ImplIsOverText(
Point aPosition)
const
63 Size aSize = GetOutputSizePixel();
69 return aPosition.
X() > (aSize.
Width() - m_nTextLen);
73 bIsOver = aPosition.
X() > (aSize.
Width() / 2 - m_nTextLen / 2) &&
74 aPosition.
X() < (aSize.
Width() / 2 + m_nTextLen / 2);
78 bIsOver = aPosition.
X() < m_nTextLen;
84void FixedHyperlink::MouseMove(
const MouseEvent& rMEvt )
87 if ( !rMEvt.
IsLeaveWindow() && IsEnabled() && ImplIsOverText(GetPointerPosPixel()) )
90 SetPointer( m_aOldPointer );
93void FixedHyperlink::MouseButtonUp(
const MouseEvent& )
96 if ( IsEnabled() && ImplIsOverText(GetPointerPosPixel()) )
100void FixedHyperlink::RequestHelp(
const HelpEvent& rHEvt )
102 if ( IsEnabled() && ImplIsOverText(GetPointerPosPixel()) )
106void FixedHyperlink::GetFocus()
108 Size aSize = GetSizePixel();
111 aFocusRect.Move(aSize.
Width() - aFocusRect.getOpenWidth(), 0);
113 aFocusRect.Move((aSize.
Width() - aFocusRect.getOpenWidth()) / 2, 0);
115 Invalidate(aFocusRect);
116 ShowFocus(aFocusRect);
119void FixedHyperlink::LoseFocus()
121 SetTextColor( GetControlForeground() );
126void FixedHyperlink::KeyInput(
const KeyEvent& rKEvt )
132 m_aClickHdl.Call( *
this );
140void FixedHyperlink::SetURL(
const OUString& rNewURL )
143 SetQuickHelpText( m_sURL );
147void FixedHyperlink::SetText(
const OUString& rNewDescription)
150 m_nTextLen = GetOutDev()->GetCtrlTextWidth(GetText());
153bool FixedHyperlink::set_property(
const OUString &rKey,
const OUString &rValue)
162IMPL_LINK(FixedHyperlink, HandleClick, FixedHyperlink&, rHyperlink,
void)
164 if ( rHyperlink.m_sURL.isEmpty() )
169 uno::Reference< system::XSystemShellExecute > xSystemShellExecute(
172 xSystemShellExecute->execute( rHyperlink.m_sURL, OUString(), system::SystemShellExecuteFlags::URIS_ONLY );
174 catch (
const uno::Exception& )
179 std::shared_ptr<weld::MessageDialog> xErrorBox(
181 xErrorBox->set_title(rHyperlink.GetText());
182 xErrorBox->runAsync(xErrorBox, [](sal_Int32){});
static const AllSettings & GetSettings()
Gets the application's settings.
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
virtual void SetText(const OUString &rStr) override
virtual bool set_property(const OUString &rKey, const OUString &rValue) override
const vcl::KeyCode & GetKeyCode() const
bool IsLeaveWindow() const
constexpr tools::Long X() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void SetUnderline(FontLineStyle)
sal_uInt16 GetCode() const
virtual void RequestHelp(const HelpEvent &rHEvt)
virtual void KeyInput(const KeyEvent &rKEvt)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
IMPL_LINK(FixedHyperlink, HandleClick, FixedHyperlink &, rHyperlink, void)
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_SPACE
#define LINK(Instance, Class, Member)
OUString anyToString(uno::Any const &value)
Reference< XComponentContext > getProcessComponentContext()
Any SAL_CALL getCaughtException()