fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / source / inc / accelerators / acceleratorcache.hxx
blob07c0cf877b946564d3b66af0605975b9552986e5
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_ACCELERATORCACHE_HXX
21 #define INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_ACCELERATORCACHE_HXX
23 #include <general.h>
24 #include <stdtypes.h>
26 #include <com/sun/star/awt/KeyEvent.hpp>
28 #include <vector>
30 // definition
32 namespace framework
35 /**
36 @short implements a cache for any accelerator configuration.
38 @descr Its implemented threadsafe, supports copy-on-write pattern
39 and a flush mechansim to support concurrent access to the same
40 configuration.
42 copy-on-write ... How? Do the following:
44 class AcceleratorCache
47 // const, types
49 public:
51 /** TODO document me
52 commands -> keys
54 typedef ::std::vector< css::awt::KeyEvent > TKeyList;
55 typedef BaseHash< TKeyList > TCommand2Keys;
57 /** TODO document me
58 keys -> commands
60 typedef std::unordered_map< css::awt::KeyEvent ,
61 OUString ,
62 KeyEventHashCode ,
63 KeyEventEqualsFunc > TKey2Commands;
65 // member
67 private:
69 /** map commands to keys in relation 1:n.
70 First key is interpreted as preferred one! */
71 TCommand2Keys m_lCommand2Keys;
73 /** map keys to commands in relation 1:1. */
74 TKey2Commands m_lKey2Commands;
76 // interface
78 public:
80 /** @short creates a new - but empty - cache instance. */
81 AcceleratorCache();
83 /** @short make a copy of this cache.
84 @descr Used for the copy-on-write feature.
86 AcceleratorCache(const AcceleratorCache& rCopy);
88 /** @short does nothing real. */
89 virtual ~AcceleratorCache();
91 /** @short write changes back to the original container.
93 @param rCopy
94 the (changed!) copy, which should be written
95 back to this original container.
97 void takeOver(const AcceleratorCache& rCopy);
99 /** TODO document me */
100 AcceleratorCache& operator=(const AcceleratorCache& rCopy);
102 /** @short checks if the specified key exists.
104 @param aKey
105 the key, which should be checked.
107 @return [bool]
108 sal_True if the speicfied key exists inside this container.
110 bool hasKey(const css::awt::KeyEvent& aKey) const;
111 bool hasCommand(const OUString& sCommand) const;
113 /** TODO document me */
114 TKeyList getAllKeys() const;
116 /** @short add a new or change an existing key-command pair
117 of this container.
119 @param aKey
120 describe the key.
122 @param sCommand
123 describe the command.
125 void setKeyCommandPair(const css::awt::KeyEvent& aKey ,
126 const OUString& sCommand);
128 /** @short returns the list of keys, which are registered
129 for this command.
131 @param sCommand
132 describe the command.
134 @return [TKeyList]
135 the list of registered keys. Can be empty!
137 TKeyList getKeysByCommand(const OUString& sCommand) const;
139 /** TODO */
140 OUString getCommandByKey(const css::awt::KeyEvent& aKey) const;
142 /** TODO */
143 void removeKey(const css::awt::KeyEvent& aKey);
144 void removeCommand(const OUString& sCommand);
147 } // namespace framework
149 #endif // INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_ACCELERATORCACHE_HXX
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */