1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef __TBUNOSEARCHCONTROLLERS_HXX_ 29 #define __TBUNOSEARCHCONTROLLERS_HXX_ 30 31 #include <com/sun/star/beans/PropertyValue.hpp> 32 #include <com/sun/star/frame/DispatchDescriptor.hpp> 33 #include <com/sun/star/frame/XDispatch.hpp> 34 #include <com/sun/star/frame/XDispatchHelper.hpp> 35 #include <com/sun/star/frame/XDispatchProvider.hpp> 36 #include <com/sun/star/frame/XStatusListener.hpp> 37 #include <com/sun/star/lang/XServiceInfo.hpp> 38 #include <com/sun/star/lang/XInitialization.hpp> 39 40 #include <comphelper/sequenceasvector.hxx> 41 #include <cppuhelper/implbase1.hxx> 42 #include <cppuhelper/weak.hxx> 43 #include <svtools/toolboxcontroller.hxx> 44 #include <vcl/combobox.hxx> 45 #include <vcl/window.hxx> 46 47 #include <map> 48 49 namespace css = ::com::sun::star ; 50 namespace svx 51 { 52 53 class FindTextFieldControl : public ComboBox 54 { 55 public: 56 FindTextFieldControl( Window* pParent, WinBits nStyle, 57 css::uno::Reference< css::frame::XFrame >& xFrame, 58 css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); 59 virtual ~FindTextFieldControl(); 60 61 virtual void Modify(); 62 virtual long PreNotify( NotifyEvent& rNEvt ); 63 64 void InitControls_Impl(); 65 void Remember_Impl(const String& rStr); 66 67 private: 68 69 css::uno::Reference< css::frame::XFrame > m_xFrame; 70 css::uno::Reference< css::lang::XMultiServiceFactory > m_xServiceManager; 71 sal_Bool m_bToClearTextField; 72 73 }; 74 75 class SearchToolbarControllersManager 76 { 77 public: 78 79 SearchToolbarControllersManager(); 80 ~SearchToolbarControllersManager(); 81 82 static SearchToolbarControllersManager* createControllersManager(); 83 84 void registryController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL ); 85 void freeController ( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL ); 86 css::uno::Reference< css::frame::XStatusListener > findController( const css::uno::Reference< css::frame::XFrame >& xFrame, const ::rtl::OUString& sCommandURL ); 87 88 private: 89 90 static SearchToolbarControllersManager* m_pInstance; 91 92 typedef ::comphelper::SequenceAsVector< css::beans::PropertyValue > SearchToolbarControllersVec; 93 typedef ::std::map< css::uno::Reference< css::frame::XFrame >, SearchToolbarControllersVec > SearchToolbarControllersMap; 94 SearchToolbarControllersMap aSearchToolbarControllersMap; 95 96 }; 97 98 class FindTextToolbarController : public svt::ToolboxController, 99 public css::lang::XServiceInfo 100 { 101 public: 102 103 FindTextToolbarController( const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager ); 104 ~FindTextToolbarController(); 105 106 // XInterface 107 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException ); 108 virtual void SAL_CALL acquire() throw (); 109 virtual void SAL_CALL release() throw (); 110 111 // XServiceInfo 112 virtual ::rtl::OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException ); 113 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException ); 114 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException ); 115 116 static ::rtl::OUString getImplementationName_Static() throw() 117 { 118 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.svx.FindTextToolboxController" )); 119 } 120 121 static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw(); 122 123 // XComponent 124 virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException ); 125 126 // XInitialization 127 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException ); 128 129 // XToolbarController 130 virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException); 131 virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException ); 132 133 // XStatusListener 134 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException ); 135 136 DECL_LINK(EditModifyHdl, void*); 137 138 private: 139 140 FindTextFieldControl* m_pFindTextFieldControl; 141 142 sal_uInt16 m_nDownSearchId; // item position of findbar 143 sal_uInt16 m_nUpSearchId; // item position of findbar 144 145 }; 146 147 class DownSearchToolboxController : public svt::ToolboxController, 148 public css::lang::XServiceInfo 149 { 150 public: 151 152 DownSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager ); 153 ~DownSearchToolboxController(); 154 155 // XInterface 156 virtual css::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 (); 159 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 ); 164 165 static ::rtl::OUString getImplementationName_Static() throw() 166 { 167 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.svx.DownSearchToolboxController" )); 168 } 169 170 static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw(); 171 172 // XComponent 173 virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException ); 174 175 // XInitialization 176 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException ); 177 178 // XToolbarController 179 virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException); 180 181 // XStatusListener 182 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException ); 183 184 }; 185 186 class UpSearchToolboxController : public svt::ToolboxController, 187 public css::lang::XServiceInfo 188 { 189 public: 190 191 UpSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager ); 192 ~UpSearchToolboxController(); 193 194 // XInterface 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 (); 198 199 // XServiceInfo 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 ); 203 204 static ::rtl::OUString getImplementationName_Static() throw() 205 { 206 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.svx.UpSearchToolboxController" )); 207 } 208 209 static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw(); 210 211 // XComponent 212 virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException ); 213 214 // XInitialization 215 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException); 216 217 // XToolbarController 218 virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException ); 219 220 // XStatusListener 221 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException ); 222 223 }; 224 225 // protocol handler for "vnd.sun.star.findbar:*" URLs 226 // The dispatch object will be used for shortcut commands for findbar 227 class FindbarDispatcher : public css::lang::XServiceInfo, 228 public css::lang::XInitialization, 229 public css::frame::XDispatchProvider, 230 public css::frame::XDispatch, 231 public ::cppu::OWeakObject 232 { 233 public: 234 235 FindbarDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); 236 virtual ~FindbarDispatcher(); 237 238 // XInterface 239 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException ); 240 virtual void SAL_CALL acquire() throw(); 241 virtual void SAL_CALL release() throw(); 242 243 // XServiceInfo 244 virtual ::rtl::OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException ); 245 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException ); 246 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException ); 247 248 static ::rtl::OUString getImplementationName_Static() throw() 249 { 250 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.Impl.FindbarDispatcher" )); 251 } 252 253 static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw(); 254 255 // XInitialization 256 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException ); 257 258 // XDispatchProvider 259 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 ); 260 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 ); 261 262 // XDispatch 263 virtual void SAL_CALL dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException ); 264 virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener, const css::util::URL& aURL ) throw( css::uno::RuntimeException ); 265 virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener, const css::util::URL& aURL ) throw( css::uno::RuntimeException ); 266 267 private: 268 269 css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; 270 css::uno::Reference< css::frame::XFrame > m_xFrame; 271 272 }; 273 274 // createInstance 275 css::uno::Reference< css::uno::XInterface > SAL_CALL FindTextToolbarController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ); 276 css::uno::Reference< css::uno::XInterface > SAL_CALL DownSearchToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ); 277 css::uno::Reference< css::uno::XInterface > SAL_CALL UpSearchToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ); 278 css::uno::Reference< css::uno::XInterface > SAL_CALL FindbarDispatcher_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr ); 279 280 } 281 282 #endif // __TBUNOSEARCHCONTROLLERS_HXX_ 283