1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file
5f6e50924SAndrew Rist * distributed with this work for additional information
6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist * software distributed under the License is distributed on an
15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the
17f6e50924SAndrew Rist * specific language governing permissions and limitations
18f6e50924SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20f6e50924SAndrew Rist *************************************************************/
21f6e50924SAndrew Rist
22f6e50924SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "tbunosearchcontrollers.hxx"
28cdf0e10cSrcweir #include <svx/dialogs.hrc>
29cdf0e10cSrcweir #include <svx/dialmgr.hxx>
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
32cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp>
33cdf0e10cSrcweir #include <com/sun/star/ui/XUIElement.hpp>
34cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp>
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
37cdf0e10cSrcweir #include <vcl/toolbox.hxx>
38cdf0e10cSrcweir #include <vcl/svapp.hxx>
39cdf0e10cSrcweir #include <vos/mutex.hxx>
40cdf0e10cSrcweir
41cdf0e10cSrcweir namespace svx
42cdf0e10cSrcweir {
43cdf0e10cSrcweir
44cdf0e10cSrcweir static const ::rtl::OUString SEARCHITEM_SEARCHSTRING = ::rtl::OUString::createFromAscii("SearchItem.SearchString");
45cdf0e10cSrcweir static const ::rtl::OUString SEARCHITEM_SEARCHBACKWARD = ::rtl::OUString::createFromAscii("SearchItem.Backward");
46cdf0e10cSrcweir
47cdf0e10cSrcweir static const ::rtl::OUString COMMAND_EXECUTESEARCH = ::rtl::OUString::createFromAscii(".uno:ExecuteSearch");
48cdf0e10cSrcweir static const ::rtl::OUString COMMAND_FINDTEXT = ::rtl::OUString::createFromAscii(".uno:FindText");
49cdf0e10cSrcweir static const ::rtl::OUString COMMAND_DOWNSEARCH = ::rtl::OUString::createFromAscii(".uno:DownSearch");
50cdf0e10cSrcweir static const ::rtl::OUString COMMAND_UPSEARCH = ::rtl::OUString::createFromAscii(".uno:UpSearch");
51cdf0e10cSrcweir static const ::rtl::OUString COMMAND_APPENDSEARCHHISTORY = ::rtl::OUString::createFromAscii("AppendSearchHistory");
52cdf0e10cSrcweir
53cdf0e10cSrcweir static const ::rtl::OUString SERVICENAME_URLTRANSFORMER = ::rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer");
54cdf0e10cSrcweir static const sal_Int32 REMEMBER_SIZE = 10;
55cdf0e10cSrcweir
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)56cdf0e10cSrcweir 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 )
57cdf0e10cSrcweir {
58cdf0e10cSrcweir css::uno::Reference< css::util::XURLTransformer > xURLTransformer( rSMgr->createInstance(SERVICENAME_URLTRANSFORMER), css::uno::UNO_QUERY );
59cdf0e10cSrcweir if ( xURLTransformer.is() )
60cdf0e10cSrcweir {
61cdf0e10cSrcweir css::util::URL aURL;
62cdf0e10cSrcweir aURL.Complete = COMMAND_EXECUTESEARCH;
63cdf0e10cSrcweir xURLTransformer->parseStrict(aURL);
64cdf0e10cSrcweir
65cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider(xFrame, css::uno::UNO_QUERY);
66cdf0e10cSrcweir if ( xDispatchProvider.is() )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatch > xDispatch = xDispatchProvider->queryDispatch( aURL, ::rtl::OUString(), 0 );
69cdf0e10cSrcweir if ( xDispatch.is() && aURL.Complete.getLength() > 0 )
70cdf0e10cSrcweir xDispatch->dispatch( aURL, lArgs );
71cdf0e10cSrcweir }
72cdf0e10cSrcweir }
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
FindTextFieldControl(Window * pParent,WinBits nStyle,css::uno::Reference<css::frame::XFrame> & xFrame,css::uno::Reference<css::lang::XMultiServiceFactory> & xServiceManager)75cdf0e10cSrcweir FindTextFieldControl::FindTextFieldControl( Window* pParent, WinBits nStyle,
76cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame >& xFrame,
77cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager) :
78cdf0e10cSrcweir ComboBox( pParent, nStyle ),
79cdf0e10cSrcweir m_xFrame(xFrame),
80cdf0e10cSrcweir m_xServiceManager(xServiceManager),
81cdf0e10cSrcweir m_bToClearTextField(sal_True)
82cdf0e10cSrcweir {
83cdf0e10cSrcweir InitControls_Impl();
84cdf0e10cSrcweir }
85cdf0e10cSrcweir
~FindTextFieldControl()86cdf0e10cSrcweir FindTextFieldControl::~FindTextFieldControl()
87cdf0e10cSrcweir {
88cdf0e10cSrcweir }
89cdf0e10cSrcweir
InitControls_Impl()90cdf0e10cSrcweir void FindTextFieldControl::InitControls_Impl()
91cdf0e10cSrcweir {
92cdf0e10cSrcweir SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_FIND ) );
93cdf0e10cSrcweir SetControlForeground(GetSettings().GetStyleSettings().GetDisableColor());
94cdf0e10cSrcweir
95cdf0e10cSrcweir EnableAutocomplete(sal_True, sal_True);
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
Remember_Impl(const String & rStr)98cdf0e10cSrcweir void FindTextFieldControl::Remember_Impl(const String& rStr)
99cdf0e10cSrcweir {
100cdf0e10cSrcweir sal_uInt16 nCount = GetEntryCount();
101cdf0e10cSrcweir
102cdf0e10cSrcweir for (sal_uInt16 i=0; i<nCount; ++i)
103cdf0e10cSrcweir {
104cdf0e10cSrcweir if ( rStr == GetEntry(i))
105cdf0e10cSrcweir return;
106cdf0e10cSrcweir }
107cdf0e10cSrcweir
108cdf0e10cSrcweir if (nCount == REMEMBER_SIZE)
109cdf0e10cSrcweir RemoveEntry(REMEMBER_SIZE-1);
110cdf0e10cSrcweir
111cdf0e10cSrcweir InsertEntry(rStr, 0);
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
Modify()114cdf0e10cSrcweir void FindTextFieldControl::Modify()
115cdf0e10cSrcweir {
116cdf0e10cSrcweir ComboBox::Modify();
117cdf0e10cSrcweir
118cdf0e10cSrcweir SetControlForeground( GetSettings().GetStyleSettings().GetWindowTextColor() );
119cdf0e10cSrcweir }
120cdf0e10cSrcweir
PreNotify(NotifyEvent & rNEvt)121cdf0e10cSrcweir long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt )
122cdf0e10cSrcweir {
123cdf0e10cSrcweir long nRet= ComboBox::PreNotify( rNEvt );
124cdf0e10cSrcweir
125cdf0e10cSrcweir switch ( rNEvt.GetType() )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir case EVENT_KEYINPUT:
128cdf0e10cSrcweir {
129cdf0e10cSrcweir const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
130cdf0e10cSrcweir sal_Bool bCtrl = pKeyEvent->GetKeyCode().IsMod1();
131cdf0e10cSrcweir sal_Bool bAlt = pKeyEvent->GetKeyCode().IsMod2();
132cdf0e10cSrcweir sal_Bool bShift = pKeyEvent->GetKeyCode().IsShift();
133cdf0e10cSrcweir sal_uInt16 nCode = pKeyEvent->GetKeyCode().GetCode();
134cdf0e10cSrcweir
135cdf0e10cSrcweir if ( (bCtrl && bAlt && KEY_F == nCode) || KEY_ESCAPE == nCode )
136cdf0e10cSrcweir {
137cdf0e10cSrcweir nRet = 1;
138cdf0e10cSrcweir GrabFocusToDocument();
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
141cdf0e10cSrcweir if ( KEY_RETURN == nCode )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir Remember_Impl(GetText());
144cdf0e10cSrcweir
145cdf0e10cSrcweir ::rtl::OUString sFindText = GetText();
146cdf0e10cSrcweir css::uno::Sequence< css::beans::PropertyValue > lArgs(2);
147cdf0e10cSrcweir
148cdf0e10cSrcweir lArgs[0].Name = SEARCHITEM_SEARCHSTRING;
149cdf0e10cSrcweir lArgs[0].Value <<= sFindText;
150cdf0e10cSrcweir
151cdf0e10cSrcweir lArgs[1].Name = SEARCHITEM_SEARCHBACKWARD;
152cdf0e10cSrcweir if (bShift)
153cdf0e10cSrcweir lArgs[1].Value <<= sal_True;
154cdf0e10cSrcweir else
155cdf0e10cSrcweir lArgs[1].Value <<= sal_False;
156cdf0e10cSrcweir
157cdf0e10cSrcweir impl_executeSearch(m_xServiceManager, m_xFrame, lArgs);
158cdf0e10cSrcweir nRet = 1;
159cdf0e10cSrcweir }
160cdf0e10cSrcweir break;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir case EVENT_GETFOCUS:
164cdf0e10cSrcweir if ( m_bToClearTextField )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir SetText( String() );
167cdf0e10cSrcweir m_bToClearTextField = sal_False;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
170cdf0e10cSrcweir break;
171cdf0e10cSrcweir
172cdf0e10cSrcweir case EVENT_LOSEFOCUS:
173cdf0e10cSrcweir if ( GetText().Len() == 0 )
174cdf0e10cSrcweir {
175cdf0e10cSrcweir SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_FIND ) );
176cdf0e10cSrcweir SetControlForeground(GetSettings().GetStyleSettings().GetDisableColor());
177cdf0e10cSrcweir m_bToClearTextField = sal_True;
178cdf0e10cSrcweir }
179cdf0e10cSrcweir break;
180cdf0e10cSrcweir }
181cdf0e10cSrcweir
182cdf0e10cSrcweir return nRet;
183cdf0e10cSrcweir }
184cdf0e10cSrcweir
185cdf0e10cSrcweir
186cdf0e10cSrcweir //-----------------------------------------------------------------------------------------------------------
187cdf0e10cSrcweir // SearchToolbarControllersManager
188cdf0e10cSrcweir
189cdf0e10cSrcweir SearchToolbarControllersManager* SearchToolbarControllersManager::m_pInstance = 0;
190cdf0e10cSrcweir
SearchToolbarControllersManager()191cdf0e10cSrcweir SearchToolbarControllersManager::SearchToolbarControllersManager()
192cdf0e10cSrcweir {
193cdf0e10cSrcweir }
194cdf0e10cSrcweir
~SearchToolbarControllersManager()195cdf0e10cSrcweir SearchToolbarControllersManager::~SearchToolbarControllersManager()
196cdf0e10cSrcweir {
197cdf0e10cSrcweir }
198cdf0e10cSrcweir
createControllersManager()199cdf0e10cSrcweir SearchToolbarControllersManager* SearchToolbarControllersManager::createControllersManager()
200cdf0e10cSrcweir {
201cdf0e10cSrcweir if (!m_pInstance)
202cdf0e10cSrcweir m_pInstance = new SearchToolbarControllersManager();
203cdf0e10cSrcweir
204cdf0e10cSrcweir return m_pInstance;
205cdf0e10cSrcweir }
206cdf0e10cSrcweir
registryController(const css::uno::Reference<css::frame::XFrame> & xFrame,const css::uno::Reference<css::frame::XStatusListener> & xStatusListener,const::rtl::OUString & sCommandURL)207cdf0e10cSrcweir void SearchToolbarControllersManager::registryController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL )
208cdf0e10cSrcweir {
209cdf0e10cSrcweir SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame);
210cdf0e10cSrcweir if (pIt == aSearchToolbarControllersMap.end())
211cdf0e10cSrcweir {
212cdf0e10cSrcweir SearchToolbarControllersVec lControllers(1);
213cdf0e10cSrcweir lControllers[0].Name = sCommandURL;
214cdf0e10cSrcweir lControllers[0].Value <<= xStatusListener;
215cdf0e10cSrcweir aSearchToolbarControllersMap.insert(SearchToolbarControllersMap::value_type(xFrame, lControllers));
216cdf0e10cSrcweir }
217cdf0e10cSrcweir else
218cdf0e10cSrcweir {
219cdf0e10cSrcweir sal_Int32 nSize = pIt->second.size();
220cdf0e10cSrcweir for (sal_Int32 i=0; i<nSize; ++i)
221cdf0e10cSrcweir {
222cdf0e10cSrcweir if (pIt->second[i].Name.equals(sCommandURL))
223cdf0e10cSrcweir return;
224cdf0e10cSrcweir }
225cdf0e10cSrcweir
226cdf0e10cSrcweir pIt->second.resize(nSize+1);
227cdf0e10cSrcweir pIt->second[nSize].Name = sCommandURL;
228cdf0e10cSrcweir pIt->second[nSize].Value <<= xStatusListener;
229cdf0e10cSrcweir }
230cdf0e10cSrcweir }
231cdf0e10cSrcweir
freeController(const css::uno::Reference<css::frame::XFrame> & xFrame,const css::uno::Reference<css::frame::XStatusListener> &,const::rtl::OUString & sCommandURL)232cdf0e10cSrcweir void SearchToolbarControllersManager::freeController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& /*xStatusListener*/, const ::rtl::OUString& sCommandURL )
233cdf0e10cSrcweir {
234cdf0e10cSrcweir SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame);
235cdf0e10cSrcweir if (pIt != aSearchToolbarControllersMap.end())
236cdf0e10cSrcweir {
237cdf0e10cSrcweir for (SearchToolbarControllersVec::iterator pItCtrl=pIt->second.begin(); pItCtrl!=pIt->second.end(); ++pItCtrl)
238cdf0e10cSrcweir {
239cdf0e10cSrcweir if (pItCtrl->Name.equals(sCommandURL))
240cdf0e10cSrcweir {
241cdf0e10cSrcweir pIt->second.erase(pItCtrl);
242cdf0e10cSrcweir break;
243cdf0e10cSrcweir }
244cdf0e10cSrcweir }
245cdf0e10cSrcweir
246cdf0e10cSrcweir if (pIt->second.empty())
247cdf0e10cSrcweir aSearchToolbarControllersMap.erase(pIt);
248cdf0e10cSrcweir }
249cdf0e10cSrcweir }
250cdf0e10cSrcweir
findController(const css::uno::Reference<css::frame::XFrame> & xFrame,const::rtl::OUString & sCommandURL)251cdf0e10cSrcweir css::uno::Reference< css::frame::XStatusListener > SearchToolbarControllersManager::findController( const css::uno::Reference< css::frame::XFrame >& xFrame, const ::rtl::OUString& sCommandURL )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir css::uno::Reference< css::frame::XStatusListener > xStatusListener;
254cdf0e10cSrcweir
255cdf0e10cSrcweir SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame);
256cdf0e10cSrcweir if (pIt != aSearchToolbarControllersMap.end())
257cdf0e10cSrcweir {
258cdf0e10cSrcweir for (SearchToolbarControllersVec::iterator pItCtrl =pIt->second.begin(); pItCtrl != pIt->second.end(); ++pItCtrl)
259cdf0e10cSrcweir {
260cdf0e10cSrcweir if (pItCtrl->Name.equals(sCommandURL))
261cdf0e10cSrcweir {
262cdf0e10cSrcweir pItCtrl->Value >>= xStatusListener;
263cdf0e10cSrcweir break;
264cdf0e10cSrcweir }
265cdf0e10cSrcweir }
266cdf0e10cSrcweir }
267cdf0e10cSrcweir
268cdf0e10cSrcweir return xStatusListener;
269cdf0e10cSrcweir }
270cdf0e10cSrcweir
271cdf0e10cSrcweir //-----------------------------------------------------------------------------------------------------------
272cdf0e10cSrcweir // FindTextToolbarController
273cdf0e10cSrcweir
FindTextToolbarController(const css::uno::Reference<css::lang::XMultiServiceFactory> & rServiceManager)274cdf0e10cSrcweir FindTextToolbarController::FindTextToolbarController( const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager )
275cdf0e10cSrcweir :svt::ToolboxController( rServiceManager,
276cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame >(),
277cdf0e10cSrcweir COMMAND_FINDTEXT )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir }
280cdf0e10cSrcweir
~FindTextToolbarController()281cdf0e10cSrcweir FindTextToolbarController::~FindTextToolbarController()
282cdf0e10cSrcweir {
283cdf0e10cSrcweir }
284cdf0e10cSrcweir
285cdf0e10cSrcweir // XInterface
queryInterface(const css::uno::Type & aType)286cdf0e10cSrcweir css::uno::Any SAL_CALL FindTextToolbarController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException )
287cdf0e10cSrcweir {
288cdf0e10cSrcweir css::uno::Any a = ToolboxController::queryInterface( aType );
289cdf0e10cSrcweir if ( a.hasValue() )
290cdf0e10cSrcweir return a;
291cdf0e10cSrcweir
292cdf0e10cSrcweir return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) );
293cdf0e10cSrcweir }
294cdf0e10cSrcweir
acquire()295cdf0e10cSrcweir void SAL_CALL FindTextToolbarController::acquire() throw ()
296cdf0e10cSrcweir {
297cdf0e10cSrcweir ToolboxController::acquire();
298cdf0e10cSrcweir }
299cdf0e10cSrcweir
release()300cdf0e10cSrcweir void SAL_CALL FindTextToolbarController::release() throw ()
301cdf0e10cSrcweir {
302cdf0e10cSrcweir ToolboxController::release();
303cdf0e10cSrcweir }
304cdf0e10cSrcweir
305cdf0e10cSrcweir // XServiceInfo
getImplementationName()306cdf0e10cSrcweir ::rtl::OUString SAL_CALL FindTextToolbarController::getImplementationName() throw( css::uno::RuntimeException )
307cdf0e10cSrcweir {
308cdf0e10cSrcweir return getImplementationName_Static();
309cdf0e10cSrcweir }
310cdf0e10cSrcweir
supportsService(const::rtl::OUString & ServiceName)311cdf0e10cSrcweir sal_Bool SAL_CALL FindTextToolbarController::supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir const css::uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() );
314cdf0e10cSrcweir const ::rtl::OUString * pArray = aSNL.getConstArray();
315cdf0e10cSrcweir
316cdf0e10cSrcweir for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
317cdf0e10cSrcweir if( pArray[i] == ServiceName )
318cdf0e10cSrcweir return true;
319cdf0e10cSrcweir
320cdf0e10cSrcweir return false;
321cdf0e10cSrcweir }
322cdf0e10cSrcweir
getSupportedServiceNames()323cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > SAL_CALL FindTextToolbarController::getSupportedServiceNames() throw( css::uno::RuntimeException )
324cdf0e10cSrcweir {
325cdf0e10cSrcweir return getSupportedServiceNames_Static();
326cdf0e10cSrcweir }
327cdf0e10cSrcweir
getSupportedServiceNames_Static()328cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > FindTextToolbarController::getSupportedServiceNames_Static() throw()
329cdf0e10cSrcweir {
330cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > aSNS( 1 );
331cdf0e10cSrcweir aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ) );
332cdf0e10cSrcweir return aSNS;
333cdf0e10cSrcweir }
334cdf0e10cSrcweir
335cdf0e10cSrcweir // XComponent
dispose()336cdf0e10cSrcweir void SAL_CALL FindTextToolbarController::dispose() throw ( css::uno::RuntimeException )
337cdf0e10cSrcweir {
338cdf0e10cSrcweir vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
339cdf0e10cSrcweir
340cdf0e10cSrcweir SearchToolbarControllersManager::createControllersManager()->freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
341cdf0e10cSrcweir
342cdf0e10cSrcweir svt::ToolboxController::dispose();
343cdf0e10cSrcweir delete m_pFindTextFieldControl;
344cdf0e10cSrcweir m_pFindTextFieldControl = 0;
345cdf0e10cSrcweir }
346cdf0e10cSrcweir
347cdf0e10cSrcweir // XInitialization
initialize(const css::uno::Sequence<::com::sun::star::uno::Any> & aArguments)348cdf0e10cSrcweir void SAL_CALL FindTextToolbarController::initialize( const css::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException)
349cdf0e10cSrcweir {
350cdf0e10cSrcweir svt::ToolboxController::initialize(aArguments);
351cdf0e10cSrcweir
352cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( getParent() );
353cdf0e10cSrcweir ToolBox* pToolBox = (ToolBox*)pWindow;
354cdf0e10cSrcweir if ( pToolBox )
355cdf0e10cSrcweir {
356cdf0e10cSrcweir sal_uInt16 nItemCount = pToolBox->GetItemCount();
357cdf0e10cSrcweir for ( sal_uInt16 i=0; i<nItemCount; ++i )
358cdf0e10cSrcweir {
359cdf0e10cSrcweir ::rtl::OUString sItemCommand = pToolBox->GetItemCommand(i);
360cdf0e10cSrcweir if ( sItemCommand.equals( COMMAND_DOWNSEARCH ) )
361*843af519Smseidel {
362*843af519Smseidel pToolBox->EnableItem(i, sal_False);
363cdf0e10cSrcweir m_nDownSearchId = i;
364*843af519Smseidel }
365cdf0e10cSrcweir else if (sItemCommand.equals( COMMAND_UPSEARCH ))
366*843af519Smseidel {
367*843af519Smseidel pToolBox->EnableItem(i, sal_False);
368cdf0e10cSrcweir m_nUpSearchId = i;
369cdf0e10cSrcweir }
370cdf0e10cSrcweir }
371*843af519Smseidel }
372cdf0e10cSrcweir
373cdf0e10cSrcweir SearchToolbarControllersManager::createControllersManager()->registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
374cdf0e10cSrcweir }
375cdf0e10cSrcweir
376cdf0e10cSrcweir // XToolbarController
execute(sal_Int16)377cdf0e10cSrcweir void SAL_CALL FindTextToolbarController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException )
378cdf0e10cSrcweir {
379cdf0e10cSrcweir }
380cdf0e10cSrcweir
createItemWindow(const css::uno::Reference<css::awt::XWindow> & Parent)381cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > SAL_CALL FindTextToolbarController::createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException )
382cdf0e10cSrcweir {
383cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > xItemWindow;
384cdf0e10cSrcweir
385cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > xParent( Parent );
386cdf0e10cSrcweir Window* pParent = VCLUnoHelper::GetWindow( xParent );
387cdf0e10cSrcweir if ( pParent )
388cdf0e10cSrcweir {
389cdf0e10cSrcweir ToolBox* pToolbar = ( ToolBox* )pParent;
390cdf0e10cSrcweir m_pFindTextFieldControl = new FindTextFieldControl( pToolbar, WinBits( WB_DROPDOWN | WB_VSCROLL), m_xFrame, m_xServiceManager );
391cdf0e10cSrcweir
392cdf0e10cSrcweir Size aSize(100, m_pFindTextFieldControl->GetTextHeight() + 200);
393cdf0e10cSrcweir m_pFindTextFieldControl->SetSizePixel( aSize );
394cdf0e10cSrcweir m_pFindTextFieldControl->SetModifyHdl(LINK(this, FindTextToolbarController, EditModifyHdl));
395cdf0e10cSrcweir }
396cdf0e10cSrcweir xItemWindow = VCLUnoHelper::GetInterface( m_pFindTextFieldControl );
397cdf0e10cSrcweir
398cdf0e10cSrcweir return xItemWindow;
399cdf0e10cSrcweir }
400cdf0e10cSrcweir
401cdf0e10cSrcweir // XStatusListener
statusChanged(const css::frame::FeatureStateEvent & rEvent)402cdf0e10cSrcweir void SAL_CALL FindTextToolbarController::statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException )
403cdf0e10cSrcweir {
404cdf0e10cSrcweir vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
405cdf0e10cSrcweir if ( m_bDisposed )
406cdf0e10cSrcweir return;
407cdf0e10cSrcweir
408cdf0e10cSrcweir ::rtl::OUString aFeatureURL = rEvent.FeatureURL.Complete;
409cdf0e10cSrcweir if (aFeatureURL.equalsAscii("AppendSearchHistory"))
410cdf0e10cSrcweir {
411cdf0e10cSrcweir m_pFindTextFieldControl->Remember_Impl(m_pFindTextFieldControl->GetText());
412cdf0e10cSrcweir }
413cdf0e10cSrcweir }
414cdf0e10cSrcweir
IMPL_LINK(FindTextToolbarController,EditModifyHdl,void *,EMPTYARG)415cdf0e10cSrcweir IMPL_LINK( FindTextToolbarController, EditModifyHdl, void *, EMPTYARG )
416cdf0e10cSrcweir {
417cdf0e10cSrcweir // enable or disable item DownSearch/UpSearch of findbar
418cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( getParent() );
419cdf0e10cSrcweir ToolBox* pToolBox = (ToolBox*)pWindow;
420cdf0e10cSrcweir if ( pToolBox && m_pFindTextFieldControl )
421cdf0e10cSrcweir {
422cdf0e10cSrcweir if (m_pFindTextFieldControl->GetText().Len()>0)
423cdf0e10cSrcweir {
424cdf0e10cSrcweir if ( !pToolBox->IsItemEnabled(m_nDownSearchId) )
425cdf0e10cSrcweir pToolBox->EnableItem(m_nDownSearchId, sal_True);
426cdf0e10cSrcweir if ( !pToolBox->IsItemEnabled(m_nUpSearchId) )
427cdf0e10cSrcweir pToolBox->EnableItem(m_nUpSearchId, sal_True);
428cdf0e10cSrcweir }
429cdf0e10cSrcweir else
430cdf0e10cSrcweir {
431cdf0e10cSrcweir if ( pToolBox->IsItemEnabled(m_nDownSearchId) )
432cdf0e10cSrcweir pToolBox->EnableItem(m_nDownSearchId, sal_False);
433cdf0e10cSrcweir if ( pToolBox->IsItemEnabled(m_nUpSearchId) )
434cdf0e10cSrcweir pToolBox->EnableItem(m_nUpSearchId, sal_False);
435cdf0e10cSrcweir }
436cdf0e10cSrcweir }
437cdf0e10cSrcweir
438cdf0e10cSrcweir return 0;
439cdf0e10cSrcweir }
440cdf0e10cSrcweir
441cdf0e10cSrcweir //-----------------------------------------------------------------------------------------------------------
442cdf0e10cSrcweir // class DownSearchToolboxController
443cdf0e10cSrcweir
DownSearchToolboxController(const css::uno::Reference<css::lang::XMultiServiceFactory> & rServiceManager)444cdf0e10cSrcweir DownSearchToolboxController::DownSearchToolboxController(const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager )
445cdf0e10cSrcweir : svt::ToolboxController( rServiceManager,
446cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame >(),
447cdf0e10cSrcweir COMMAND_DOWNSEARCH )
448cdf0e10cSrcweir {
449cdf0e10cSrcweir }
450cdf0e10cSrcweir
~DownSearchToolboxController()451cdf0e10cSrcweir DownSearchToolboxController::~DownSearchToolboxController()
452cdf0e10cSrcweir {
453cdf0e10cSrcweir }
454cdf0e10cSrcweir
455cdf0e10cSrcweir // XInterface
queryInterface(const css::uno::Type & aType)456cdf0e10cSrcweir css::uno::Any SAL_CALL DownSearchToolboxController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir css::uno::Any a = ToolboxController::queryInterface( aType );
459cdf0e10cSrcweir if ( a.hasValue() )
460cdf0e10cSrcweir return a;
461cdf0e10cSrcweir
462cdf0e10cSrcweir return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) );
463cdf0e10cSrcweir }
464cdf0e10cSrcweir
acquire()465cdf0e10cSrcweir void SAL_CALL DownSearchToolboxController::acquire() throw ()
466cdf0e10cSrcweir {
467cdf0e10cSrcweir ToolboxController::acquire();
468cdf0e10cSrcweir }
469cdf0e10cSrcweir
release()470cdf0e10cSrcweir void SAL_CALL DownSearchToolboxController::release() throw ()
471cdf0e10cSrcweir {
472cdf0e10cSrcweir ToolboxController::release();
473cdf0e10cSrcweir }
474cdf0e10cSrcweir
475cdf0e10cSrcweir // XServiceInfo
getImplementationName()476cdf0e10cSrcweir ::rtl::OUString SAL_CALL DownSearchToolboxController::getImplementationName() throw( css::uno::RuntimeException )
477cdf0e10cSrcweir {
478cdf0e10cSrcweir return getImplementationName_Static();
479cdf0e10cSrcweir }
480cdf0e10cSrcweir
supportsService(const::rtl::OUString & ServiceName)481cdf0e10cSrcweir sal_Bool SAL_CALL DownSearchToolboxController::supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException )
482cdf0e10cSrcweir {
483cdf0e10cSrcweir const css::uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() );
484cdf0e10cSrcweir const ::rtl::OUString * pArray = aSNL.getConstArray();
485cdf0e10cSrcweir
486cdf0e10cSrcweir for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
487cdf0e10cSrcweir if( pArray[i] == ServiceName )
488cdf0e10cSrcweir return true;
489cdf0e10cSrcweir
490cdf0e10cSrcweir return false;
491cdf0e10cSrcweir }
492cdf0e10cSrcweir
getSupportedServiceNames()493cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > SAL_CALL DownSearchToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException )
494cdf0e10cSrcweir {
495cdf0e10cSrcweir return getSupportedServiceNames_Static();
496cdf0e10cSrcweir }
497cdf0e10cSrcweir
getSupportedServiceNames_Static()498cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > DownSearchToolboxController::getSupportedServiceNames_Static() throw()
499cdf0e10cSrcweir {
500cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > aSNS( 1 );
501cdf0e10cSrcweir aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
502cdf0e10cSrcweir return aSNS;
503cdf0e10cSrcweir }
504cdf0e10cSrcweir
505cdf0e10cSrcweir // XComponent
dispose()506cdf0e10cSrcweir void SAL_CALL DownSearchToolboxController::dispose() throw ( css::uno::RuntimeException )
507cdf0e10cSrcweir {
508cdf0e10cSrcweir vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
509cdf0e10cSrcweir
510cdf0e10cSrcweir SearchToolbarControllersManager::createControllersManager()->freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
511cdf0e10cSrcweir
512cdf0e10cSrcweir svt::ToolboxController::dispose();
513cdf0e10cSrcweir }
514cdf0e10cSrcweir
515cdf0e10cSrcweir // XInitialization
initialize(const css::uno::Sequence<css::uno::Any> & aArguments)516cdf0e10cSrcweir void SAL_CALL DownSearchToolboxController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException )
517cdf0e10cSrcweir {
518cdf0e10cSrcweir svt::ToolboxController::initialize( aArguments );
519cdf0e10cSrcweir SearchToolbarControllersManager::createControllersManager()->registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
520cdf0e10cSrcweir }
521cdf0e10cSrcweir
522cdf0e10cSrcweir // XToolbarController
execute(sal_Int16)523cdf0e10cSrcweir void SAL_CALL DownSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException)
524cdf0e10cSrcweir {
525cdf0e10cSrcweir if ( m_bDisposed )
526cdf0e10cSrcweir throw css::lang::DisposedException();
527cdf0e10cSrcweir
528cdf0e10cSrcweir ::rtl::OUString sFindText;
529cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( getParent() );
530cdf0e10cSrcweir ToolBox* pToolBox = (ToolBox*)pWindow;
531cdf0e10cSrcweir if ( pToolBox )
532cdf0e10cSrcweir {
533cdf0e10cSrcweir sal_uInt16 nItemCount = pToolBox->GetItemCount();
534cdf0e10cSrcweir for ( sal_uInt16 i=0; i<nItemCount; ++i )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir ::rtl::OUString sItemCommand = pToolBox->GetItemCommand(i);
537cdf0e10cSrcweir if ( sItemCommand.equals( COMMAND_FINDTEXT ) )
538cdf0e10cSrcweir {
539cdf0e10cSrcweir Window* pItemWin = pToolBox->GetItemWindow(i);
540cdf0e10cSrcweir if (pItemWin)
541cdf0e10cSrcweir sFindText = pItemWin->GetText();
542cdf0e10cSrcweir break;
543cdf0e10cSrcweir }
544cdf0e10cSrcweir }
545cdf0e10cSrcweir }
546cdf0e10cSrcweir
547cdf0e10cSrcweir css::uno::Sequence< css::beans::PropertyValue > lArgs(2);
548cdf0e10cSrcweir lArgs[0].Name = SEARCHITEM_SEARCHSTRING;
549cdf0e10cSrcweir lArgs[0].Value <<= sFindText;
550cdf0e10cSrcweir lArgs[1].Name = SEARCHITEM_SEARCHBACKWARD;
551cdf0e10cSrcweir lArgs[1].Value <<= sal_False;
552cdf0e10cSrcweir
553cdf0e10cSrcweir impl_executeSearch(m_xServiceManager, m_xFrame, lArgs);
554cdf0e10cSrcweir
555cdf0e10cSrcweir css::frame::FeatureStateEvent aEvent;
556cdf0e10cSrcweir aEvent.FeatureURL.Complete = COMMAND_APPENDSEARCHHISTORY;
557cdf0e10cSrcweir css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager()->findController(m_xFrame, COMMAND_FINDTEXT);
558cdf0e10cSrcweir if (xStatusListener.is())
559cdf0e10cSrcweir xStatusListener->statusChanged( aEvent );
560cdf0e10cSrcweir }
561cdf0e10cSrcweir
562cdf0e10cSrcweir // XStatusListener
statusChanged(const css::frame::FeatureStateEvent &)563cdf0e10cSrcweir void SAL_CALL DownSearchToolboxController::statusChanged( const css::frame::FeatureStateEvent& /*rEvent*/ ) throw ( css::uno::RuntimeException )
564cdf0e10cSrcweir {
565cdf0e10cSrcweir vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
566cdf0e10cSrcweir if ( m_bDisposed )
567cdf0e10cSrcweir return;
568cdf0e10cSrcweir }
569cdf0e10cSrcweir
570cdf0e10cSrcweir //-----------------------------------------------------------------------------------------------------------
571cdf0e10cSrcweir // class UpSearchToolboxController
572cdf0e10cSrcweir
UpSearchToolboxController(const css::uno::Reference<css::lang::XMultiServiceFactory> & rServiceManager)573cdf0e10cSrcweir UpSearchToolboxController::UpSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager )
574cdf0e10cSrcweir :svt::ToolboxController( rServiceManager,
575cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame >(),
576cdf0e10cSrcweir COMMAND_UPSEARCH )
577cdf0e10cSrcweir {
578cdf0e10cSrcweir }
579cdf0e10cSrcweir
~UpSearchToolboxController()580cdf0e10cSrcweir UpSearchToolboxController::~UpSearchToolboxController()
581cdf0e10cSrcweir {
582cdf0e10cSrcweir }
583cdf0e10cSrcweir
584cdf0e10cSrcweir // XInterface
queryInterface(const css::uno::Type & aType)585cdf0e10cSrcweir css::uno::Any SAL_CALL UpSearchToolboxController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException )
586cdf0e10cSrcweir {
587cdf0e10cSrcweir css::uno::Any a = ToolboxController::queryInterface( aType );
588cdf0e10cSrcweir if ( a.hasValue() )
589cdf0e10cSrcweir return a;
590cdf0e10cSrcweir
591cdf0e10cSrcweir return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) );
592cdf0e10cSrcweir }
593cdf0e10cSrcweir
acquire()594cdf0e10cSrcweir void SAL_CALL UpSearchToolboxController::acquire() throw ()
595cdf0e10cSrcweir {
596cdf0e10cSrcweir ToolboxController::acquire();
597cdf0e10cSrcweir }
598cdf0e10cSrcweir
release()599cdf0e10cSrcweir void SAL_CALL UpSearchToolboxController::release() throw ()
600cdf0e10cSrcweir {
601cdf0e10cSrcweir ToolboxController::release();
602cdf0e10cSrcweir }
603cdf0e10cSrcweir
604cdf0e10cSrcweir // XServiceInfo
getImplementationName()605cdf0e10cSrcweir ::rtl::OUString SAL_CALL UpSearchToolboxController::getImplementationName() throw( css::uno::RuntimeException )
606cdf0e10cSrcweir {
607cdf0e10cSrcweir return getImplementationName_Static();
608cdf0e10cSrcweir }
609cdf0e10cSrcweir
supportsService(const::rtl::OUString & ServiceName)610cdf0e10cSrcweir sal_Bool SAL_CALL UpSearchToolboxController::supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException )
611cdf0e10cSrcweir {
612cdf0e10cSrcweir const css::uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() );
613cdf0e10cSrcweir const ::rtl::OUString * pArray = aSNL.getConstArray();
614cdf0e10cSrcweir
615cdf0e10cSrcweir for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
616cdf0e10cSrcweir if( pArray[i] == ServiceName )
617cdf0e10cSrcweir return true;
618cdf0e10cSrcweir
619cdf0e10cSrcweir return false;
620cdf0e10cSrcweir }
621cdf0e10cSrcweir
getSupportedServiceNames()622cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > SAL_CALL UpSearchToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException )
623cdf0e10cSrcweir {
624cdf0e10cSrcweir return getSupportedServiceNames_Static();
625cdf0e10cSrcweir }
626cdf0e10cSrcweir
getSupportedServiceNames_Static()627cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > UpSearchToolboxController::getSupportedServiceNames_Static() throw()
628cdf0e10cSrcweir {
629cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > aSNS( 1 );
630cdf0e10cSrcweir aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ) );
631cdf0e10cSrcweir return aSNS;
632cdf0e10cSrcweir }
633cdf0e10cSrcweir
634cdf0e10cSrcweir // XComponent
dispose()635cdf0e10cSrcweir void SAL_CALL UpSearchToolboxController::dispose() throw ( css::uno::RuntimeException )
636cdf0e10cSrcweir {
637cdf0e10cSrcweir vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
638cdf0e10cSrcweir
639cdf0e10cSrcweir SearchToolbarControllersManager::createControllersManager()->freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
640cdf0e10cSrcweir
641cdf0e10cSrcweir svt::ToolboxController::dispose();
642cdf0e10cSrcweir }
643cdf0e10cSrcweir
644cdf0e10cSrcweir // XInitialization
initialize(const css::uno::Sequence<css::uno::Any> & aArguments)645cdf0e10cSrcweir void SAL_CALL UpSearchToolboxController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException )
646cdf0e10cSrcweir {
647cdf0e10cSrcweir svt::ToolboxController::initialize( aArguments );
648cdf0e10cSrcweir SearchToolbarControllersManager::createControllersManager()->registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
649cdf0e10cSrcweir }
650cdf0e10cSrcweir
651cdf0e10cSrcweir // XToolbarController
execute(sal_Int16)652cdf0e10cSrcweir void SAL_CALL UpSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException )
653cdf0e10cSrcweir {
654cdf0e10cSrcweir if ( m_bDisposed )
655cdf0e10cSrcweir throw css::lang::DisposedException();
656cdf0e10cSrcweir
657cdf0e10cSrcweir ::rtl::OUString sFindText;
658cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( getParent() );
659cdf0e10cSrcweir ToolBox* pToolBox = (ToolBox*)pWindow;
660cdf0e10cSrcweir if ( pToolBox )
661cdf0e10cSrcweir {
662cdf0e10cSrcweir sal_uInt16 nItemCount = pToolBox->GetItemCount();
663cdf0e10cSrcweir for ( sal_uInt16 i=0; i<nItemCount; ++i )
664cdf0e10cSrcweir {
665cdf0e10cSrcweir ::rtl::OUString sItemCommand = pToolBox->GetItemCommand(i);
666cdf0e10cSrcweir if ( sItemCommand.equals( COMMAND_FINDTEXT ) )
667cdf0e10cSrcweir {
668cdf0e10cSrcweir Window* pItemWin = pToolBox->GetItemWindow(i);
669cdf0e10cSrcweir if (pItemWin)
670cdf0e10cSrcweir sFindText = pItemWin->GetText();
671cdf0e10cSrcweir break;
672cdf0e10cSrcweir }
673cdf0e10cSrcweir }
674cdf0e10cSrcweir }
675cdf0e10cSrcweir
676cdf0e10cSrcweir css::uno::Sequence< css::beans::PropertyValue > lArgs(2);
677cdf0e10cSrcweir lArgs[0].Name = SEARCHITEM_SEARCHSTRING;
678cdf0e10cSrcweir lArgs[0].Value <<= sFindText;
679cdf0e10cSrcweir lArgs[1].Name = SEARCHITEM_SEARCHBACKWARD;
680cdf0e10cSrcweir lArgs[1].Value <<= sal_True;
681cdf0e10cSrcweir
682cdf0e10cSrcweir impl_executeSearch(m_xServiceManager, m_xFrame, lArgs);
683cdf0e10cSrcweir
684cdf0e10cSrcweir css::frame::FeatureStateEvent aEvent;
685cdf0e10cSrcweir aEvent.FeatureURL.Complete = COMMAND_APPENDSEARCHHISTORY;
686cdf0e10cSrcweir css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager()->findController(m_xFrame, COMMAND_FINDTEXT);
687cdf0e10cSrcweir if (xStatusListener.is())
688cdf0e10cSrcweir xStatusListener->statusChanged( aEvent );
689cdf0e10cSrcweir }
690cdf0e10cSrcweir
691cdf0e10cSrcweir // XStatusListener
statusChanged(const css::frame::FeatureStateEvent &)692cdf0e10cSrcweir void SAL_CALL UpSearchToolboxController::statusChanged( const css::frame::FeatureStateEvent& /*rEvent*/ ) throw ( css::uno::RuntimeException )
693cdf0e10cSrcweir {
694cdf0e10cSrcweir vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
695cdf0e10cSrcweir if ( m_bDisposed )
696cdf0e10cSrcweir return;
697cdf0e10cSrcweir }
698cdf0e10cSrcweir
699cdf0e10cSrcweir //-----------------------------------------------------------------------------------------------------------
700cdf0e10cSrcweir // class FindbarDispatcher
701cdf0e10cSrcweir
FindbarDispatcher(const css::uno::Reference<css::lang::XMultiServiceFactory> & xFactory)702cdf0e10cSrcweir FindbarDispatcher::FindbarDispatcher(const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory)
703cdf0e10cSrcweir : m_xFactory( xFactory )
704cdf0e10cSrcweir {
705cdf0e10cSrcweir }
706cdf0e10cSrcweir
~FindbarDispatcher()707cdf0e10cSrcweir FindbarDispatcher::~FindbarDispatcher()
708cdf0e10cSrcweir {
709cdf0e10cSrcweir m_xFactory = NULL;
710cdf0e10cSrcweir m_xFrame = NULL;
711cdf0e10cSrcweir }
712cdf0e10cSrcweir
713cdf0e10cSrcweir // XInterface
queryInterface(const css::uno::Type & aType)714cdf0e10cSrcweir css::uno::Any SAL_CALL FindbarDispatcher::queryInterface( const css::uno::Type& aType ) throw( css::uno::RuntimeException )
715cdf0e10cSrcweir {
716cdf0e10cSrcweir css::uno::Any aReturn( ::cppu::queryInterface( aType,
717cdf0e10cSrcweir static_cast< css::lang::XServiceInfo* >(this),
718cdf0e10cSrcweir static_cast< css::lang::XInitialization* >(this),
719cdf0e10cSrcweir static_cast< css::frame::XDispatchProvider* >(this),
720cdf0e10cSrcweir static_cast< css::frame::XDispatch* >(this)) );
721cdf0e10cSrcweir
722cdf0e10cSrcweir if ( aReturn.hasValue() )
723cdf0e10cSrcweir return aReturn;
724cdf0e10cSrcweir
725cdf0e10cSrcweir return OWeakObject::queryInterface( aType );
726cdf0e10cSrcweir }
727cdf0e10cSrcweir
acquire()728cdf0e10cSrcweir void SAL_CALL FindbarDispatcher::acquire() throw()
729cdf0e10cSrcweir {
730cdf0e10cSrcweir OWeakObject::acquire();
731cdf0e10cSrcweir }
732cdf0e10cSrcweir
release()733cdf0e10cSrcweir void SAL_CALL FindbarDispatcher::release() throw()
734cdf0e10cSrcweir {
735cdf0e10cSrcweir OWeakObject::release();
736cdf0e10cSrcweir }
737cdf0e10cSrcweir
738cdf0e10cSrcweir // XServiceInfo
getImplementationName()739cdf0e10cSrcweir ::rtl::OUString SAL_CALL FindbarDispatcher::getImplementationName() throw( css::uno::RuntimeException )
740cdf0e10cSrcweir {
741cdf0e10cSrcweir return getImplementationName_Static();
742cdf0e10cSrcweir }
743cdf0e10cSrcweir
supportsService(const::rtl::OUString & ServiceName)744cdf0e10cSrcweir sal_Bool SAL_CALL FindbarDispatcher::supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException )
745cdf0e10cSrcweir {
746cdf0e10cSrcweir return (
747cdf0e10cSrcweir ServiceName.equalsAscii("com.sun.star.comp.svx.FindbarDispatcher") ||
748cdf0e10cSrcweir ServiceName.equalsAscii("com.sun.star.frame.ProtocolHandler")
749cdf0e10cSrcweir );
750cdf0e10cSrcweir }
751cdf0e10cSrcweir
getSupportedServiceNames()752cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > SAL_CALL FindbarDispatcher::getSupportedServiceNames() throw( css::uno::RuntimeException )
753cdf0e10cSrcweir {
754cdf0e10cSrcweir return getSupportedServiceNames_Static();
755cdf0e10cSrcweir }
756cdf0e10cSrcweir
getSupportedServiceNames_Static()757cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > FindbarDispatcher::getSupportedServiceNames_Static() throw()
758cdf0e10cSrcweir {
759cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > aSNS( 2 );
760cdf0e10cSrcweir aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.FindbarDispatcher" ));
761cdf0e10cSrcweir aSNS.getArray()[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ProtocolHandler" ));
762cdf0e10cSrcweir return aSNS;
763cdf0e10cSrcweir }
764cdf0e10cSrcweir
765cdf0e10cSrcweir // XInitialization
initialize(const css::uno::Sequence<css::uno::Any> & aArguments)766cdf0e10cSrcweir void SAL_CALL FindbarDispatcher::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException )
767cdf0e10cSrcweir {
768cdf0e10cSrcweir if ( aArguments.getLength() )
769cdf0e10cSrcweir aArguments[0] >>= m_xFrame;
770cdf0e10cSrcweir }
771cdf0e10cSrcweir
772cdf0e10cSrcweir // XDispatchProvider
queryDispatch(const css::util::URL & aURL,const::rtl::OUString &,sal_Int32)773cdf0e10cSrcweir 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 )
774cdf0e10cSrcweir {
775cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatch > xDispatch;
776cdf0e10cSrcweir
777cdf0e10cSrcweir if ( aURL.Protocol.equalsAscii("vnd.sun.star.findbar:") )
778cdf0e10cSrcweir xDispatch = this;
779cdf0e10cSrcweir
780cdf0e10cSrcweir return xDispatch;
781cdf0e10cSrcweir }
782cdf0e10cSrcweir
queryDispatches(const css::uno::Sequence<css::frame::DispatchDescriptor> & seqDescripts)783cdf0e10cSrcweir 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 )
784cdf0e10cSrcweir {
785cdf0e10cSrcweir sal_Int32 nCount = seqDescripts.getLength();
786cdf0e10cSrcweir css::uno::Sequence < css::uno::Reference < XDispatch > > lDispatcher( nCount );
787cdf0e10cSrcweir
788cdf0e10cSrcweir for( sal_Int32 i=0; i<nCount; ++i )
789cdf0e10cSrcweir lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL, seqDescripts[i].FrameName, seqDescripts[i].SearchFlags );
790cdf0e10cSrcweir
791cdf0e10cSrcweir return lDispatcher;
792cdf0e10cSrcweir }
793cdf0e10cSrcweir
794cdf0e10cSrcweir // XDispatch
dispatch(const css::util::URL & aURL,const css::uno::Sequence<css::beans::PropertyValue> &)795cdf0e10cSrcweir void SAL_CALL FindbarDispatcher::dispatch( const css::util::URL& aURL, const css::uno::Sequence < css::beans::PropertyValue >& /*lArgs*/ ) throw( css::uno::RuntimeException )
796cdf0e10cSrcweir {
797cdf0e10cSrcweir //vnd.sun.star.findbar:FocusToFindbar - set cursor to the FindTextFieldControl of the findbar
798cdf0e10cSrcweir if ( aURL.Path.equalsAscii("FocusToFindbar") )
799cdf0e10cSrcweir {
800cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertySet > xPropSet(m_xFrame, css::uno::UNO_QUERY);
801cdf0e10cSrcweir if(!xPropSet.is())
802cdf0e10cSrcweir return;
803cdf0e10cSrcweir
804cdf0e10cSrcweir css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
805cdf0e10cSrcweir css::uno::Any aValue = xPropSet->getPropertyValue( ::rtl::OUString::createFromAscii("LayoutManager") );
806cdf0e10cSrcweir aValue >>= xLayoutManager;
807cdf0e10cSrcweir if (!xLayoutManager.is())
808cdf0e10cSrcweir return;
809cdf0e10cSrcweir
810cdf0e10cSrcweir const ::rtl::OUString sResourceURL = ::rtl::OUString::createFromAscii("private:resource/toolbar/findbar");
811cdf0e10cSrcweir css::uno::Reference< css::ui::XUIElement > xUIElement = xLayoutManager->getElement(sResourceURL);
812cdf0e10cSrcweir if (!xUIElement.is())
813cdf0e10cSrcweir return;
814cdf0e10cSrcweir
815cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > xWindow(xUIElement->getRealInterface(), css::uno::UNO_QUERY);
816cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
817cdf0e10cSrcweir ToolBox* pToolBox = (ToolBox*)pWindow;
818cdf0e10cSrcweir if ( pToolBox )
819cdf0e10cSrcweir {
820cdf0e10cSrcweir sal_uInt16 nItemCount = pToolBox->GetItemCount();
821cdf0e10cSrcweir for ( sal_uInt16 i=0; i<nItemCount; ++i )
822cdf0e10cSrcweir {
823cdf0e10cSrcweir ::rtl::OUString sItemCommand = pToolBox->GetItemCommand(i);
824cdf0e10cSrcweir if ( sItemCommand.equalsAscii(".uno:FindText") )
825cdf0e10cSrcweir {
826cdf0e10cSrcweir Window* pItemWin = pToolBox->GetItemWindow( i );
827cdf0e10cSrcweir if ( pItemWin )
828cdf0e10cSrcweir {
829cdf0e10cSrcweir pItemWin->GrabFocus();
830cdf0e10cSrcweir return;
831cdf0e10cSrcweir }
832cdf0e10cSrcweir }
833cdf0e10cSrcweir }
834cdf0e10cSrcweir }
835cdf0e10cSrcweir
836cdf0e10cSrcweir }
837cdf0e10cSrcweir }
838cdf0e10cSrcweir
addStatusListener(const css::uno::Reference<css::frame::XStatusListener> &,const css::util::URL &)839cdf0e10cSrcweir void SAL_CALL FindbarDispatcher::addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& /*xControl*/, const css::util::URL& /*aURL*/ ) throw ( css::uno::RuntimeException )
840cdf0e10cSrcweir {
841cdf0e10cSrcweir }
842cdf0e10cSrcweir
removeStatusListener(const css::uno::Reference<css::frame::XStatusListener> &,const css::util::URL &)843cdf0e10cSrcweir void SAL_CALL FindbarDispatcher::removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& /*xControl*/, const css::util::URL& /*aURL*/ ) throw ( css::uno::RuntimeException )
844cdf0e10cSrcweir {
845cdf0e10cSrcweir }
846cdf0e10cSrcweir
847cdf0e10cSrcweir //-----------------------------------------------------------------------------------------------------------
848cdf0e10cSrcweir // create Instance
849cdf0e10cSrcweir
FindTextToolbarController_createInstance(const css::uno::Reference<css::lang::XMultiServiceFactory> & rSMgr)850cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > SAL_CALL FindTextToolbarController_createInstance(
851cdf0e10cSrcweir const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr )
852cdf0e10cSrcweir {
853cdf0e10cSrcweir return *new FindTextToolbarController( rSMgr );
854cdf0e10cSrcweir }
855cdf0e10cSrcweir
DownSearchToolboxController_createInstance(const css::uno::Reference<css::lang::XMultiServiceFactory> & rSMgr)856cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > SAL_CALL DownSearchToolboxController_createInstance(
857cdf0e10cSrcweir const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr )
858cdf0e10cSrcweir {
859cdf0e10cSrcweir return *new DownSearchToolboxController( rSMgr );
860cdf0e10cSrcweir }
861cdf0e10cSrcweir
UpSearchToolboxController_createInstance(const css::uno::Reference<css::lang::XMultiServiceFactory> & rSMgr)862cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > SAL_CALL UpSearchToolboxController_createInstance(
863cdf0e10cSrcweir const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr )
864cdf0e10cSrcweir {
865cdf0e10cSrcweir return *new UpSearchToolboxController( rSMgr );
866cdf0e10cSrcweir }
867cdf0e10cSrcweir
FindbarDispatcher_createInstance(const css::uno::Reference<css::lang::XMultiServiceFactory> & rSMgr)868cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > SAL_CALL FindbarDispatcher_createInstance(
869cdf0e10cSrcweir const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr )
870cdf0e10cSrcweir {
871cdf0e10cSrcweir return *new FindbarDispatcher( rSMgr );
872cdf0e10cSrcweir }
873cdf0e10cSrcweir
874cdf0e10cSrcweir //-----------------------------------------------------------------------------------------------------------
875cdf0e10cSrcweir }
876