diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-05-23 20:41:19 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2013-05-28 14:16:55 +0000 |
commit | e8352a90c2b6d9b20c71e3b2867169236bca13f5 (patch) | |
tree | a52f43a9050b9bc602fd0f5c385da0f1f227842f /svx | |
parent | 3f923bf9cf9b6fe728e7804fdb13aabe620d3dbc (diff) |
fdo#64451 Add "Find All" to the Find bar.
Change-Id: I7a5f2881d2aa77f2d5c6c302c8eac1162b194bcf
Reviewed-on: https://gerrit.libreoffice.org/4016
Reviewed-by: Jan Holesovsky <kendy@suse.cz>
Tested-by: Jan Holesovsky <kendy@suse.cz>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/inc/tbunosearchcontrollers.hxx | 38 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbunosearchcontrollers.cxx | 120 | ||||
-rw-r--r-- | svx/source/unodraw/unoctabl.cxx | 7 | ||||
-rw-r--r-- | svx/util/svx.component | 3 |
4 files changed, 166 insertions, 2 deletions
diff --git a/svx/inc/tbunosearchcontrollers.hxx b/svx/inc/tbunosearchcontrollers.hxx index b68b4b528be0..ab3693c0e34d 100644 --- a/svx/inc/tbunosearchcontrollers.hxx +++ b/svx/inc/tbunosearchcontrollers.hxx @@ -257,6 +257,43 @@ private: CheckBox* m_pMatchCaseControl; }; +class FindAllToolboxController : public svt::ToolboxController, + public css::lang::XServiceInfo +{ +public: + FindAllToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + ~FindAllToolboxController(); + + // XInterface + virtual ::com::sun::star::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 OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException ); + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException ); + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException ); + + static OUString getImplementationName_Static( ) throw() + { + return OUString( "com.sun.star.svx.FindAllToolboxController" ); + } + + static css::uno::Sequence< 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 ); +}; + // protocol handler for "vnd.sun.star.findbar:*" URLs // The dispatch object will be used for shortcut commands for findbar class FindbarDispatcher : public css::lang::XServiceInfo, @@ -310,6 +347,7 @@ 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 ); css::uno::Reference< css::uno::XInterface > SAL_CALL UpSearchToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ); css::uno::Reference< css::uno::XInterface > SAL_CALL MatchCaseToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ); +css::uno::Reference< css::uno::XInterface > SAL_CALL FindAllToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ); css::uno::Reference< css::uno::XInterface > SAL_CALL ExitFindbarToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ); css::uno::Reference< css::uno::XInterface > SAL_CALL FindbarDispatcher_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ); diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index 5270b076afa7..dcb32066abad 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -31,6 +31,7 @@ #include <com/sun/star/util/URL.hpp> #include <com/sun/star/util/URLTransformer.hpp> +#include <svl/srchitem.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/toolbox.hxx> #include <vcl/svapp.hxx> @@ -40,6 +41,7 @@ namespace svx { +static const char SEARCHITEM_COMMAND[] = "SearchItem.Command"; static const char SEARCHITEM_SEARCHSTRING[] = "SearchItem.SearchString"; static const char SEARCHITEM_SEARCHBACKWARD[] = "SearchItem.Backward"; static const char SEARCHITEM_SEARCHFLAGS[] = "SearchItem.SearchFlags"; @@ -58,7 +60,8 @@ static const sal_Int32 REMEMBER_SIZE = 10; void impl_executeSearch( const css::uno::Reference< css::uno::XComponentContext >& rxContext, const css::uno::Reference< css::frame::XFrame >& xFrame, const ToolBox* pToolBox, - const sal_Bool aSearchBackwards = false ) + const sal_Bool aSearchBackwards = false, + const sal_Bool aFindAll = false ) { css::uno::Reference< css::util::XURLTransformer > xURLTransformer( css::util::URLTransformer::create( rxContext ) ); css::util::URL aURL; @@ -87,7 +90,7 @@ void impl_executeSearch( const css::uno::Reference< css::uno::XComponentContext } } - css::uno::Sequence< css::beans::PropertyValue > lArgs(4); + css::uno::Sequence< css::beans::PropertyValue > lArgs(5); lArgs[0].Name = OUString(SEARCHITEM_SEARCHSTRING); lArgs[0].Value <<= sFindText; lArgs[1].Name = OUString(SEARCHITEM_SEARCHBACKWARD); @@ -97,6 +100,9 @@ void impl_executeSearch( const css::uno::Reference< css::uno::XComponentContext lArgs[3].Name = OUString(SEARCHITEM_TRANSLITERATEFLAGS); lArgs[3].Value <<= (sal_Int32)(!aMatchCase ? com::sun::star::i18n::TransliterationModules_IGNORE_CASE : 0); + lArgs[4].Name = OUString(SEARCHITEM_COMMAND); + lArgs[4].Value <<= (sal_Int16)(aFindAll ? + SVX_SEARCHCMD_FIND_ALL : SVX_SEARCHCMD_FIND ); css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider(xFrame, css::uno::UNO_QUERY); if ( xDispatchProvider.is() ) @@ -726,6 +732,109 @@ void SAL_CALL MatchCaseToolboxController::statusChanged( const css::frame::Featu } //----------------------------------------------------------------------------------------------------------- +// class FindAllToolboxController + +FindAllToolboxController::FindAllToolboxController( const css::uno::Reference< css::uno::XComponentContext > & rxContext ) + : svt::ToolboxController( rxContext, + css::uno::Reference< css::frame::XFrame >(), + OUString( COMMAND_EXITSEARCH ) ) +{ +} + +FindAllToolboxController::~FindAllToolboxController() +{ +} + +// XInterface +css::uno::Any SAL_CALL FindAllToolboxController::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 FindAllToolboxController::acquire() throw () +{ + ToolboxController::acquire(); +} + +void SAL_CALL FindAllToolboxController::release() throw () +{ + ToolboxController::release(); +} + +// XServiceInfo +OUString SAL_CALL FindAllToolboxController::getImplementationName() throw( css::uno::RuntimeException ) +{ + return getImplementationName_Static( ); +} + + +sal_Bool SAL_CALL FindAllToolboxController::supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException ) +{ + const css::uno::Sequence< OUString > aSNL( getSupportedServiceNames() ); + const OUString * pArray = aSNL.getConstArray(); + + for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return true; + + return false; + +} + +css::uno::Sequence< OUString > SAL_CALL FindAllToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException ) +{ + return getSupportedServiceNames_Static(); +} + +css::uno::Sequence< OUString > FindAllToolboxController::getSupportedServiceNames_Static() throw() +{ + css::uno::Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString("com.sun.star.frame.ToolbarController"); + return aSNS; +} + +// XComponent +void SAL_CALL FindAllToolboxController::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 FindAllToolboxController::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 FindAllToolboxController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException ) +{ + if ( m_bDisposed ) + throw css::lang::DisposedException(); + + Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); + ToolBox* pToolBox = (ToolBox*)pWindow; + + impl_executeSearch(m_xContext, m_xFrame, pToolBox, false, true); +} + +// XStatusListener +void SAL_CALL FindAllToolboxController::statusChanged( const css::frame::FeatureStateEvent& /*rEvent*/ ) throw ( css::uno::RuntimeException ) +{ + SolarMutexGuard aSolarMutexGuard; + if ( m_bDisposed ) + return; +} + +//----------------------------------------------------------------------------------------------------------- // class ExitSearchToolboxController ExitSearchToolboxController::ExitSearchToolboxController( const css::uno::Reference< css::uno::XComponentContext > & rxContext ) @@ -1028,6 +1137,13 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL MatchCaseToolboxController_ new MatchCaseToolboxController( comphelper::getComponentContext(rSMgr) ) ); } +css::uno::Reference< css::uno::XInterface > SAL_CALL FindAllToolboxController_createInstance( + const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ) +{ + return static_cast< cppu::OWeakObject * >( + new FindAllToolboxController( comphelper::getComponentContext(rSMgr) ) ); +} + css::uno::Reference< css::uno::XInterface > SAL_CALL ExitFindbarToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ) { diff --git a/svx/source/unodraw/unoctabl.cxx b/svx/source/unodraw/unoctabl.cxx index ada66924b7a0..605f09264b2e 100644 --- a/svx/source/unodraw/unoctabl.cxx +++ b/svx/source/unodraw/unoctabl.cxx @@ -315,6 +315,13 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL svx_component_getFactory ( svx::MatchCaseToolboxController_createInstance, svx::MatchCaseToolboxController::getSupportedServiceNames_Static() ); } + else if ( svx::FindAllToolboxController::getImplementationName_Static().equalsAscii( pImplName ) ) + { + xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), + svx::FindAllToolboxController::getImplementationName_Static(), + svx::FindAllToolboxController_createInstance, + svx::FindAllToolboxController::getSupportedServiceNames_Static() ); + } else if ( svx::ExitSearchToolboxController::getImplementationName_Static().equalsAscii( pImplName ) ) { xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), diff --git a/svx/util/svx.component b/svx/util/svx.component index 458e2adba2d4..943a38a9883c 100644 --- a/svx/util/svx.component +++ b/svx/util/svx.component @@ -61,6 +61,9 @@ <implementation name="com.sun.star.svx.MatchCaseToolboxController"> <service name="com.sun.star.frame.ToolbarController"/> </implementation> + <implementation name="com.sun.star.svx.FindAllToolboxController"> + <service name="com.sun.star.frame.ToolbarController"/> + </implementation> <implementation name="com.sun.star.svx.FontHeightToolBoxController"> <service name="com.sun.star.frame.ToolbarController"/> </implementation> |