Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / svx / inc / tbunosearchcontrollers.hxx
blob032662cf361d7aa1e9b503feef4633af62a4eeaf
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef __TBUNOSEARCHCONTROLLERS_HXX_
30 #define __TBUNOSEARCHCONTROLLERS_HXX_
32 #include <com/sun/star/beans/PropertyValue.hpp>
33 #include <com/sun/star/frame/DispatchDescriptor.hpp>
34 #include <com/sun/star/frame/XDispatch.hpp>
35 #include <com/sun/star/frame/XDispatchHelper.hpp>
36 #include <com/sun/star/frame/XDispatchProvider.hpp>
37 #include <com/sun/star/frame/XStatusListener.hpp>
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #include <com/sun/star/lang/XInitialization.hpp>
41 #include <comphelper/sequenceasvector.hxx>
42 #include <cppuhelper/implbase1.hxx>
43 #include <cppuhelper/weak.hxx>
44 #include <svtools/toolboxcontroller.hxx>
45 #include <vcl/combobox.hxx>
46 #include <vcl/window.hxx>
48 #include <map>
50 namespace css = ::com::sun::star ;
51 namespace svx
54 class FindTextFieldControl : public ComboBox
56 public:
57 FindTextFieldControl( Window* pParent, WinBits nStyle,
58 css::uno::Reference< css::frame::XFrame >& xFrame,
59 css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
60 virtual ~FindTextFieldControl();
62 virtual void Modify();
63 virtual long PreNotify( NotifyEvent& rNEvt );
65 void InitControls_Impl();
66 void Remember_Impl(const String& rStr);
68 private:
70 css::uno::Reference< css::frame::XFrame > m_xFrame;
71 css::uno::Reference< css::lang::XMultiServiceFactory > m_xServiceManager;
72 sal_Bool m_bToClearTextField;
76 class SearchToolbarControllersManager
78 public:
80 SearchToolbarControllersManager();
81 ~SearchToolbarControllersManager();
83 static SearchToolbarControllersManager& createControllersManager();
85 void registryController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL );
86 void freeController ( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL );
87 css::uno::Reference< css::frame::XStatusListener > findController( const css::uno::Reference< css::frame::XFrame >& xFrame, const ::rtl::OUString& sCommandURL );
89 private:
91 typedef ::comphelper::SequenceAsVector< css::beans::PropertyValue > SearchToolbarControllersVec;
92 typedef ::std::map< css::uno::Reference< css::frame::XFrame >, SearchToolbarControllersVec > SearchToolbarControllersMap;
93 SearchToolbarControllersMap aSearchToolbarControllersMap;
97 class FindTextToolbarController : public svt::ToolboxController,
98 public css::lang::XServiceInfo
100 public:
102 FindTextToolbarController( const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager );
103 ~FindTextToolbarController();
105 // XInterface
106 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException );
107 virtual void SAL_CALL acquire() throw ();
108 virtual void SAL_CALL release() throw ();
110 // XServiceInfo
111 virtual ::rtl::OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
112 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException );
113 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
115 static ::rtl::OUString getImplementationName_Static() throw()
117 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.svx.FindTextToolboxController" ));
120 static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw();
122 // XComponent
123 virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException );
125 // XInitialization
126 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException );
128 // XToolbarController
129 virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException);
130 virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException );
132 // XStatusListener
133 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException );
135 DECL_LINK(EditModifyHdl, void*);
137 private:
139 FindTextFieldControl* m_pFindTextFieldControl;
141 sal_uInt16 m_nDownSearchId; // item position of findbar
142 sal_uInt16 m_nUpSearchId; // item position of findbar
146 class UpDownSearchToolboxController : public svt::ToolboxController,
147 public css::lang::XServiceInfo
149 public:
150 enum Type { UP, DOWN };
152 UpDownSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager, Type eType );
153 ~UpDownSearchToolboxController();
155 // XInterface
156 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException );
157 virtual void SAL_CALL acquire() throw ();
158 virtual void SAL_CALL release() throw ();
160 // XServiceInfo
161 virtual ::rtl::OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
162 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException );
163 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
165 static ::rtl::OUString getImplementationName_Static( Type eType ) throw()
167 return eType == UP? ::rtl::OUString( "com.sun.star.svx.UpSearchToolboxController" ) :
168 ::rtl::OUString( "com.sun.star.svx.DownSearchToolboxController" );
171 static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw();
173 // XComponent
174 virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException );
176 // XInitialization
177 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException);
179 // XToolbarController
180 virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException );
182 // XStatusListener
183 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException );
185 private:
186 Type meType;
189 // protocol handler for "vnd.sun.star.findbar:*" URLs
190 // The dispatch object will be used for shortcut commands for findbar
191 class FindbarDispatcher : public css::lang::XServiceInfo,
192 public css::lang::XInitialization,
193 public css::frame::XDispatchProvider,
194 public css::frame::XDispatch,
195 public ::cppu::OWeakObject
197 public:
199 FindbarDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
200 virtual ~FindbarDispatcher();
202 // XInterface
203 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException );
204 virtual void SAL_CALL acquire() throw();
205 virtual void SAL_CALL release() throw();
207 // XServiceInfo
208 virtual ::rtl::OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
209 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException );
210 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
212 static ::rtl::OUString getImplementationName_Static() throw()
214 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.Impl.FindbarDispatcher" ));
217 static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw();
219 // XInitialization
220 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException );
222 // XDispatchProvider
223 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 );
224 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 );
226 // XDispatch
227 virtual void SAL_CALL dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException );
228 virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener, const css::util::URL& aURL ) throw( css::uno::RuntimeException );
229 virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener, const css::util::URL& aURL ) throw( css::uno::RuntimeException );
231 private:
233 css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory;
234 css::uno::Reference< css::frame::XFrame > m_xFrame;
238 // createInstance
239 css::uno::Reference< css::uno::XInterface > SAL_CALL FindTextToolbarController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
240 css::uno::Reference< css::uno::XInterface > SAL_CALL DownSearchToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
241 css::uno::Reference< css::uno::XInterface > SAL_CALL UpSearchToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
242 css::uno::Reference< css::uno::XInterface > SAL_CALL FindbarDispatcher_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
246 #endif // __TBUNOSEARCHCONTROLLERS_HXX_
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */