1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef __TBUNOSEARCHCONTROLLERS_HXX_
29*cdf0e10cSrcweir #define __TBUNOSEARCHCONTROLLERS_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/frame/DispatchDescriptor.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchHelper.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/frame/XStatusListener.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #include <comphelper/sequenceasvector.hxx>
41*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
42*cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
43*cdf0e10cSrcweir #include <svtools/toolboxcontroller.hxx>
44*cdf0e10cSrcweir #include <vcl/combobox.hxx>
45*cdf0e10cSrcweir #include <vcl/window.hxx>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir #include <map>
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir namespace css = ::com::sun::star        ;
50*cdf0e10cSrcweir namespace svx
51*cdf0e10cSrcweir {
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir class FindTextFieldControl : public ComboBox
54*cdf0e10cSrcweir {
55*cdf0e10cSrcweir public:
56*cdf0e10cSrcweir     FindTextFieldControl( Window* pParent, WinBits nStyle,
57*cdf0e10cSrcweir         css::uno::Reference< css::frame::XFrame >& xFrame,
58*cdf0e10cSrcweir         css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
59*cdf0e10cSrcweir     virtual ~FindTextFieldControl();
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir     virtual void Modify();
62*cdf0e10cSrcweir     virtual long PreNotify( NotifyEvent& rNEvt );
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir     void InitControls_Impl();
65*cdf0e10cSrcweir     void Remember_Impl(const String& rStr);
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir private:
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir     css::uno::Reference< css::frame::XFrame > m_xFrame;
70*cdf0e10cSrcweir     css::uno::Reference< css::lang::XMultiServiceFactory > m_xServiceManager;
71*cdf0e10cSrcweir     sal_Bool m_bToClearTextField;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir };
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir class SearchToolbarControllersManager
76*cdf0e10cSrcweir {
77*cdf0e10cSrcweir public:
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir     SearchToolbarControllersManager();
80*cdf0e10cSrcweir     ~SearchToolbarControllersManager();
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir     static SearchToolbarControllersManager* createControllersManager();
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir     void registryController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL );
85*cdf0e10cSrcweir     void freeController ( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL );
86*cdf0e10cSrcweir     css::uno::Reference< css::frame::XStatusListener > findController( const css::uno::Reference< css::frame::XFrame >& xFrame, const ::rtl::OUString& sCommandURL );
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir private:
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir     static SearchToolbarControllersManager* m_pInstance;
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir     typedef ::comphelper::SequenceAsVector< css::beans::PropertyValue > SearchToolbarControllersVec;
93*cdf0e10cSrcweir     typedef ::std::map< css::uno::Reference< css::frame::XFrame >, SearchToolbarControllersVec > SearchToolbarControllersMap;
94*cdf0e10cSrcweir     SearchToolbarControllersMap aSearchToolbarControllersMap;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir };
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir class FindTextToolbarController : public svt::ToolboxController,
99*cdf0e10cSrcweir                                   public css::lang::XServiceInfo
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir public:
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir     FindTextToolbarController( const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager );
104*cdf0e10cSrcweir     ~FindTextToolbarController();
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     // XInterface
107*cdf0e10cSrcweir     virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException );
108*cdf0e10cSrcweir     virtual void SAL_CALL acquire() throw ();
109*cdf0e10cSrcweir     virtual void SAL_CALL release() throw ();
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     // XServiceInfo
112*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
113*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException );
114*cdf0e10cSrcweir     virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir     static ::rtl::OUString getImplementationName_Static() throw()
117*cdf0e10cSrcweir     {
118*cdf0e10cSrcweir         return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.svx.FindTextToolboxController" ));
119*cdf0e10cSrcweir     }
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir     static ::com::sun::star::uno::Sequence< ::rtl::OUString >  getSupportedServiceNames_Static() throw();
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir     // XComponent
124*cdf0e10cSrcweir     virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException );
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir     // XInitialization
127*cdf0e10cSrcweir     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException );
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir     // XToolbarController
130*cdf0e10cSrcweir     virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException);
131*cdf0e10cSrcweir     virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException );
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir     // XStatusListener
134*cdf0e10cSrcweir     virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException );
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir     DECL_LINK(EditModifyHdl, void*);
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir private:
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     FindTextFieldControl* m_pFindTextFieldControl;
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir     sal_uInt16 m_nDownSearchId; // item position of findbar
143*cdf0e10cSrcweir     sal_uInt16 m_nUpSearchId;   // item position of findbar
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir };
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir class DownSearchToolboxController : public svt::ToolboxController,
148*cdf0e10cSrcweir                                     public css::lang::XServiceInfo
149*cdf0e10cSrcweir {
150*cdf0e10cSrcweir public:
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     DownSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager );
153*cdf0e10cSrcweir     ~DownSearchToolboxController();
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir     // XInterface
156*cdf0e10cSrcweir     virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException );
157*cdf0e10cSrcweir     virtual void SAL_CALL acquire() throw ();
158*cdf0e10cSrcweir     virtual void SAL_CALL release() throw ();
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir     // XServiceInfo
161*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
162*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException );
163*cdf0e10cSrcweir     virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir     static ::rtl::OUString getImplementationName_Static() throw()
166*cdf0e10cSrcweir     {
167*cdf0e10cSrcweir         return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.svx.DownSearchToolboxController" ));
168*cdf0e10cSrcweir     }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     static css::uno::Sequence< ::rtl::OUString >  getSupportedServiceNames_Static() throw();
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     // XComponent
173*cdf0e10cSrcweir     virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException );
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir     // XInitialization
176*cdf0e10cSrcweir     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException );
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir     // XToolbarController
179*cdf0e10cSrcweir     virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException);
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir     // XStatusListener
182*cdf0e10cSrcweir     virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException );
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir };
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir class UpSearchToolboxController : public svt::ToolboxController,
187*cdf0e10cSrcweir                                   public css::lang::XServiceInfo
188*cdf0e10cSrcweir {
189*cdf0e10cSrcweir public:
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir     UpSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager );
192*cdf0e10cSrcweir     ~UpSearchToolboxController();
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir     // XInterface
195*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException );
196*cdf0e10cSrcweir     virtual void SAL_CALL acquire() throw ();
197*cdf0e10cSrcweir     virtual void SAL_CALL release() throw ();
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir     // XServiceInfo
200*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
201*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException );
202*cdf0e10cSrcweir     virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir     static ::rtl::OUString getImplementationName_Static() throw()
205*cdf0e10cSrcweir     {
206*cdf0e10cSrcweir         return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.svx.UpSearchToolboxController" ));
207*cdf0e10cSrcweir     }
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir     static css::uno::Sequence< ::rtl::OUString >  getSupportedServiceNames_Static() throw();
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir     // XComponent
212*cdf0e10cSrcweir     virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException );
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir     // XInitialization
215*cdf0e10cSrcweir     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException);
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir     // XToolbarController
218*cdf0e10cSrcweir     virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException );
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir     // XStatusListener
221*cdf0e10cSrcweir     virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException );
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir };
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir // protocol handler for "vnd.sun.star.findbar:*" URLs
226*cdf0e10cSrcweir // The dispatch object will be used for shortcut commands for findbar
227*cdf0e10cSrcweir class FindbarDispatcher : public css::lang::XServiceInfo,
228*cdf0e10cSrcweir                           public css::lang::XInitialization,
229*cdf0e10cSrcweir                           public css::frame::XDispatchProvider,
230*cdf0e10cSrcweir                           public css::frame::XDispatch,
231*cdf0e10cSrcweir                           public ::cppu::OWeakObject
232*cdf0e10cSrcweir {
233*cdf0e10cSrcweir public:
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir     FindbarDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
236*cdf0e10cSrcweir     virtual ~FindbarDispatcher();
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir     // XInterface
239*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException );
240*cdf0e10cSrcweir     virtual void SAL_CALL acquire() throw();
241*cdf0e10cSrcweir     virtual void SAL_CALL release() throw();
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir     // XServiceInfo
244*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
245*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException );
246*cdf0e10cSrcweir     virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir     static ::rtl::OUString getImplementationName_Static() throw()
249*cdf0e10cSrcweir     {
250*cdf0e10cSrcweir         return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.Impl.FindbarDispatcher" ));
251*cdf0e10cSrcweir     }
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir     static css::uno::Sequence< ::rtl::OUString >  getSupportedServiceNames_Static() throw();
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir     // XInitialization
256*cdf0e10cSrcweir     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException );
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir     // XDispatchProvider
259*cdf0e10cSrcweir     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 );
260*cdf0e10cSrcweir     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 );
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir     // XDispatch
263*cdf0e10cSrcweir     virtual void SAL_CALL dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException );
264*cdf0e10cSrcweir     virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener, const css::util::URL& aURL ) throw( css::uno::RuntimeException );
265*cdf0e10cSrcweir     virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener, const css::util::URL& aURL ) throw( css::uno::RuntimeException );
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir private:
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir     css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory;
270*cdf0e10cSrcweir     css::uno::Reference< css::frame::XFrame > m_xFrame;
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir };
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir // createInstance
275*cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > SAL_CALL FindTextToolbarController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
276*cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > SAL_CALL DownSearchToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
277*cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > SAL_CALL UpSearchToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
278*cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > SAL_CALL FindbarDispatcher_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir #endif // __TBUNOSEARCHCONTROLLERS_HXX_
283