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>
50 namespace css
= ::com::sun::star
;
54 class FindTextFieldControl
: public ComboBox
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
);
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
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
);
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
102 FindTextToolbarController( const css::uno::Reference
< css::lang::XMultiServiceFactory
> & rServiceManager
);
103 ~FindTextToolbarController();
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 ();
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();
123 virtual void SAL_CALL
dispose() throw ( css::uno::RuntimeException
);
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
);
133 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& Event
) throw ( css::uno::RuntimeException
);
135 DECL_LINK(EditModifyHdl
, void*);
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
150 enum Type
{ UP
, DOWN
};
152 UpDownSearchToolboxController( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rServiceManager
, Type eType
);
153 ~UpDownSearchToolboxController();
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 ();
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();
174 virtual void SAL_CALL
dispose() throw ( css::uno::RuntimeException
);
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
);
183 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& rEvent
) throw ( css::uno::RuntimeException
);
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
199 FindbarDispatcher( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xFactory
);
200 virtual ~FindbarDispatcher();
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();
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();
220 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) throw ( css::uno::Exception
, css::uno::RuntimeException
);
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
);
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
);
233 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xFactory
;
234 css::uno::Reference
< css::frame::XFrame
> m_xFrame
;
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: */