27#include <com/sun/star/frame/XLayoutManager.hpp>
28#include <com/sun/star/frame/theStatusbarControllerFactory.hpp>
29#include <com/sun/star/ui/ItemStyle.hpp>
30#include <com/sun/star/ui/ItemType.hpp>
31#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
32#include <com/sun/star/lang/XMultiServiceFactory.hpp>
33#include <com/sun/star/beans/XPropertySet.hpp>
34#include <com/sun/star/awt/Command.hpp>
35#include <com/sun/star/ui/XStatusbarItem.hpp>
61struct lcl_UpdateController
63 void operator()(
typename MAP::value_type &rElement )
const
67 if ( rElement.second.is() )
68 rElement.second->update();
70 catch ( uno::Exception& )
77struct lcl_RemoveController
79 void operator()(
typename MAP::value_type &rElement )
const
83 if ( rElement.second.is() )
84 rElement.second->dispose();
86 catch ( uno::Exception& )
96 if (( nStyle & css::ui::ItemStyle::ALIGN_RIGHT ) == css::ui::ItemStyle::ALIGN_RIGHT )
97 nItemBits |= StatusBarItemBits::Right;
98 else if ( nStyle & css::ui::ItemStyle::ALIGN_LEFT )
99 nItemBits |= StatusBarItemBits::Left;
101 nItemBits |= StatusBarItemBits::Center;
103 if (( nStyle & css::ui::ItemStyle::DRAW_FLAT ) == css::ui::ItemStyle::DRAW_FLAT )
104 nItemBits |= StatusBarItemBits::Flat;
105 else if ( nStyle & css::ui::ItemStyle::DRAW_OUT3D )
106 nItemBits |= StatusBarItemBits::Out;
108 nItemBits |= StatusBarItemBits::In;
110 if (( nStyle & css::ui::ItemStyle::AUTO_SIZE ) == css::ui::ItemStyle::AUTO_SIZE )
111 nItemBits |= StatusBarItemBits::AutoSize;
112 if ( nStyle & css::ui::ItemStyle::OWNER_DRAW )
113 nItemBits |= StatusBarItemBits::UserDraw;
115 if ( nStyle & css::ui::ItemStyle::MANDATORY )
116 nItemBits |= StatusBarItemBits::Mandatory;
124 uno::Reference< uno::XComponentContext > xContext,
125 uno::Reference< frame::XFrame > rFrame,
128 m_bFrameActionRegistered( false ),
129 m_bUpdateControllers( false ),
130 m_pStatusBar( pStatusBar ),
136 ::comphelper::getProcessComponentContext());
156 if (
Action.
Action == frame::FrameAction_CONTEXT_CHANGED )
169 if (
Source.Source == uno::Reference< uno::XInterface >(
m_xFrame, uno::UNO_QUERY ))
178 uno::Reference< lang::XComponent > xThis(
this );
181 lang::EventObject
aEvent( xThis );
182 std::unique_lock aGuard(
m_mutex);
206 m_xFrame->removeFrameActionListener( uno::Reference< frame::XFrameActionListener >(
this) );
208 catch (
const uno::Exception& )
226 throw lang::DisposedException();
228 std::unique_lock aGuard(
m_mutex);
234 std::unique_lock aGuard(
m_mutex);
270 lcl_UpdateController< StatusBarControllerMap >() );
282 lcl_RemoveController< StatusBarControllerMap >() );
298 uno::Reference< frame::XStatusbarController >
xController;
302 beans::PropertyValue aPropValue;
303 std::vector< uno::Any > aPropVector;
305 aPropValue.Name =
"CommandURL";
306 aPropValue.Value <<= aCommandURL;
307 aPropVector.push_back(
uno::Any( aPropValue ) );
309 aPropValue.Name =
"ModuleIdentifier";
310 aPropValue.Value <<= OUString();
311 aPropVector.push_back(
uno::Any( aPropValue ) );
313 aPropValue.Name =
"Frame";
315 aPropVector.push_back(
uno::Any( aPropValue ) );
318 aPropValue.Name =
"ServiceManager";
319 aPropValue.Value <<= uno::Reference<lang::XMultiServiceFactory>(
m_xContext->getServiceManager(), uno::UNO_QUERY_THROW);
320 aPropVector.push_back(
uno::Any( aPropValue ) );
322 aPropValue.Name =
"ParentWindow";
323 aPropValue.Value <<= xStatusbarWindow;
324 aPropVector.push_back(
uno::Any( aPropValue ) );
327 aPropValue.Name =
"Identifier";
328 aPropValue.Value <<=
nId;
329 aPropVector.push_back(
uno::Any( aPropValue ) );
331 aPropValue.Name =
"StatusbarItem";
332 aPropValue.Value <<= xStatusbarItem;
333 aPropVector.push_back(
uno::Any( aPropValue ) );
380 m_xFrame->addFrameActionListener( uno::Reference< frame::XFrameActionListener >(
this) );
399 for ( sal_Int32
n = 0;
n < rItemContainer->getCount();
n++ )
401 uno::Sequence< beans::PropertyValue > aProps;
402 OUString aCommandURL;
403 sal_Int16 nOffset( 0 );
404 sal_Int16 nStyle( 0 );
405 sal_Int16 nWidth( 0 );
406 sal_uInt16
nType( css::ui::ItemType::DEFAULT );
410 if ( rItemContainer->getByIndex(
n ) >>= aProps )
412 for ( beans::PropertyValue
const & prop : std::as_const(aProps) )
414 if ( prop.Name ==
"CommandURL" )
416 prop.Value >>= aCommandURL;
418 else if ( prop.Name ==
"Style" )
420 prop.Value >>= nStyle;
422 else if ( prop.Name ==
"Type" )
424 prop.Value >>=
nType;
426 else if ( prop.Name ==
"Width" )
428 prop.Value >>= nWidth;
430 else if ( prop.Name ==
"Offset" )
432 prop.Value >>= nOffset;
436 if ((
nType == css::ui::ItemType::DEFAULT ) && !aCommandURL.isEmpty() )
449 catch (
const css::lang::IndexOutOfBoundsException& )
456 constexpr sal_uInt16 STATUSBAR_ITEM_STARTID = 1000;
458 if ( !aMergeInstructions.empty() )
460 const sal_uInt32
nCount = aMergeInstructions.size();
461 sal_uInt16 nItemId( STATUSBAR_ITEM_STARTID );
463 for ( sal_uInt32
i = 0;
i <
nCount;
i++ )
504 if ((( rDCEvt.
GetType() == DataChangedEventType::SETTINGS ) ||
505 ( rDCEvt.
GetType() == DataChangedEventType::FONTS ) ||
506 ( rDCEvt.
GetType() == DataChangedEventType::FONTSUBSTITUTION ) ||
507 ( rDCEvt.
GetType() == DataChangedEventType::DISPLAY )) &&
508 ( rDCEvt.
GetFlags() & AllSettingsFlags::STYLE ))
510 css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
511 css::uno::Reference< css::beans::XPropertySet > xPropSet(
m_xFrame, css::uno::UNO_QUERY );
513 xPropSet->getPropertyValue(
"LayoutManager") >>= xLayoutManager;
514 if ( xLayoutManager.is() )
517 xLayoutManager->doLayout();
534 uno::Reference< frame::XStatusbarController >
xController( it->second );
555 if ( rEvt.
GetCommand() != CommandEventId::ContextMenu )
562 uno::Reference< frame::XStatusbarController >
xController( it->second );
575 MouseButton(rMEvt,&frame::XStatusbarController::mouseMove);
590 uno::Reference< frame::XStatusbarController >
xController( it->second );
593 css::awt::MouseEvent aMouseEvent;
597 aMouseEvent.ClickCount = rMEvt.
GetClicks();
604 MouseButton(rMEvt,&frame::XStatusbarController::mouseButtonDown);
609 MouseButton(rMEvt,&frame::XStatusbarController::mouseButtonUp);
619 sal_uInt16
nId = m_pStatusBar->GetCurItemId();
620 StatusBarControllerMap::const_iterator it = m_aControllerMap.find(
nId );
621 if ((
nId > 0 ) && ( it != m_aControllerMap.end() ))
623 uno::Reference< frame::XStatusbarController >
xController( it->second );
626 const Point aVCLPos = m_pStatusBar->GetPointerPosPixel();
627 const awt::Point aAWTPoint( aVCLPos.
X(), aVCLPos.
Y() );
640 sal_uInt16
nId = m_pStatusBar->GetCurItemId();
641 StatusBarControllerMap::const_iterator it = m_aControllerMap.find(
nId );
642 if ((
nId > 0 ) && ( it != m_aControllerMap.end() ))
644 uno::Reference< frame::XStatusbarController >
xController( it->second );
647 const Point aVCLPos = m_pStatusBar->GetPointerPosPixel();
648 const awt::Point aAWTPoint( aVCLPos.
X(), aVCLPos.
Y() );
PropertiesInfo aProperties
css::uno::Reference< css::lang::XComponent > m_xFrame
CommandEventId GetCommand() const
const Point & GetMousePosPixel() const
DataChangedEventType GetType() const
AllSettingsFlags GetFlags() const
sal_uInt16 GetClicks() const
sal_uInt16 GetButtons() const
const Point & GetPosPixel() const
css::uno::Reference< css::awt::XGraphics > CreateUnoGraphics()
constexpr tools::Long Y() const
constexpr tools::Long X() const
vcl::RenderContext * GetRenderContext() const
const tools::Rectangle & GetRect() const
sal_uInt16 GetItemId() const
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
sal_Int32 addInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
sal_Int32 removeInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent &Action) override
css::uno::Reference< css::frame::XUIControllerFactory > m_xStatusbarControllerFactory
void MouseButton(const MouseEvent &rMEvt, sal_Bool(SAL_CALL css::frame::XStatusbarController::*_pMethod)(const css::awt::MouseEvent &))
virtual ~StatusBarManager() override
void DataChanged(const DataChangedEvent &rDCEvt)
VclPtr< StatusBar > m_pStatusBar
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
void UserDraw(const UserDrawEvent &rUDEvt)
css::uno::Reference< css::uno::XComponentContext > m_xContext
bool m_bUpdateControllers
StatusBarControllerMap m_aControllerMap
virtual void SAL_CALL elementRemoved(const css::ui::ConfigurationEvent &Event) override
void Command(const CommandEvent &rEvt)
css::uno::Reference< css::frame::XFrame > m_xFrame
void MouseButtonDown(const MouseEvent &rMEvt)
virtual void SAL_CALL elementReplaced(const css::ui::ConfigurationEvent &Event) override
void MouseButtonUp(const MouseEvent &rMEvt)
comphelper::OInterfaceContainerHelper4< XEventListener > m_aListenerContainer
void SAL_CALL addEventListener(const css::uno::Reference< XEventListener > &xListener) override
void MouseMove(const MouseEvent &rMEvt)
void FillStatusBar(const css::uno::Reference< css::container::XIndexAccess > &rStatusBarData)
StatusBarManager(css::uno::Reference< css::uno::XComponentContext > xContext, css::uno::Reference< css::frame::XFrame > xFrame, StatusBar *pStatusBar)
bool m_bFrameActionRegistered
void SAL_CALL dispose() override
virtual void SAL_CALL elementInserted(const css::ui::ConfigurationEvent &Event) override
void SAL_CALL removeEventListener(const css::uno::Reference< XEventListener > &xListener) override
StatusBar * GetStatusBar() const
#define DBG_TESTSOLARMUTEX()
css::uno::Reference< css::uno::XComponentContext > m_xContext
#define LINK(Instance, Class, Member)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
bool ConvertSeqSeqToVector(const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > &rSequence, AddonStatusbarItemContainer &rContainer)
bool ProcessMergeOperation(StatusBar *pStatusbar, sal_uInt16 nPos, sal_uInt16 &rItemId, std::u16string_view rMergeCommand, std::u16string_view rMergeCommandParameter, const AddonStatusbarItemContainer &rItems)
bool IsCorrectContext(std::u16string_view aContext)
bool ProcessMergeFallback(StatusBar *pStatusbar, sal_uInt16 &rItemId, std::u16string_view rMergeCommand, std::u16string_view rMergeFallback, const AddonStatusbarItemContainer &rItems)
sal_uInt16 FindReferencePos(StatusBar *pStatusbar, std::u16string_view rReferencePoint)
::std::vector< MergeStatusbarInstruction > MergeStatusbarInstructionContainer
IMPL_LINK_NOARG(CloseDispatcher, impl_asyncCallback, LinkParamNone *, void)
asynchronous callback @descr We start all actions inside this object asynchronous (see comments there...
::std::vector< AddonStatusbarItem > AddonStatusbarItemContainer
rtl::Reference< svt::StatusbarController > CreateStatusBarController(const Reference< XFrame > &rFrame, StatusBar *pStatusBar, unsigned short nID, const OUString &aCommandURL)
Sequence< beans::PropertyValue > GetCommandProperties(const OUString &rsCommandName, const OUString &rsModuleName)
OUString GetLabelForCommand(const css::uno::Sequence< css::beans::PropertyValue > &rProperties)
#define STATUSBAR_ITEM_NOTFOUND
css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > aMergeStatusbarItems
OUString aMergeCommandParameter
Reference< XController > xController