fdo#63035 Add "Match Case" to Find bar.

Change-Id: I1339767de7980426d32960bf5ee60e2f5c011be4
This commit is contained in:
Andrzej J.R. Hunt 2013-05-20 14:08:48 +01:00
parent f2321c529a
commit bfd495d975
16 changed files with 254 additions and 42 deletions

View File

@ -22,6 +22,7 @@
<toolbar:toolbaritem xlink:href=".uno:FindText"/>
<toolbar:toolbaritem xlink:href=".uno:DownSearch"/>
<toolbar:toolbaritem xlink:href=".uno:UpSearch"/>
<toolbar:toolbaritem xlink:href=".uno:MatchCase"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:SearchDialog"/>
</toolbar:toolbar>

View File

@ -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)

View File

@ -429,6 +429,17 @@
<value>com.sun.star.svx.UpSearchToolboxController</value>
</prop>
</node>
<node oor:name="com.sun.star.svx.MatchCaseToolboxController" oor:op="replace">
<prop oor:name="Command">
<value>.uno:MatchCase</value>
</prop>
<prop oor:name="Module">
<value/>
</prop>
<prop oor:name="Controller">
<value>com.sun.star.svx.MatchCaseToolboxController</value>
</prop>
</node>
<node oor:name="c4" oor:op="replace" install:module="reportbuilder">
<prop oor:name="Command">
<value>.uno:FontColor</value>

View File

@ -1478,6 +1478,11 @@
<value>1</value>
</prop>
</node>
<node oor:name=".uno:MatchCase" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Match Case</value>
</prop>
</node>
<node oor:name=".uno:ExitSearch" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Exit Search</value>

View File

@ -22,6 +22,7 @@
<toolbar:toolbaritem xlink:href=".uno:FindText"/>
<toolbar:toolbaritem xlink:href=".uno:DownSearch"/>
<toolbar:toolbaritem xlink:href=".uno:UpSearch"/>
<toolbar:toolbaritem xlink:href=".uno:MatchCase"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:SearchDialog"/>
</toolbar:toolbar>

View File

@ -22,6 +22,7 @@
<toolbar:toolbaritem xlink:href=".uno:FindText"/>
<toolbar:toolbaritem xlink:href=".uno:DownSearch"/>
<toolbar:toolbaritem xlink:href=".uno:UpSearch"/>
<toolbar:toolbaritem xlink:href=".uno:MatchCase"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:SearchDialog"/>
</toolbar:toolbar>

View File

@ -22,6 +22,7 @@
<toolbar:toolbaritem xlink:href=".uno:FindText"/>
<toolbar:toolbaritem xlink:href=".uno:DownSearch"/>
<toolbar:toolbaritem xlink:href=".uno:UpSearch"/>
<toolbar:toolbaritem xlink:href=".uno:MatchCase"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:SearchDialog"/>
</toolbar:toolbar>

View File

@ -33,6 +33,7 @@
#include <cppuhelper/implbase1.hxx>
#include <cppuhelper/weak.hxx>
#include <svtools/toolboxcontroller.hxx>
#include <vcl/button.hxx>
#include <vcl/combobox.hxx>
#include <vcl/window.hxx>
@ -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 );

View File

@ -17,14 +17,15 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "tbunosearchcontrollers.hxx"
#include <svx/dialogs.hrc>
#include <svx/dialmgr.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/i18n/TransliterationModules.hpp>
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/ui/XUIElement.hpp>
#include <com/sun/star/util/URL.hpp>
@ -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; i<nItemCount; ++i )
{
OUString sItemCommand = pToolBox->GetItemCommand(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);
Window* pWindow = GetParent();
ToolBox* pToolBox = (ToolBox*)pWindow;
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;
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; i<nItemCount; ++i )
{
OUString sItemCommand = pToolBox->GetItemCommand(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 )
{

View File

@ -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: */

View File

@ -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 ),

View File

@ -58,6 +58,9 @@
<implementation name="com.sun.star.svx.FindTextToolboxController">
<service name="com.sun.star.frame.ToolbarController"/>
</implementation>
<implementation name="com.sun.star.svx.MatchCaseToolboxController">
<service name="com.sun.star.frame.ToolbarController"/>
</implementation>
<implementation name="com.sun.star.svx.FontHeightToolBoxController">
<service name="com.sun.star.frame.ToolbarController"/>
</implementation>

View File

@ -22,6 +22,7 @@
<toolbar:toolbaritem xlink:href=".uno:FindText"/>
<toolbar:toolbaritem xlink:href=".uno:DownSearch"/>
<toolbar:toolbaritem xlink:href=".uno:UpSearch"/>
<toolbar:toolbaritem xlink:href=".uno:MatchCase"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:SearchDialog"/>
</toolbar:toolbar>

View File

@ -22,6 +22,7 @@
<toolbar:toolbaritem xlink:href=".uno:FindText"/>
<toolbar:toolbaritem xlink:href=".uno:DownSearch"/>
<toolbar:toolbaritem xlink:href=".uno:UpSearch"/>
<toolbar:toolbaritem xlink:href=".uno:MatchCase"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:SearchDialog"/>
</toolbar:toolbar>

View File

@ -22,6 +22,7 @@
<toolbar:toolbaritem xlink:href=".uno:FindText"/>
<toolbar:toolbaritem xlink:href=".uno:DownSearch"/>
<toolbar:toolbaritem xlink:href=".uno:UpSearch"/>
<toolbar:toolbaritem xlink:href=".uno:MatchCase"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:SearchDialog"/>
</toolbar:toolbar>

View File

@ -22,6 +22,7 @@
<toolbar:toolbaritem xlink:href=".uno:FindText"/>
<toolbar:toolbaritem xlink:href=".uno:DownSearch"/>
<toolbar:toolbaritem xlink:href=".uno:UpSearch"/>
<toolbar:toolbaritem xlink:href=".uno:MatchCase"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:SearchDialog"/>
</toolbar:toolbar>