fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / source / inc / accelerators / acceleratorconfiguration.hxx
blob290fd0a8adab4beb3df5afa7e1f5ca42678b9575
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_ACCELERATORCONFIGURATION_HXX
21 #define INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_ACCELERATORCONFIGURATION_HXX
23 #include <accelerators/istoragelistener.hxx>
24 #include <accelerators/presethandler.hxx>
25 #include <accelerators/acceleratorcache.hxx>
26 #include <accelerators/keymapping.hxx>
27 #include <macros/xinterface.hxx>
28 #include <macros/xtypeprovider.hxx>
29 #include <general.h>
30 #include <stdtypes.h>
32 #include <com/sun/star/container/XNameAccess.hpp>
33 #include <com/sun/star/lang/XTypeProvider.hpp>
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
36 #include <com/sun/star/ui/XUIConfiguration.hpp>
37 #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
39 #include <com/sun/star/ui/XUIConfigurationStorage.hpp>
40 #include <com/sun/star/io/XStream.hpp>
41 #include <com/sun/star/io/XInputStream.hpp>
42 #include <com/sun/star/io/XOutputStream.hpp>
43 #include <com/sun/star/util/XChangesListener.hpp>
45 // TODO use XPresetHandler interface instead if available
46 #include <com/sun/star/form/XReset.hpp>
48 #include <cppuhelper/propshlp.hxx>
49 #include <cppuhelper/implbase2.hxx>
50 #include <cppuhelper/implbase4.hxx>
51 #include <salhelper/singletonref.hxx>
53 // definition
55 namespace framework
58 const char CFG_ENTRY_PRIMARY[] = "PrimaryKeys";
59 const char CFG_ENTRY_GLOBAL[] = "Global";
60 const char CFG_ENTRY_MODULES[] = "Modules";
62 /**
63 implements a read/write access to the accelerator configuration.
65 class XMLBasedAcceleratorConfiguration : public IStorageListener,
66 public ::cppu::WeakImplHelper2<
67 css::form::XReset, // TODO use XPresetHandler instead if available
68 css::ui::XAcceleratorConfiguration > // => css::ui::XUIConfigurationPersistence
69 // css::ui::XUIConfigurationStorage
70 // css::ui::XUIConfiguration
73 // member
75 protected:
77 /** the global uno service manager.
78 Must be used to create own needed services. */
79 css::uno::Reference< css::uno::XComponentContext > m_xContext;
81 /** used to:
82 i ) copy configuration files from the share to the user layer
83 ii ) provide access to these config files
84 iii) cache all sub storages on the path from the top to the bottom(!)
85 iv ) provide commit for changes. */
86 PresetHandler m_aPresetHandler;
88 /** contains the cached configuration data */
89 AcceleratorCache m_aReadCache;
91 /** used to implement the copy on write pattern! */
92 AcceleratorCache* m_pWriteCache;
94 // native interface!
96 public:
98 XMLBasedAcceleratorConfiguration( const css::uno::Reference< css::uno::XComponentContext >& xContext);
99 virtual ~XMLBasedAcceleratorConfiguration( );
101 // uno interface!
103 public:
105 // XAcceleratorConfiguration
106 virtual css::uno::Sequence< css::awt::KeyEvent > SAL_CALL getAllKeyEvents()
107 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
109 virtual OUString SAL_CALL getCommandByKeyEvent(const css::awt::KeyEvent& aKeyEvent)
110 throw(css::container::NoSuchElementException,
111 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
113 virtual void SAL_CALL setKeyEvent(const css::awt::KeyEvent& aKeyEvent,
114 const OUString& sCommand )
115 throw(css::lang::IllegalArgumentException,
116 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
118 virtual void SAL_CALL removeKeyEvent(const css::awt::KeyEvent& aKeyEvent)
119 throw(css::container::NoSuchElementException,
120 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
122 virtual css::uno::Sequence< css::awt::KeyEvent > SAL_CALL getKeyEventsByCommand(const OUString& sCommand)
123 throw(css::lang::IllegalArgumentException ,
124 css::container::NoSuchElementException,
125 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
127 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPreferredKeyEventsForCommandList(const css::uno::Sequence< OUString >& lCommandList)
128 throw (css::lang::IllegalArgumentException, css::container::NoSuchElementException,
129 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
131 virtual void SAL_CALL removeCommandFromAllKeyEvents(const OUString& sCommand)
132 throw(css::lang::IllegalArgumentException ,
133 css::container::NoSuchElementException,
134 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
136 // XUIConfigurationPersistence
137 virtual void SAL_CALL reload()
138 throw(css::uno::Exception ,
139 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 virtual void SAL_CALL store()
142 throw(css::uno::Exception ,
143 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
145 virtual void SAL_CALL storeToStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
146 throw(css::uno::Exception ,
147 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
149 virtual sal_Bool SAL_CALL isModified()
150 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
152 virtual sal_Bool SAL_CALL isReadOnly()
153 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
155 // XUIConfigurationStorage
156 virtual void SAL_CALL setStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
157 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
159 virtual sal_Bool SAL_CALL hasStorage()
160 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
162 // XUIConfiguration
163 virtual void SAL_CALL addConfigurationListener(const css::uno::Reference< css::ui::XUIConfigurationListener >& xListener)
164 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
166 virtual void SAL_CALL removeConfigurationListener(const css::uno::Reference< css::ui::XUIConfigurationListener >& xListener)
167 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
169 // XReset
170 // TODO use XPresetHandler instead if available
171 virtual void SAL_CALL reset()
172 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
174 virtual void SAL_CALL addResetListener(const css::uno::Reference< css::form::XResetListener >& xListener)
175 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
177 virtual void SAL_CALL removeResetListener(const css::uno::Reference< css::form::XResetListener >& xListener)
178 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
180 // IStorageListener
181 virtual void changesOccurred(const OUString& sPath) SAL_OVERRIDE;
183 // helper for derived classes
185 protected:
187 /** @short return the current office locale.
189 @descr We do not cache this value, because we are not listen
190 for changes on the configuration layer ...
192 @return OUString
193 The current office locale as BCP47 string.
195 OUString impl_ts_getLocale() const;
197 // helper
199 private:
201 /** @short load a configuration set, using the given stream.
203 @param xStream
204 provides the XML structure as stream.
206 void impl_ts_load(const css::uno::Reference< css::io::XInputStream >& xStream);
208 /** @short save a configuration set, using the given stream.
210 @param xStream
211 the XML structure can be written there.
213 void impl_ts_save(const css::uno::Reference< css::io::XOutputStream >& xStream);
215 /** @short try to locate and open a sub storage.
217 @descr It search at the root storage for the specified
218 sub storage. If it exists - it will be opened.
219 By default this method tries to open the storage
220 for reading. But the calli can request a writeable
221 storage.
223 @param xRooStorage
224 used to locate the sub storage.
226 @param sSubStorage
227 relativ path of the sub storage.
229 @param bOutStream
230 force open of the sub storage in
231 write mode - instead of read mode, which
232 is the default.
234 @return [XInterface]
235 will be a css::io::XInpoutStream or a css::io::XOutputStream.
236 Depends from the parameter bWriteable!
238 css::uno::Reference< css::uno::XInterface > impl_ts_openSubStorage(const css::uno::Reference< css::embed::XStorage >& xRootStorage,
239 const OUString& sSubStorage ,
240 bool bOutStream );
242 /** @short returns a reference to one of our internal cache members.
244 @descr We implement the copy-on-write pattern. Doing so
245 we know two caches internally. The second one is used
246 only, if the container was changed.
248 This method here returns access to one of these
249 caches - depending on the change state of this
250 configuration service.
252 @param bWriteAccessRequested
253 if the outside code wish to change the container
254 it must call this method with "sal_True". So the internal
255 cache can be prepared for that (means copy-on-write ...).
257 @return [AcceleratorCache]
258 c++ reference(!) to one of our internal caches.
260 AcceleratorCache& impl_getCFG(bool bWriteAccessRequested = false);
264 class XCUBasedAcceleratorConfiguration : public ::cppu::WeakImplHelper4<
265 css::util::XChangesListener,
266 css::lang::XComponent,
267 css::form::XReset, // TODO use XPresetHandler instead if available
268 css::ui::XAcceleratorConfiguration > // => css::ui::XUIConfigurationPersistence
269 // css::ui::XUIConfigurationStorage
270 // css::ui::XUIConfiguration
273 // member
275 protected:
277 /** the global uno service manager.
278 Must be used to create own needed services. */
279 css::uno::Reference< css::uno::XComponentContext > m_xContext;
281 css::uno::Reference< css::container::XNameAccess > m_xCfg;
282 AcceleratorCache m_aPrimaryReadCache;
283 AcceleratorCache m_aSecondaryReadCache;
284 AcceleratorCache* m_pPrimaryWriteCache;
285 AcceleratorCache* m_pSecondaryWriteCache;
287 OUString m_sGlobalOrModules;
288 OUString m_sModuleCFG;
290 ::salhelper::SingletonRef< KeyMapping > m_rKeyMapping;
292 // native interface!
294 public:
296 XCUBasedAcceleratorConfiguration( const css::uno::Reference< css::uno::XComponentContext >& xContext );
297 virtual ~XCUBasedAcceleratorConfiguration( );
299 // uno interface!
301 public:
303 // XAcceleratorConfiguration
304 virtual css::uno::Sequence< css::awt::KeyEvent > SAL_CALL getAllKeyEvents()
305 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
307 virtual OUString SAL_CALL getCommandByKeyEvent(const css::awt::KeyEvent& aKeyEvent)
308 throw(css::container::NoSuchElementException,
309 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
311 virtual void SAL_CALL setKeyEvent(const css::awt::KeyEvent& aKeyEvent,
312 const OUString& sCommand )
313 throw (css::lang::IllegalArgumentException, css::container::NoSuchElementException,
314 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
316 virtual void SAL_CALL removeKeyEvent(const css::awt::KeyEvent& aKeyEvent)
317 throw(css::container::NoSuchElementException,
318 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
320 virtual css::uno::Sequence< css::awt::KeyEvent > SAL_CALL getKeyEventsByCommand(const OUString& sCommand)
321 throw(css::lang::IllegalArgumentException ,
322 css::container::NoSuchElementException,
323 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
325 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPreferredKeyEventsForCommandList(const css::uno::Sequence< OUString >& lCommandList)
326 throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException,
327 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
329 virtual void SAL_CALL removeCommandFromAllKeyEvents(const OUString& sCommand)
330 throw(css::lang::IllegalArgumentException ,
331 css::container::NoSuchElementException,
332 css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
334 // XUIConfigurationPersistence
335 virtual void SAL_CALL reload()
336 throw(css::uno::Exception ,
337 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
339 virtual void SAL_CALL store()
340 throw(css::uno::Exception ,
341 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
343 virtual void SAL_CALL storeToStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
344 throw(css::uno::Exception ,
345 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
347 virtual sal_Bool SAL_CALL isModified()
348 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
350 virtual sal_Bool SAL_CALL isReadOnly()
351 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
353 // XUIConfigurationStorage
354 virtual void SAL_CALL setStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
355 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
357 virtual sal_Bool SAL_CALL hasStorage()
358 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
360 // XUIConfiguration
361 virtual void SAL_CALL addConfigurationListener(const css::uno::Reference< css::ui::XUIConfigurationListener >& xListener)
362 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
364 virtual void SAL_CALL removeConfigurationListener(const css::uno::Reference< css::ui::XUIConfigurationListener >& xListener)
365 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
367 // XReset
368 // TODO use XPresetHandler instead if available
369 virtual void SAL_CALL reset()
370 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
372 virtual void SAL_CALL addResetListener(const css::uno::Reference< css::form::XResetListener >& xListener)
373 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
375 virtual void SAL_CALL removeResetListener(const css::uno::Reference< css::form::XResetListener >& xListener)
376 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
378 // css.util.XChangesListener
379 virtual void SAL_CALL changesOccurred(const css::util::ChangesEvent& aEvent)
380 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
382 // css.lang.XEventListener
383 virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
384 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
386 // XComponent
387 virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
388 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
389 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
391 // helper for derived classes
393 protected:
395 /** @short return the current office locale.
397 @descr We do not cache this value, because we are not listen
398 for changes on the configuration layer ...
400 @return OUString
401 The current office locale as BCP47 string.
403 OUString impl_ts_getLocale() const;
405 // helper
407 private:
409 void impl_ts_load(bool bPreferred, const css::uno::Reference< css::container::XNameAccess >& xCfg);
410 void impl_ts_save(bool bPreferred, const css::uno::Reference< css::container::XNameAccess >& xCfg);
412 void insertKeyToConfiguration(const css::awt::KeyEvent& aKeyEvent, const OUString& sCommand, const bool bPreferred);
413 void removeKeyFromConfiguration(const css::awt::KeyEvent& aKeyEvent, const bool bPreferred);
415 void reloadChanged(const OUString& sPrimarySecondary, const OUString& sGlobalModules, const OUString& sModule, const OUString& sKey);
416 AcceleratorCache& impl_getCFG(bool bPreferred, bool bWriteAccessRequested = false);
420 } // namespace framework
422 #endif // INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_ACCELERATORCONFIGURATION_HXX
424 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */