From d44cfa5bdb007fb566387f5764328ad2e2ece393 Mon Sep 17 00:00:00 2001 From: Wu Yan Date: Wed, 28 Apr 2010 18:45:33 +0800 Subject: findbar01: enhancements for findbar --- svx/inc/tbunosearchcontrollers.hxx | 284 +++++++ svx/source/tbxctrls/makefile.mk | 3 +- svx/source/tbxctrls/tbunosearchcontrollers.cxx | 1018 ++++++++++++++++++++++++ svx/source/unodraw/unoctabl.cxx | 35 + 4 files changed, 1339 insertions(+), 1 deletion(-) create mode 100644 svx/inc/tbunosearchcontrollers.hxx create mode 100644 svx/source/tbxctrls/tbunosearchcontrollers.cxx diff --git a/svx/inc/tbunosearchcontrollers.hxx b/svx/inc/tbunosearchcontrollers.hxx new file mode 100644 index 0000000000..512dea9b70 --- /dev/null +++ b/svx/inc/tbunosearchcontrollers.hxx @@ -0,0 +1,284 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __TBUNOSEARCHCONTROLLERS_HXX_ +#define __TBUNOSEARCHCONTROLLERS_HXX_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +namespace css = ::com::sun::star ; +namespace svx +{ + +class FindTextFieldControl; + +struct ExecuteInfo +{ + css::uno::Reference< css::frame::XDispatch > xDispatch; + css::util::URL aTargetURL; + css::uno::Sequence< css::beans::PropertyValue > aArgs; +}; + +class SearchToolbarControllersManager +{ +public: + + SearchToolbarControllersManager(); + ~SearchToolbarControllersManager(); + + static SearchToolbarControllersManager* createControllersManager(); + + void registryController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL ); + void freeController ( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL ); + css::uno::Reference< css::frame::XStatusListener > findController( const css::uno::Reference< css::frame::XFrame >& xFrame, const ::rtl::OUString& sCommandURL ); + +private: + + static SearchToolbarControllersManager* m_pInstance; + + typedef ::comphelper::SequenceAsVector< css::beans::PropertyValue > SearchToolbarControllersVec; + typedef ::std::map< css::uno::Reference< css::frame::XFrame >, SearchToolbarControllersVec > SearchToolbarControllersMap; + SearchToolbarControllersMap aSearchToolbarControllersMap; + +}; + +class FindTextToolbarController : public svt::ToolboxController, + public css::lang::XServiceInfo +{ +public: + + FindTextToolbarController( const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager ); + ~FindTextToolbarController(); + + // 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.FindTextToolboxController" )); + } + + static ::com::sun::star::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); + 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& Event ) throw ( css::uno::RuntimeException ); + + sal_Int32 getFontSizePixel( const Window* pWindow ); + + DECL_STATIC_LINK( FindTextToolbarController, ExecuteHdl_Impl, ExecuteInfo* ); + DECL_LINK(EditModifyHdl, void*); + +private: + + css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; + FindTextFieldControl* m_pFindTextFieldControl; + + USHORT m_nDownSearchId; // item position of findbar + USHORT m_nUpSearchId; // item position of findbar + +}; + +class DownSearchToolboxController : public svt::ToolboxController, + public css::lang::XServiceInfo +{ +public: + + 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 ); + + DECL_STATIC_LINK( DownSearchToolboxController, ExecuteHdl_Impl, ExecuteInfo* ); + +private : + + css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; + +}; + +class UpSearchToolboxController : public svt::ToolboxController, + public css::lang::XServiceInfo +{ +public: + + UpSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager ); + ~UpSearchToolboxController(); + + // 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 ::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.UpSearchToolboxController" )); + } + + 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 ); + + DECL_STATIC_LINK( UpSearchToolboxController, ExecuteHdl_Impl, ExecuteInfo* ); + +private : + + css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; + +}; + +// 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, + public css::lang::XInitialization, + public css::frame::XDispatchProvider, + public css::frame::XDispatch, + public ::cppu::OWeakObject +{ +public: + + FindbarDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); + virtual ~FindbarDispatcher(); + + // 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 ::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.comp.svx.Impl.FindbarDispatcher" )); + } + + static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw(); + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException ); + + // XDispatchProvider + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( const css::util::URL& aURL, const ::rtl::OUString& sTargetFrameName , sal_Int32 nSearchFlags ) throw( css::uno::RuntimeException ); + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptions ) throw( css::uno::RuntimeException ); + + // XDispatch + virtual void SAL_CALL dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException ); + virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener, const css::util::URL& aURL ) throw( css::uno::RuntimeException ); + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener, const css::util::URL& aURL ) throw( css::uno::RuntimeException ); + +private: + + css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + css::uno::Reference< css::frame::XFrame > m_xFrame; + +}; + +// createInstance +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 FindbarDispatcher_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ); + +} + +#endif // __TBUNOSEARCHCONTROLLERS_HXX_ diff --git a/svx/source/tbxctrls/makefile.mk b/svx/source/tbxctrls/makefile.mk index 47da008e87..d7b264d30f 100644 --- a/svx/source/tbxctrls/makefile.mk +++ b/svx/source/tbxctrls/makefile.mk @@ -62,7 +62,8 @@ LIB2OBJFILES= \ $(SLO)$/verttexttbxctrl.obj \ $(SLO)$/subtoolboxcontrol.obj \ $(SLO)$/tbxcolor.obj \ - $(SLO)$/tbunocontroller.obj + $(SLO)$/tbunocontroller.obj \ + $(SLO)$/tbunosearchcontrollers.obj SLOFILES = $(LIB1OBJFILES) $(LIB2OBJFILES) diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx new file mode 100644 index 0000000000..26dd2c4ae7 --- /dev/null +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -0,0 +1,1018 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include "tbunosearchcontrollers.hxx" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace svx +{ + +static const ::rtl::OUString SEARCHITEM_SEARCHSTRING = ::rtl::OUString::createFromAscii("SearchItem.SearchString"); +static const ::rtl::OUString SEARCHITEM_SEARCHBACKWARD = ::rtl::OUString::createFromAscii("SearchItem.Backward"); + +static const ::rtl::OUString COMMAND_FINDTEXT = ::rtl::OUString::createFromAscii(".uno:FindText") ; +static const ::rtl::OUString COMMAND_DOWNSEARCH = ::rtl::OUString::createFromAscii(".uno:DownSearch"); +static const ::rtl::OUString COMMAND_UPSEARCH = ::rtl::OUString::createFromAscii(".uno:UpSearch") ; + +static const ::rtl::OUString COMMAND_APPENDSEARCHHISTORY = ::rtl::OUString::createFromAscii("AppendSearchHistory") ; + +class FindTextFieldControl : public ComboBox +{ +public: + FindTextFieldControl( Window* pParent, WinBits nStyle, + css::uno::Reference< css::frame::XFrame >& xFrame, + css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + virtual ~FindTextFieldControl(); + + virtual void Modify(); + virtual long PreNotify( NotifyEvent& rNEvt ); + + void InitControls_Impl(); + void Remember_Impl(const String& rStr); + +private: + + css::uno::Reference< css::frame::XFrame > m_xFrame; + css::uno::Reference < css::util::XURLTransformer > m_xURLTransformer; + css::uno::Reference< css::lang::XMultiServiceFactory > m_xServiceManager; + + sal_Bool m_bToClearTextField; + +}; + +FindTextFieldControl::FindTextFieldControl( Window* pParent, WinBits nStyle, + css::uno::Reference< css::frame::XFrame >& xFrame, + css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager) : + ComboBox( pParent, nStyle ), + m_xFrame(xFrame), + m_xServiceManager(xServiceManager), + m_bToClearTextField(sal_True) +{ + m_xURLTransformer = css::uno::Reference< css::util::XURLTransformer >( m_xServiceManager->createInstance( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), + css::uno::UNO_QUERY_THROW ); + + InitControls_Impl(); +} + +FindTextFieldControl::~FindTextFieldControl() +{ +} + +void FindTextFieldControl::InitControls_Impl() +{ + SetText( String( ::rtl::OUString::createFromAscii("Find") ) ); + SetControlForeground(COL_GRAY); + + EnableAutocomplete(TRUE, TRUE); +} + +void FindTextFieldControl::Remember_Impl(const String& rStr) +{ + USHORT nCount = GetEntryCount(); + for (USHORT i=0; iGetKeyCode().GetCode(); + sal_Bool bCtrl = pKeyEvent->GetKeyCode().IsMod1(); + if (bCtrl && KEY_G== nCode) + GrabFocusToDocument(); + + if (KEY_RETURN == nCode) + { + vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); + + Remember_Impl(GetText()); + + css::uno::Reference< css::frame::XDispatch > xDispatch; + css::util::URL aTargetURL; + + if ( m_xURLTransformer.is() ) + { + aTargetURL.Complete = ::rtl::OUString::createFromAscii(".uno:ExecuteSearch"); + m_xURLTransformer->parseStrict( aTargetURL ); + + css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( m_xFrame, css::uno::UNO_QUERY); + if ( xDispatchProvider.is() ) + xDispatch = xDispatchProvider->queryDispatch( aTargetURL, rtl::OUString(), 0 ); + } + + if ( xDispatch.is() && aTargetURL.Complete.getLength() > 0 ) + { + ::rtl::OUString sFindText = GetText(); + css::uno::Sequence< css::beans::PropertyValue > aArgs( 2 ); + aArgs[0].Name = SEARCHITEM_SEARCHSTRING; + aArgs[0].Value <<= sFindText; + aArgs[1].Name = SEARCHITEM_SEARCHBACKWARD; + aArgs[1].Value <<= sal_False; + + // Execute dispatch asynchronously + ExecuteInfo* pExecuteInfo = new ExecuteInfo; + pExecuteInfo->xDispatch = xDispatch; + pExecuteInfo->aTargetURL = aTargetURL; + pExecuteInfo->aArgs = aArgs; + Application::PostUserEvent( STATIC_LINK(0, DownSearchToolboxController , ExecuteHdl_Impl), pExecuteInfo ); + } + } + break; + } + + case EVENT_GETFOCUS: + if ( m_bToClearTextField ) + { + SetText( String() ); + m_bToClearTextField = sal_False; + } + break; + + case EVENT_LOSEFOCUS: + if ( GetText().Len() == 0 ) + { + SetText( String( ::rtl::OUString::createFromAscii("Find") ) ); + SetControlForeground(COL_GRAY); + + m_bToClearTextField = sal_True; + } + break; + } + + return nRet; +} + + +//----------------------------------------------------------------------------------------------------------- +// SearchToolbarControllersManager + +SearchToolbarControllersManager* SearchToolbarControllersManager::m_pInstance = 0; + +SearchToolbarControllersManager::SearchToolbarControllersManager() +{ +} + +SearchToolbarControllersManager::~SearchToolbarControllersManager() +{ +} + +SearchToolbarControllersManager* SearchToolbarControllersManager::createControllersManager() +{ + if (!m_pInstance) + m_pInstance = new SearchToolbarControllersManager(); + + return m_pInstance; +} + +void SearchToolbarControllersManager::registryController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL ) +{ + SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame); + if (pIt == aSearchToolbarControllersMap.end()) + { + SearchToolbarControllersVec lControllers(1); + lControllers[0].Name = sCommandURL; + lControllers[0].Value <<= xStatusListener; + aSearchToolbarControllersMap.insert(SearchToolbarControllersMap::value_type(xFrame, lControllers)); + } + else + { + sal_Int32 nSize = pIt->second.size(); + for (sal_Int32 i=0; isecond[i].Name.equals(sCommandURL)) + return; + } + + pIt->second.resize(nSize+1); + pIt->second[nSize].Name = sCommandURL; + pIt->second[nSize].Value <<= xStatusListener; + } + +} + +void SearchToolbarControllersManager::freeController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL ) +{ + SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame); + if (pIt != aSearchToolbarControllersMap.end()) + { + for (SearchToolbarControllersVec::iterator pItCtrl=pIt->second.begin(); pItCtrl!=pIt->second.end(); ++pItCtrl) + { + if (pItCtrl->Name.equals(sCommandURL)) + { + pIt->second.erase(pItCtrl); + break; + } + } + + if (pIt->second.empty()) + aSearchToolbarControllersMap.erase(pIt); + } +} + +css::uno::Reference< css::frame::XStatusListener > SearchToolbarControllersManager::findController( const css::uno::Reference< css::frame::XFrame >& xFrame, const ::rtl::OUString& sCommandURL ) +{ + css::uno::Reference< css::frame::XStatusListener > xStatusListener; + + SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame); + if (pIt != aSearchToolbarControllersMap.end()) + { + for (SearchToolbarControllersVec::iterator pItCtrl =pIt->second.begin(); pItCtrl != pIt->second.end(); ++pItCtrl) + { + if (pItCtrl->Name.equals(sCommandURL)) + { + pItCtrl->Value >>= xStatusListener; + break; + } + } + } + + return xStatusListener; +} + +//----------------------------------------------------------------------------------------------------------- +// FindTextToolbarController + +FindTextToolbarController::FindTextToolbarController( const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager ) + :svt::ToolboxController( rServiceManager, + css::uno::Reference< css::frame::XFrame >(), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FindText" )) ) +{ + m_xURLTransformer = css::uno::Reference< css::util::XURLTransformer >( m_xServiceManager->createInstance( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), + css::uno::UNO_QUERY_THROW ); +} + +FindTextToolbarController::~FindTextToolbarController() +{ +} + +// XInterface +css::uno::Any SAL_CALL FindTextToolbarController::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 FindTextToolbarController::acquire() throw () +{ + ToolboxController::acquire(); +} + +void SAL_CALL FindTextToolbarController::release() throw () +{ + ToolboxController::release(); +} + +// XServiceInfo +::rtl::OUString SAL_CALL FindTextToolbarController::getImplementationName() throw( css::uno::RuntimeException ) +{ + return getImplementationName_Static(); +} + +sal_Bool SAL_CALL FindTextToolbarController::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 FindTextToolbarController::getSupportedServiceNames() throw( css::uno::RuntimeException ) +{ + return getSupportedServiceNames_Static(); +} + +css::uno::Sequence< ::rtl::OUString > FindTextToolbarController::getSupportedServiceNames_Static() throw() +{ + css::uno::Sequence< ::rtl::OUString > aSNS( 1 ); + aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ) ); + return aSNS; +} + +// XComponent +void SAL_CALL FindTextToolbarController::dispose() throw ( css::uno::RuntimeException ) +{ + vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); + + 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_pFindTextFieldControl; + m_pFindTextFieldControl = 0; +} + +// XInitialization +void SAL_CALL FindTextToolbarController::initialize( const css::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException) +{ + svt::ToolboxController::initialize(aArguments); + + Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); + ToolBox* pToolBox = (ToolBox*)pWindow; + if ( pToolBox ) + { + USHORT nItemCount = pToolBox->GetItemCount(); + for ( USHORT i=0; iGetItemCommand(i); + if ( sItemCommand.equals( COMMAND_DOWNSEARCH ) ) + m_nDownSearchId = i; + else if (sItemCommand.equals( COMMAND_UPSEARCH )) + m_nUpSearchId = i; + } + } + + 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 FindTextToolbarController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException ) +{ +} + +css::uno::Reference< css::awt::XWindow > SAL_CALL FindTextToolbarController::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_pFindTextFieldControl = new FindTextFieldControl( pToolbar, WinBits( WB_DROPDOWN | WB_VSCROLL), m_xFrame, m_xServiceManager ); + + // Calculate height of the edit field according to the application font height + sal_Int32 nHeight = getFontSizePixel( m_pFindTextFieldControl ); + nHeight += 200; + m_pFindTextFieldControl->SetSizePixel( Size( 100, nHeight )); + + m_pFindTextFieldControl->SetModifyHdl(LINK(this, FindTextToolbarController, EditModifyHdl)); + + } + xItemWindow = VCLUnoHelper::GetInterface( m_pFindTextFieldControl ); + + return xItemWindow; +} + +// XStatusListener +void SAL_CALL FindTextToolbarController::statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException ) +{ + vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); + if ( m_bDisposed ) + return; + + ::rtl::OUString aFeatureURL = rEvent.FeatureURL.Complete; + if (aFeatureURL.equalsAscii("AppendSearchHistory")) + { + m_pFindTextFieldControl->Remember_Impl(m_pFindTextFieldControl->GetText()); + } +} + +sal_Int32 FindTextToolbarController::getFontSizePixel( const Window* pWindow ) +{ + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + const Font& rFont = rSettings.GetAppFont(); + + // Calculate height of the application font used by window + sal_Int32 nHeight = sal_Int32( rFont.GetHeight() ); + ::Size aPixelSize = pWindow->LogicToPixel( ::Size( 0, nHeight ), MAP_APPFONT ); + return aPixelSize.Height(); +} + +IMPL_STATIC_LINK_NOINSTANCE( FindTextToolbarController, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo ) +{ + const sal_uInt32 nRef = Application::ReleaseSolarMutex(); + try + { + // Asynchronous execution as this can lead to our own destruction! + // Framework can recycle our current frame and the layout manager disposes all user interface + // elements if a component gets detached from its frame! + pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs ); + } + catch ( css::uno::Exception& ) + { + + } + + Application::AcquireSolarMutex( nRef ); + delete pExecuteInfo; + + return 0; +} + +IMPL_LINK( FindTextToolbarController, EditModifyHdl, void *, EMPTYARG ) +{ + // enable or disable item DownSearch/UpSearch of findbar + Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); + ToolBox* pToolBox = (ToolBox*)pWindow; + if ( pToolBox && m_pFindTextFieldControl ) + { + if (m_pFindTextFieldControl->GetText().Len()>0) + { + if ( !pToolBox->IsItemEnabled(m_nDownSearchId) ) + pToolBox->EnableItem(m_nDownSearchId, sal_True); + if ( !pToolBox->IsItemEnabled(m_nUpSearchId) ) + pToolBox->EnableItem(m_nUpSearchId, sal_True); + } + else + { + if ( pToolBox->IsItemEnabled(m_nDownSearchId) ) + pToolBox->EnableItem(m_nDownSearchId, sal_False); + if ( pToolBox->IsItemEnabled(m_nUpSearchId) ) + pToolBox->EnableItem(m_nUpSearchId, sal_False); + } + } + + return 0; +} + +//----------------------------------------------------------------------------------------------------------- +// class DownSearchToolboxController + +DownSearchToolboxController::DownSearchToolboxController(const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager ) + : svt::ToolboxController( rServiceManager, + css::uno::Reference< css::frame::XFrame >(), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DownSearch" )) ) +{ + m_xURLTransformer = css::uno::Reference< css::util::XURLTransformer >( m_xServiceManager->createInstance( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), + css::uno::UNO_QUERY_THROW ); +} + +DownSearchToolboxController::~DownSearchToolboxController() +{ +} + +// XInterface +css::uno::Any SAL_CALL DownSearchToolboxController::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 DownSearchToolboxController::acquire() throw () +{ + ToolboxController::acquire(); +} + +void SAL_CALL DownSearchToolboxController::release() throw () +{ + ToolboxController::release(); +} + +// XServiceInfo +::rtl::OUString SAL_CALL DownSearchToolboxController::getImplementationName() throw( css::uno::RuntimeException ) +{ + return getImplementationName_Static(); +} + +sal_Bool SAL_CALL DownSearchToolboxController::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 DownSearchToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException ) +{ + return getSupportedServiceNames_Static(); +} + +css::uno::Sequence< ::rtl::OUString > DownSearchToolboxController::getSupportedServiceNames_Static() throw() +{ + css::uno::Sequence< ::rtl::OUString > aSNS( 1 ); + aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" )); + return aSNS; +} + +// XComponent +void SAL_CALL DownSearchToolboxController::dispose() throw ( css::uno::RuntimeException ) +{ + vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); + + 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 DownSearchToolboxController::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) +{ + if ( m_bDisposed ) + throw css::lang::DisposedException(); + + vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); + + css::uno::Reference< css::frame::XDispatch > xDispatch; + css::util::URL aTargetURL; + + if ( m_xURLTransformer.is() ) + { + aTargetURL.Complete = ::rtl::OUString::createFromAscii(".uno:ExecuteSearch"); + m_xURLTransformer->parseStrict( aTargetURL ); + + css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( m_xFrame, css::uno::UNO_QUERY); + if ( xDispatchProvider.is() ) + xDispatch = xDispatchProvider->queryDispatch( aTargetURL, rtl::OUString(), 0 ); + } + + if ( xDispatch.is() && aTargetURL.Complete.getLength() > 0 ) + { + ::rtl::OUString sFindText; + Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); + ToolBox* pToolBox = (ToolBox*)pWindow; + if ( pToolBox ) + { + USHORT nItemCount = pToolBox->GetItemCount(); + for ( USHORT i=0; iGetItemCommand(i); + if ( sItemCommand.equals( COMMAND_FINDTEXT ) ) + { + Window* pItemWin = pToolBox->GetItemWindow(i); + if (pItemWin) + sFindText = pItemWin->GetText(); + break; + } + } + } + + css::uno::Sequence< css::beans::PropertyValue > aArgs( 2 ); + aArgs[0].Name = SEARCHITEM_SEARCHSTRING; + aArgs[0].Value <<= sFindText; + aArgs[1].Name = SEARCHITEM_SEARCHBACKWARD; + aArgs[1].Value <<= sal_False; + + // Execute dispatch asynchronously + ExecuteInfo* pExecuteInfo = new ExecuteInfo; + pExecuteInfo->xDispatch = xDispatch; + pExecuteInfo->aTargetURL = aTargetURL; + pExecuteInfo->aArgs = aArgs; + Application::PostUserEvent( STATIC_LINK(0, DownSearchToolboxController , ExecuteHdl_Impl), pExecuteInfo ); + + css::frame::FeatureStateEvent aEvent; + css::util::URL aCommand; + aCommand.Complete = COMMAND_APPENDSEARCHHISTORY; + aEvent.FeatureURL = aCommand; + aEvent.IsEnabled = sal_True; + + css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager()->findController(m_xFrame, COMMAND_FINDTEXT); + xStatusListener->statusChanged( aEvent ); + } +} + +// XStatusListener +void SAL_CALL DownSearchToolboxController::statusChanged( const css::frame::FeatureStateEvent& /*rEvent*/ ) throw ( css::uno::RuntimeException ) +{ +} + +IMPL_STATIC_LINK_NOINSTANCE( DownSearchToolboxController, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo ) +{ + const sal_uInt32 nRef = Application::ReleaseSolarMutex(); + try + { + // Asynchronous execution as this can lead to our own destruction! + // Framework can recycle our current frame and the layout manager disposes all user interface + // elements if a component gets detached from its frame! + pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs ); + } + catch ( css::uno::Exception& ) + { + } + + Application::AcquireSolarMutex( nRef ); + delete pExecuteInfo; + + return 0; +} + +//----------------------------------------------------------------------------------------------------------- +// class UpSearchToolboxController + +UpSearchToolboxController::UpSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager ) + :svt::ToolboxController( rServiceManager, + css::uno::Reference< css::frame::XFrame >(), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:UpSearch" )) ) +{ + m_xURLTransformer = css::uno::Reference< css::util::XURLTransformer >( m_xServiceManager->createInstance( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), + css::uno::UNO_QUERY_THROW ); +} + +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( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ) ); + return aSNS; +} + +// XComponent +void SAL_CALL UpSearchToolboxController::dispose() throw ( css::uno::RuntimeException ) +{ + vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); + + 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(); + + vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); + + css::uno::Reference< css::frame::XDispatch > xDispatch; + css::util::URL aTargetURL; + + if ( m_xURLTransformer.is() ) + { + aTargetURL.Complete = ::rtl::OUString::createFromAscii(".uno:ExecuteSearch"); + m_xURLTransformer->parseStrict( aTargetURL ); + + css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( m_xFrame, css::uno::UNO_QUERY); + if ( xDispatchProvider.is() ) + xDispatch = xDispatchProvider->queryDispatch( aTargetURL, rtl::OUString(), 0 ); + } + + if ( xDispatch.is() && aTargetURL.Complete.getLength() > 0 ) + { + ::rtl::OUString sFindText; + Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); + ToolBox* pToolBox = (ToolBox*)pWindow; + if ( pToolBox ) + { + USHORT nItemCount = pToolBox->GetItemCount(); + for ( USHORT i=0; iGetItemCommand(i); + if ( sItemCommand.equals( COMMAND_FINDTEXT ) ) + { + Window* pItemWin = pToolBox->GetItemWindow(i); + if (pItemWin) + sFindText = pItemWin->GetText(); + break; + } + } + } + + css::uno::Sequence< css::beans::PropertyValue > aArgs( 2 ); + aArgs[0].Name = SEARCHITEM_SEARCHSTRING; + aArgs[0].Value <<= sFindText; + aArgs[1].Name = SEARCHITEM_SEARCHBACKWARD; + aArgs[1].Value <<= sal_True; + + // Execute dispatch asynchronously + ExecuteInfo* pExecuteInfo = new ExecuteInfo; + pExecuteInfo->xDispatch = xDispatch; + pExecuteInfo->aTargetURL = aTargetURL; + pExecuteInfo->aArgs = aArgs; + Application::PostUserEvent( STATIC_LINK(0, UpSearchToolboxController , ExecuteHdl_Impl), pExecuteInfo ); + + css::frame::FeatureStateEvent aEvent; + css::util::URL aCommand; + aCommand.Complete = COMMAND_APPENDSEARCHHISTORY; + aEvent.FeatureURL = aCommand; + aEvent.IsEnabled = sal_True; + + css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager()->findController(m_xFrame, COMMAND_FINDTEXT); + xStatusListener->statusChanged( aEvent ); + } +} + +// XStatusListener +void SAL_CALL UpSearchToolboxController::statusChanged( const css::frame::FeatureStateEvent& /*rEvent*/ ) throw ( css::uno::RuntimeException ) +{ +} + +IMPL_STATIC_LINK_NOINSTANCE( UpSearchToolboxController, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo ) +{ + const sal_uInt32 nRef = Application::ReleaseSolarMutex(); + try + { + // Asynchronous execution as this can lead to our own destruction! + // Framework can recycle our current frame and the layout manager disposes all user interface + // elements if a component gets detached from its frame! + pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs ); + } + catch ( css::uno::Exception& ) + { + } + + Application::AcquireSolarMutex( nRef ); + delete pExecuteInfo; + + return 0; +} + +//----------------------------------------------------------------------------------------------------------- +// class FindbarDispatcher + +FindbarDispatcher::FindbarDispatcher(const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory) + : m_xFactory( xFactory ) +{ +} + +FindbarDispatcher::~FindbarDispatcher() +{ + m_xFactory = NULL; + m_xFrame = NULL; +} + +// XInterface +css::uno::Any SAL_CALL FindbarDispatcher::queryInterface( const css::uno::Type& aType ) throw( css::uno::RuntimeException ) +{ + css::uno::Any aReturn( ::cppu::queryInterface( aType, + static_cast< css::lang::XServiceInfo* >(this), + static_cast< css::lang::XInitialization* >(this), + static_cast< css::frame::XDispatchProvider* >(this), + static_cast< css::frame::XDispatch* >(this)) ); + + if ( aReturn.hasValue() ) + return aReturn; + + return OWeakObject::queryInterface( aType ); +} + +void SAL_CALL FindbarDispatcher::acquire() throw() +{ + OWeakObject::acquire(); +} + +void SAL_CALL FindbarDispatcher::release() throw() +{ + OWeakObject::release(); +} + +// XServiceInfo +::rtl::OUString SAL_CALL FindbarDispatcher::getImplementationName() throw( css::uno::RuntimeException ) +{ + return getImplementationName_Static(); +} + +sal_Bool SAL_CALL FindbarDispatcher::supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException ) +{ + return ( + ServiceName.equalsAscii("com.sun.star.comp.svx.FindbarDispatcher") || + ServiceName.equalsAscii("com.sun.star.frame.ProtocolHandler") + ); +} + +css::uno::Sequence< ::rtl::OUString > SAL_CALL FindbarDispatcher::getSupportedServiceNames() throw( css::uno::RuntimeException ) +{ + return getSupportedServiceNames_Static(); +} + +css::uno::Sequence< ::rtl::OUString > FindbarDispatcher::getSupportedServiceNames_Static() throw() +{ + css::uno::Sequence< ::rtl::OUString > aSNS( 2 ); + aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.FindbarDispatcher" )); + aSNS.getArray()[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ProtocolHandler" )); + return aSNS; +} + +// XInitialization +void SAL_CALL FindbarDispatcher::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException ) +{ + if ( aArguments.getLength() ) + { + aArguments[0] >>= m_xFrame; + } +} + +// XDispatchProvider +css::uno::Reference< css::frame::XDispatch > SAL_CALL FindbarDispatcher::queryDispatch( const css::util::URL& aURL, const ::rtl::OUString& /*sTargetFrameName*/, sal_Int32 /*nSearchFlags*/ ) throw( css::uno::RuntimeException ) +{ + css::uno::Reference< css::frame::XDispatch > xDispatch; + + if ( aURL.Protocol.equalsAscii("vnd.sun.star.findbar:") ) + xDispatch = this; + + return xDispatch; +} + +css::uno::Sequence < css::uno::Reference< css::frame::XDispatch > > SAL_CALL FindbarDispatcher::queryDispatches( const css::uno::Sequence < css::frame::DispatchDescriptor >& seqDescripts ) throw( css::uno::RuntimeException ) +{ + sal_Int32 nCount = seqDescripts.getLength(); + css::uno::Sequence < css::uno::Reference < XDispatch > > lDispatcher( nCount ); + + for( sal_Int32 i=0; i& /*lArgs*/ ) throw( css::uno::RuntimeException ) +{ + //vnd.sun.star.findbar:FocusToFindbar - set cursor to the FindTextFieldControl of the findbar + if ( aURL.Path.equalsAscii("FocusToFindbar") ) + { + css::uno::Reference< css::beans::XPropertySet > xPropSet(m_xFrame, css::uno::UNO_QUERY); + if(!xPropSet.is()) + return; + + css::uno::Reference< css::frame::XLayoutManager > xLayoutManager; + css::uno::Any aValue = xPropSet->getPropertyValue( ::rtl::OUString::createFromAscii("LayoutManager") ); + aValue >>= xLayoutManager; + if (!xLayoutManager.is()) + return; + + const ::rtl::OUString sResourceURL = ::rtl::OUString::createFromAscii("private:resource/toolbar/findbar"); + css::uno::Reference< css::ui::XUIElement > xUIElement = xLayoutManager->getElement(sResourceURL); + if (!xUIElement.is()) + return; + + css::uno::Reference< css::awt::XWindow > xWindow(xUIElement->getRealInterface(), css::uno::UNO_QUERY); + Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); + ToolBox* pToolBox = (ToolBox*)pWindow; + if ( pToolBox ) + { + USHORT nItemCount = pToolBox->GetItemCount(); + for ( USHORT i=0; iGetItemCommand(i); + if ( sItemCommand.equalsAscii(".uno:FindText") ) + { + Window* pItemWin = pToolBox->GetItemWindow( i ); + if ( pItemWin ) + { + pItemWin->GrabFocus(); + return; + } + } + } + } + + } +} + +void SAL_CALL FindbarDispatcher::addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& /*xControl*/, const css::util::URL& /*aURL*/ ) throw ( css::uno::RuntimeException ) +{ +} + +void SAL_CALL FindbarDispatcher::removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& /*xControl*/, const css::util::URL& /*aURL*/ ) throw ( css::uno::RuntimeException ) +{ +} + +//----------------------------------------------------------------------------------------------------------- +// create Instance + +css::uno::Reference< css::uno::XInterface > SAL_CALL FindTextToolbarController_createInstance( + const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ) +{ + return *new FindTextToolbarController( rSMgr ); +} + +css::uno::Reference< css::uno::XInterface > SAL_CALL DownSearchToolboxController_createInstance( + const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ) +{ + return *new DownSearchToolboxController( rSMgr ); +} + +css::uno::Reference< css::uno::XInterface > SAL_CALL UpSearchToolboxController_createInstance( + const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ) +{ + return *new UpSearchToolboxController( rSMgr ); +} + +css::uno::Reference< css::uno::XInterface > SAL_CALL FindbarDispatcher_createInstance( + const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ) +{ + return *new FindbarDispatcher( rSMgr ); +} + +//----------------------------------------------------------------------------------------------------------- +} diff --git a/svx/source/unodraw/unoctabl.cxx b/svx/source/unodraw/unoctabl.cxx index 8e4a387893..a215051dbc 100644 --- a/svx/source/unodraw/unoctabl.cxx +++ b/svx/source/unodraw/unoctabl.cxx @@ -39,6 +39,7 @@ #include "recoveryui.hxx" #include "xmlgrhlp.hxx" #include "tbunocontroller.hxx" +#include "tbunosearchcontrollers.hxx" using namespace ::com::sun::star; using namespace ::rtl; @@ -283,6 +284,12 @@ SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo ( writeInfo( pKey, svx::GraphicExporter_getImplementationName(), svx::GraphicExporter_getSupportedServiceNames() ); #endif writeInfo( pKey, svx::FontHeightToolBoxControl::getImplementationName_Static(), svx::FontHeightToolBoxControl::getSupportedServiceNames_Static() ); + + writeInfo( pKey, svx::FindTextToolbarController::getImplementationName_Static(), svx::FindTextToolbarController::getSupportedServiceNames_Static() ); + writeInfo( pKey, svx::DownSearchToolboxController::getImplementationName_Static(), svx::DownSearchToolboxController::getSupportedServiceNames_Static() ); + writeInfo( pKey, svx::UpSearchToolboxController::getImplementationName_Static(), svx::UpSearchToolboxController::getSupportedServiceNames_Static() ); + writeInfo( pKey, svx::FindbarDispatcher::getImplementationName_Static(), svx::FindbarDispatcher::getSupportedServiceNames_Static() ); + writeInfo( pKey, ::unogallery::GalleryThemeProvider_getImplementationName(),::unogallery::GalleryThemeProvider_getSupportedServiceNames() ); // XPrimitiveFactory2D @@ -354,6 +361,34 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory ( svx::FontHeightToolBoxControl_createInstance, svx::FontHeightToolBoxControl::getSupportedServiceNames_Static() ); } + else if ( svx::FindTextToolbarController::getImplementationName_Static().equalsAscii( pImplName ) ) + { + xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), + svx::FindTextToolbarController::getImplementationName_Static(), + svx::FindTextToolbarController_createInstance, + svx::FindTextToolbarController::getSupportedServiceNames_Static() ); + } + else if ( svx::DownSearchToolboxController::getImplementationName_Static().equalsAscii( pImplName ) ) + { + xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), + svx::DownSearchToolboxController::getImplementationName_Static(), + svx::DownSearchToolboxController_createInstance, + svx::DownSearchToolboxController::getSupportedServiceNames_Static() ); + } + else if ( svx::UpSearchToolboxController::getImplementationName_Static().equalsAscii( pImplName ) ) + { + xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), + svx::UpSearchToolboxController::getImplementationName_Static(), + svx::UpSearchToolboxController_createInstance, + svx::UpSearchToolboxController::getSupportedServiceNames_Static() ); + } + else if ( svx::FindbarDispatcher::getImplementationName_Static().equalsAscii( pImplName ) ) + { + xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), + svx::FindbarDispatcher::getImplementationName_Static(), + svx::FindbarDispatcher_createInstance, + svx::FindbarDispatcher::getSupportedServiceNames_Static() ); + } else if( ::unogallery::GalleryThemeProvider_getImplementationName().equalsAscii( pImplName ) ) { xFactory = ::cppu::createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ), -- cgit v1.2.3 From 4042099dccaaa580857193c5a58947e2b9dd3009 Mon Sep 17 00:00:00 2001 From: Wu Yan Date: Wed, 28 Apr 2010 18:50:45 +0800 Subject: findbar01: enhancements for findbar --- .../data/org/openoffice/Office/Accelerators.xcu | 4 +++ .../data/org/openoffice/Office/ProtocolHandler.xcu | 5 ++++ .../org/openoffice/Office/UI/CalcWindowState.xcu | 20 +++++++++++++ .../data/org/openoffice/Office/UI/Controller.xcu | 33 ++++++++++++++++++++++ .../org/openoffice/Office/UI/DrawWindowState.xcu | 20 +++++++++++++ .../org/openoffice/Office/UI/GenericCommands.xcu | 24 ++++++++++++++++ .../openoffice/Office/UI/ImpressWindowState.xcu | 20 +++++++++++++ .../org/openoffice/Office/UI/WriterWindowState.xcu | 20 +++++++++++++ 8 files changed, 146 insertions(+) diff --git a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu index c197b77231..e40224001d 100755 --- a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu @@ -577,6 +577,7 @@ I10N SHORTCUTS - NO TRANSLATE .uno:RepeatSearch + vnd.sun.star.findbar:FocusToFindbar .uno:Bold @@ -1097,6 +1098,7 @@ I10N SHORTCUTS - NO TRANSLATE + vnd.sun.star.findbar:FocusToFindbar .uno:Save .uno:Bold @@ -2061,6 +2063,7 @@ I10N SHORTCUTS - NO TRANSLATE + vnd.sun.star.findbar:FocusToFindbar .uno:Save .uno:Bold @@ -4451,6 +4454,7 @@ I10N SHORTCUTS - NO TRANSLATE .uno:RepeatSearch + vnd.sun.star.findbar:FocusToFindbar .uno:Bold diff --git a/officecfg/registry/data/org/openoffice/Office/ProtocolHandler.xcu b/officecfg/registry/data/org/openoffice/Office/ProtocolHandler.xcu index 52db8cb5de..4a8002e167 100644 --- a/officecfg/registry/data/org/openoffice/Office/ProtocolHandler.xcu +++ b/officecfg/registry/data/org/openoffice/Office/ProtocolHandler.xcu @@ -63,5 +63,10 @@ vnd.sun.star.popup:* + + + vnd.sun.star.findbar:* + + diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu index b3ddf0ce33..270da6be84 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu @@ -293,6 +293,26 @@ true + + + 1,0 + + + true + + + 0 + + + Find Toolbar + + + true + + + false + + 0,1 diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu index d57d1b3b4d..0fbaba3cfd 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu @@ -218,6 +218,39 @@ com.sun.star.svx.FontHeightToolBoxController + + + .uno:FindText + + + + + + com.sun.star.svx.FindTextToolboxController + + + + + .uno:DownSearch + + + + + + com.sun.star.svx.DownSearchToolboxController + + + + + .uno:UpSearch + + + + + + com.sun.star.svx.UpSearchToolboxController + + .uno:ChartElementSelector diff --git a/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu index 385617f693..e88d0922be 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu @@ -106,6 +106,26 @@ true + + + 1,0 + + + true + + + 0 + + + Find Toolbar + + + true + + + false + + 0,1 diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index ab40f205c3..cb5e696346 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -1459,6 +1459,30 @@ 1 + + + Find Text + + + 1 + + + + + Find Next + + + 1 + + + + + Find Previous + + + 1 + + What's ~This? diff --git a/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu index af45c79cdf..125b8e70eb 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu @@ -594,6 +594,26 @@ true + + + 1,0 + + + true + + + 0 + + + Find Toolbar + + + true + + + false + + false diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu index ec708174a6..b387c8082e 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu @@ -52,6 +52,26 @@ true + + + 1,0 + + + true + + + 0 + + + Find Toolbar + + + true + + + false + + 0,1 -- cgit v1.2.3 From aac2e203d0ae77c21513bf12e27b68acaa0cae1f Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Tue, 11 May 2010 09:38:26 +0200 Subject: findbar01: #i10000# Fix build problem with gcc --- svx/source/tbxctrls/tbunosearchcontrollers.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index 26dd2c4ae7..fe9a683458 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -245,7 +245,7 @@ void SearchToolbarControllersManager::registryController( const css::uno::Refere } -void SearchToolbarControllersManager::freeController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL ) +void SearchToolbarControllersManager::freeController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& /*xStatusListener*/, const ::rtl::OUString& sCommandURL ) { SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame); if (pIt != aSearchToolbarControllersMap.end()) -- cgit v1.2.3 From 7911d7c5e35beef4609acfb9e5c621ff7d50446a Mon Sep 17 00:00:00 2001 From: Wu Yan Date: Thu, 20 May 2010 11:36:59 +0800 Subject: findbar01:#111709# Fix shortcut name for Ctrl-G --- .../registry/data/org/openoffice/Office/UI/GenericCommands.xcu | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index cb5e696346..04c945df21 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -1483,6 +1483,14 @@ 1 + + + Focus to Findbar + + + 1 + + What's ~This? -- cgit v1.2.3 From 4411578150e3e020f801a441914752a02fad0734 Mon Sep 17 00:00:00 2001 From: Wu Yan Date: Wed, 26 May 2010 16:34:58 +0800 Subject: findbar01: #111823# change QuickFind shortcut to Ctrl-Alt-F --- .../data/org/openoffice/Office/Accelerators.xcu | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu index e40224001d..ef65ca92f2 100755 --- a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu @@ -568,6 +568,11 @@ .uno:CalculateHard + + I10N SHORTCUTS - NO TRANSLATE + vnd.sun.star.findbar:FocusToFindbar + + I10N SHORTCUTS - NO TRANSLATE .uno:Bold @@ -577,7 +582,6 @@ I10N SHORTCUTS - NO TRANSLATE .uno:RepeatSearch - vnd.sun.star.findbar:FocusToFindbar .uno:Bold @@ -1091,6 +1095,11 @@ .uno:TextFitToSize + + I10N SHORTCUTS - NO TRANSLATE + vnd.sun.star.findbar:FocusToFindbar + + I10N SHORTCUTS - NO TRANSLATE .uno:Bold @@ -1098,7 +1107,6 @@ I10N SHORTCUTS - NO TRANSLATE - vnd.sun.star.findbar:FocusToFindbar .uno:Save .uno:Bold @@ -2056,6 +2064,11 @@ .uno:TextFitToSize + + I10N SHORTCUTS - NO TRANSLATE + vnd.sun.star.findbar:FocusToFindbar + + I10N SHORTCUTS - NO TRANSLATE .uno:Bold @@ -2063,7 +2076,6 @@ I10N SHORTCUTS - NO TRANSLATE - vnd.sun.star.findbar:FocusToFindbar .uno:Save .uno:Bold @@ -4445,6 +4457,11 @@ .uno:UpdateInputFields + + I10N SHORTCUTS - NO TRANSLATE + vnd.sun.star.findbar:FocusToFindbar + + I10N SHORTCUTS - NO TRANSLATE .uno:Bold @@ -4454,7 +4471,6 @@ I10N SHORTCUTS - NO TRANSLATE .uno:RepeatSearch - vnd.sun.star.findbar:FocusToFindbar .uno:Bold -- cgit v1.2.3 From d14fdec31f9592d1339373e3c25b8ff8c3ef36d0 Mon Sep 17 00:00:00 2001 From: Wu Yan Date: Wed, 26 May 2010 16:38:12 +0800 Subject: findbar01: #111826#, #111827# and make some optimizations for the code --- svx/inc/tbunosearchcontrollers.hxx | 42 ++- svx/source/tbxctrls/tbunosearchcontrollers.cxx | 367 ++++++++----------------- 2 files changed, 128 insertions(+), 281 deletions(-) diff --git a/svx/inc/tbunosearchcontrollers.hxx b/svx/inc/tbunosearchcontrollers.hxx index 512dea9b70..12cff7ecd1 100644 --- a/svx/inc/tbunosearchcontrollers.hxx +++ b/svx/inc/tbunosearchcontrollers.hxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -49,13 +50,26 @@ namespace css = ::com::sun::star ; namespace svx { -class FindTextFieldControl; - -struct ExecuteInfo +class FindTextFieldControl : public ComboBox { - css::uno::Reference< css::frame::XDispatch > xDispatch; - css::util::URL aTargetURL; - css::uno::Sequence< css::beans::PropertyValue > aArgs; +public: + FindTextFieldControl( Window* pParent, WinBits nStyle, + css::uno::Reference< css::frame::XFrame >& xFrame, + css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + virtual ~FindTextFieldControl(); + + virtual void Modify(); + virtual long PreNotify( NotifyEvent& rNEvt ); + + void InitControls_Impl(); + void Remember_Impl(const String& rStr); + +private: + + css::uno::Reference< css::frame::XFrame > m_xFrame; + css::uno::Reference< css::lang::XMultiServiceFactory > m_xServiceManager; + sal_Bool m_bToClearTextField; + }; class SearchToolbarControllersManager @@ -119,14 +133,10 @@ public: // XStatusListener virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException ); - sal_Int32 getFontSizePixel( const Window* pWindow ); - - DECL_STATIC_LINK( FindTextToolbarController, ExecuteHdl_Impl, ExecuteInfo* ); DECL_LINK(EditModifyHdl, void*); private: - css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; FindTextFieldControl* m_pFindTextFieldControl; USHORT m_nDownSearchId; // item position of findbar @@ -171,12 +181,6 @@ public: // XStatusListener virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException ); - DECL_STATIC_LINK( DownSearchToolboxController, ExecuteHdl_Impl, ExecuteInfo* ); - -private : - - css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; - }; class UpSearchToolboxController : public svt::ToolboxController, @@ -216,12 +220,6 @@ public: // XStatusListener virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException ); - DECL_STATIC_LINK( UpSearchToolboxController, ExecuteHdl_Impl, ExecuteInfo* ); - -private : - - css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; - }; // protocol handler for "vnd.sun.star.findbar:*" URLs diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index fe9a683458..02192ca256 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -36,7 +36,6 @@ #include #include -#include #include #include #include @@ -47,35 +46,33 @@ namespace svx static const ::rtl::OUString SEARCHITEM_SEARCHSTRING = ::rtl::OUString::createFromAscii("SearchItem.SearchString"); static const ::rtl::OUString SEARCHITEM_SEARCHBACKWARD = ::rtl::OUString::createFromAscii("SearchItem.Backward"); +static const ::rtl::OUString COMMAND_EXECUTESEARCH = ::rtl::OUString::createFromAscii(".uno:ExecuteSearch"); static const ::rtl::OUString COMMAND_FINDTEXT = ::rtl::OUString::createFromAscii(".uno:FindText") ; static const ::rtl::OUString COMMAND_DOWNSEARCH = ::rtl::OUString::createFromAscii(".uno:DownSearch"); static const ::rtl::OUString COMMAND_UPSEARCH = ::rtl::OUString::createFromAscii(".uno:UpSearch") ; +static const ::rtl::OUString COMMAND_APPENDSEARCHHISTORY = ::rtl::OUString::createFromAscii("AppendSearchHistory"); -static const ::rtl::OUString COMMAND_APPENDSEARCHHISTORY = ::rtl::OUString::createFromAscii("AppendSearchHistory") ; +static const ::rtl::OUString SERVICENAME_URLTRANSFORMER = ::rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer"); +static const sal_Int32 REMEMBER_SIZE = 10; -class FindTextFieldControl : public ComboBox +void impl_executeSearch( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr, css::uno::Reference< css::frame::XFrame >& xFrame, css::uno::Sequence< css::beans::PropertyValue >& lArgs ) { -public: - FindTextFieldControl( Window* pParent, WinBits nStyle, - css::uno::Reference< css::frame::XFrame >& xFrame, - css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); - virtual ~FindTextFieldControl(); + css::uno::Reference< css::util::XURLTransformer > xURLTransformer( rSMgr->createInstance(SERVICENAME_URLTRANSFORMER), css::uno::UNO_QUERY ); + if ( xURLTransformer.is() ) + { + css::util::URL aURL; + aURL.Complete = COMMAND_EXECUTESEARCH; + xURLTransformer->parseStrict(aURL); - virtual void Modify(); - virtual long PreNotify( NotifyEvent& rNEvt ); - - void InitControls_Impl(); - void Remember_Impl(const String& rStr); - -private: - - css::uno::Reference< css::frame::XFrame > m_xFrame; - css::uno::Reference < css::util::XURLTransformer > m_xURLTransformer; - css::uno::Reference< css::lang::XMultiServiceFactory > m_xServiceManager; - - sal_Bool m_bToClearTextField; - -}; + css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider(xFrame, css::uno::UNO_QUERY); + if ( xDispatchProvider.is() ) + { + css::uno::Reference< css::frame::XDispatch > xDispatch = xDispatchProvider->queryDispatch( aURL, ::rtl::OUString(), 0 ); + if ( xDispatch.is() && aURL.Complete.getLength() > 0 ) + xDispatch->dispatch( aURL, lArgs ); + } + } +} FindTextFieldControl::FindTextFieldControl( Window* pParent, WinBits nStyle, css::uno::Reference< css::frame::XFrame >& xFrame, @@ -85,10 +82,6 @@ FindTextFieldControl::FindTextFieldControl( Window* pParent, WinBits nStyle, m_xServiceManager(xServiceManager), m_bToClearTextField(sal_True) { - m_xURLTransformer = css::uno::Reference< css::util::XURLTransformer >( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - css::uno::UNO_QUERY_THROW ); - InitControls_Impl(); } @@ -107,11 +100,16 @@ void FindTextFieldControl::InitControls_Impl() void FindTextFieldControl::Remember_Impl(const String& rStr) { USHORT nCount = GetEntryCount(); + for (USHORT i=0; iGetKeyCode().GetCode(); sal_Bool bCtrl = pKeyEvent->GetKeyCode().IsMod1(); - if (bCtrl && KEY_G== nCode) + sal_Bool bAlt = pKeyEvent->GetKeyCode().IsMod2(); + sal_Bool bShift = pKeyEvent->GetKeyCode().IsShift(); + sal_uInt16 nCode = pKeyEvent->GetKeyCode().GetCode(); + + if ( bCtrl && bAlt && KEY_F == nCode ) GrabFocusToDocument(); - if (KEY_RETURN == nCode) + if ( KEY_RETURN == nCode ) { - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - Remember_Impl(GetText()); - css::uno::Reference< css::frame::XDispatch > xDispatch; - css::util::URL aTargetURL; + ::rtl::OUString sFindText = GetText(); + css::uno::Sequence< css::beans::PropertyValue > lArgs(2); - if ( m_xURLTransformer.is() ) - { - aTargetURL.Complete = ::rtl::OUString::createFromAscii(".uno:ExecuteSearch"); - m_xURLTransformer->parseStrict( aTargetURL ); + lArgs[0].Name = SEARCHITEM_SEARCHSTRING; + lArgs[0].Value <<= sFindText; - css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( m_xFrame, css::uno::UNO_QUERY); - if ( xDispatchProvider.is() ) - xDispatch = xDispatchProvider->queryDispatch( aTargetURL, rtl::OUString(), 0 ); - } + lArgs[1].Name = SEARCHITEM_SEARCHBACKWARD; + if (bShift) + lArgs[1].Value <<= sal_True; + else + lArgs[1].Value <<= sal_False; - if ( xDispatch.is() && aTargetURL.Complete.getLength() > 0 ) - { - ::rtl::OUString sFindText = GetText(); - css::uno::Sequence< css::beans::PropertyValue > aArgs( 2 ); - aArgs[0].Name = SEARCHITEM_SEARCHSTRING; - aArgs[0].Value <<= sFindText; - aArgs[1].Name = SEARCHITEM_SEARCHBACKWARD; - aArgs[1].Value <<= sal_False; - - // Execute dispatch asynchronously - ExecuteInfo* pExecuteInfo = new ExecuteInfo; - pExecuteInfo->xDispatch = xDispatch; - pExecuteInfo->aTargetURL = aTargetURL; - pExecuteInfo->aArgs = aArgs; - Application::PostUserEvent( STATIC_LINK(0, DownSearchToolboxController , ExecuteHdl_Impl), pExecuteInfo ); - } + impl_executeSearch(m_xServiceManager, m_xFrame, lArgs); } break; } @@ -180,7 +163,8 @@ long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) { SetText( String() ); m_bToClearTextField = sal_False; - } + } + SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); break; case EVENT_LOSEFOCUS: @@ -188,7 +172,6 @@ long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) { SetText( String( ::rtl::OUString::createFromAscii("Find") ) ); SetControlForeground(COL_GRAY); - m_bToClearTextField = sal_True; } break; @@ -242,7 +225,6 @@ void SearchToolbarControllersManager::registryController( const css::uno::Refere pIt->second[nSize].Name = sCommandURL; pIt->second[nSize].Value <<= xStatusListener; } - } void SearchToolbarControllersManager::freeController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& /*xStatusListener*/, const ::rtl::OUString& sCommandURL ) @@ -290,11 +272,8 @@ css::uno::Reference< css::frame::XStatusListener > SearchToolbarControllersManag FindTextToolbarController::FindTextToolbarController( const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager ) :svt::ToolboxController( rServiceManager, css::uno::Reference< css::frame::XFrame >(), - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FindText" )) ) -{ - m_xURLTransformer = css::uno::Reference< css::util::XURLTransformer >( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - css::uno::UNO_QUERY_THROW ); + COMMAND_FINDTEXT ) +{ } FindTextToolbarController::~FindTextToolbarController() @@ -402,13 +381,9 @@ css::uno::Reference< css::awt::XWindow > SAL_CALL FindTextToolbarController::cre ToolBox* pToolbar = ( ToolBox* )pParent; m_pFindTextFieldControl = new FindTextFieldControl( pToolbar, WinBits( WB_DROPDOWN | WB_VSCROLL), m_xFrame, m_xServiceManager ); - // Calculate height of the edit field according to the application font height - sal_Int32 nHeight = getFontSizePixel( m_pFindTextFieldControl ); - nHeight += 200; - m_pFindTextFieldControl->SetSizePixel( Size( 100, nHeight )); - + Size aSize(100, m_pFindTextFieldControl->GetTextHeight() + 200); + m_pFindTextFieldControl->SetSizePixel( aSize ); m_pFindTextFieldControl->SetModifyHdl(LINK(this, FindTextToolbarController, EditModifyHdl)); - } xItemWindow = VCLUnoHelper::GetInterface( m_pFindTextFieldControl ); @@ -429,38 +404,6 @@ void SAL_CALL FindTextToolbarController::statusChanged( const css::frame::Featur } } -sal_Int32 FindTextToolbarController::getFontSizePixel( const Window* pWindow ) -{ - const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); - const Font& rFont = rSettings.GetAppFont(); - - // Calculate height of the application font used by window - sal_Int32 nHeight = sal_Int32( rFont.GetHeight() ); - ::Size aPixelSize = pWindow->LogicToPixel( ::Size( 0, nHeight ), MAP_APPFONT ); - return aPixelSize.Height(); -} - -IMPL_STATIC_LINK_NOINSTANCE( FindTextToolbarController, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo ) -{ - const sal_uInt32 nRef = Application::ReleaseSolarMutex(); - try - { - // Asynchronous execution as this can lead to our own destruction! - // Framework can recycle our current frame and the layout manager disposes all user interface - // elements if a component gets detached from its frame! - pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs ); - } - catch ( css::uno::Exception& ) - { - - } - - Application::AcquireSolarMutex( nRef ); - delete pExecuteInfo; - - return 0; -} - IMPL_LINK( FindTextToolbarController, EditModifyHdl, void *, EMPTYARG ) { // enable or disable item DownSearch/UpSearch of findbar @@ -493,11 +436,8 @@ IMPL_LINK( FindTextToolbarController, EditModifyHdl, void *, EMPTYARG ) DownSearchToolboxController::DownSearchToolboxController(const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager ) : svt::ToolboxController( rServiceManager, css::uno::Reference< css::frame::XFrame >(), - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DownSearch" )) ) + COMMAND_DOWNSEARCH ) { - m_xURLTransformer = css::uno::Reference< css::util::XURLTransformer >( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - css::uno::UNO_QUERY_THROW ); } DownSearchToolboxController::~DownSearchToolboxController() @@ -577,89 +517,46 @@ void SAL_CALL DownSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) if ( m_bDisposed ) throw css::lang::DisposedException(); - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - css::uno::Reference< css::frame::XDispatch > xDispatch; - css::util::URL aTargetURL; - - if ( m_xURLTransformer.is() ) - { - aTargetURL.Complete = ::rtl::OUString::createFromAscii(".uno:ExecuteSearch"); - m_xURLTransformer->parseStrict( aTargetURL ); - - css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( m_xFrame, css::uno::UNO_QUERY); - if ( xDispatchProvider.is() ) - xDispatch = xDispatchProvider->queryDispatch( aTargetURL, rtl::OUString(), 0 ); - } - - if ( xDispatch.is() && aTargetURL.Complete.getLength() > 0 ) + ::rtl::OUString sFindText; + Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); + ToolBox* pToolBox = (ToolBox*)pWindow; + if ( pToolBox ) { - ::rtl::OUString sFindText; - Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); - ToolBox* pToolBox = (ToolBox*)pWindow; - if ( pToolBox ) + USHORT nItemCount = pToolBox->GetItemCount(); + for ( USHORT i=0; iGetItemCount(); - for ( USHORT i=0; iGetItemCommand(i); + if ( sItemCommand.equals( COMMAND_FINDTEXT ) ) { - ::rtl::OUString sItemCommand = pToolBox->GetItemCommand(i); - if ( sItemCommand.equals( COMMAND_FINDTEXT ) ) - { - Window* pItemWin = pToolBox->GetItemWindow(i); - if (pItemWin) - sFindText = pItemWin->GetText(); - break; - } - } + Window* pItemWin = pToolBox->GetItemWindow(i); + if (pItemWin) + sFindText = pItemWin->GetText(); + break; + } } + } - css::uno::Sequence< css::beans::PropertyValue > aArgs( 2 ); - aArgs[0].Name = SEARCHITEM_SEARCHSTRING; - aArgs[0].Value <<= sFindText; - aArgs[1].Name = SEARCHITEM_SEARCHBACKWARD; - aArgs[1].Value <<= sal_False; - - // Execute dispatch asynchronously - ExecuteInfo* pExecuteInfo = new ExecuteInfo; - pExecuteInfo->xDispatch = xDispatch; - pExecuteInfo->aTargetURL = aTargetURL; - pExecuteInfo->aArgs = aArgs; - Application::PostUserEvent( STATIC_LINK(0, DownSearchToolboxController , ExecuteHdl_Impl), pExecuteInfo ); - - css::frame::FeatureStateEvent aEvent; - css::util::URL aCommand; - aCommand.Complete = COMMAND_APPENDSEARCHHISTORY; - aEvent.FeatureURL = aCommand; - aEvent.IsEnabled = sal_True; - - css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager()->findController(m_xFrame, COMMAND_FINDTEXT); + css::uno::Sequence< css::beans::PropertyValue > lArgs(2); + lArgs[0].Name = SEARCHITEM_SEARCHSTRING; + lArgs[0].Value <<= sFindText; + lArgs[1].Name = SEARCHITEM_SEARCHBACKWARD; + lArgs[1].Value <<= sal_False; + + impl_executeSearch(m_xServiceManager, m_xFrame, lArgs); + + css::frame::FeatureStateEvent aEvent; + aEvent.FeatureURL.Complete = 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 ) { -} - -IMPL_STATIC_LINK_NOINSTANCE( DownSearchToolboxController, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo ) -{ - const sal_uInt32 nRef = Application::ReleaseSolarMutex(); - try - { - // Asynchronous execution as this can lead to our own destruction! - // Framework can recycle our current frame and the layout manager disposes all user interface - // elements if a component gets detached from its frame! - pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs ); - } - catch ( css::uno::Exception& ) - { - } - - Application::AcquireSolarMutex( nRef ); - delete pExecuteInfo; - - return 0; + vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); + if ( m_bDisposed ) + return; } //----------------------------------------------------------------------------------------------------------- @@ -668,11 +565,8 @@ IMPL_STATIC_LINK_NOINSTANCE( DownSearchToolboxController, ExecuteHdl_Impl, Execu UpSearchToolboxController::UpSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager ) :svt::ToolboxController( rServiceManager, css::uno::Reference< css::frame::XFrame >(), - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:UpSearch" )) ) + COMMAND_UPSEARCH ) { - m_xURLTransformer = css::uno::Reference< css::util::XURLTransformer >( m_xServiceManager->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), - css::uno::UNO_QUERY_THROW ); } UpSearchToolboxController::~UpSearchToolboxController() @@ -752,89 +646,46 @@ void SAL_CALL UpSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) th if ( m_bDisposed ) throw css::lang::DisposedException(); - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - css::uno::Reference< css::frame::XDispatch > xDispatch; - css::util::URL aTargetURL; - - if ( m_xURLTransformer.is() ) - { - aTargetURL.Complete = ::rtl::OUString::createFromAscii(".uno:ExecuteSearch"); - m_xURLTransformer->parseStrict( aTargetURL ); - - css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( m_xFrame, css::uno::UNO_QUERY); - if ( xDispatchProvider.is() ) - xDispatch = xDispatchProvider->queryDispatch( aTargetURL, rtl::OUString(), 0 ); - } - - if ( xDispatch.is() && aTargetURL.Complete.getLength() > 0 ) + ::rtl::OUString sFindText; + Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); + ToolBox* pToolBox = (ToolBox*)pWindow; + if ( pToolBox ) { - ::rtl::OUString sFindText; - Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); - ToolBox* pToolBox = (ToolBox*)pWindow; - if ( pToolBox ) + USHORT nItemCount = pToolBox->GetItemCount(); + for ( USHORT i=0; iGetItemCount(); - for ( USHORT i=0; iGetItemCommand(i); + if ( sItemCommand.equals( COMMAND_FINDTEXT ) ) { - ::rtl::OUString sItemCommand = pToolBox->GetItemCommand(i); - if ( sItemCommand.equals( COMMAND_FINDTEXT ) ) - { - Window* pItemWin = pToolBox->GetItemWindow(i); - if (pItemWin) - sFindText = pItemWin->GetText(); - break; - } - } + Window* pItemWin = pToolBox->GetItemWindow(i); + if (pItemWin) + sFindText = pItemWin->GetText(); + break; + } } + } - css::uno::Sequence< css::beans::PropertyValue > aArgs( 2 ); - aArgs[0].Name = SEARCHITEM_SEARCHSTRING; - aArgs[0].Value <<= sFindText; - aArgs[1].Name = SEARCHITEM_SEARCHBACKWARD; - aArgs[1].Value <<= sal_True; - - // Execute dispatch asynchronously - ExecuteInfo* pExecuteInfo = new ExecuteInfo; - pExecuteInfo->xDispatch = xDispatch; - pExecuteInfo->aTargetURL = aTargetURL; - pExecuteInfo->aArgs = aArgs; - Application::PostUserEvent( STATIC_LINK(0, UpSearchToolboxController , ExecuteHdl_Impl), pExecuteInfo ); - - css::frame::FeatureStateEvent aEvent; - css::util::URL aCommand; - aCommand.Complete = COMMAND_APPENDSEARCHHISTORY; - aEvent.FeatureURL = aCommand; - aEvent.IsEnabled = sal_True; - - css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager()->findController(m_xFrame, COMMAND_FINDTEXT); + css::uno::Sequence< css::beans::PropertyValue > lArgs(2); + lArgs[0].Name = SEARCHITEM_SEARCHSTRING; + lArgs[0].Value <<= sFindText; + lArgs[1].Name = SEARCHITEM_SEARCHBACKWARD; + lArgs[1].Value <<= sal_True; + + impl_executeSearch(m_xServiceManager, m_xFrame, lArgs); + + css::frame::FeatureStateEvent aEvent; + aEvent.FeatureURL.Complete = 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 UpSearchToolboxController::statusChanged( const css::frame::FeatureStateEvent& /*rEvent*/ ) throw ( css::uno::RuntimeException ) { -} - -IMPL_STATIC_LINK_NOINSTANCE( UpSearchToolboxController, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo ) -{ - const sal_uInt32 nRef = Application::ReleaseSolarMutex(); - try - { - // Asynchronous execution as this can lead to our own destruction! - // Framework can recycle our current frame and the layout manager disposes all user interface - // elements if a component gets detached from its frame! - pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs ); - } - catch ( css::uno::Exception& ) - { - } - - Application::AcquireSolarMutex( nRef ); - delete pExecuteInfo; - - return 0; + vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); + if ( m_bDisposed ) + return; } //----------------------------------------------------------------------------------------------------------- @@ -907,9 +758,7 @@ css::uno::Sequence< ::rtl::OUString > FindbarDispatcher::getSupportedServiceNam void SAL_CALL FindbarDispatcher::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException ) { if ( aArguments.getLength() ) - { aArguments[0] >>= m_xFrame; - } } // XDispatchProvider -- cgit v1.2.3 From c4832a2cc01b9480e8bdd8c37c5532e9ff6fcbc9 Mon Sep 17 00:00:00 2001 From: Wu Yan Date: Wed, 26 May 2010 16:44:22 +0800 Subject: findbar01: #111826#, #111827# and make some optimizations for the code --- svx/source/tbxctrls/tbunosearchcontrollers.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index 02192ca256..b3048bd1fe 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -55,7 +55,7 @@ static const ::rtl::OUString COMMAND_APPENDSEARCHHISTORY = ::rtl::OUString::cr static const ::rtl::OUString SERVICENAME_URLTRANSFORMER = ::rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer"); static const sal_Int32 REMEMBER_SIZE = 10; -void impl_executeSearch( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr, css::uno::Reference< css::frame::XFrame >& xFrame, css::uno::Sequence< css::beans::PropertyValue >& lArgs ) +void impl_executeSearch( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr, const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Sequence< css::beans::PropertyValue >& lArgs ) { css::uno::Reference< css::util::XURLTransformer > xURLTransformer( rSMgr->createInstance(SERVICENAME_URLTRANSFORMER), css::uno::UNO_QUERY ); if ( xURLTransformer.is() ) -- cgit v1.2.3 From 05806943d5dd4f68024df8a41b407383f0bfed45 Mon Sep 17 00:00:00 2001 From: Wu Yan Date: Thu, 27 May 2010 17:06:33 +0800 Subject: findbar01: #i111840# set focus back to document when key is used in findbar text field --- svx/source/tbxctrls/tbunosearchcontrollers.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index b3048bd1fe..407ef59149 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -134,7 +134,7 @@ long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) sal_Bool bShift = pKeyEvent->GetKeyCode().IsShift(); sal_uInt16 nCode = pKeyEvent->GetKeyCode().GetCode(); - if ( bCtrl && bAlt && KEY_F == nCode ) + if ( (bCtrl && bAlt && KEY_F == nCode) || KEY_ESCAPE == nCode ) GrabFocusToDocument(); if ( KEY_RETURN == nCode ) -- cgit v1.2.3 From 12c14be7254bcee08186208920a1d42524c64faf Mon Sep 17 00:00:00 2001 From: Wu Yan Date: Thu, 27 May 2010 17:22:17 +0800 Subject: findbar01: #i111848#, #i111852# change title of findbar and show/hide the findbar according to specification --- .../data/org/openoffice/Office/Accelerators.xcu | 15 +++++++++++++++ .../org/openoffice/Office/UI/CalcWindowState.xcu | 2 +- .../org/openoffice/Office/UI/DrawWindowState.xcu | 4 ++-- .../org/openoffice/Office/UI/ImpressWindowState.xcu | 4 ++-- .../openoffice/Office/UI/WriterGlobalWindowState.xcu | 20 ++++++++++++++++++++ .../openoffice/Office/UI/WriterWebWindowState.xcu | 20 ++++++++++++++++++++ .../org/openoffice/Office/UI/WriterWindowState.xcu | 2 +- .../org/openoffice/Office/UI/XFormsWindowState.xcu | 20 ++++++++++++++++++++ 8 files changed, 81 insertions(+), 6 deletions(-) diff --git a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu index ef65ca92f2..ae316b6cc3 100755 --- a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu @@ -1576,6 +1576,11 @@ .uno:UpdateInputFields + + I10N SHORTCUTS - NO TRANSLATE + vnd.sun.star.findbar:FocusToFindbar + + I10N SHORTCUTS - NO TRANSLATE .uno:Bold @@ -2612,6 +2617,11 @@ .uno:UpdateInputFields + + I10N SHORTCUTS - NO TRANSLATE + vnd.sun.star.findbar:FocusToFindbar + + I10N SHORTCUTS - NO TRANSLATE .uno:Bold @@ -5072,6 +5082,11 @@ .uno:UpdateInputFields + + I10N SHORTCUTS - NO TRANSLATE + vnd.sun.star.findbar:FocusToFindbar + + I10N SHORTCUTS - NO TRANSLATE .uno:Bold diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu index 270da6be84..85687bb9f4 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu @@ -304,7 +304,7 @@ 0 - Find Toolbar + Find true diff --git a/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu index 8efec101f6..57a14b4889 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu @@ -117,10 +117,10 @@ 0 - Find Toolbar + Find - true + false false diff --git a/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu index 68c371b02d..8d08896e48 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu @@ -605,10 +605,10 @@ 0 - Find Toolbar + Find - true + false false diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterGlobalWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterGlobalWindowState.xcu index 3988e6dcd6..c18fc70f36 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterGlobalWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterGlobalWindowState.xcu @@ -52,6 +52,26 @@ true + + + 1,0 + + + true + + + 0 + + + Find + + + true + + + false + + 0,1 diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterWebWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterWebWindowState.xcu index 49c862fb92..5b0ddd349f 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterWebWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterWebWindowState.xcu @@ -52,6 +52,26 @@ true + + + 1,0 + + + true + + + 0 + + + Find + + + true + + + false + + 0,1 diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu index b387c8082e..51b7224b47 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu @@ -63,7 +63,7 @@ 0 - Find Toolbar + Find true diff --git a/officecfg/registry/data/org/openoffice/Office/UI/XFormsWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/XFormsWindowState.xcu index 841514c25f..a77f3fa59e 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/XFormsWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/XFormsWindowState.xcu @@ -53,6 +53,26 @@ true + + + 1,0 + + + true + + + 0 + + + Find + + + true + + + false + + 0,1 -- cgit v1.2.3