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