diff options
author | Jan Holesovsky <kendy@suse.cz> | 2012-04-15 01:15:27 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2012-04-15 01:16:25 +0200 |
commit | 69805b85f2643d3df4266a30f019e5f90c9a0826 (patch) | |
tree | 53b50fee63e325a7e8d130a068119bbef1e04a35 | |
parent | 93b1c8b4a5a0f2d12b21fb6e8e8a01c63d43027d (diff) |
findbar: Kill copy'n'paste.
-rw-r--r-- | svx/inc/tbunosearchcontrollers.hxx | 55 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbunosearchcontrollers.cxx | 172 | ||||
-rw-r--r-- | svx/source/unodraw/unoctabl.cxx | 12 |
3 files changed, 37 insertions, 202 deletions
diff --git a/svx/inc/tbunosearchcontrollers.hxx b/svx/inc/tbunosearchcontrollers.hxx index 2bfa26547af1..032662cf361d 100644 --- a/svx/inc/tbunosearchcontrollers.hxx +++ b/svx/inc/tbunosearchcontrollers.hxx @@ -143,52 +143,14 @@ private: }; -class DownSearchToolboxController : public svt::ToolboxController, - public css::lang::XServiceInfo +class UpDownSearchToolboxController : public svt::ToolboxController, + public css::lang::XServiceInfo { public: + enum Type { UP, DOWN }; - DownSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager ); - ~DownSearchToolboxController(); - - // XInterface - virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException ); - virtual void SAL_CALL acquire() throw (); - virtual void SAL_CALL release() throw (); - - // XServiceInfo - virtual ::rtl::OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException ); - virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException ); - virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException ); - - static ::rtl::OUString getImplementationName_Static() throw() - { - return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.svx.DownSearchToolboxController" )); - } - - static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw(); - - // XComponent - virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException ); - - // XInitialization - virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException ); - - // XToolbarController - virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException); - - // XStatusListener - virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException ); - -}; - -class UpSearchToolboxController : public svt::ToolboxController, - public css::lang::XServiceInfo -{ -public: - - UpSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager ); - ~UpSearchToolboxController(); + UpDownSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager, Type eType ); + ~UpDownSearchToolboxController(); // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException ); @@ -200,9 +162,10 @@ public: virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException ); virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException ); - static ::rtl::OUString getImplementationName_Static() throw() + static ::rtl::OUString getImplementationName_Static( Type eType ) throw() { - return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.svx.UpSearchToolboxController" )); + return eType == UP? ::rtl::OUString( "com.sun.star.svx.UpSearchToolboxController" ) : + ::rtl::OUString( "com.sun.star.svx.DownSearchToolboxController" ); } static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw(); @@ -219,6 +182,8 @@ public: // XStatusListener virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException ); +private: + Type meType; }; // protocol handler for "vnd.sun.star.findbar:*" URLs diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index 184c6db400f0..de6f1619d568 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -459,21 +459,22 @@ IMPL_LINK_NOARG(FindTextToolbarController, EditModifyHdl) } //----------------------------------------------------------------------------------------------------------- -// class DownSearchToolboxController +// class UpDownSearchToolboxController -DownSearchToolboxController::DownSearchToolboxController(const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager ) +UpDownSearchToolboxController::UpDownSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager, Type eType ) : svt::ToolboxController( rServiceManager, - css::uno::Reference< css::frame::XFrame >(), - rtl::OUString(COMMAND_DOWNSEARCH) ) + css::uno::Reference< css::frame::XFrame >(), + (eType == UP) ? rtl::OUString( COMMAND_UPSEARCH ): rtl::OUString( COMMAND_DOWNSEARCH ) ), + meType( eType ) { } -DownSearchToolboxController::~DownSearchToolboxController() +UpDownSearchToolboxController::~UpDownSearchToolboxController() { } // XInterface -css::uno::Any SAL_CALL DownSearchToolboxController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException ) +css::uno::Any SAL_CALL UpDownSearchToolboxController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException ) { css::uno::Any a = ToolboxController::queryInterface( aType ); if ( a.hasValue() ) @@ -482,23 +483,23 @@ css::uno::Any SAL_CALL DownSearchToolboxController::queryInterface( const css::u return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) ); } -void SAL_CALL DownSearchToolboxController::acquire() throw () +void SAL_CALL UpDownSearchToolboxController::acquire() throw () { ToolboxController::acquire(); } -void SAL_CALL DownSearchToolboxController::release() throw () +void SAL_CALL UpDownSearchToolboxController::release() throw () { ToolboxController::release(); } // XServiceInfo -::rtl::OUString SAL_CALL DownSearchToolboxController::getImplementationName() throw( css::uno::RuntimeException ) +::rtl::OUString SAL_CALL UpDownSearchToolboxController::getImplementationName() throw( css::uno::RuntimeException ) { - return getImplementationName_Static(); + return getImplementationName_Static( meType ); } -sal_Bool SAL_CALL DownSearchToolboxController::supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException ) +sal_Bool SAL_CALL UpDownSearchToolboxController::supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException ) { const css::uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() ); const ::rtl::OUString * pArray = aSNL.getConstArray(); @@ -510,12 +511,12 @@ sal_Bool SAL_CALL DownSearchToolboxController::supportsService( const ::rtl::OUS return false; } -css::uno::Sequence< ::rtl::OUString > SAL_CALL DownSearchToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException ) +css::uno::Sequence< ::rtl::OUString > SAL_CALL UpDownSearchToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException ) { return getSupportedServiceNames_Static(); } -css::uno::Sequence< ::rtl::OUString > DownSearchToolboxController::getSupportedServiceNames_Static() throw() +css::uno::Sequence< ::rtl::OUString > UpDownSearchToolboxController::getSupportedServiceNames_Static() throw() { css::uno::Sequence< ::rtl::OUString > aSNS( 1 ); aSNS.getArray()[0] = ::rtl::OUString("com.sun.star.frame.ToolbarController"); @@ -523,7 +524,7 @@ css::uno::Sequence< ::rtl::OUString > DownSearchToolboxController::getSupported } // XComponent -void SAL_CALL DownSearchToolboxController::dispose() throw ( css::uno::RuntimeException ) +void SAL_CALL UpDownSearchToolboxController::dispose() throw ( css::uno::RuntimeException ) { SolarMutexGuard aSolarMutexGuard; @@ -533,14 +534,14 @@ void SAL_CALL DownSearchToolboxController::dispose() throw ( css::uno::RuntimeEx } // XInitialization -void SAL_CALL DownSearchToolboxController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException ) +void SAL_CALL UpDownSearchToolboxController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException ) { svt::ToolboxController::initialize( aArguments ); SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); } // XToolbarController -void SAL_CALL DownSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException) +void SAL_CALL UpDownSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException ) { if ( m_bDisposed ) throw css::lang::DisposedException(); @@ -568,138 +569,7 @@ void SAL_CALL DownSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) lArgs[0].Name = rtl::OUString(SEARCHITEM_SEARCHSTRING); lArgs[0].Value <<= sFindText; lArgs[1].Name = rtl::OUString(SEARCHITEM_SEARCHBACKWARD); - lArgs[1].Value <<= sal_False; - lArgs[2].Name = rtl::OUString(SEARCHITEM_SEARCHFLAGS); - lArgs[2].Value <<= (sal_Int32)0; - - impl_executeSearch(m_xServiceManager, m_xFrame, lArgs); - - css::frame::FeatureStateEvent aEvent; - aEvent.FeatureURL.Complete = rtl::OUString(COMMAND_APPENDSEARCHHISTORY); - css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager().findController(m_xFrame, COMMAND_FINDTEXT); - if (xStatusListener.is()) - xStatusListener->statusChanged( aEvent ); -} - -// XStatusListener -void SAL_CALL DownSearchToolboxController::statusChanged( const css::frame::FeatureStateEvent& /*rEvent*/ ) throw ( css::uno::RuntimeException ) -{ - SolarMutexGuard aSolarMutexGuard; - if ( m_bDisposed ) - return; -} - -//----------------------------------------------------------------------------------------------------------- -// class UpSearchToolboxController - -UpSearchToolboxController::UpSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager ) - :svt::ToolboxController( rServiceManager, - css::uno::Reference< css::frame::XFrame >(), - rtl::OUString(COMMAND_UPSEARCH) ) -{ -} - -UpSearchToolboxController::~UpSearchToolboxController() -{ -} - -// XInterface -css::uno::Any SAL_CALL UpSearchToolboxController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException ) -{ - css::uno::Any a = ToolboxController::queryInterface( aType ); - if ( a.hasValue() ) - return a; - - return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) ); -} - -void SAL_CALL UpSearchToolboxController::acquire() throw () -{ - ToolboxController::acquire(); -} - -void SAL_CALL UpSearchToolboxController::release() throw () -{ - ToolboxController::release(); -} - -// XServiceInfo -::rtl::OUString SAL_CALL UpSearchToolboxController::getImplementationName() throw( css::uno::RuntimeException ) -{ - return getImplementationName_Static(); -} - -sal_Bool SAL_CALL UpSearchToolboxController::supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException ) -{ - const css::uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() ); - const ::rtl::OUString * pArray = aSNL.getConstArray(); - - for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) - if( pArray[i] == ServiceName ) - return true; - - return false; -} - -css::uno::Sequence< ::rtl::OUString > SAL_CALL UpSearchToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException ) -{ - return getSupportedServiceNames_Static(); -} - -css::uno::Sequence< ::rtl::OUString > UpSearchToolboxController::getSupportedServiceNames_Static() throw() -{ - css::uno::Sequence< ::rtl::OUString > aSNS( 1 ); - aSNS.getArray()[0] = ::rtl::OUString("com.sun.star.frame.ToolbarController"); - return aSNS; -} - -// XComponent -void SAL_CALL UpSearchToolboxController::dispose() throw ( css::uno::RuntimeException ) -{ - SolarMutexGuard aSolarMutexGuard; - - SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); - - svt::ToolboxController::dispose(); -} - -// XInitialization -void SAL_CALL UpSearchToolboxController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException ) -{ - svt::ToolboxController::initialize( aArguments ); - SearchToolbarControllersManager::createControllersManager().registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL); -} - -// XToolbarController -void SAL_CALL UpSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException ) -{ - if ( m_bDisposed ) - throw css::lang::DisposedException(); - - ::rtl::OUString sFindText; - Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); - ToolBox* pToolBox = (ToolBox*)pWindow; - if ( pToolBox ) - { - sal_uInt16 nItemCount = pToolBox->GetItemCount(); - for ( sal_uInt16 i=0; i<nItemCount; ++i ) - { - ::rtl::OUString sItemCommand = pToolBox->GetItemCommand(i); - if ( sItemCommand.equals( COMMAND_FINDTEXT ) ) - { - Window* pItemWin = pToolBox->GetItemWindow(i); - if (pItemWin) - sFindText = pItemWin->GetText(); - break; - } - } - } - - css::uno::Sequence< css::beans::PropertyValue > lArgs(3); - lArgs[0].Name = rtl::OUString(SEARCHITEM_SEARCHSTRING); - lArgs[0].Value <<= sFindText; - lArgs[1].Name = rtl::OUString(SEARCHITEM_SEARCHBACKWARD); - lArgs[1].Value <<= sal_True; + lArgs[1].Value <<= sal_Bool( meType == UP ); lArgs[2].Name = rtl::OUString(SEARCHITEM_SEARCHFLAGS); lArgs[2].Value <<= (sal_Int32)0; @@ -713,7 +583,7 @@ void SAL_CALL UpSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) th } // XStatusListener -void SAL_CALL UpSearchToolboxController::statusChanged( const css::frame::FeatureStateEvent& /*rEvent*/ ) throw ( css::uno::RuntimeException ) +void SAL_CALL UpDownSearchToolboxController::statusChanged( const css::frame::FeatureStateEvent& /*rEvent*/ ) throw ( css::uno::RuntimeException ) { SolarMutexGuard aSolarMutexGuard; if ( m_bDisposed ) @@ -887,13 +757,13 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL FindTextToolbarController_c css::uno::Reference< css::uno::XInterface > SAL_CALL DownSearchToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ) { - return *new DownSearchToolboxController( rSMgr ); + return *new UpDownSearchToolboxController( rSMgr, UpDownSearchToolboxController::DOWN ); } css::uno::Reference< css::uno::XInterface > SAL_CALL UpSearchToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ) { - return *new UpSearchToolboxController( rSMgr ); + return *new UpDownSearchToolboxController( rSMgr, UpDownSearchToolboxController::UP ); } css::uno::Reference< css::uno::XInterface > SAL_CALL FindbarDispatcher_createInstance( diff --git a/svx/source/unodraw/unoctabl.cxx b/svx/source/unodraw/unoctabl.cxx index e7fb9692568a..9498eac4a308 100644 --- a/svx/source/unodraw/unoctabl.cxx +++ b/svx/source/unodraw/unoctabl.cxx @@ -310,19 +310,19 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL svx_component_getFactory ( svx::FindTextToolbarController_createInstance, svx::FindTextToolbarController::getSupportedServiceNames_Static() ); } - else if ( svx::DownSearchToolboxController::getImplementationName_Static().equalsAscii( pImplName ) ) + else if ( svx::UpDownSearchToolboxController::getImplementationName_Static( svx::UpDownSearchToolboxController::DOWN ).equalsAscii( pImplName ) ) { xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), - svx::DownSearchToolboxController::getImplementationName_Static(), + svx::UpDownSearchToolboxController::getImplementationName_Static( svx::UpDownSearchToolboxController::DOWN ), svx::DownSearchToolboxController_createInstance, - svx::DownSearchToolboxController::getSupportedServiceNames_Static() ); + svx::UpDownSearchToolboxController::getSupportedServiceNames_Static() ); } - else if ( svx::UpSearchToolboxController::getImplementationName_Static().equalsAscii( pImplName ) ) + else if ( svx::UpDownSearchToolboxController::getImplementationName_Static( svx::UpDownSearchToolboxController::UP ).equalsAscii( pImplName ) ) { xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), - svx::UpSearchToolboxController::getImplementationName_Static(), + svx::UpDownSearchToolboxController::getImplementationName_Static( svx::UpDownSearchToolboxController::UP ), svx::UpSearchToolboxController_createInstance, - svx::UpSearchToolboxController::getSupportedServiceNames_Static() ); + svx::UpDownSearchToolboxController::getSupportedServiceNames_Static() ); } else if ( svx::FindbarDispatcher::getImplementationName_Static().equalsAscii( pImplName ) ) { |