1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef __TBUNOSEARCHCONTROLLERS_HXX_
21 #define __TBUNOSEARCHCONTROLLERS_HXX_
23 #include <com/sun/star/beans/PropertyValue.hpp>
24 #include <com/sun/star/frame/DispatchDescriptor.hpp>
25 #include <com/sun/star/frame/XDispatch.hpp>
26 #include <com/sun/star/frame/XDispatchHelper.hpp>
27 #include <com/sun/star/frame/XDispatchProvider.hpp>
28 #include <com/sun/star/frame/XStatusListener.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/lang/XInitialization.hpp>
32 #include <comphelper/sequenceasvector.hxx>
33 #include <cppuhelper/implbase1.hxx>
34 #include <cppuhelper/weak.hxx>
35 #include <svtools/toolboxcontroller.hxx>
36 #include <vcl/button.hxx>
37 #include <vcl/combobox.hxx>
38 #include <vcl/window.hxx>
46 class FindTextFieldControl
: public ComboBox
49 FindTextFieldControl( Window
* pParent
, WinBits nStyle
,
50 css::uno::Reference
< css::frame::XFrame
>& xFrame
,
51 const css::uno::Reference
< css::uno::XComponentContext
>& xContext
);
52 virtual ~FindTextFieldControl();
54 virtual long PreNotify( NotifyEvent
& rNEvt
);
56 void Remember_Impl(const String
& rStr
);
57 void SetTextToSelected_Impl();
61 css::uno::Reference
< css::frame::XFrame
> m_xFrame
;
62 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
65 class SearchToolbarControllersManager
69 SearchToolbarControllersManager();
70 ~SearchToolbarControllersManager();
72 static SearchToolbarControllersManager
& createControllersManager();
74 void registryController( const css::uno::Reference
< css::frame::XFrame
>& xFrame
, const css::uno::Reference
< css::frame::XStatusListener
>& xStatusListener
, const OUString
& sCommandURL
);
75 void freeController ( const css::uno::Reference
< css::frame::XFrame
>& xFrame
, const css::uno::Reference
< css::frame::XStatusListener
>& xStatusListener
, const OUString
& sCommandURL
);
76 css::uno::Reference
< css::frame::XStatusListener
> findController( const css::uno::Reference
< css::frame::XFrame
>& xFrame
, const OUString
& sCommandURL
);
78 void saveSearchHistory(const FindTextFieldControl
* m_pFindTextFieldControl
);
79 void loadSearchHistory(FindTextFieldControl
* m_pFindTextFieldControl
);
83 typedef ::comphelper::SequenceAsVector
< css::beans::PropertyValue
> SearchToolbarControllersVec
;
84 typedef ::std::map
< css::uno::Reference
< css::frame::XFrame
>, SearchToolbarControllersVec
> SearchToolbarControllersMap
;
85 SearchToolbarControllersMap aSearchToolbarControllersMap
;
86 std::vector
<OUString
> m_aSearchStrings
;
90 class FindTextToolbarController
: public svt::ToolboxController
,
91 public css::lang::XServiceInfo
95 FindTextToolbarController( const css::uno::Reference
< css::uno::XComponentContext
> & rxContext
);
96 ~FindTextToolbarController();
99 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) throw ( css::uno::RuntimeException
);
100 virtual void SAL_CALL
acquire() throw ();
101 virtual void SAL_CALL
release() throw ();
104 virtual OUString SAL_CALL
getImplementationName() throw( css::uno::RuntimeException
);
105 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw( css::uno::RuntimeException
);
106 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw( css::uno::RuntimeException
);
108 static OUString
getImplementationName_Static() throw()
110 return OUString("com.sun.star.svx.FindTextToolboxController");
113 static ::com::sun::star::uno::Sequence
< OUString
> getSupportedServiceNames_Static() throw();
116 virtual void SAL_CALL
dispose() throw ( css::uno::RuntimeException
);
119 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) throw ( css::uno::Exception
, css::uno::RuntimeException
);
121 // XToolbarController
122 virtual void SAL_CALL
execute( sal_Int16 KeyModifier
) throw ( css::uno::RuntimeException
);
123 virtual css::uno::Reference
< css::awt::XWindow
> SAL_CALL
createItemWindow( const css::uno::Reference
< css::awt::XWindow
>& Parent
) throw ( css::uno::RuntimeException
);
126 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& Event
) throw ( css::uno::RuntimeException
);
128 DECL_LINK(EditModifyHdl
, void*);
132 FindTextFieldControl
* m_pFindTextFieldControl
;
134 sal_uInt16 m_nDownSearchId
; // item position of findbar
135 sal_uInt16 m_nUpSearchId
; // item position of findbar
139 class ExitSearchToolboxController
: public svt::ToolboxController
,
140 public css::lang::XServiceInfo
143 ExitSearchToolboxController( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
144 ~ExitSearchToolboxController();
147 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) throw ( css::uno::RuntimeException
);
148 virtual void SAL_CALL
acquire() throw ();
149 virtual void SAL_CALL
release() throw ();
152 virtual OUString SAL_CALL
getImplementationName() throw( css::uno::RuntimeException
);
153 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw( css::uno::RuntimeException
);
154 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw( css::uno::RuntimeException
);
156 static OUString
getImplementationName_Static( ) throw()
158 return OUString( "com.sun.star.svx.ExitFindbarToolboxController" );
161 static css::uno::Sequence
< OUString
> getSupportedServiceNames_Static() throw();
164 virtual void SAL_CALL
dispose() throw ( css::uno::RuntimeException
);
167 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) throw ( css::uno::Exception
, css::uno::RuntimeException
);
169 // XToolbarController
170 virtual void SAL_CALL
execute( sal_Int16 KeyModifier
) throw ( css::uno::RuntimeException
);
173 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& rEvent
) throw ( css::uno::RuntimeException
);
176 class UpDownSearchToolboxController
: public svt::ToolboxController
,
177 public css::lang::XServiceInfo
180 enum Type
{ UP
, DOWN
};
182 UpDownSearchToolboxController( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
, Type eType
);
183 ~UpDownSearchToolboxController();
186 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) throw ( css::uno::RuntimeException
);
187 virtual void SAL_CALL
acquire() throw ();
188 virtual void SAL_CALL
release() throw ();
191 virtual OUString SAL_CALL
getImplementationName() throw( css::uno::RuntimeException
);
192 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw( css::uno::RuntimeException
);
193 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw( css::uno::RuntimeException
);
195 static OUString
getImplementationName_Static( Type eType
) throw()
197 return eType
== UP
? OUString( "com.sun.star.svx.UpSearchToolboxController" ) :
198 OUString( "com.sun.star.svx.DownSearchToolboxController" );
201 static css::uno::Sequence
< OUString
> getSupportedServiceNames_Static() throw();
204 virtual void SAL_CALL
dispose() throw ( css::uno::RuntimeException
);
207 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) throw ( css::uno::Exception
, css::uno::RuntimeException
);
209 // XToolbarController
210 virtual void SAL_CALL
execute( sal_Int16 KeyModifier
) throw ( css::uno::RuntimeException
);
213 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& rEvent
) throw ( css::uno::RuntimeException
);
219 class MatchCaseToolboxController
: public svt::ToolboxController
,
220 public css::lang::XServiceInfo
223 MatchCaseToolboxController( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
224 ~MatchCaseToolboxController();
227 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) throw ( css::uno::RuntimeException
);
228 virtual void SAL_CALL
acquire() throw ();
229 virtual void SAL_CALL
release() throw ();
232 virtual OUString SAL_CALL
getImplementationName() throw( css::uno::RuntimeException
);
233 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw( css::uno::RuntimeException
);
234 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw( css::uno::RuntimeException
);
236 static OUString
getImplementationName_Static( ) throw()
238 return OUString( "com.sun.star.svx.MatchCaseToolboxController" );
241 static css::uno::Sequence
< OUString
> getSupportedServiceNames_Static() throw();
244 virtual void SAL_CALL
dispose() throw ( css::uno::RuntimeException
);
247 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) throw ( css::uno::Exception
, css::uno::RuntimeException
);
249 // XToolbarController
250 virtual void SAL_CALL
execute( sal_Int16 KeyModifier
) throw ( css::uno::RuntimeException
);
251 virtual css::uno::Reference
< css::awt::XWindow
> SAL_CALL
createItemWindow( const css::uno::Reference
< css::awt::XWindow
>& Parent
) throw ( css::uno::RuntimeException
);
254 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& rEvent
) throw ( css::uno::RuntimeException
);
257 CheckBox
* m_pMatchCaseControl
;
260 // protocol handler for "vnd.sun.star.findbar:*" URLs
261 // The dispatch object will be used for shortcut commands for findbar
262 class FindbarDispatcher
: public css::lang::XServiceInfo
,
263 public css::lang::XInitialization
,
264 public css::frame::XDispatchProvider
,
265 public css::frame::XDispatch
,
266 public ::cppu::OWeakObject
271 virtual ~FindbarDispatcher();
274 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) throw ( css::uno::RuntimeException
);
275 virtual void SAL_CALL
acquire() throw();
276 virtual void SAL_CALL
release() throw();
279 virtual OUString SAL_CALL
getImplementationName() throw( css::uno::RuntimeException
);
280 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw( css::uno::RuntimeException
);
281 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw( css::uno::RuntimeException
);
283 static OUString
getImplementationName_Static() throw()
285 return OUString("com.sun.star.comp.svx.Impl.FindbarDispatcher");
288 static css::uno::Sequence
< OUString
> getSupportedServiceNames_Static() throw();
291 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) throw ( css::uno::Exception
, css::uno::RuntimeException
);
294 virtual css::uno::Reference
< css::frame::XDispatch
> SAL_CALL
queryDispatch( const css::util::URL
& aURL
, const OUString
& sTargetFrameName
, sal_Int32 nSearchFlags
) throw( css::uno::RuntimeException
);
295 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
);
298 virtual void SAL_CALL
dispatch( const css::util::URL
& aURL
, const css::uno::Sequence
< css::beans::PropertyValue
>& lArguments
) throw( css::uno::RuntimeException
);
299 virtual void SAL_CALL
addStatusListener( const css::uno::Reference
< css::frame::XStatusListener
>& xListener
, const css::util::URL
& aURL
) throw( css::uno::RuntimeException
);
300 virtual void SAL_CALL
removeStatusListener( const css::uno::Reference
< css::frame::XStatusListener
>& xListener
, const css::util::URL
& aURL
) throw( css::uno::RuntimeException
);
304 css::uno::Reference
< css::frame::XFrame
> m_xFrame
;
309 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
FindTextToolbarController_createInstance( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rSMgr
);
310 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
DownSearchToolboxController_createInstance( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rSMgr
);
311 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
UpSearchToolboxController_createInstance( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rSMgr
);
312 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
MatchCaseToolboxController_createInstance( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rSMgr
);
313 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
ExitFindbarToolboxController_createInstance( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rSMgr
);
314 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
FindbarDispatcher_createInstance( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rSMgr
);
318 #endif // __TBUNOSEARCHCONTROLLERS_HXX_
320 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */