From bfd495d9754e293d6561363ab6e27b45e2e403f0 Mon Sep 17 00:00:00 2001 From: "Andrzej J.R. Hunt" Date: Mon, 20 May 2013 14:08:48 +0100 Subject: fdo#63035 Add "Match Case" to Find bar. Change-Id: I1339767de7980426d32960bf5ee60e2f5c011be4 --- basctl/uiconfig/basicide/toolbar/findbar.xml | 1 + include/svx/dialogs.hrc | 1 + .../data/org/openoffice/Office/UI/Controller.xcu | 11 ++ .../org/openoffice/Office/UI/GenericCommands.xcu | 5 + sc/uiconfig/scalc/toolbar/findbar.xml | 1 + sd/uiconfig/sdraw/toolbar/findbar.xml | 1 + sd/uiconfig/simpress/toolbar/findbar.xml | 1 + svx/inc/tbunosearchcontrollers.hxx | 43 +++++ svx/source/tbxctrls/tbunosearchcontrollers.cxx | 213 +++++++++++++++++---- svx/source/tbxctrls/tbunosearchcontrollers.src | 5 + svx/source/unodraw/unoctabl.cxx | 7 + svx/util/svx.component | 3 + sw/uiconfig/sglobal/toolbar/findbar.xml | 1 + sw/uiconfig/sweb/toolbar/findbar.xml | 1 + sw/uiconfig/swriter/toolbar/findbar.xml | 1 + sw/uiconfig/swxform/toolbar/findbar.xml | 1 + 16 files changed, 254 insertions(+), 42 deletions(-) diff --git a/basctl/uiconfig/basicide/toolbar/findbar.xml b/basctl/uiconfig/basicide/toolbar/findbar.xml index 42baa21a72fa..57aec06d6ee0 100644 --- a/basctl/uiconfig/basicide/toolbar/findbar.xml +++ b/basctl/uiconfig/basicide/toolbar/findbar.xml @@ -22,6 +22,7 @@ + diff --git a/include/svx/dialogs.hrc b/include/svx/dialogs.hrc index 9950f2c73b2a..e714c3941fd9 100644 --- a/include/svx/dialogs.hrc +++ b/include/svx/dialogs.hrc @@ -961,6 +961,7 @@ #define RID_SVXSTR_TEXTCOLOR (RID_SVX_START + 1178) +#define RID_SVXSTR_FINDBAR_MATCHCASE (RID_SVX_START + 1189) #define RID_SVXSTR_FINDBAR_FIND (RID_SVX_START + 1190) #define RID_SVXSTR_NUMBULLET_NONE (RID_SVX_START + 1191) diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu index 5abc0a8cc901..64fa7b078fd3 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu @@ -429,6 +429,17 @@ com.sun.star.svx.UpSearchToolboxController + + + .uno:MatchCase + + + + + + com.sun.star.svx.MatchCaseToolboxController + + .uno:FontColor diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index 7b01925f58a3..74fbeeb3c516 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -1478,6 +1478,11 @@ 1 + + + Match Case + + Exit Search diff --git a/sc/uiconfig/scalc/toolbar/findbar.xml b/sc/uiconfig/scalc/toolbar/findbar.xml index a0e6037522c5..f8052a181bfe 100644 --- a/sc/uiconfig/scalc/toolbar/findbar.xml +++ b/sc/uiconfig/scalc/toolbar/findbar.xml @@ -22,6 +22,7 @@ + diff --git a/sd/uiconfig/sdraw/toolbar/findbar.xml b/sd/uiconfig/sdraw/toolbar/findbar.xml index a0e6037522c5..f8052a181bfe 100644 --- a/sd/uiconfig/sdraw/toolbar/findbar.xml +++ b/sd/uiconfig/sdraw/toolbar/findbar.xml @@ -22,6 +22,7 @@ + diff --git a/sd/uiconfig/simpress/toolbar/findbar.xml b/sd/uiconfig/simpress/toolbar/findbar.xml index a0e6037522c5..f8052a181bfe 100644 --- a/sd/uiconfig/simpress/toolbar/findbar.xml +++ b/sd/uiconfig/simpress/toolbar/findbar.xml @@ -22,6 +22,7 @@ + diff --git a/svx/inc/tbunosearchcontrollers.hxx b/svx/inc/tbunosearchcontrollers.hxx index 23eb22fd12b4..b68b4b528be0 100644 --- a/svx/inc/tbunosearchcontrollers.hxx +++ b/svx/inc/tbunosearchcontrollers.hxx @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -215,6 +216,47 @@ private: Type meType; }; +class MatchCaseToolboxController : public svt::ToolboxController, + public css::lang::XServiceInfo +{ +public: + MatchCaseToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + ~MatchCaseToolboxController(); + + // 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.MatchCaseToolboxController" ); + } + + 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 ); + virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException ); + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException ); + +private: + CheckBox* m_pMatchCaseControl; +}; + // 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, @@ -267,6 +309,7 @@ private: css::uno::Reference< css::uno::XInterface > SAL_CALL FindTextToolbarController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ); 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 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 d67e5aca88a3..5270b076afa7 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -17,14 +17,15 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #include "tbunosearchcontrollers.hxx" + #include #include #include #include #include +#include #include #include #include @@ -42,23 +43,61 @@ namespace svx static const char SEARCHITEM_SEARCHSTRING[] = "SearchItem.SearchString"; static const char SEARCHITEM_SEARCHBACKWARD[] = "SearchItem.Backward"; static const char SEARCHITEM_SEARCHFLAGS[] = "SearchItem.SearchFlags"; +static const char SEARCHITEM_TRANSLITERATEFLAGS[] = "SearchItem.TransliterateFlags"; static const char COMMAND_EXECUTESEARCH[] = ".uno:ExecuteSearch"; static const char COMMAND_FINDTEXT[] = ".uno:FindText"; static const char COMMAND_DOWNSEARCH[] = ".uno:DownSearch"; static const char COMMAND_UPSEARCH[] = ".uno:UpSearch"; static const char COMMAND_EXITSEARCH[] = ".uno:ExitSearch"; +static const char COMMAND_MATCHCASE[] = ".uno:MatchCase"; static const char COMMAND_APPENDSEARCHHISTORY[] = "AppendSearchHistory"; 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 css::uno::Sequence< css::beans::PropertyValue >& lArgs ) +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 ) { css::uno::Reference< css::util::XURLTransformer > xURLTransformer( css::util::URLTransformer::create( rxContext ) ); css::util::URL aURL; aURL.Complete = OUString(COMMAND_EXECUTESEARCH); xURLTransformer->parseStrict(aURL); + OUString sFindText; + sal_Bool aMatchCase = false; + if ( pToolBox ) + { + sal_uInt16 nItemCount = pToolBox->GetItemCount(); + for ( sal_uInt16 i=0; iGetItemCommand(i); + if ( sItemCommand == COMMAND_FINDTEXT ) + { + Window* pItemWin = pToolBox->GetItemWindow(i); + if (pItemWin) + sFindText = pItemWin->GetText(); + } else if ( sItemCommand == COMMAND_MATCHCASE ) + { + CheckBox* pItemWin = (CheckBox*) pToolBox->GetItemWindow(i); + if (pItemWin) + aMatchCase = pItemWin->IsChecked(); + } + } + } + + css::uno::Sequence< css::beans::PropertyValue > lArgs(4); + lArgs[0].Name = OUString(SEARCHITEM_SEARCHSTRING); + lArgs[0].Value <<= sFindText; + lArgs[1].Name = OUString(SEARCHITEM_SEARCHBACKWARD); + lArgs[1].Value <<= aSearchBackwards; + lArgs[2].Name = OUString(SEARCHITEM_SEARCHFLAGS); + lArgs[2].Value <<= (sal_Int32)0; + lArgs[3].Name = OUString(SEARCHITEM_TRANSLITERATEFLAGS); + lArgs[3].Value <<= (sal_Int32)(!aMatchCase ? + com::sun::star::i18n::TransliterationModules_IGNORE_CASE : 0); + css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider(xFrame, css::uno::UNO_QUERY); if ( xDispatchProvider.is() ) { @@ -163,22 +202,10 @@ long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) { Remember_Impl(GetText()); - OUString sFindText = GetText(); - css::uno::Sequence< css::beans::PropertyValue > lArgs(3); - - lArgs[0].Name = OUString(SEARCHITEM_SEARCHSTRING); - lArgs[0].Value <<= sFindText; - - lArgs[1].Name = OUString(SEARCHITEM_SEARCHBACKWARD); - if (bShift) - lArgs[1].Value <<= sal_True; - else - lArgs[1].Value <<= sal_False; - - lArgs[2].Name = OUString(SEARCHITEM_SEARCHFLAGS); - lArgs[2].Value <<= (sal_Int32)0; + Window* pWindow = GetParent(); + ToolBox* pToolBox = (ToolBox*)pWindow; - impl_executeSearch( m_xContext, m_xFrame, lArgs); + impl_executeSearch( m_xContext, m_xFrame, pToolBox, bShift); nRet = 1; } break; @@ -560,34 +587,10 @@ void SAL_CALL UpDownSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ if ( m_bDisposed ) throw css::lang::DisposedException(); - OUString sFindText; Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); ToolBox* pToolBox = (ToolBox*)pWindow; - if ( pToolBox ) - { - sal_uInt16 nItemCount = pToolBox->GetItemCount(); - for ( sal_uInt16 i=0; iGetItemCommand(i); - if ( sItemCommand == COMMAND_FINDTEXT ) - { - Window* pItemWin = pToolBox->GetItemWindow(i); - if (pItemWin) - sFindText = pItemWin->GetText(); - break; - } - } - } - css::uno::Sequence< css::beans::PropertyValue > lArgs(3); - lArgs[0].Name = OUString(SEARCHITEM_SEARCHSTRING); - lArgs[0].Value <<= sFindText; - lArgs[1].Name = OUString(SEARCHITEM_SEARCHBACKWARD); - lArgs[1].Value <<= sal_Bool( meType == UP ); - lArgs[2].Name = OUString(SEARCHITEM_SEARCHFLAGS); - lArgs[2].Value <<= (sal_Int32)0; - - impl_executeSearch(m_xContext, m_xFrame, lArgs); + impl_executeSearch(m_xContext, m_xFrame, pToolBox, sal_Bool( meType == UP )); css::frame::FeatureStateEvent aEvent; aEvent.FeatureURL.Complete = OUString(COMMAND_APPENDSEARCHHISTORY); @@ -603,6 +606,125 @@ void SAL_CALL UpDownSearchToolboxController::statusChanged( const css::frame::Fe if ( m_bDisposed ) return; } + +//----------------------------------------------------------------------------------------------------------- +// MatchCaseToolboxController + +MatchCaseToolboxController::MatchCaseToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext ) + :svt::ToolboxController( rxContext, + css::uno::Reference< css::frame::XFrame >(), + OUString(COMMAND_MATCHCASE) ) +{ +} + +MatchCaseToolboxController::~MatchCaseToolboxController() +{ +} + +// XInterface +css::uno::Any SAL_CALL MatchCaseToolboxController::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 MatchCaseToolboxController::acquire() throw () +{ + ToolboxController::acquire(); +} + +void SAL_CALL MatchCaseToolboxController::release() throw () +{ + ToolboxController::release(); +} + +// XServiceInfo +OUString SAL_CALL MatchCaseToolboxController::getImplementationName() throw( css::uno::RuntimeException ) +{ + return getImplementationName_Static(); +} + +sal_Bool SAL_CALL MatchCaseToolboxController::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 MatchCaseToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException ) +{ + return getSupportedServiceNames_Static(); +} + +css::uno::Sequence< OUString > MatchCaseToolboxController::getSupportedServiceNames_Static() throw() +{ + css::uno::Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( "com.sun.star.frame.ToolbarController" ); + return aSNS; +} + +// XComponent +void SAL_CALL MatchCaseToolboxController::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(); + + delete m_pMatchCaseControl; + m_pMatchCaseControl = 0; +} + +// XInitialization +void SAL_CALL MatchCaseToolboxController::initialize( const css::uno::Sequence< ::com::sun::star::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 MatchCaseToolboxController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException ) +{ +} + +css::uno::Reference< css::awt::XWindow > SAL_CALL MatchCaseToolboxController::createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException ) +{ + css::uno::Reference< css::awt::XWindow > xItemWindow; + + css::uno::Reference< css::awt::XWindow > xParent( Parent ); + Window* pParent = VCLUnoHelper::GetWindow( xParent ); + if ( pParent ) + { + ToolBox* pToolbar = (ToolBox* )pParent; + m_pMatchCaseControl = new CheckBox( pToolbar, 0 ); + m_pMatchCaseControl->SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_MATCHCASE ) ); + Size aSize( m_pMatchCaseControl->GetOptimalSize() ); + m_pMatchCaseControl->SetSizePixel( aSize ); + } + xItemWindow = VCLUnoHelper::GetInterface( m_pMatchCaseControl ); + + return xItemWindow; +} + +// XStatusListener +void SAL_CALL MatchCaseToolboxController::statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException ) +{ + (void) rEvent; + SolarMutexGuard aSolarMutexGuard; + if ( m_bDisposed ) + return; +} + //----------------------------------------------------------------------------------------------------------- // class ExitSearchToolboxController @@ -899,6 +1021,13 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL UpSearchToolboxController_c comphelper::getComponentContext(rSMgr), UpDownSearchToolboxController::UP ) ); } +css::uno::Reference< css::uno::XInterface > SAL_CALL MatchCaseToolboxController_createInstance( + const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ) +{ + return static_cast< cppu::OWeakObject * >( + new MatchCaseToolboxController( 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/tbxctrls/tbunosearchcontrollers.src b/svx/source/tbxctrls/tbunosearchcontrollers.src index a9d42b96f1eb..d3b89201994c 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.src +++ b/svx/source/tbxctrls/tbunosearchcontrollers.src @@ -24,4 +24,9 @@ String RID_SVXSTR_FINDBAR_FIND Text [ en-US ] = "Find" ; }; +String RID_SVXSTR_FINDBAR_MATCHCASE +{ + Text [ en-US ] = "Match Case" ; +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/unodraw/unoctabl.cxx b/svx/source/unodraw/unoctabl.cxx index 60002a42a37f..ada66924b7a0 100644 --- a/svx/source/unodraw/unoctabl.cxx +++ b/svx/source/unodraw/unoctabl.cxx @@ -308,6 +308,13 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL svx_component_getFactory ( svx::UpSearchToolboxController_createInstance, svx::UpDownSearchToolboxController::getSupportedServiceNames_Static() ); } + else if ( svx::MatchCaseToolboxController::getImplementationName_Static().equalsAscii( pImplName ) ) + { + xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), + svx::MatchCaseToolboxController::getImplementationName_Static(), + svx::MatchCaseToolboxController_createInstance, + svx::MatchCaseToolboxController::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 8745a592a2a1..458e2adba2d4 100644 --- a/svx/util/svx.component +++ b/svx/util/svx.component @@ -58,6 +58,9 @@ + + + diff --git a/sw/uiconfig/sglobal/toolbar/findbar.xml b/sw/uiconfig/sglobal/toolbar/findbar.xml index a0e6037522c5..f8052a181bfe 100644 --- a/sw/uiconfig/sglobal/toolbar/findbar.xml +++ b/sw/uiconfig/sglobal/toolbar/findbar.xml @@ -22,6 +22,7 @@ + diff --git a/sw/uiconfig/sweb/toolbar/findbar.xml b/sw/uiconfig/sweb/toolbar/findbar.xml index a0e6037522c5..f8052a181bfe 100644 --- a/sw/uiconfig/sweb/toolbar/findbar.xml +++ b/sw/uiconfig/sweb/toolbar/findbar.xml @@ -22,6 +22,7 @@ + diff --git a/sw/uiconfig/swriter/toolbar/findbar.xml b/sw/uiconfig/swriter/toolbar/findbar.xml index a0e6037522c5..f8052a181bfe 100644 --- a/sw/uiconfig/swriter/toolbar/findbar.xml +++ b/sw/uiconfig/swriter/toolbar/findbar.xml @@ -22,6 +22,7 @@ + diff --git a/sw/uiconfig/swxform/toolbar/findbar.xml b/sw/uiconfig/swxform/toolbar/findbar.xml index a0e6037522c5..f8052a181bfe 100644 --- a/sw/uiconfig/swxform/toolbar/findbar.xml +++ b/sw/uiconfig/swxform/toolbar/findbar.xml @@ -22,6 +22,7 @@ + -- cgit