diff options
author | Christian Lippka <cl@openoffice.org> | 2010-01-17 18:25:26 +0100 |
---|---|---|
committer | Christian Lippka <cl@openoffice.org> | 2010-01-17 18:25:26 +0100 |
commit | ae3991040d82bb3a9e504bb1307384004b355dfd (patch) | |
tree | 1faf5bcdd92933e8efe9f4db595d9f61edb2455c | |
parent | 8cddfc59f4a7b218eb0580729db19254cbd12770 (diff) |
allow vcl::DockManager popup with ToolbarMenu class for a nicer look
-rw-r--r-- | svx/inc/extrusioncontrols.hxx | 48 | ||||
-rw-r--r-- | svx/inc/fontworkgallery.hxx | 23 | ||||
-rw-r--r-- | svx/inc/svx/toolbarmenu.hxx | 46 | ||||
-rw-r--r-- | svx/source/tbxctrls/extrusioncontrols.cxx | 377 | ||||
-rw-r--r-- | svx/source/tbxctrls/extrusioncontrols.src | 8 | ||||
-rw-r--r-- | svx/source/tbxctrls/fontworkgallery.cxx | 172 | ||||
-rw-r--r-- | svx/source/tbxctrls/fontworkgallery.src | 4 | ||||
-rw-r--r-- | svx/source/tbxctrls/toolbarmenu.cxx | 121 |
8 files changed, 347 insertions, 452 deletions
diff --git a/svx/inc/extrusioncontrols.hxx b/svx/inc/extrusioncontrols.hxx index cd4d298cbee6..cf0432d888f2 100644 --- a/svx/inc/extrusioncontrols.hxx +++ b/svx/inc/extrusioncontrols.hxx @@ -55,8 +55,6 @@ class ToolboxButtonColorUpdater; class ExtrusionDirectionWindow : public ToolbarMenu { - using FloatingWindow::StateChanged; - private: ValueSet* mpDirectionSet; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame; @@ -72,7 +70,8 @@ private: Image maImgParallel; Image maImgParallelH; - bool mbPopupMode; + const rtl::OUString msExtrusionDirection; + const rtl::OUString msExtrusionProjection; DECL_LINK( SelectHdl, void * ); void FillValueSet(); @@ -82,9 +81,6 @@ private: void implInit(); protected: - virtual BOOL Close(); - virtual void PopupModeEnd(); - /** This function is called when the window gets the focus. It grabs the focus to the line ends value set so that it can be controlled with the keyboard. @@ -99,9 +95,7 @@ public: void StartSelection(); - virtual SfxPopupWindow* Clone() const; - - virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ); + virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); virtual void DataChanged( const DataChangedEvent& rDCEvt ); }; @@ -124,8 +118,6 @@ public: class ExtrusionDepthWindow : public ToolbarMenu { - using FloatingWindow::StateChanged; - private: Image maImgDepth0; Image maImgDepth1; @@ -145,11 +137,13 @@ private: SfxStatusForwarder* mpMetricForewarder; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame; - bool mbPopupMode; FieldUnit meUnit; double mfDepth; bool mbEnabled; + const rtl::OUString msExtrusionDepth; + const rtl::OUString msMetricUnit; + DECL_LINK( SelectHdl, void * ); void implFillStrings( FieldUnit eUnit ); @@ -157,9 +151,6 @@ private: void implInit(); protected: - virtual BOOL Close(); - virtual void PopupModeEnd(); - /** This function is called when the window gets the focus. It grabs the focus to the line ends value set so that it can be controlled with the keyboard. @@ -174,9 +165,7 @@ public: void StartSelection(); - virtual SfxPopupWindow* Clone() const; - - virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ); + virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); virtual void DataChanged( const DataChangedEvent& rDCEvt ); }; @@ -199,8 +188,6 @@ public: class ExtrusionLightingWindow : public ToolbarMenu { - using FloatingWindow::StateChanged; - private: ValueSet* mpLightingSet; @@ -223,12 +210,14 @@ private: SfxStatusForwarder* mpLightingIntensityForewarder; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame; - bool mbPopupMode; int mnLevel; bool mbLevelEnabled; int mnDirection; bool mbDirectionEnabled; + const rtl::OUString msExtrusionLightingDirection; + const rtl::OUString msExtrusionLightingIntensity; + void implSetIntensity( int nLevel, bool bEnabled ); void implSetDirection( int nDirection, bool bEnabled ); void implInit(); @@ -236,9 +225,6 @@ private: DECL_LINK( SelectHdl, void * ); protected: - virtual BOOL Close(); - virtual void PopupModeEnd(); - /** This function is called when the window gets the focus. It grabs the focus to the line ends value set so that it can be controlled with the keyboard. @@ -253,9 +239,7 @@ public: void StartSelection(); - virtual SfxPopupWindow* Clone() const; - - virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ); + virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); virtual void DataChanged( const DataChangedEvent& rDCEvt ); }; @@ -278,7 +262,6 @@ public: class ExtrusionSurfaceWindow : public ToolbarMenu { - using FloatingWindow::StateChanged; private: Image maImgSurface1; Image maImgSurface2; @@ -292,7 +275,7 @@ private: SfxStatusForwarder* mpSurfaceForewarder; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame; - bool mbPopupMode; + const rtl::OUString msExtrusionSurface; DECL_LINK( SelectHdl, void * ); @@ -300,9 +283,6 @@ private: void implInit(); protected: - virtual BOOL Close(); - virtual void PopupModeEnd(); - /** This function is called when the window gets the focus. It grabs the focus to the line ends value set so that it can be controlled with the keyboard. @@ -317,9 +297,7 @@ public: void StartSelection(); - virtual SfxPopupWindow* Clone() const; - - virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ); + virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); virtual void DataChanged( const DataChangedEvent& rDCEvt ); }; diff --git a/svx/inc/fontworkgallery.hxx b/svx/inc/fontworkgallery.hxx index b41f1a942c95..617243f2959a 100644 --- a/svx/inc/fontworkgallery.hxx +++ b/svx/inc/fontworkgallery.hxx @@ -61,7 +61,6 @@ namespace svx class FontWorkAlignmentWindow : public ToolbarMenu { - using FloatingWindow::StateChanged; private: Image maImgAlgin1; Image maImgAlgin2; @@ -76,7 +75,7 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame; - bool mbPopupMode; + const rtl::OUString msFontworkAlignment; DECL_LINK( SelectHdl, void * ); @@ -84,9 +83,6 @@ private: void implInit(); protected: - virtual BOOL Close(); - virtual void PopupModeEnd(); - /** This function is called when the window gets the focus. It grabs the focus to the line ends value set so that it can be controlled with the keyboard. @@ -101,9 +97,7 @@ public: void StartSelection(); - virtual SfxPopupWindow* Clone() const; - - virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ); + virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); virtual void DataChanged( const DataChangedEvent& rDCEvt ); }; @@ -124,11 +118,11 @@ public: class FontWorkCharacterSpacingWindow : public ToolbarMenu { - using FloatingWindow::StateChanged; private: ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame; - bool mbPopupMode; + const rtl::OUString msFontworkCharacterSpacing; + const rtl::OUString msFontworkKernCharacterPairs; DECL_LINK( SelectHdl, void * ); @@ -137,9 +131,6 @@ private: void implInit(); protected: - virtual BOOL Close(); - virtual void PopupModeEnd(); - /** This function is called when the window gets the focus. It grabs the focus to the line ends value set so that it can be controlled with the keyboard. @@ -156,9 +147,7 @@ public: void StartSelection(); - virtual SfxPopupWindow* Clone() const; - - virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ); + virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); virtual void DataChanged( const DataChangedEvent& rDCEvt ); }; @@ -187,8 +176,6 @@ public: ~FontWorkShapeTypeControl(); virtual void Select( BOOL bMod1 = FALSE ); - virtual void StateChanged( USHORT nSID, SfxItemState eState, - const SfxPoolItem* pState ); virtual SfxPopupWindowType GetPopupWindowType() const; virtual SfxPopupWindow* CreatePopupWindow(); }; diff --git a/svx/inc/svx/toolbarmenu.hxx b/svx/inc/svx/toolbarmenu.hxx index 7809d373e1fa..a0f5aa55c6d0 100644 --- a/svx/inc/svx/toolbarmenu.hxx +++ b/svx/inc/svx/toolbarmenu.hxx @@ -31,28 +31,37 @@ #ifndef _SVX_TOOLBARMENU_HXX_ #define _SVX_TOOLBARMENU_HXX_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/frame/XFrame.hpp> + #include <vector> +#include <rtl/ref.hxx> + #include <vcl/ctrl.hxx> #include <vcl/menu.hxx> +#include <vcl/dockwin.hxx> + +#include <svtools/framestatuslistener.hxx> #include <sfx2/tbxctrl.hxx> + #include "svx/svxdllapi.h" class ToolbarMenuEntry; + typedef std::vector< ToolbarMenuEntry * > ToolbarMenuEntryVector; -class SVX_DLLPUBLIC ToolbarMenu : public SfxPopupWindow +class SVX_DLLPUBLIC ToolbarMenu : public DockingWindow { + friend class ToolbarMenuStatusListener; public: - ToolbarMenu( USHORT nId, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + ToolbarMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow, WinBits nBits ); - ToolbarMenu( USHORT nId, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + ToolbarMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow, const ResId& rResId ); @@ -99,7 +108,29 @@ public: int getSelectedEntryId() const; int getHighlightedEntryId() const; +protected: + // todo: move to new base class that will replace SfxPopupWindo + void AddStatusListener( const rtl::OUString& rCommandURL ); + void RemoveStatusListener( const rtl::OUString& rCommandURL ); + void UpdateStatus( const rtl::OUString& rCommandURL ); + + bool IsInPopupMode(); + void EndPopupMode(); + + // XStatusListener (subclasses must override this one to get the status updates + virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); + + void StateChanged( StateChangedType nType ); + void DataChanged( const DataChangedEvent& rDCEvt ); + + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetFrame() const { return mxFrame; } private: + void initStatusListener(); + + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame; + rtl::Reference< svt::FrameStatusListener > mxStatusListener; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxServiceManager; + ToolbarMenuEntryVector maEntryVector; int mnCheckPos; @@ -116,9 +147,6 @@ private: void implInit(); - void StateChanged( StateChangedType nType ); - void DataChanged( const DataChangedEvent& rDCEvt ); - void initWindow(); Size implCalcSize(); @@ -126,7 +154,7 @@ private: void appendEntry( ToolbarMenuEntry* pEntry ); void implPaint( ToolbarMenuEntry* pThisOnly = NULL, bool bHighlight = false ); - void implDrawBorder(); +// void implDrawBorder(); void implHighlightEntry( int nHighlightEntry, bool bHighlight ); void implHighlightEntry( const MouseEvent& rMEvt, bool bMBDown ); diff --git a/svx/source/tbxctrls/extrusioncontrols.cxx b/svx/source/tbxctrls/extrusioncontrols.cxx index 14da4459e04d..972a9b951bc1 100644 --- a/svx/source/tbxctrls/extrusioncontrols.cxx +++ b/svx/source/tbxctrls/extrusioncontrols.cxx @@ -78,20 +78,15 @@ SFX_IMPL_TOOLBOX_CONTROL( ExtrusionDirectionControl, SfxBoolItem ); static sal_Int32 gSkewList[] = { 135, 90, 45, 180, 0, -360, -135, -90, -45 }; -ExtrusionDirectionWindow::ExtrusionDirectionWindow( - USHORT nId, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, - Window* pParentWindow ) : - ToolbarMenu( nId, - rFrame, - pParentWindow, - SVX_RES( RID_SVXFLOAT_EXTRUSION_DIRECTION )), - mxFrame( rFrame ), - maImgPerspective( SVX_RES( IMG_PERSPECTIVE ) ), - maImgPerspectiveH( SVX_RES( IMG_PERSPECTIVE_H ) ), - maImgParallel( SVX_RES( IMG_PARALLEL ) ), - maImgParallelH( SVX_RES( IMG_PARALLEL_H ) ), - mbPopupMode ( TRUE ) +ExtrusionDirectionWindow::ExtrusionDirectionWindow( USHORT /*nId*/, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow ) +: ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_DIRECTION )) +, mxFrame( rFrame ) +, maImgPerspective( SVX_RES( IMG_PERSPECTIVE ) ) +, maImgPerspectiveH( SVX_RES( IMG_PERSPECTIVE_H ) ) +, maImgParallel( SVX_RES( IMG_PARALLEL ) ) +, maImgParallelH( SVX_RES( IMG_PARALLEL_H ) ) +, msExtrusionDirection( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDirection" ) ) +, msExtrusionProjection( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionProjection" ) ) { implInit(); } @@ -142,18 +137,16 @@ void ExtrusionDirectionWindow::implInit() FreeResource(); - AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDirection" ))); - AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionProjection" ))); -} - -SfxPopupWindow* ExtrusionDirectionWindow::Clone() const -{ - return new ExtrusionDirectionWindow( GetId(), mxFrame, 0 ); + AddStatusListener( msExtrusionDirection ); + AddStatusListener( msExtrusionProjection ); } void ExtrusionDirectionWindow::DataChanged( const DataChangedEvent& rDCEvt ) { - SfxPopupWindow::DataChanged( rDCEvt ); + AddStatusListener( msExtrusionDirection ); + AddStatusListener( msExtrusionProjection ); + + ToolbarMenu::DataChanged( rDCEvt ); if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) { @@ -220,37 +213,32 @@ void ExtrusionDirectionWindow::implSetProjection( sal_Int32 nProjection, bool bE // ----------------------------------------------------------------------- -void ExtrusionDirectionWindow::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) +void SAL_CALL ExtrusionDirectionWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ) { - switch( nSID ) + if( Event.FeatureURL.Path.equals( msExtrusionDirection ) ) { - case SID_EXTRUSION_DIRECTION: + if( !Event.IsEnabled ) { - if( eState == SFX_ITEM_DISABLED ) - { - implSetDirection( -1, false ); - } - else - { - const SfxInt32Item* pStateItem = PTR_CAST( SfxInt32Item, pState ); - if( pStateItem ) - implSetDirection( pStateItem->GetValue(), true ); - } - break; + implSetDirection( -1, false ); } - case SID_EXTRUSION_PROJECTION: + else { - if( eState == SFX_ITEM_DISABLED ) - { - implSetProjection( -1, false ); - } - else - { - const SfxInt32Item* pStateItem = PTR_CAST( SfxInt32Item, pState ); - if( pStateItem ) - implSetProjection( pStateItem->GetValue(), true ); - } - break; + sal_Int32 nValue = 0; + if( Event.State >>= nValue ) + implSetDirection( nValue, true ); + } + } + else if( Event.FeatureURL.Path.equals( msExtrusionProjection ) ) + { + if( !Event.IsEnabled ) + { + implSetProjection( -1, false ); + } + else + { + sal_Int32 nValue = 0; + if( Event.State >>= nValue ) + implSetProjection( nValue, true ); } } } @@ -269,7 +257,7 @@ IMPL_LINK( ExtrusionDirectionWindow, SelectHdl, void *, pControl ) sal_Int32 nSkew = gSkewList[mpDirectionSet->GetSelectItemId()-1]; SfxInt32Item aItem( SID_EXTRUSION_DIRECTION, nSkew ); - rtl::OUString aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDirection" )); + rtl::OUString aCommand( msExtrusionDirection ); Any a; INetURLObject aObj( aCommand ); @@ -291,7 +279,7 @@ IMPL_LINK( ExtrusionDirectionWindow, SelectHdl, void *, pControl ) if( (nProjection >= 0) && (nProjection < 2 ) ) { SfxInt32Item aItem( SID_EXTRUSION_PROJECTION, nProjection ); - rtl::OUString aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionProjection" )); + rtl::OUString aCommand( msExtrusionProjection ); Any a; INetURLObject aObj( aCommand ); @@ -326,27 +314,9 @@ void ExtrusionDirectionWindow::StartSelection() // ----------------------------------------------------------------------- -BOOL ExtrusionDirectionWindow::Close() -{ - return SfxPopupWindow::Close(); -} - -// ----------------------------------------------------------------------- - -void ExtrusionDirectionWindow::PopupModeEnd() -{ - if ( IsVisible() ) - { - mbPopupMode = FALSE; - } - SfxPopupWindow::PopupModeEnd(); -} - -// ----------------------------------------------------------------------- - void ExtrusionDirectionWindow::GetFocus (void) { - SfxPopupWindow::GetFocus(); + ToolbarMenu::GetFocus(); // Grab the focus to the line ends value set so that it can be controlled // with the keyboard. if( mpDirectionSet ) @@ -384,10 +354,12 @@ SfxPopupWindowType ExtrusionDirectionControl::GetPopupWindowType() const SfxPopupWindow* ExtrusionDirectionControl::CreatePopupWindow() { ExtrusionDirectionWindow* pWin = new ExtrusionDirectionWindow( GetId(), m_xFrame, &GetToolBox() ); - pWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_ALLOWTEAROFF|FLOATWIN_POPUPMODE_REMOVEDECORATION ); + StartPopupMode( pWin ); +// pWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_ALLOWTEAROFF ); pWin->StartSelection(); - SetPopupWindow( pWin ); - return pWin; + // SetPopupWindow( pWin ); +// return pWin; + return 0; } // ----------------------------------------------------------------------- @@ -432,13 +404,10 @@ double ExtrusionDepthDialog::getDepth() const SFX_IMPL_TOOLBOX_CONTROL( ExtrusionDepthControl, SfxBoolItem ); -ExtrusionDepthWindow::ExtrusionDepthWindow( USHORT nId, +ExtrusionDepthWindow::ExtrusionDepthWindow( USHORT /*nId*/, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow ) : - ToolbarMenu( nId, - rFrame, - pParentWindow, - SVX_RES( RID_SVXFLOAT_EXTRUSION_DEPTH )), + ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_DEPTH )), maImgDepth0( SVX_RES( IMG_DEPTH_0 ) ), maImgDepth1( SVX_RES( IMG_DEPTH_1 ) ), maImgDepth2( SVX_RES( IMG_DEPTH_2 ) ), @@ -452,9 +421,10 @@ ExtrusionDepthWindow::ExtrusionDepthWindow( USHORT nId, maImgDepth4h( SVX_RES( IMG_DEPTH_4_H ) ), maImgDepthInfinityh( SVX_RES( IMG_DEPTH_INFINITY_H ) ), mxFrame( rFrame ), - mbPopupMode ( true ), mfDepth( -1.0 ), - mbEnabled( false ) + mbEnabled( false ), + msExtrusionDepth( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDepth" ) ), + msMetricUnit( RTL_CONSTASCII_USTRINGPARAM( ".uno:MetricUnit" ) ) { implInit(); } @@ -463,9 +433,6 @@ void ExtrusionDepthWindow::implInit() { SetHelpId( HID_POPUP_EXTRUSION_DEPTH ); -// mpDepthForewarder = new SfxStatusForwarder( SID_EXTRUSION_DEPTH, *this ); -// mpMetricForewarder = new SfxStatusForwarder( SID_ATTR_METRIC, *this ); - // mpMenu = new ToolbarMenu( this, WB_CLIPCHILDREN ); /*mpMenu->*/SetHelpId( HID_MENU_EXTRUSION_DEPTH ); @@ -489,13 +456,8 @@ void ExtrusionDepthWindow::implInit() FreeResource(); - AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDepth" ))); - AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:MetricUnit" ))); -} - -SfxPopupWindow* ExtrusionDepthWindow::Clone() const -{ - return new ExtrusionDepthWindow( GetId(), mxFrame, 0 ); + AddStatusListener( msExtrusionDepth ); + AddStatusListener( msMetricUnit ); } // ----------------------------------------------------------------------- @@ -548,30 +510,29 @@ void ExtrusionDepthWindow::implFillStrings( FieldUnit eUnit ) // ----------------------------------------------------------------------- -void ExtrusionDepthWindow::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) +void SAL_CALL ExtrusionDepthWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ) { - switch( nSID ) + if( Event.FeatureURL.Path.equals( msExtrusionDepth ) ) { - case SID_EXTRUSION_DEPTH: + if( !Event.IsEnabled ) { - if( eState == SFX_ITEM_DISABLED ) - { - implSetDepth( 0, false ); - } - else - { - const SvxDoubleItem* pStateItem = PTR_CAST( SvxDoubleItem, pState ); - if( pStateItem ) - implSetDepth( pStateItem->GetValue(), true ); - } - break; + implSetDepth( 0, false ); } - case SID_ATTR_METRIC: + else { - const SfxUInt16Item* pStateItem = PTR_CAST( SfxUInt16Item, pState ); - if( pStateItem ) + double fValue = 0.0; + if( Event.State >>= fValue ) + implSetDepth( fValue, true ); + } + } + else if( Event.FeatureURL.Path.equals( msMetricUnit ) ) + { + if( Event.IsEnabled ) + { + sal_Int32 nValue = 0; + if( Event.State >>= nValue ) { - implFillStrings( (FieldUnit)pStateItem->GetValue() ); + implFillStrings( static_cast<FieldUnit>(nValue) ); if( mfDepth >= 0.0 ) implSetDepth( mfDepth, mbEnabled ); } @@ -583,7 +544,7 @@ void ExtrusionDepthWindow::StateChanged( USHORT nSID, SfxItemState eState, const void ExtrusionDepthWindow::DataChanged( const DataChangedEvent& rDCEvt ) { - SfxPopupWindow::DataChanged( rDCEvt ); + ToolbarMenu::DataChanged( rDCEvt ); if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) { @@ -646,7 +607,7 @@ IMPL_LINK( ExtrusionDepthWindow, SelectHdl, void *, EMPTYARG ) } SvxDoubleItem aItem( fDepth, SID_EXTRUSION_DEPTH ); - rtl::OUString aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDepth" )); + rtl::OUString aCommand( msExtrusionDepth ); Any a; INetURLObject aObj( aCommand ); @@ -676,27 +637,11 @@ void ExtrusionDepthWindow::StartSelection() // ----------------------------------------------------------------------- -BOOL ExtrusionDepthWindow::Close() -{ - return SfxPopupWindow::Close(); -} - -// ----------------------------------------------------------------------- - -void ExtrusionDepthWindow::PopupModeEnd() -{ - if ( IsVisible() ) - { - mbPopupMode = FALSE; - } - SfxPopupWindow::PopupModeEnd(); -} - // ----------------------------------------------------------------------- void ExtrusionDepthWindow::GetFocus (void) { - SfxPopupWindow::GetFocus(); + ToolbarMenu::GetFocus(); // Grab the focus to the line ends value set so that it can be controlled // with the keyboard. //if( mpMenu ) @@ -730,10 +675,8 @@ SfxPopupWindowType ExtrusionDepthControl::GetPopupWindowType() const SfxPopupWindow* ExtrusionDepthControl::CreatePopupWindow() { ExtrusionDepthWindow* pWin = new ExtrusionDepthWindow( GetId(), m_xFrame, &GetToolBox() ); - pWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_ALLOWTEAROFF|FLOATWIN_POPUPMODE_REMOVEDECORATION ); - pWin->StartSelection(); - SetPopupWindow( pWin ); - return pWin; + StartPopupMode( pWin ); + return 0; } // ----------------------------------------------------------------------- @@ -754,13 +697,10 @@ SFX_IMPL_TOOLBOX_CONTROL( ExtrusionLightingControl, SfxBoolItem ); // ------------------------------------------------------------------------- ExtrusionLightingWindow::ExtrusionLightingWindow( - USHORT nId, + USHORT /*nId*/, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow ) : - ToolbarMenu( nId, - rFrame, - pParentWindow, - SVX_RES( RID_SVXFLOAT_EXTRUSION_LIGHTING ) ), + ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_LIGHTING ) ), maImgBright( SVX_RES( IMG_LIGHTING_BRIGHT ) ), maImgNormal( SVX_RES( IMG_LIGHTING_NORMAL ) ), maImgDim( SVX_RES( IMG_LIGHTING_DIM ) ), @@ -768,11 +708,12 @@ ExtrusionLightingWindow::ExtrusionLightingWindow( maImgNormalh( SVX_RES( IMG_LIGHTING_NORMAL_H ) ), maImgDimh( SVX_RES( IMG_LIGHTING_DIM_H ) ), mxFrame( rFrame ), - mbPopupMode( true ), mnLevel( 0 ), mbLevelEnabled( false ), mnDirection( FROM_FRONT ), - mbDirectionEnabled( false ) + mbDirectionEnabled( false ), + msExtrusionLightingDirection( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionLightingDirection" )), + msExtrusionLightingIntensity( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionLightingIntensity" )) { implInit(); } @@ -836,15 +777,8 @@ void ExtrusionLightingWindow::implInit() FreeResource(); - AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionLightingDirection" ))); - AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionLightingIntensity" ))); -} - -// ----------------------------------------------------------------------- - -SfxPopupWindow* ExtrusionLightingWindow::Clone() const -{ - return new ExtrusionLightingWindow( GetId(), mxFrame, 0 ); + AddStatusListener( msExtrusionLightingDirection ); + AddStatusListener( msExtrusionLightingIntensity ); } // ----------------------------------------------------------------------- @@ -905,37 +839,32 @@ void ExtrusionLightingWindow::implSetDirection( int nDirection, bool bEnabled ) // ----------------------------------------------------------------------- -void ExtrusionLightingWindow::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) +void SAL_CALL ExtrusionLightingWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ) { - switch( nSID ) + if( Event.FeatureURL.Path.equals( msExtrusionLightingIntensity ) ) { - case SID_EXTRUSION_LIGHTING_INTENSITY: + if( !Event.IsEnabled ) { - if( eState == SFX_ITEM_DISABLED ) - { - implSetIntensity( 0, false ); - } - else - { - const SfxInt32Item* pStateItem = PTR_CAST( SfxInt32Item, pState ); - if( pStateItem ) - implSetIntensity( pStateItem->GetValue(), true ); - } - break; + implSetIntensity( 0, false ); } - case SID_EXTRUSION_LIGHTING_DIRECTION: + else { - if( eState == SFX_ITEM_DISABLED ) - { - implSetDirection( 0, false ); - } - else - { - const SfxInt32Item* pStateItem = PTR_CAST( SfxInt32Item, pState ); - if( pStateItem ) - implSetDirection( pStateItem->GetValue(), true ); - } - break; + sal_Int32 nValue = 0; + if( Event.State >>= nValue ) + implSetIntensity( nValue, true ); + } + } + else if( Event.FeatureURL.Path.equals( msExtrusionLightingDirection ) ) + { + if( !Event.IsEnabled ) + { + implSetDirection( 0, false ); + } + else + { + sal_Int32 nValue = 0; + if( Event.State >>= nValue ) + implSetDirection( nValue, true ); } } } @@ -944,7 +873,7 @@ void ExtrusionLightingWindow::StateChanged( USHORT nSID, SfxItemState eState, co void ExtrusionLightingWindow::DataChanged( const DataChangedEvent& rDCEvt ) { - SfxPopupWindow::DataChanged( rDCEvt ); + ToolbarMenu::DataChanged( rDCEvt ); if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) { @@ -974,7 +903,7 @@ IMPL_LINK( ExtrusionLightingWindow, SelectHdl, void *, pControl ) if( nLevel != 3 ) { SfxInt32Item aItem( SID_EXTRUSION_LIGHTING_INTENSITY, nLevel ); - rtl::OUString aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionLightingIntensity" )); + rtl::OUString aCommand( msExtrusionLightingIntensity ); Any a; INetURLObject aObj( aCommand ); @@ -988,7 +917,6 @@ IMPL_LINK( ExtrusionLightingWindow, SelectHdl, void *, pControl ) aCommand, aArgs ); -// pDisp->Execute( SID_EXTRUSION_LIGHTING_INTENSITY, SFX_CALLMODE_RECORD, &aItem, 0L , 0L ); implSetIntensity( nLevel, true ); } } @@ -1002,7 +930,7 @@ IMPL_LINK( ExtrusionLightingWindow, SelectHdl, void *, pControl ) nDirection--; SfxInt32Item aItem( SID_EXTRUSION_LIGHTING_DIRECTION, nDirection ); - rtl::OUString aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionLightingDirection" )); + rtl::OUString aCommand( msExtrusionLightingDirection ); Any a; INetURLObject aObj( aCommand ); @@ -1015,7 +943,6 @@ IMPL_LINK( ExtrusionLightingWindow, SelectHdl, void *, pControl ) mxFrame->getController(), UNO_QUERY ), aCommand, aArgs ); -// pDisp->Execute( SID_EXTRUSION_LIGHTING_DIRECTION, SFX_CALLMODE_RECORD, &aItem, 0L , 0L ); implSetDirection( nDirection, true ); } @@ -1033,27 +960,11 @@ void ExtrusionLightingWindow::StartSelection() // ----------------------------------------------------------------------- -BOOL ExtrusionLightingWindow::Close() -{ - return SfxPopupWindow::Close(); -} - -// ----------------------------------------------------------------------- - -void ExtrusionLightingWindow::PopupModeEnd() -{ - if ( IsVisible() ) - { - mbPopupMode = FALSE; - } - SfxPopupWindow::PopupModeEnd(); -} - // ----------------------------------------------------------------------- void ExtrusionLightingWindow::GetFocus (void) { - SfxPopupWindow::GetFocus(); + ToolbarMenu::GetFocus(); // Grab the focus to the line ends value set so that it can be controlled // with the keyboard. // if( mpMenu ) @@ -1086,10 +997,8 @@ SfxPopupWindowType ExtrusionLightingControl::GetPopupWindowType() const SfxPopupWindow* ExtrusionLightingControl::CreatePopupWindow() { ExtrusionLightingWindow* pWin = new ExtrusionLightingWindow( GetId(), m_xFrame, &GetToolBox() ); - pWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_ALLOWTEAROFF|FLOATWIN_POPUPMODE_REMOVEDECORATION ); - pWin->StartSelection(); - SetPopupWindow( pWin ); - return pWin; + StartPopupMode( pWin ); + return 0; } // ----------------------------------------------------------------------- @@ -1108,14 +1017,10 @@ void ExtrusionLightingControl::StateChanged( USHORT, SfxItemState eState, const SFX_IMPL_TOOLBOX_CONTROL( ExtrusionSurfaceControl, SfxBoolItem ); ExtrusionSurfaceWindow::ExtrusionSurfaceWindow( - USHORT nId, + USHORT /*nId*/, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow ) : - - ToolbarMenu( nId, - rFrame, - pParentWindow, - SVX_RES( RID_SVXFLOAT_EXTRUSION_SURFACE )), + ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_SURFACE )), maImgSurface1( SVX_RES( IMG_WIRE_FRAME ) ), maImgSurface2( SVX_RES( IMG_MATTE ) ), maImgSurface3( SVX_RES( IMG_PLASTIC ) ), @@ -1125,7 +1030,7 @@ ExtrusionSurfaceWindow::ExtrusionSurfaceWindow( maImgSurface3h( SVX_RES( IMG_PLASTIC_H ) ), maImgSurface4h( SVX_RES( IMG_METAL_H ) ), mxFrame( rFrame ), - mbPopupMode( true ) + msExtrusionSurface( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionSurface" )) { implInit(); } @@ -1154,14 +1059,7 @@ void ExtrusionSurfaceWindow::implInit() FreeResource(); - AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionSurface" ))); -} - -// ----------------------------------------------------------------------- - -SfxPopupWindow* ExtrusionSurfaceWindow::Clone() const -{ - return new ExtrusionSurfaceWindow( GetId(), mxFrame, 0 ); + AddStatusListener( msExtrusionSurface ); } // ----------------------------------------------------------------------- @@ -1188,23 +1086,19 @@ void ExtrusionSurfaceWindow::implSetSurface( int nSurface, bool bEnabled ) // ----------------------------------------------------------------------- -void ExtrusionSurfaceWindow::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) +void SAL_CALL ExtrusionSurfaceWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ) { - switch( nSID ) + if( Event.FeatureURL.Path.equals( msExtrusionSurface ) ) { - case SID_EXTRUSION_SURFACE: + if( !Event.IsEnabled ) { - if( eState == SFX_ITEM_DISABLED ) - { - implSetSurface( 0, false ); - } - else - { - const SfxInt32Item* pStateItem = PTR_CAST( SfxInt32Item, pState ); - if( pStateItem ) - implSetSurface( pStateItem->GetValue(), true ); - } - break; + implSetSurface( 0, false ); + } + else + { + sal_Int32 nValue = 0; + if( Event.State >>= nValue ) + implSetSurface( nValue, true ); } } } @@ -1213,7 +1107,7 @@ void ExtrusionSurfaceWindow::StateChanged( USHORT nSID, SfxItemState eState, con void ExtrusionSurfaceWindow::DataChanged( const DataChangedEvent& rDCEvt ) { - SfxPopupWindow::DataChanged( rDCEvt ); + ToolbarMenu::DataChanged( rDCEvt ); if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) { @@ -1239,7 +1133,7 @@ IMPL_LINK( ExtrusionSurfaceWindow, SelectHdl, void *, EMPTYARG ) if( nSurface >= 0 ) { SfxInt32Item aItem( SID_EXTRUSION_SURFACE, nSurface ); - rtl::OUString aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionSurface" )); + rtl::OUString aCommand( msExtrusionSurface ); Any a; INetURLObject aObj( aCommand ); @@ -1252,7 +1146,6 @@ IMPL_LINK( ExtrusionSurfaceWindow, SelectHdl, void *, EMPTYARG ) mxFrame->getController(), UNO_QUERY ), aCommand, aArgs ); -// pDisp->Execute( SID_EXTRUSION_SURFACE, SFX_CALLMODE_RECORD, &aItem, 0L , 0L ); implSetSurface( nSurface, true ); } @@ -1268,27 +1161,11 @@ void ExtrusionSurfaceWindow::StartSelection() // ----------------------------------------------------------------------- -BOOL ExtrusionSurfaceWindow::Close() -{ - return SfxPopupWindow::Close(); -} - -// ----------------------------------------------------------------------- - -void ExtrusionSurfaceWindow::PopupModeEnd() -{ - if ( IsVisible() ) - { - mbPopupMode = FALSE; - } - SfxPopupWindow::PopupModeEnd(); -} - // ----------------------------------------------------------------------- void ExtrusionSurfaceWindow::GetFocus (void) { - SfxPopupWindow::GetFocus(); + ToolbarMenu::GetFocus(); // Grab the focus to the line ends value set so that it can be controlled // with the keyboard. //if( mpMenu ) @@ -1322,10 +1199,8 @@ SfxPopupWindowType ExtrusionSurfaceControl::GetPopupWindowType() const SfxPopupWindow* ExtrusionSurfaceControl::CreatePopupWindow() { ExtrusionSurfaceWindow* pWin = new ExtrusionSurfaceWindow( GetId(), m_xFrame, &GetToolBox() ); - pWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_ALLOWTEAROFF|FLOATWIN_POPUPMODE_REMOVEDECORATION ); - pWin->StartSelection(); - SetPopupWindow( pWin ); - return pWin; + StartPopupMode( pWin ); + return 0; } // ----------------------------------------------------------------------- diff --git a/svx/source/tbxctrls/extrusioncontrols.src b/svx/source/tbxctrls/extrusioncontrols.src index 0a5e2a4b11a2..9d5949fbc825 100644 --- a/svx/source/tbxctrls/extrusioncontrols.src +++ b/svx/source/tbxctrls/extrusioncontrols.src @@ -33,7 +33,7 @@ #define MASKCOLOR MaskColor = Color { Red=0xFFFF; Green=0x0000; Blue=0xFFFF; }; -FloatingWindow RID_SVXFLOAT_EXTRUSION_DIRECTION +DockingWindow RID_SVXFLOAT_EXTRUSION_DIRECTION { Border = FALSE ; Hide = TRUE ; @@ -203,7 +203,7 @@ FloatingWindow RID_SVXFLOAT_EXTRUSION_DIRECTION }; }; -FloatingWindow RID_SVXFLOAT_EXTRUSION_DEPTH +DockingWindow RID_SVXFLOAT_EXTRUSION_DEPTH { Border = FALSE ; Hide = TRUE ; @@ -292,7 +292,7 @@ FloatingWindow RID_SVXFLOAT_EXTRUSION_DEPTH }; }; -FloatingWindow RID_SVXFLOAT_EXTRUSION_LIGHTING +DockingWindow RID_SVXFLOAT_EXTRUSION_LIGHTING { Border = FALSE ; Hide = TRUE ; @@ -608,7 +608,7 @@ FloatingWindow RID_SVXFLOAT_EXTRUSION_LIGHTING }; }; -FloatingWindow RID_SVXFLOAT_EXTRUSION_SURFACE +DockingWindow RID_SVXFLOAT_EXTRUSION_SURFACE { Border = FALSE ; Hide = TRUE ; diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx index ed25ad41d43e..b6cd012f9aea 100644 --- a/svx/source/tbxctrls/fontworkgallery.cxx +++ b/svx/source/tbxctrls/fontworkgallery.cxx @@ -328,13 +328,6 @@ SfxPopupWindow* FontWorkShapeTypeControl::CreatePopupWindow() // ----------------------------------------------------------------------- -void FontWorkShapeTypeControl::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) -{ - SfxToolBoxControl::StateChanged( nSID, eState, pState ); -} - -// ----------------------------------------------------------------------- - void FontWorkShapeTypeControl::Select( BOOL ) { @@ -345,13 +338,11 @@ void FontWorkShapeTypeControl::Select( BOOL ) SFX_IMPL_TOOLBOX_CONTROL( FontWorkAlignmentControl, SfxBoolItem ); FontWorkAlignmentWindow::FontWorkAlignmentWindow( - USHORT nId, + USHORT /*nId*/, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow ) : - ToolbarMenu( nId, - rFrame, pParentWindow, - SVX_RES( RID_SVXFLOAT_FONTWORK_ALIGNMENT )), + ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_FONTWORK_ALIGNMENT )), maImgAlgin1( SVX_RES( IMG_FONTWORK_ALIGN_LEFT_16 ) ), maImgAlgin2( SVX_RES( IMG_FONTWORK_ALIGN_CENTER_16 ) ), maImgAlgin3( SVX_RES( IMG_FONTWORK_ALIGN_RIGHT_16 ) ), @@ -363,7 +354,7 @@ FontWorkAlignmentWindow::FontWorkAlignmentWindow( maImgAlgin4h( SVX_RES( IMG_FONTWORK_ALIGN_WORD_16_H ) ), maImgAlgin5h( SVX_RES( IMG_FONTWORK_ALIGN_STRETCH_16_H ) ), mxFrame( rFrame ), - mbPopupMode( true ) + msFontworkAlignment( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkAlignment" ) ) { SetHelpId( HID_WIN_FONTWORK_ALIGN ); implInit(); @@ -388,12 +379,7 @@ void FontWorkAlignmentWindow::implInit() FreeResource(); - AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkAlignment" ))); -} - -SfxPopupWindow* FontWorkAlignmentWindow::Clone() const -{ - return new FontWorkAlignmentWindow( GetId(), mxFrame, 0 ); + AddStatusListener( msFontworkAlignment ); } // ----------------------------------------------------------------------- @@ -416,23 +402,19 @@ void FontWorkAlignmentWindow::implSetAlignment( int nSurface, bool bEnabled ) // ----------------------------------------------------------------------- -void FontWorkAlignmentWindow::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) +void SAL_CALL FontWorkAlignmentWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ) { - switch( nSID ) + if( Event.FeatureURL.Path.equals( msFontworkAlignment ) ) { - case SID_FONTWORK_ALIGNMENT: + if( !Event.IsEnabled ) { - if( eState == SFX_ITEM_DISABLED ) - { - implSetAlignment( 0, false ); - } - else - { - const SfxInt32Item* pStateItem = PTR_CAST( SfxInt32Item, pState ); - if( pStateItem ) - implSetAlignment( pStateItem->GetValue(), true ); - } - break; + implSetAlignment( 0, false ); + } + else + { + sal_Int32 nValue; + if( Event.State >>= nValue ) + implSetAlignment( nValue, true ); } } } @@ -441,7 +423,7 @@ void FontWorkAlignmentWindow::StateChanged( USHORT nSID, SfxItemState eState, co void FontWorkAlignmentWindow::DataChanged( const DataChangedEvent& rDCEvt ) { - SfxPopupWindow::DataChanged( rDCEvt ); + ToolbarMenu::DataChanged( rDCEvt ); if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) { @@ -496,27 +478,9 @@ void FontWorkAlignmentWindow::StartSelection() // ----------------------------------------------------------------------- -BOOL FontWorkAlignmentWindow::Close() -{ - return SfxPopupWindow::Close(); -} - -// ----------------------------------------------------------------------- - -void FontWorkAlignmentWindow::PopupModeEnd() -{ - if ( IsVisible() ) - { - mbPopupMode = FALSE; - } - SfxPopupWindow::PopupModeEnd(); -} - -// ----------------------------------------------------------------------- - void FontWorkAlignmentWindow::GetFocus (void) { - SfxPopupWindow::GetFocus(); + ToolbarMenu::GetFocus(); // Grab the focus to the line ends value set so that it can be controlled // with the keyboard. GrabFocus(); @@ -549,10 +513,8 @@ SfxPopupWindowType FontWorkAlignmentControl::GetPopupWindowType() const SfxPopupWindow* FontWorkAlignmentControl::CreatePopupWindow() { FontWorkAlignmentWindow* pWin = new FontWorkAlignmentWindow( GetId(), m_xFrame, &GetToolBox() ); - pWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_ALLOWTEAROFF|FLOATWIN_POPUPMODE_REMOVEDECORATION ); - pWin->StartSelection(); - SetPopupWindow( pWin ); - return pWin; + StartPopupMode( pWin ); + return 0; } // ----------------------------------------------------------------------- @@ -570,17 +532,11 @@ void FontWorkAlignmentControl::StateChanged( USHORT /*nSID*/, SfxItemState eStat SFX_IMPL_TOOLBOX_CONTROL( FontWorkCharacterSpacingControl, SfxBoolItem ); -FontWorkCharacterSpacingWindow::FontWorkCharacterSpacingWindow( - USHORT nId, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, - Window* pParentWindow ) : - - ToolbarMenu( nId, - rFrame, - pParentWindow, - SVX_RES( RID_SVXFLOAT_FONTWORK_CHARSPACING )), - mxFrame( rFrame ), - mbPopupMode( true ) +FontWorkCharacterSpacingWindow::FontWorkCharacterSpacingWindow( USHORT /*nId*/, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow ) +: ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_FONTWORK_CHARSPACING )) +, mxFrame( rFrame ) +, msFontworkCharacterSpacing( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacing" ) ) +, msFontworkKernCharacterPairs( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkKernCharacterPairs" ) ) { implInit(); } @@ -607,12 +563,8 @@ void FontWorkCharacterSpacingWindow::implInit() FreeResource(); - AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacing" ))); -} - -SfxPopupWindow* FontWorkCharacterSpacingWindow::Clone() const -{ - return new FontWorkCharacterSpacingWindow( GetId(), mxFrame, 0 ); + AddStatusListener( msFontworkCharacterSpacing ); + AddStatusListener( msFontworkKernCharacterPairs ); } // ----------------------------------------------------------------------- @@ -647,6 +599,8 @@ void FontWorkCharacterSpacingWindow::implSetCharacterSpacing( sal_Int32 nCharact } } +// ----------------------------------------------------------------------- + void FontWorkCharacterSpacingWindow::implSetKernCharacterPairs( sal_Bool, bool bEnabled ) { enableEntry( 6, bEnabled ); @@ -655,35 +609,33 @@ void FontWorkCharacterSpacingWindow::implSetKernCharacterPairs( sal_Bool, bool b // ----------------------------------------------------------------------- -void FontWorkCharacterSpacingWindow::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) +void SAL_CALL FontWorkCharacterSpacingWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ) { - switch( nSID ) + if( Event.FeatureURL.Path.equals( msFontworkCharacterSpacing ) ) { - case SID_FONTWORK_CHARACTER_SPACING: + if( !Event.IsEnabled ) { - if( eState == SFX_ITEM_DISABLED ) - implSetCharacterSpacing( 0, false ); - else - { - const SfxInt32Item* pStateItem = PTR_CAST( SfxInt32Item, pState ); - if( pStateItem ) - implSetCharacterSpacing( pStateItem->GetValue(), true ); - } + implSetCharacterSpacing( 0, false ); } - break; - - case SID_FONTWORK_KERN_CHARACTER_PAIRS : + else { - if( eState == SFX_ITEM_DISABLED ) - implSetKernCharacterPairs( 0, false ); - else - { - const SfxBoolItem* pStateItem = PTR_CAST( SfxBoolItem, pState ); - if( pStateItem ) - implSetKernCharacterPairs( pStateItem->GetValue(), true ); - } + sal_Int32 nValue = 0; + if( Event.State >>= nValue ) + implSetCharacterSpacing( nValue, true ); + } + } + else if( Event.FeatureURL.Path.equals( msFontworkKernCharacterPairs ) ) + { + if( !Event.IsEnabled ) + { + implSetKernCharacterPairs( 0, false ); + } + else + { + sal_Bool bValue = sal_False; + if( Event.State >>= bValue ) + implSetKernCharacterPairs( bValue, true ); } - break; } } @@ -691,7 +643,7 @@ void FontWorkCharacterSpacingWindow::StateChanged( USHORT nSID, SfxItemState eSt void FontWorkCharacterSpacingWindow::DataChanged( const DataChangedEvent& rDCEvt ) { - SfxPopupWindow::DataChanged( rDCEvt ); + ToolbarMenu::DataChanged( rDCEvt ); if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) { @@ -790,27 +742,9 @@ void FontWorkCharacterSpacingWindow::StartSelection() // ----------------------------------------------------------------------- -BOOL FontWorkCharacterSpacingWindow::Close() -{ - return SfxPopupWindow::Close(); -} - -// ----------------------------------------------------------------------- - -void FontWorkCharacterSpacingWindow::PopupModeEnd() -{ - if ( IsVisible() ) - { - mbPopupMode = FALSE; - } - SfxPopupWindow::PopupModeEnd(); -} - -// ----------------------------------------------------------------------- - void FontWorkCharacterSpacingWindow::GetFocus (void) { - SfxPopupWindow::GetFocus(); + ToolbarMenu::GetFocus(); // Grab the focus to the line ends value set so that it can be controlled // with the keyboard. GrabFocus(); @@ -843,10 +777,8 @@ SfxPopupWindowType FontWorkCharacterSpacingControl::GetPopupWindowType() const SfxPopupWindow* FontWorkCharacterSpacingControl::CreatePopupWindow() { FontWorkCharacterSpacingWindow* pWin = new FontWorkCharacterSpacingWindow( GetId(), m_xFrame, &GetToolBox() ); - pWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_ALLOWTEAROFF|FLOATWIN_POPUPMODE_REMOVEDECORATION ); - pWin->StartSelection(); - SetPopupWindow( pWin ); - return pWin; + StartPopupMode( pWin ); + return 0; } // ----------------------------------------------------------------------- diff --git a/svx/source/tbxctrls/fontworkgallery.src b/svx/source/tbxctrls/fontworkgallery.src index d21bb3fdac0e..df3e52a168f6 100644 --- a/svx/source/tbxctrls/fontworkgallery.src +++ b/svx/source/tbxctrls/fontworkgallery.src @@ -95,7 +95,7 @@ ModalDialog RID_SVX_MDLG_FONTWORK_GALLERY }; }; -FloatingWindow RID_SVXFLOAT_FONTWORK_ALIGNMENT +DockingWindow RID_SVXFLOAT_FONTWORK_ALIGNMENT { Border = FALSE ; Hide = TRUE ; @@ -230,7 +230,7 @@ FloatingWindow RID_SVXFLOAT_FONTWORK_ALIGNMENT }; }; -FloatingWindow RID_SVXFLOAT_FONTWORK_CHARSPACING +DockingWindow RID_SVXFLOAT_FONTWORK_CHARSPACING { Border = FALSE ; Hide = TRUE ; diff --git a/svx/source/tbxctrls/toolbarmenu.cxx b/svx/source/tbxctrls/toolbarmenu.cxx index 382ab0581919..9867210b41af 100644 --- a/svx/source/tbxctrls/toolbarmenu.cxx +++ b/svx/source/tbxctrls/toolbarmenu.cxx @@ -32,6 +32,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" +#include <comphelper/processfactory.hxx> + +#include <vcl/dockwin.hxx> #include <vcl/menu.hxx> #include <vcl/decoview.hxx> #include <vcl/image.hxx> @@ -143,20 +146,20 @@ ToolbarMenuEntry::~ToolbarMenuEntry() delete mpControl; } -ToolbarMenu::ToolbarMenu( USHORT nId, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, +ToolbarMenu::ToolbarMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow, WinBits nBits ) -: SfxPopupWindow(nId, rFrame, pParentWindow, nBits) +: DockingWindow(pParentWindow, nBits) +, mxFrame( rFrame ) { implInit(); } -ToolbarMenu::ToolbarMenu( USHORT nId, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, +ToolbarMenu::ToolbarMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow, const ResId& rResId ) -: SfxPopupWindow(nId, rFrame, pParentWindow, rResId) +: DockingWindow(pParentWindow, rResId) +, mxFrame( rFrame ) { implInit(); } @@ -167,6 +170,8 @@ void ToolbarMenu::implInit() // EnableChildTransparentMode(); + mxServiceManager = ::comphelper::getProcessServiceFactory(); + mnCheckPos = 0; mnImagePos = 0; mnTextPos = 0; @@ -178,6 +183,12 @@ void ToolbarMenu::implInit() ToolbarMenu::~ToolbarMenu() { + if ( mxStatusListener.is() ) + { + mxStatusListener->dispose(); + mxStatusListener.clear(); + } + // delete all menu entries const int nEntryCount = maEntryVector.size(); int nEntry; @@ -446,7 +457,7 @@ void ToolbarMenu::GetFocus() implChangeHighlightEntry( 0 ); } */ - SfxPopupWindow::GetFocus(); + DockingWindow::GetFocus(); } void ToolbarMenu::LoseFocus() @@ -455,7 +466,7 @@ void ToolbarMenu::LoseFocus() { implChangeHighlightEntry( -1 ); } - SfxPopupWindow::LoseFocus(); + DockingWindow::LoseFocus(); } void ToolbarMenu::appendEntry( int nEntryId, const String& rStr, MenuItemBits nItemBits ) @@ -498,7 +509,7 @@ void ToolbarMenu::appendSeparator() void ToolbarMenu::Resize() { - Window::Resize(); + DockingWindow::Resize(); } ToolbarMenuEntry* ToolbarMenu::implGetEntry( int nEntry ) const @@ -853,6 +864,7 @@ void ToolbarMenu::KeyInput( const KeyEvent& rKEvent ) } } +/* void ToolbarMenu::implDrawBorder() { SetFillColor(); @@ -872,6 +884,7 @@ void ToolbarMenu::implDrawBorder() DrawRect( aRect ); SetClipRegion( oldClipRgn ); } +*/ void ToolbarMenu::implPaint( ToolbarMenuEntry* pThisOnly, bool bHighlighted ) { @@ -1024,7 +1037,7 @@ void ToolbarMenu::implPaint( ToolbarMenuEntry* pThisOnly, bool bHighlighted ) void ToolbarMenu::Paint( const Rectangle& ) { - implDrawBorder(); +// implDrawBorder(); implPaint(); if( mnHighlightedEntry != -1 ) @@ -1033,12 +1046,12 @@ void ToolbarMenu::Paint( const Rectangle& ) void ToolbarMenu::RequestHelp( const HelpEvent& rHEvt ) { - Window::RequestHelp( rHEvt ); + DockingWindow::RequestHelp( rHEvt ); } void ToolbarMenu::StateChanged( StateChangedType nType ) { - SfxPopupWindow::StateChanged( nType ); + DockingWindow::StateChanged( nType ); if ( ( nType == STATE_CHANGE_CONTROLFOREGROUND ) || ( nType == STATE_CHANGE_CONTROLBACKGROUND ) ) { @@ -1049,7 +1062,7 @@ void ToolbarMenu::StateChanged( StateChangedType nType ) void ToolbarMenu::DataChanged( const DataChangedEvent& rDCEvt ) { - SfxPopupWindow::DataChanged( rDCEvt ); + DockingWindow::DataChanged( rDCEvt ); if ( (rDCEvt.GetType() == DATACHANGED_FONTS) || (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) || @@ -1072,3 +1085,85 @@ void ToolbarMenu::Command( const CommandEvent& rCEvt ) } } } + +// todo: move to new base class that will replace SfxPopupWindo +void ToolbarMenu::AddStatusListener( const rtl::OUString& rCommandURL ) +{ + initStatusListener(); + mxStatusListener->addStatusListener( rCommandURL ); +} + +// -------------------------------------------------------------------- + +void ToolbarMenu::RemoveStatusListener( const rtl::OUString& rCommandURL ) +{ + mxStatusListener->removeStatusListener( rCommandURL ); +} +// -------------------------------------------------------------------- + + +void ToolbarMenu::UpdateStatus( const rtl::OUString& rCommandURL ) +{ + mxStatusListener->updateStatus( rCommandURL ); +} + +// -------------------------------------------------------------------- + +// XStatusListener (subclasses must override this one to get the status updates +void SAL_CALL ToolbarMenu::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& /*Event*/ ) throw ( ::com::sun::star::uno::RuntimeException ) +{ +} + +// -------------------------------------------------------------------- + +class ToolbarMenuStatusListener : public svt::FrameStatusListener +{ +public: + ToolbarMenuStatusListener( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xServiceManager, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, + ToolbarMenu& rToolbarMenu ); + + virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); + + ToolbarMenu* mpMenu; +}; + +ToolbarMenuStatusListener::ToolbarMenuStatusListener( + const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xServiceManager, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, + ToolbarMenu& rToolbarMenu ) +: svt::FrameStatusListener( xServiceManager, xFrame ) +, mpMenu( &rToolbarMenu ) +{ +} + +void SAL_CALL ToolbarMenuStatusListener::dispose() throw (::com::sun::star::uno::RuntimeException) +{ + mpMenu = 0; + svt::FrameStatusListener::dispose(); +} + +void SAL_CALL ToolbarMenuStatusListener::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ) +{ + if( mpMenu ) + mpMenu->statusChanged( Event ); +} + +void ToolbarMenu::initStatusListener() +{ + if( !mxStatusListener.is() ) + mxStatusListener.set( new ToolbarMenuStatusListener( mxServiceManager, mxFrame, *this ) ); +} + +bool ToolbarMenu::IsInPopupMode() +{ + return GetDockingManager()->IsInPopupMode(this); +} + +void ToolbarMenu::EndPopupMode() +{ + GetDockingManager()->EndPopupMode(this); +} + + |