summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2018-06-20 11:39:02 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2018-06-25 07:19:21 +0200
commitcdef92ae11cb2f35572c942ef3ff0742fdd21dc0 (patch)
tree35865c578178609de19994b0c9500299188cb401
parent6e70ed4b8724eab5553a16ef1562025b1574d92a (diff)
Split some stuff from ToolbarMenu to a base class
i.e. implement "todo: move to new base class that will replace SfxPopupWindow" Change-Id: I1b300e1e0c6423bf27d9dae7d75703b988afb154
-rw-r--r--include/svtools/toolbarmenu.hxx41
-rw-r--r--svtools/source/control/toolbarmenu.cxx124
-rw-r--r--svtools/source/control/toolbarmenuimp.hxx6
3 files changed, 90 insertions, 81 deletions
diff --git a/include/svtools/toolbarmenu.hxx b/include/svtools/toolbarmenu.hxx
index a5f06e7a36a3..6856f0db7d4f 100644
--- a/include/svtools/toolbarmenu.hxx
+++ b/include/svtools/toolbarmenu.hxx
@@ -36,15 +36,39 @@
#include <vcl/dockwin.hxx>
class ValueSet;
+namespace svt { class FrameStatusListener; }
namespace svtools {
class ToolbarMenuEntry;
struct ToolbarMenu_Impl;
-class SVT_DLLPUBLIC ToolbarMenu : public DockingWindow
+class SVT_DLLPUBLIC ToolbarPopup : public DockingWindow
+{
+ friend class ToolbarPopupStatusListener;
+public:
+ ToolbarPopup(const css::uno::Reference<css::frame::XFrame>& rFrame,
+ vcl::Window* pParentWindow,
+ WinBits nBits );
+ virtual ~ToolbarPopup() override;
+ virtual void dispose() override;
+
+protected:
+ void AddStatusListener( const OUString& rCommandURL );
+
+ bool IsInPopupMode();
+ void EndPopupMode();
+
+ // Forwarded from XStatusListener (subclasses must override this one to get the status updates):
+ virtual void statusChanged(const css::frame::FeatureStateEvent& Event ) throw (css::uno::RuntimeException, std::exception);
+
+private:
+ css::uno::Reference< css::frame::XFrame > mxFrame;
+ rtl::Reference< svt::FrameStatusListener > mxStatusListener;
+};
+
+class SVT_DLLPUBLIC ToolbarMenu : public ToolbarPopup
{
- friend class ToolbarMenuStatusListener;
friend struct ToolbarMenu_Impl;
public:
ToolbarMenu(const css::uno::Reference<css::frame::XFrame>& rFrame,
@@ -92,25 +116,12 @@ public:
protected:
virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
- // todo: move to new base class that will replace SfxPopupWindow
- void AddStatusListener( const OUString& rCommandURL );
-
- bool IsInPopupMode();
- void EndPopupMode();
-
- // Forwarded from XStatusListener (subclasses must override this one to get
- // the status updates):
- virtual void statusChanged(const css::frame::FeatureStateEvent& Event ) throw (css::uno::RuntimeException, std::exception);
-
void StateChanged( StateChangedType nType ) override;
void DataChanged( const DataChangedEvent& rDCEvt ) override;
private:
DECL_LINK_TYPED( HighlightHdl, ValueSet*, void );
- void initStatusListener();
-
- void implInit(const css::uno::Reference<css::frame::XFrame>& rFrame);
void initWindow();
Size implCalcSize();
diff --git a/svtools/source/control/toolbarmenu.cxx b/svtools/source/control/toolbarmenu.cxx
index 4eee26515b98..50a3859cf3ff 100644
--- a/svtools/source/control/toolbarmenu.cxx
+++ b/svtools/source/control/toolbarmenu.cxx
@@ -30,6 +30,7 @@
#include <vcl/toolbox.hxx>
#include <vcl/settings.hxx>
+#include <svtools/framestatuslistener.hxx>
#include <svtools/valueset.hxx>
#include <svtools/toolbarmenu.hxx>
#include "toolbarmenuimp.hxx"
@@ -181,9 +182,8 @@ Reference< XAccessible > ToolbarMenuEntry::getAccessibleChild( sal_Int32 index )
}
-ToolbarMenu_Impl::ToolbarMenu_Impl( ToolbarMenu& rMenu, const css::uno::Reference< css::frame::XFrame >& xFrame )
+ToolbarMenu_Impl::ToolbarMenu_Impl( ToolbarMenu& rMenu )
: mrMenu( rMenu )
-, mxFrame( xFrame )
, mnCheckPos(0)
, mnImagePos(0)
, mnTextPos(0)
@@ -403,24 +403,16 @@ IMPL_LINK_NOARG_TYPED( ToolbarMenu, HighlightHdl, ValueSet*, void )
mpImpl->notifyHighlightedEntry();
}
-ToolbarMenu::ToolbarMenu( const Reference< XFrame >& rFrame, vcl::Window* pParentWindow, WinBits nBits )
- : DockingWindow(pParentWindow, nBits)
-{
- implInit(rFrame);
-}
-
-void ToolbarMenu::implInit(const Reference< XFrame >& rFrame)
+ToolbarMenu::ToolbarMenu( const css::uno::Reference<css::frame::XFrame>& rFrame, vcl::Window* pParentWindow, WinBits nBits )
+ : ToolbarPopup(rFrame, pParentWindow, nBits)
{
- mpImpl = new ToolbarMenu_Impl( *this, rFrame );
+ mpImpl = new ToolbarMenu_Impl( *this );
+ //mpImpl.reset( new ToolbarMenu_Impl( *this, rFrame ) );
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
SetControlBackground( rStyleSettings.GetMenuColor() );
initWindow();
-
- vcl::Window* pWindow = GetTopMostParentSystemWindow( this );
- if ( pWindow )
- static_cast<SystemWindow*>(pWindow)->GetTaskPaneList()->AddWindow( this );
}
@@ -431,16 +423,6 @@ ToolbarMenu::~ToolbarMenu()
void ToolbarMenu::dispose()
{
- vcl::Window* pWindow = GetTopMostParentSystemWindow( this );
- if ( pWindow )
- static_cast<SystemWindow*>(pWindow)->GetTaskPaneList()->RemoveWindow( this );
-
- if ( mpImpl->mxStatusListener.is() )
- {
- mpImpl->mxStatusListener->dispose();
- mpImpl->mxStatusListener.clear();
- }
-
mpImpl->mxAccessible.clear();
std::unique_ptr<ToolbarMenu_Impl> pImpl{mpImpl};
@@ -448,7 +430,7 @@ void ToolbarMenu::dispose()
pImpl->maEntryVector.clear();
- DockingWindow::dispose();
+ ToolbarPopup::dispose();
}
@@ -704,7 +686,7 @@ void ToolbarMenu::GetFocus()
if( mpImpl && mpImpl->mnHighlightedEntry == -1 )
implChangeHighlightEntry( 0 );
- DockingWindow::GetFocus();
+ ToolbarPopup::GetFocus();
}
@@ -713,7 +695,7 @@ void ToolbarMenu::LoseFocus()
if( mpImpl && mpImpl->mnHighlightedEntry != -1 )
implChangeHighlightEntry( -1 );
- DockingWindow::LoseFocus();
+ ToolbarPopup::LoseFocus();
}
@@ -1377,13 +1359,13 @@ void ToolbarMenu::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
void ToolbarMenu::RequestHelp( const HelpEvent& rHEvt )
{
- DockingWindow::RequestHelp( rHEvt );
+ ToolbarPopup::RequestHelp( rHEvt );
}
void ToolbarMenu::StateChanged( StateChangedType nType )
{
- DockingWindow::StateChanged( nType );
+ ToolbarPopup::StateChanged( nType );
if ( ( nType == StateChangedType::ControlForeground ) || ( nType == StateChangedType::ControlBackground ) )
{
@@ -1395,7 +1377,7 @@ void ToolbarMenu::StateChanged( StateChangedType nType )
void ToolbarMenu::DataChanged( const DataChangedEvent& rDCEvt )
{
- DockingWindow::DataChanged( rDCEvt );
+ ToolbarPopup::DataChanged( rDCEvt );
if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
(rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) ||
@@ -1428,69 +1410,89 @@ Reference< css::accessibility::XAccessible > ToolbarMenu::CreateAccessible()
}
-// todo: move to new base class that will replace SfxPopupWindo
-void ToolbarMenu::AddStatusListener( const OUString& rCommandURL )
-{
- initStatusListener();
- mpImpl->mxStatusListener->addStatusListener( rCommandURL );
-}
-
-
-void ToolbarMenu::statusChanged( const css::frame::FeatureStateEvent& /*Event*/ ) throw ( css::uno::RuntimeException, std::exception )
-{
-}
-
-
-class ToolbarMenuStatusListener : public svt::FrameStatusListener
+class ToolbarPopupStatusListener : public svt::FrameStatusListener
{
public:
- ToolbarMenuStatusListener( const css::uno::Reference< css::frame::XFrame >& xFrame,
- ToolbarMenu& rToolbarMenu );
+ ToolbarPopupStatusListener( const css::uno::Reference< css::frame::XFrame >& xFrame,
+ ToolbarPopup& rToolbarPopup );
virtual void SAL_CALL dispose() throw (css::uno::RuntimeException, std::exception) override;
virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) override;
- VclPtr<ToolbarMenu> mpMenu;
+ VclPtr<ToolbarPopup> mpPopup;
};
-ToolbarMenuStatusListener::ToolbarMenuStatusListener(
+ToolbarPopupStatusListener::ToolbarPopupStatusListener(
const css::uno::Reference< css::frame::XFrame >& xFrame,
- ToolbarMenu& rToolbarMenu )
+ ToolbarPopup& rToolbarPopup )
: svt::FrameStatusListener( ::comphelper::getProcessComponentContext(), xFrame )
-, mpMenu( &rToolbarMenu )
+, mpPopup( &rToolbarPopup )
{
}
-void SAL_CALL ToolbarMenuStatusListener::dispose() throw (css::uno::RuntimeException, std::exception)
+void SAL_CALL ToolbarPopupStatusListener::dispose() throw (css::uno::RuntimeException, std::exception)
{
- mpMenu.clear();
+ mpPopup.clear();
svt::FrameStatusListener::dispose();
}
-void SAL_CALL ToolbarMenuStatusListener::statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException, std::exception )
+void SAL_CALL ToolbarPopupStatusListener::statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException, std::exception )
{
- if( mpMenu )
- mpMenu->statusChanged( Event );
+ if( mpPopup )
+ mpPopup->statusChanged( Event );
}
+ToolbarPopup::ToolbarPopup( const css::uno::Reference<css::frame::XFrame>& rFrame, vcl::Window* pParentWindow, WinBits nBits )
+ : DockingWindow(pParentWindow, nBits)
+ , mxFrame( rFrame )
+{
+ 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 ToolbarMenu::initStatusListener()
+void ToolbarPopup::AddStatusListener( const OUString& rCommandURL )
{
- if( !mpImpl->mxStatusListener.is() )
- mpImpl->mxStatusListener.set( new ToolbarMenuStatusListener( mpImpl->mxFrame, *this ) );
+ if( !mxStatusListener.is() )
+ mxStatusListener.set( new ToolbarPopupStatusListener( mxFrame, *this ) );
+
+ mxStatusListener->addStatusListener( rCommandURL );
}
+void ToolbarPopup::statusChanged( const css::frame::FeatureStateEvent& /*Event*/ ) throw ( css::uno::RuntimeException, std::exception )
+{
+}
-bool ToolbarMenu::IsInPopupMode()
+bool ToolbarPopup::IsInPopupMode()
{
return GetDockingManager()->IsInPopupMode(this);
}
-
-void ToolbarMenu::EndPopupMode()
+void ToolbarPopup::EndPopupMode()
{
GetDockingManager()->EndPopupMode(this);
}
diff --git a/svtools/source/control/toolbarmenuimp.hxx b/svtools/source/control/toolbarmenuimp.hxx
index 8576eb3377e8..e7f656dc2599 100644
--- a/svtools/source/control/toolbarmenuimp.hxx
+++ b/svtools/source/control/toolbarmenuimp.hxx
@@ -40,8 +40,6 @@
#include <memory>
#include <vector>
-#include <svtools/framestatuslistener.hxx>
-
namespace svtools {
struct ToolbarMenu_Impl;
@@ -241,8 +239,6 @@ struct ToolbarMenu_Impl
{
ToolbarMenu& mrMenu;
- css::uno::Reference< css::frame::XFrame > mxFrame;
- rtl::Reference< svt::FrameStatusListener > mxStatusListener;
rtl::Reference< ToolbarMenuAcc > mxAccessible;
css::uno::Reference< css::accessibility::XAccessible > mxOldSelection;
@@ -260,7 +256,7 @@ struct ToolbarMenu_Impl
Link<ToolbarMenu*,void> maSelectHdl;
- ToolbarMenu_Impl( ToolbarMenu& rMenu, const css::uno::Reference< css::frame::XFrame >& xFrame );
+ ToolbarMenu_Impl( ToolbarMenu& rMenu );
~ToolbarMenu_Impl();
void setAccessible( ToolbarMenuAcc* pAccessible );