diff options
-rw-r--r-- | include/svtools/toolbarmenu.hxx | 53 | ||||
-rw-r--r-- | sd/source/ui/controller/slidelayoutcontroller.cxx | 8 | ||||
-rw-r--r-- | svtools/source/control/toolbarmenu.cxx | 97 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 2 |
4 files changed, 45 insertions, 115 deletions
diff --git a/include/svtools/toolbarmenu.hxx b/include/svtools/toolbarmenu.hxx index c08da7e9c899..6e8aa5588de2 100644 --- a/include/svtools/toolbarmenu.hxx +++ b/include/svtools/toolbarmenu.hxx @@ -33,45 +33,7 @@ namespace com :: sun :: star :: frame { class XFrame; } namespace com :: sun :: star :: frame { struct FeatureStateEvent; } namespace svt { class FrameStatusListener; } -namespace svtools { - -class SVT_DLLPUBLIC ToolbarPopupBase -{ - friend class ToolbarPopupStatusListener; -public: - ToolbarPopupBase(const css::uno::Reference<css::frame::XFrame>& rFrame); - virtual ~ToolbarPopupBase(); - -protected: - void AddStatusListener( const OUString& rCommandURL ); - - // Forwarded from XStatusListener (subclasses must override this one to get the status updates): - /// @throws css::uno::RuntimeException - virtual void statusChanged(const css::frame::FeatureStateEvent& Event ); - - css::uno::Reference<css::frame::XFrame> mxFrame; - rtl::Reference<svt::FrameStatusListener> mxStatusListener; -}; - -class UNLESS_MERGELIBS(SVT_DLLPUBLIC) ToolbarPopup : public DockingWindow, public ToolbarPopupBase -{ -public: - ToolbarPopup(const css::uno::Reference<css::frame::XFrame>& rFrame, - vcl::Window* pParentWindow, - const OString& rID, const OUString& rUIXMLDescription ); - virtual ~ToolbarPopup() override; - virtual void dispose() override; - -protected: - void EndPopupMode(); - -private: - void init(); -}; - -} // namespace svtools - -class SVT_DLLPUBLIC WeldToolbarPopup : public svtools::ToolbarPopupBase +class SVT_DLLPUBLIC WeldToolbarPopup { private: DECL_LINK(FocusHdl, weld::Widget&, void); @@ -80,14 +42,20 @@ protected: std::unique_ptr<weld::Builder> m_xBuilder; std::unique_ptr<weld::Container> m_xTopLevel; std::unique_ptr<weld::Container> m_xContainer; + css::uno::Reference<css::frame::XFrame> m_xFrame; + rtl::Reference<svt::FrameStatusListener> m_xStatusListener; public: WeldToolbarPopup(const css::uno::Reference<css::frame::XFrame>& rFrame, weld::Widget* pParent, const OUString& rUIFile, const OString& rId); - virtual ~WeldToolbarPopup() override; + virtual ~WeldToolbarPopup(); weld::Container* getTopLevel() { return m_xTopLevel.get(); } weld::Container* getContainer() { return m_xContainer.get(); } + void AddStatusListener(const OUString& rCommandURL); + // Forwarded from XStatusListener (subclasses must override this one to get the status updates): + /// @throws css::uno::RuntimeException + virtual void statusChanged(const css::frame::FeatureStateEvent& Event); virtual void GrabFocus() = 0; }; @@ -116,10 +84,11 @@ public: void unsetPopover(); }; -class SVT_DLLPUBLIC InterimToolbarPopup final : public svtools::ToolbarPopup +class SVT_DLLPUBLIC InterimToolbarPopup final : public DockingWindow { private: VclPtr<vcl::Window> m_xBox; + css::uno::Reference<css::frame::XFrame> m_xFrame; std::unique_ptr<weld::Builder> m_xBuilder; std::unique_ptr<weld::Container> m_xContainer; std::unique_ptr<WeldToolbarPopup> m_xPopup; @@ -132,7 +101,7 @@ public: virtual void GetFocus() override; - using ToolbarPopup::EndPopupMode; + void EndPopupMode(); }; #endif diff --git a/sd/source/ui/controller/slidelayoutcontroller.cxx b/sd/source/ui/controller/slidelayoutcontroller.cxx index 41071def8409..284df02be296 100644 --- a/sd/source/ui/controller/slidelayoutcontroller.cxx +++ b/sd/source/ui/controller/slidelayoutcontroller.cxx @@ -170,9 +170,9 @@ LayoutToolbarMenu::LayoutToolbarMenu(SlideLayoutController* pControl, weld::Widg DrawViewMode eMode = DrawViewMode_DRAW; // find out which view is running - if( mxFrame.is() ) try + if( m_xFrame.is() ) try { - Reference< XPropertySet > xControllerSet( mxFrame->getController(), UNO_QUERY_THROW ); + Reference< XPropertySet > xControllerSet( m_xFrame->getController(), UNO_QUERY_THROW ); xControllerSet->getPropertyValue( "DrawViewMode" ) >>= eMode; } catch( Exception& ) @@ -220,7 +220,7 @@ LayoutToolbarMenu::LayoutToolbarMenu(SlideLayoutController* pControl, weld::Widg if( eMode != DrawViewMode_DRAW ) return; - if( !mxFrame.is() ) + if( !m_xFrame.is() ) return; OUString sSlotStr; @@ -230,7 +230,7 @@ LayoutToolbarMenu::LayoutToolbarMenu(SlideLayoutController* pControl, weld::Widg else sSlotStr = ".uno:Undo"; - css::uno::Reference<css::graphic::XGraphic> xSlotImage = vcl::CommandInfoProvider::GetXGraphicForCommand(sSlotStr, mxFrame); + css::uno::Reference<css::graphic::XGraphic> xSlotImage = vcl::CommandInfoProvider::GetXGraphicForCommand(sSlotStr, m_xFrame); OUString sSlotTitle; if( bInsertPage ) diff --git a/svtools/source/control/toolbarmenu.cxx b/svtools/source/control/toolbarmenu.cxx index 5c76ae6cad89..e0688f6e9fe3 100644 --- a/svtools/source/control/toolbarmenu.cxx +++ b/svtools/source/control/toolbarmenu.cxx @@ -36,9 +36,9 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::accessibility; -namespace svtools { +namespace { -static vcl::Window* GetTopMostParentSystemWindow( vcl::Window* pWindow ) +vcl::Window* GetTopMostParentSystemWindow( vcl::Window* pWindow ) { OSL_ASSERT( pWindow ); if ( pWindow ) @@ -65,18 +65,18 @@ class ToolbarPopupStatusListener : public svt::FrameStatusListener { public: ToolbarPopupStatusListener( const css::uno::Reference< css::frame::XFrame >& xFrame, - ToolbarPopupBase& rToolbarPopup ); + WeldToolbarPopup& rToolbarPopup ); virtual void SAL_CALL dispose() override; virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; - ToolbarPopupBase* mpPopup; + WeldToolbarPopup* mpPopup; }; ToolbarPopupStatusListener::ToolbarPopupStatusListener( const css::uno::Reference< css::frame::XFrame >& xFrame, - ToolbarPopupBase& rToolbarPopup ) + WeldToolbarPopup& rToolbarPopup ) : svt::FrameStatusListener( ::comphelper::getProcessComponentContext(), xFrame ) , mpPopup( &rToolbarPopup ) { @@ -96,89 +96,40 @@ void SAL_CALL ToolbarPopupStatusListener::statusChanged( const css::frame::Featu mpPopup->statusChanged( Event ); } -ToolbarPopupBase::ToolbarPopupBase(const css::uno::Reference<css::frame::XFrame>& rFrame) - : mxFrame(rFrame) -{ -} - -ToolbarPopupBase::~ToolbarPopupBase() -{ - if (mxStatusListener.is()) - { - mxStatusListener->dispose(); - mxStatusListener.clear(); - } -} - -ToolbarPopup::ToolbarPopup( const css::uno::Reference<css::frame::XFrame>& rFrame, vcl::Window* pParentWindow, - const OString& rID, const OUString& rUIXMLDescription ) - : DockingWindow(pParentWindow, rID, rUIXMLDescription, rFrame) - , ToolbarPopupBase(rFrame) -{ - init(); -} - -void ToolbarPopup::init() -{ - vcl::Window* pWindow = GetTopMostParentSystemWindow( this ); - if ( pWindow ) - static_cast<SystemWindow*>(pWindow)->GetTaskPaneList()->AddWindow( this ); -} - -ToolbarPopup::~ToolbarPopup() -{ - disposeOnce(); -} - -void ToolbarPopup::dispose() -{ - vcl::Window* pWindow = GetTopMostParentSystemWindow( this ); - if ( pWindow ) - static_cast<SystemWindow*>(pWindow)->GetTaskPaneList()->RemoveWindow( this ); - - if ( mxStatusListener.is() ) - { - mxStatusListener->dispose(); - mxStatusListener.clear(); - } - - mxFrame.clear(); - DockingWindow::dispose(); } -void ToolbarPopupBase::AddStatusListener( const OUString& rCommandURL ) +void WeldToolbarPopup::AddStatusListener(const OUString& rCommandURL) { - if( !mxStatusListener.is() ) - mxStatusListener.set( new ToolbarPopupStatusListener( mxFrame, *this ) ); + if (!m_xStatusListener.is()) + m_xStatusListener.set(new ToolbarPopupStatusListener(m_xFrame, *this)); - mxStatusListener->addStatusListener( rCommandURL ); + m_xStatusListener->addStatusListener(rCommandURL); } -void ToolbarPopupBase::statusChanged( const css::frame::FeatureStateEvent& /*Event*/ ) +void WeldToolbarPopup::statusChanged(const css::frame::FeatureStateEvent& /*Event*/) { } -void ToolbarPopup::EndPopupMode() +void InterimToolbarPopup::EndPopupMode() { GetDockingManager()->EndPopupMode(this); } - -} - WeldToolbarPopup::WeldToolbarPopup(const css::uno::Reference<css::frame::XFrame>& rFrame, weld::Widget* pParent, const OUString& rUIFile, const OString& rId) - : ToolbarPopupBase(rFrame) - , m_xBuilder(Application::CreateBuilder(pParent, rUIFile)) + : m_xBuilder(Application::CreateBuilder(pParent, rUIFile)) , m_xTopLevel(m_xBuilder->weld_container(rId)) , m_xContainer(m_xBuilder->weld_container("container")) + , m_xFrame(rFrame) { m_xTopLevel->connect_focus_in(LINK(this, WeldToolbarPopup, FocusHdl)); } WeldToolbarPopup::~WeldToolbarPopup() { + if (m_xStatusListener.is()) + m_xStatusListener->dispose(); } IMPL_LINK_NOARG(WeldToolbarPopup, FocusHdl, weld::Widget&, void) @@ -224,19 +175,24 @@ IMPL_LINK_NOARG(ToolbarPopupContainer, FocusHdl, weld::Widget&, void) InterimToolbarPopup::InterimToolbarPopup(const css::uno::Reference<css::frame::XFrame>& rFrame, vcl::Window* pParent, std::unique_ptr<WeldToolbarPopup> xPopup) - : ToolbarPopup(rFrame, pParent, "InterimDockParent", "svx/ui/interimdockparent.ui") + : DockingWindow(pParent, "InterimDockParent", "svx/ui/interimdockparent.ui", rFrame) , m_xBox(get("box")) + , m_xFrame(rFrame) , m_xBuilder(Application::CreateInterimBuilder(m_xBox.get(), "svx/ui/interimparent.ui")) , m_xContainer(m_xBuilder->weld_container("container")) , m_xPopup(std::move(xPopup)) { + vcl::Window* pWindow = GetTopMostParentSystemWindow(this); + if (pWindow) + static_cast<SystemWindow*>(pWindow)->GetTaskPaneList()->AddWindow(this); + // move the WeldToolbarPopup contents into this interim toolbar so welded contents can appear as a dropdown in an unwelded toolbar m_xPopup->getTopLevel()->move(m_xPopup->getContainer(), m_xContainer.get()); } void InterimToolbarPopup::GetFocus() { - ToolbarPopup::GetFocus(); + DockingWindow::GetFocus(); if (!m_xPopup) return; m_xPopup->GrabFocus(); @@ -244,11 +200,15 @@ void InterimToolbarPopup::GetFocus() void InterimToolbarPopup::dispose() { + vcl::Window* pWindow = GetTopMostParentSystemWindow(this); + if (pWindow) + static_cast<SystemWindow*>(pWindow)->GetTaskPaneList()->RemoveWindow(this); + // if we have focus when disposed, pick the document window as destination // for focus rather than let it go to an arbitrary windows if (HasFocus()) { - if (auto xWindow = mxFrame->getContainerWindow()) + if (auto xWindow = m_xFrame->getContainerWindow()) xWindow->setFocus(); } // move the contents back where it belongs @@ -256,7 +216,8 @@ void InterimToolbarPopup::dispose() m_xPopup.reset(); m_xContainer.reset(); m_xBox.clear(); - ToolbarPopup::dispose(); + m_xFrame.clear(); + DockingWindow::dispose(); } InterimToolbarPopup::~InterimToolbarPopup() diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index e4d6e08dcdb6..64533b2c786b 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -2413,7 +2413,7 @@ SvxLineWindow_Impl::SvxLineWindow_Impl(SvxFrameToolBoxControl* pControl, weld::W { try { - Reference< lang::XServiceInfo > xServices(mxFrame->getController()->getModel(), UNO_QUERY_THROW); + Reference< lang::XServiceInfo > xServices(m_xFrame->getController()->getModel(), UNO_QUERY_THROW); m_bIsWriter = xServices->supportsService("com.sun.star.text.TextDocument"); } catch(const uno::Exception& ) |