22#include <com/sun/star/util/XURLTransformer.hpp>
23#include <com/sun/star/frame/XDispatch.hpp>
24#include <com/sun/star/lang/DisposedException.hpp>
25#include <com/sun/star/frame/status/ItemStatus.hpp>
26#include <com/sun/star/frame/status/Visibility.hpp>
27#include <com/sun/star/frame/ControlCommand.hpp>
43using namespace ::com::sun::star::frame::status;
52 return (
aURL.GetProtocol() == INetProtocol::Uno ) &&
53 (
aURL.GetURLPath().indexOf(
'.' ) != -1);
60 OUString aEnumCommand;
61 OUString aURLPath =
aURL.GetURLPath();
62 sal_Int32
nIndex = aURLPath.indexOf(
'.' );
64 aEnumCommand = aURLPath.copy(
nIndex+1 );
71 OUString aMasterCommand( rCommand );
73 if (
aURL.GetProtocol() == INetProtocol::Uno )
75 sal_Int32
nIndex =
aURL.GetURLPath().indexOf(
'.' );
82 return aMasterCommand;
86 const Reference< XFrame >& rFrame,
90 svt::ToolboxController( rxContext, rFrame,
aCommand )
91 , m_xToolbar( pToolbar )
94 , m_bMirrored( false )
95 , m_bMadeInvisible( false )
104 m_bInitialized =
true;
107GenericToolbarController::GenericToolbarController(
const Reference< XComponentContext >& rxContext,
108 const Reference< XFrame >& rFrame,
113 m_pToolbar = &rToolbar;
116GenericToolbarController::~GenericToolbarController()
120void SAL_CALL GenericToolbarController::dispose()
126 m_pToolbar =
nullptr;
131void SAL_CALL GenericToolbarController::execute( sal_Int16 KeyModifier )
134 OUString aCommandURL;
140 throw DisposedException();
142 if ( m_bInitialized &&
144 !m_aCommandURL.isEmpty() )
146 aCommandURL = m_aCommandURL;
147 URLToDispatchMap::iterator pIter = m_aListenerMap.find( m_aCommandURL );
148 if ( pIter != m_aListenerMap.end() )
166 aTargetURL.Complete = sRealCommand.isEmpty() ? aCommandURL : sRealCommand;
167 if ( m_xUrlTransformer.is() )
174 pExecuteInfo->
aArgs = aArgs;
178void GenericToolbarController::statusChanged(
const FeatureStateEvent& Event )
187 m_pToolbar->set_item_sensitive(m_aCommandURL, Event.IsEnabled);
193 if ( Event.State >>= bValue )
196 m_pToolbar->set_item_active(m_aCommandURL, bValue);
198 else if ( Event.State >>= aStrValue )
200 m_pToolbar->set_item_label(m_aCommandURL, aStrValue);
202 else if ( aImageItem.
PutValue( Event.State, 0 ) && aImageItem.
IsMirrored() != m_bMirrored )
204 m_pToolbar->set_item_image_mirrored(m_aCommandURL, aImageItem.
IsMirrored());
206 m_pToolbar->set_item_image(m_aCommandURL, xGraphic);
207 m_bMirrored = !m_bMirrored;
210 m_pToolbar->set_item_active(m_aCommandURL,
false);
218 m_xToolbar->EnableItem( m_nID, Event.IsEnabled );
226 ItemStatus aItemState;
228 ControlCommand aControlCommand;
231 if (( Event.State >>= bValue ) && !m_bEnumCommand )
234 if ( m_bMadeInvisible )
235 m_xToolbar->ShowItem( m_nID );
236 m_xToolbar->CheckItem( m_nID, bValue );
239 nItemBits |= ToolBoxItemBits::CHECKABLE;
241 else if ( Event.State >>= aStrValue )
243 if ( m_bEnumCommand )
245 bValue = aStrValue == m_aEnumCommand;
247 m_xToolbar->CheckItem( m_nID, bValue );
250 nItemBits |= ToolBoxItemBits::CHECKABLE;
255 if ( aStrValue.startsWith(
"($1)") )
257 aStrValue =
FwkResId(STR_UPDATEDOC) +
" " + aStrValue.subView( 4 );
259 else if ( aStrValue.startsWith(
"($2)") )
261 aStrValue =
FwkResId(STR_CLOSEDOC_ANDRETURN) + aStrValue.subView( 4 );
263 else if ( aStrValue.startsWith(
"($3)") )
265 aStrValue =
FwkResId(STR_SAVECOPYDOC) + aStrValue.subView( 4 );
267 m_xToolbar->SetItemText( m_nID, aStrValue );
269 m_xToolbar->SetQuickHelpText(m_nID, aStrValue.replaceFirst(
"~",
""));
272 if ( m_bMadeInvisible )
273 m_xToolbar->ShowItem( m_nID );
275 else if (( Event.State >>= aItemState ) && !m_bEnumCommand )
278 nItemBits |= ToolBoxItemBits::CHECKABLE;
279 if ( m_bMadeInvisible )
280 m_xToolbar->ShowItem( m_nID );
282 else if ( Event.State >>= aItemVisibility )
284 m_xToolbar->ShowItem( m_nID, aItemVisibility.bVisible );
285 m_bMadeInvisible = !aItemVisibility.bVisible;
287 else if ( Event.State >>= aControlCommand )
289 if (aControlCommand.Command ==
"SetQuickHelpText")
291 for ( NamedValue
const & rArg : std::as_const(aControlCommand.Arguments) )
293 if (rArg.Name ==
"HelpText")
296 rArg.Value >>= aHelpText;
297 m_xToolbar->SetQuickHelpText(m_nID, aHelpText);
302 if ( m_bMadeInvisible )
303 m_xToolbar->ShowItem( m_nID );
305 else if ( aImageItem.
PutValue( Event.State, 0 ) && aImageItem.
IsMirrored() != m_bMirrored )
307 m_xToolbar->SetItemImageMirrorMode( m_nID, aImageItem.
IsMirrored() );
309 m_xToolbar->SetItemImage( m_nID, aImage );
310 m_bMirrored = !m_bMirrored;
311 if ( m_bMadeInvisible )
312 m_xToolbar->ShowItem( m_nID );
314 else if ( m_bMadeInvisible )
315 m_xToolbar->ShowItem( m_nID );
317 m_xToolbar->SetItemState( m_nID, eTri );
318 m_xToolbar->SetItemBits( m_nID, nItemBits );
323 ExecuteInfo* pExecuteInfo =
static_cast<ExecuteInfo*
>(
p);
330 pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs );
339ImageOrientationController::ImageOrientationController(
const Reference<XComponentContext>& rContext,
340 const Reference<XFrame>& rFrame,
341 const Reference<css::awt::XWindow>& rParentWindow,
342 const OUString& rModuleName)
343 : ToolboxController(rContext, rFrame,
".uno:ImageOrientation")
344 , m_nRotationAngle(0_deg10)
356 ToolboxController::dispose();
364 if (
m_bDisposed || rWindowEvent.GetId() != VclEventId::ToolboxItemAdded)
367 ToolBox* pToolBox =
static_cast<ToolBox*
>(rWindowEvent.GetWindow());
380 throw DisposedException();
408 for (ToolBox::ImplToolItems::size_type
i = 0;
i < pToolBox->
GetItemCount(); ++
i)
412 bool bModified =
false;
PropertiesInfo aProperties
css::uno::Reference< css::lang::XComponent > m_xFrame
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
Degree10 GetRotation() const
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
void SAL_CALL statusChanged(const css::frame::FeatureStateEvent &rEvent) override
void SAL_CALL dispose() override
Degree10 m_nRotationAngle
void AddEventListener(const Link< VclWindowEvent &, void > &rEventListener)
Reference< XDispatch > xDispatch
OUString FwkResId(TranslateId aId)
#define LINK(Instance, Class, Member)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
static OUString getEnumCommand(std::u16string_view rCommand)
IMPL_STATIC_LINK(GenericToolbarController, ExecuteHdl_Impl, void *, p, void)
IMPL_LINK(WindowCommandDispatch, impl_notifyCommand, VclWindowEvent &, rEvent, void)
static bool isEnumCommand(std::u16string_view rCommand)
static OUString getMasterCommand(const OUString &rCommand)
Sequence< beans::PropertyValue > GetCommandProperties(const OUString &rsCommandName, const OUString &rsModuleName)
bool IsRotated(const OUString &rsCommandName, const OUString &rsModuleName)
OUString GetRealCommandForCommand(const css::uno::Sequence< css::beans::PropertyValue > &rProperties)
Reference< graphic::XGraphic > GetXGraphicForCommand(const OUString &rsCommandName, const Reference< frame::XFrame > &rxFrame, vcl::ImageType eImageType)
OUString GetModuleIdentifier(const Reference< frame::XFrame > &rxFrame)
Image GetImageForCommand(const OUString &rsCommandName, const Reference< frame::XFrame > &rxFrame, vcl::ImageType eImageType)
bool IsMirrored(const OUString &rsCommandName, const OUString &rsModuleName)