26#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
27#include <com/sun/star/ui/ItemType.hpp>
28#include <com/sun/star/frame/XModuleManager.hpp>
29#include <com/sun/star/frame/ModuleManager.hpp>
30#include <com/sun/star/frame/XFrame.hpp>
31#include <com/sun/star/uno/Reference.h>
32#include <com/sun/star/awt/PopupMenuDirection.hpp>
33#include <com/sun/star/awt/XVclWindowPeer.hpp>
34#include <com/sun/star/frame/XPopupMenuController.hpp>
42constexpr OUStringLiteral
TOOLBAR_STR =
u"private:resource/toolbar/notebookbarshortcuts";
44using namespace css::uno;
45using namespace css::ui;
46using namespace css::frame;
61 const Reference<XModuleManager> xModuleManager = ModuleManager::create( xContext );
62 Reference<XFrame>
xFrame = pViewFrm->GetFrame().GetFrameInterface();
63 OUString aModuleName = xModuleManager->identify(
xFrame );
65 Reference<XUIConfigurationManager> m_xConfigManager;
66 Reference<XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier(
67 theModuleUIConfigurationManagerSupplier::get( xContext ) );
68 m_xConfigManager.set( xModuleCfgMgrSupplier->getUIConfigurationManager( aModuleName ) );
69 css::uno::Reference< css::ui::XUIConfiguration > xConfig( m_xConfigManager, css::uno::UNO_QUERY_THROW );
70 xConfig->addConfigurationListener(
this );
73 catch(
const css::uno::RuntimeException& ) {}
77 virtual void SAL_CALL
elementInserted(
const ConfigurationEvent& rEvent )
override
82 m_pParent->StateChanged(StateChangedType::UpdateMode);
86 virtual void SAL_CALL
elementRemoved(
const ConfigurationEvent& rEvent )
override
91 virtual void SAL_CALL
elementReplaced(
const ConfigurationEvent& rEvent )
override
96 virtual void SAL_CALL
disposing(const ::css::lang::EventObject&)
override
103 const Reference<XModuleManager> xModuleManager = ModuleManager::create( xContext );
104 Reference<XFrame>
xFrame = pViewFrm->GetFrame().GetFrameInterface();
105 OUString aModuleName = xModuleManager->identify(
xFrame );
107 Reference<XUIConfigurationManager> m_xConfigManager;
108 Reference<XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier(
109 theModuleUIConfigurationManagerSupplier::get( xContext ) );
110 m_xConfigManager.set( xModuleCfgMgrSupplier->getUIConfigurationManager( aModuleName ) );
111 css::uno::Reference< css::ui::XUIConfiguration > xConfig( m_xConfigManager, css::uno::UNO_QUERY_THROW );
112 xConfig->removeConfigurationListener(
this );
115 catch(
const css::uno::RuntimeException& ) {}
126 ShortcutsToolBox( Window* pParent )
127 :
sfx2::sidebar::SidebarToolBox( pParent )
129 mbUseDefaultButtonSize =
false;
139 if ( nCode == KEY_RIGHT || nCode == KEY_LEFT )
152: NotebookbarTabControlBase( pParent )
153, m_bInitialized( false )
154, m_bInvalidate( true )
164 ToolBox* pToolBox( GetToolBox() );
165 Control* pOpenMenu( GetOpenMenu() );
173 else if ( pOpenMenu )
176 else if ( pToolBox && pToolBox->
HasFocus() )
183 else if ( pOpenMenu && pOpenMenu->
HasFocus() )
197 else if ( pToolBox && pToolBox->
HasFocus() )
201 else if ( pOpenMenu && pOpenMenu->
HasFocus() )
222 return NotebookbarTabControlBase::KeyInput( rKEvt );
227 if ( rNEvt.
GetType() == NotifyEventType::KEYINPUT )
230 sal_uInt16 nCode = rKey.
GetCode();
237 return NotebookbarTabControlBase::EventNotify( rNEvt );
248 SetToolBox(
static_cast<ToolBox*
>( pShortcuts.
get() ) );
257 ToolBox* pToolBox = GetToolBox();
264 const Reference<XModuleManager> xModuleManager = ModuleManager::create( xContext );
266 OUString aModuleName = xModuleManager->identify(
m_xFrame );
273 ImplPlaceTabs( GetSizePixel().getWidth() );
277 NotebookbarTabControlBase::StateChanged( nStateChange );
281 const Reference<XFrame>& xFrame,
282 const OUString& aModuleName,
286 Reference<::com::sun::star::container::XIndexAccess> xIndex;
290 Reference<XUIConfigurationManager> m_xConfigManager;
291 Reference<XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier(
292 theModuleUIConfigurationManagerSupplier::get( xContext ) );
293 m_xConfigManager.set( xModuleCfgMgrSupplier->getUIConfigurationManager( aModuleName ) );
294 xIndex = m_xConfigManager->getSettings(
TOOLBAR_STR,
false );
301 Sequence< css::beans::PropertyValue > aPropSequence;
302 for ( sal_Int32
i = 0;
i < xIndex->getCount(); ++
i )
306 if ( xIndex->getByIndex(
i ) >>= aPropSequence )
308 OUString aCommandURL;
309 sal_uInt16
nType = ItemType::DEFAULT;
312 for (
const auto& aProp: std::as_const(aPropSequence) )
314 if ( aProp.Name ==
"CommandURL" )
315 aProp.Value >>= aCommandURL;
316 else if ( aProp.Name ==
"Type" )
317 aProp.Value >>=
nType;
318 else if ( aProp.Name ==
"IsVisible" )
334 if (!pNotebookbar || !
m_xFrame.is())
337 Sequence<Any> aArgs {
342 Reference<XPopupMenuController> xPopupController(
343 xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
344 "com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), UNO_QUERY);
348 if (!xPopupController.is() || !xPopupMenu.is())
351 xPopupController->setPopupMenu(xPopupMenu);
352 Point aPos(pNotebookbar->GetSizePixel().getWidth(), NotebookbarTabControl::GetHeaderHeight() -
ICON_SIZE + 10);
353 xPopupMenu->execute(pNotebookbar->GetComponentInterface(),
354 css::awt::Rectangle(aPos.
X(), aPos.
Y(), 1, 1),
355 css::awt::PopupMenuDirection::EXECUTE_DOWN);
357 Reference<css::lang::XComponent> xComponent(xPopupController, UNO_QUERY);
359 xComponent->dispose();
364 Size aSize = NotebookbarTabControlBase::calculateRequisition();
366 for (
int i = 0;
i < GetPageCount();
i++)
379 if (aSize.
Width() < 400)
constexpr OUStringLiteral TOOLBAR_STR
IMPL_LINK(NotebookbarTabControl, OpenNotebookbarPopupMenu, NotebookBar *, pNotebookbar, void)
css::uno::Reference< css::lang::XComponent > m_xFrame
#define VCL_BUILDER_FACTORY(typeName)
virtual void SAL_CALL elementRemoved(const ConfigurationEvent &rEvent) override
virtual void SAL_CALL disposing(const ::css::lang::EventObject &) override
virtual void SAL_CALL elementReplaced(const ConfigurationEvent &rEvent) override
virtual void SAL_CALL elementInserted(const ConfigurationEvent &rEvent) override
ChangedUIEventListener(NotebookbarTabControl *p)
VclPtr< NotebookbarTabControl > m_pParent
const vcl::KeyCode & GetKeyCode() const
css::uno::Reference< css::frame::XFrame > m_xFrame
css::uno::Reference< css::ui::XUIConfigurationListener > m_pListener
virtual Size calculateRequisition() const override
friend class ChangedUIEventListener
~NotebookbarTabControl() override
virtual void KeyInput(const KeyEvent &rKEvt) override
virtual bool EventNotify(NotifyEvent &rNEvt) override
static void FillShortcutsToolBox(css::uno::Reference< css::uno::XComponentContext > const &xContext, const css::uno::Reference< css::frame::XFrame > &xFrame, const OUString &aModuleName, ToolBox *pShortcuts)
void ArrowStops(sal_uInt16 nCode)
virtual void StateChanged(StateChangedType nStateChange) override
NotebookbarTabControl(Window *pParent)
const KeyEvent * GetKeyEvent() const
NotifyEventType GetType() const
constexpr tools::Long Y() const
constexpr tools::Long X() const
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
SfxFrame & GetFrame() const
constexpr tools::Long getWidth() const
void setWidth(tools::Long nWidth)
constexpr tools::Long Width() const
sal_uInt16 GetPageId(sal_uInt16 nPos) const
static Size getLayoutRequisition(const vcl::Window &rWindow)
reference_type * get() const
static VclPtr< reference_type > Create(Arg &&... arg)
sal_uInt16 GetCode() const
vcl::Window * GetParent() const
virtual void KeyInput(const KeyEvent &rKEvt)
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
constexpr sal_uInt16 KEY_LEFT
constexpr sal_uInt16 KEY_RIGHT
#define LINK(Instance, Class, Member)
Reference< XComponentContext > getProcessComponentContext()
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
Reference< XFrame > xFrame