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/combobox.hxx>
37 #include <vcl/window.hxx>
45 class FindTextFieldControl
: public ComboBox
48 FindTextFieldControl( Window
* pParent
, WinBits nStyle
,
49 css::uno::Reference
< css::frame::XFrame
>& xFrame
,
50 css::uno::Reference
< css::lang::XMultiServiceFactory
>& xServiceManager
);
51 virtual ~FindTextFieldControl();
53 virtual long PreNotify( NotifyEvent
& rNEvt
);
55 void Remember_Impl(const String
& rStr
);
56 void SetTextToSelected_Impl();
60 css::uno::Reference
< css::frame::XFrame
> m_xFrame
;
61 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xServiceManager
;
64 class SearchToolbarControllersManager
68 SearchToolbarControllersManager();
69 ~SearchToolbarControllersManager();
71 static SearchToolbarControllersManager
& createControllersManager();
73 void registryController( const css::uno::Reference
< css::frame::XFrame
>& xFrame
, const css::uno::Reference
< css::frame::XStatusListener
>& xStatusListener
, const ::rtl::OUString
& sCommandURL
);
74 void freeController ( const css::uno::Reference
< css::frame::XFrame
>& xFrame
, const css::uno::Reference
< css::frame::XStatusListener
>& xStatusListener
, const ::rtl::OUString
& sCommandURL
);
75 css::uno::Reference
< css::frame::XStatusListener
> findController( const css::uno::Reference
< css::frame::XFrame
>& xFrame
, const ::rtl::OUString
& sCommandURL
);
77 void saveSearchHistory(const FindTextFieldControl
* m_pFindTextFieldControl
);
78 void loadSearchHistory(FindTextFieldControl
* m_pFindTextFieldControl
);
82 typedef ::comphelper::SequenceAsVector
< css::beans::PropertyValue
> SearchToolbarControllersVec
;
83 typedef ::std::map
< css::uno::Reference
< css::frame::XFrame
>, SearchToolbarControllersVec
> SearchToolbarControllersMap
;
84 SearchToolbarControllersMap aSearchToolbarControllersMap
;
85 std::vector
<rtl::OUString
> m_aSearchStrings
;
89 class FindTextToolbarController
: public svt::ToolboxController
,
90 public css::lang::XServiceInfo
94 FindTextToolbarController( const css::uno::Reference
< css::lang::XMultiServiceFactory
> & rServiceManager
);
95 ~FindTextToolbarController();
98 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) throw ( css::uno::RuntimeException
);
99 virtual void SAL_CALL
acquire() throw ();
100 virtual void SAL_CALL
release() throw ();
103 virtual ::rtl::OUString SAL_CALL
getImplementationName() throw( css::uno::RuntimeException
);
104 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw( css::uno::RuntimeException
);
105 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames() throw( css::uno::RuntimeException
);
107 static ::rtl::OUString
getImplementationName_Static() throw()
109 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.svx.FindTextToolboxController" ));
112 static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getSupportedServiceNames_Static() throw();
115 virtual void SAL_CALL
dispose() throw ( css::uno::RuntimeException
);
118 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) throw ( css::uno::Exception
, css::uno::RuntimeException
);
120 // XToolbarController
121 virtual void SAL_CALL
execute( sal_Int16 KeyModifier
) throw ( css::uno::RuntimeException
);
122 virtual css::uno::Reference
< css::awt::XWindow
> SAL_CALL
createItemWindow( const css::uno::Reference
< css::awt::XWindow
>& Parent
) throw ( css::uno::RuntimeException
);
125 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& Event
) throw ( css::uno::RuntimeException
);
127 DECL_LINK(EditModifyHdl
, void*);
131 FindTextFieldControl
* m_pFindTextFieldControl
;
133 sal_uInt16 m_nDownSearchId
; // item position of findbar
134 sal_uInt16 m_nUpSearchId
; // item position of findbar
138 class UpDownSearchToolboxController
: public svt::ToolboxController
,
139 public css::lang::XServiceInfo
142 enum Type
{ UP
, DOWN
};
144 UpDownSearchToolboxController( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rServiceManager
, Type eType
);
145 ~UpDownSearchToolboxController();
148 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) throw ( css::uno::RuntimeException
);
149 virtual void SAL_CALL
acquire() throw ();
150 virtual void SAL_CALL
release() throw ();
153 virtual ::rtl::OUString SAL_CALL
getImplementationName() throw( css::uno::RuntimeException
);
154 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw( css::uno::RuntimeException
);
155 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames() throw( css::uno::RuntimeException
);
157 static ::rtl::OUString
getImplementationName_Static( Type eType
) throw()
159 return eType
== UP
? ::rtl::OUString( "com.sun.star.svx.UpSearchToolboxController" ) :
160 ::rtl::OUString( "com.sun.star.svx.DownSearchToolboxController" );
163 static css::uno::Sequence
< ::rtl::OUString
> getSupportedServiceNames_Static() throw();
166 virtual void SAL_CALL
dispose() throw ( css::uno::RuntimeException
);
169 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) throw ( css::uno::Exception
, css::uno::RuntimeException
);
171 // XToolbarController
172 virtual void SAL_CALL
execute( sal_Int16 KeyModifier
) throw ( css::uno::RuntimeException
);
175 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& rEvent
) throw ( css::uno::RuntimeException
);
181 // protocol handler for "vnd.sun.star.findbar:*" URLs
182 // The dispatch object will be used for shortcut commands for findbar
183 class FindbarDispatcher
: public css::lang::XServiceInfo
,
184 public css::lang::XInitialization
,
185 public css::frame::XDispatchProvider
,
186 public css::frame::XDispatch
,
187 public ::cppu::OWeakObject
191 FindbarDispatcher( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xFactory
);
192 virtual ~FindbarDispatcher();
195 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) throw ( css::uno::RuntimeException
);
196 virtual void SAL_CALL
acquire() throw();
197 virtual void SAL_CALL
release() throw();
200 virtual ::rtl::OUString SAL_CALL
getImplementationName() throw( css::uno::RuntimeException
);
201 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw( css::uno::RuntimeException
);
202 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames() throw( css::uno::RuntimeException
);
204 static ::rtl::OUString
getImplementationName_Static() throw()
206 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.Impl.FindbarDispatcher" ));
209 static css::uno::Sequence
< ::rtl::OUString
> getSupportedServiceNames_Static() throw();
212 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) throw ( css::uno::Exception
, css::uno::RuntimeException
);
215 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
);
216 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
);
219 virtual void SAL_CALL
dispatch( const css::util::URL
& aURL
, const css::uno::Sequence
< css::beans::PropertyValue
>& lArguments
) throw( css::uno::RuntimeException
);
220 virtual void SAL_CALL
addStatusListener( const css::uno::Reference
< css::frame::XStatusListener
>& xListener
, const css::util::URL
& aURL
) throw( css::uno::RuntimeException
);
221 virtual void SAL_CALL
removeStatusListener( const css::uno::Reference
< css::frame::XStatusListener
>& xListener
, const css::util::URL
& aURL
) throw( css::uno::RuntimeException
);
225 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xFactory
;
226 css::uno::Reference
< css::frame::XFrame
> m_xFrame
;
231 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
FindTextToolbarController_createInstance( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rSMgr
);
232 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
DownSearchToolboxController_createInstance( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rSMgr
);
233 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
UpSearchToolboxController_createInstance( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rSMgr
);
234 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
FindbarDispatcher_createInstance( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rSMgr
);
238 #endif // __TBUNOSEARCHCONTROLLERS_HXX_
240 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */