30 #include <com/sun/star/system/XSystemShellExecute.hpp>
31 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
32 #include <com/sun/star/system/SystemShellExecute.hpp>
44 void FixedHyperlink::Initialize()
47 m_aOldPointer = GetPointer();
52 SetControlFont( aFont );
56 m_nTextLen = GetOutDev()->GetCtrlTextWidth( GetText() );
58 SetClickHdl(
LINK(
this, FixedHyperlink, HandleClick));
61 bool FixedHyperlink::ImplIsOverText(Point aPosition)
const
63 Size aSize = GetOutputSizePixel();
67 if (GetStyle() & WB_RIGHT)
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;
84 void FixedHyperlink::MouseMove(
const MouseEvent& rMEvt )
87 if ( !rMEvt.
IsLeaveWindow() && IsEnabled() && ImplIsOverText(GetPointerPosPixel()) )
90 SetPointer( m_aOldPointer );
93 void FixedHyperlink::MouseButtonUp(
const MouseEvent& )
96 if ( IsEnabled() && ImplIsOverText(GetPointerPosPixel()) )
100 void FixedHyperlink::RequestHelp(
const HelpEvent& rHEvt )
102 if ( IsEnabled() && ImplIsOverText(GetPointerPosPixel()) )
106 void FixedHyperlink::GetFocus()
108 Size aSize = GetSizePixel();
110 if (GetStyle() & WB_RIGHT)
111 aFocusRect.Move(aSize.
Width() - aFocusRect.getWidth(), 0);
113 aFocusRect.Move((aSize.
Width() - aFocusRect.getWidth()) / 2, 0);
115 Invalidate(aFocusRect);
116 ShowFocus(aFocusRect);
119 void FixedHyperlink::LoseFocus()
121 SetTextColor( GetControlForeground() );
126 void FixedHyperlink::KeyInput(
const KeyEvent& rKEvt )
132 m_aClickHdl.Call( *
this );
140 void FixedHyperlink::SetURL(
const OUString& rNewURL )
143 SetQuickHelpText( m_sURL );
147 void FixedHyperlink::SetText(
const OUString& rNewDescription)
150 m_nTextLen = GetOutDev()->GetCtrlTextWidth(GetText());
153 bool FixedHyperlink::set_property(
const OString &rKey,
const OUString &rValue)
162 IMPL_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){});
#define LINK(Instance, Class, Member)
IMPL_LINK(FixedHyperlink, HandleClick, FixedHyperlink &, rHyperlink, void)
static const AllSettings & GetSettings()
Gets the application's settings.
sal_uInt16 GetCode() const
constexpr sal_uInt16 KEY_SPACE
constexpr tools::Long Width() const
Any SAL_CALL getCaughtException()
void SetUnderline(FontLineStyle)
bool IsLeaveWindow() const
virtual void SetText(const OUString &rStr) override
constexpr sal_uInt16 KEY_RETURN
virtual void KeyInput(const KeyEvent &rKEvt)
const vcl::KeyCode & GetKeyCode() const
constexpr tools::Long Height() const
Reference< XComponentContext > getProcessComponentContext()
virtual bool set_property(const OString &rKey, const OUString &rValue) override
virtual void RequestHelp(const HelpEvent &rHEvt)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
OUString anyToString(uno::Any const &value)