LibreOffice Module framework (master) 1
acceleratorcache.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <stdtypes.h>
23
24#include <com/sun/star/awt/KeyEvent.hpp>
25
26#include <unordered_map>
27#include <vector>
28
29// definition
30
31namespace framework
32{
33
44{
45 public:
46
50 typedef ::std::vector< css::awt::KeyEvent > TKeyList;
51
52 private:
53
54 typedef std::unordered_map<OUString, TKeyList> TCommand2Keys;
55
59 typedef std::unordered_map< css::awt::KeyEvent ,
60 OUString ,
63
67
70
71 public:
80 bool hasKey(const css::awt::KeyEvent& aKey) const;
81 bool hasCommand(const OUString& sCommand) const;
82
83 TKeyList getAllKeys() const;
84
94 void setKeyCommandPair(const css::awt::KeyEvent& aKey ,
95 const OUString& sCommand);
96
106 TKeyList getKeysByCommand(const OUString& sCommand) const;
107
108 OUString getCommandByKey(const css::awt::KeyEvent& aKey) const;
109 void removeKey(const css::awt::KeyEvent& aKey);
110 void removeCommand(const OUString& sCommand);
111};
112
113} // namespace framework
114
115/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
implements a cache for any accelerator configuration.
TKey2Commands m_lKey2Commands
map keys to commands in relation 1:1.
TKeyList getKeysByCommand(const OUString &sCommand) const
returns the list of keys, which are registered for this command.
void setKeyCommandPair(const css::awt::KeyEvent &aKey, const OUString &sCommand)
add a new or change an existing key-command pair of this container.
::std::vector< css::awt::KeyEvent > TKeyList
commands -> keys
void removeCommand(const OUString &sCommand)
bool hasCommand(const OUString &sCommand) const
OUString getCommandByKey(const css::awt::KeyEvent &aKey) const
void removeKey(const css::awt::KeyEvent &aKey)
bool hasKey(const css::awt::KeyEvent &aKey) const
checks if the specified key exists.
std::unordered_map< css::awt::KeyEvent, OUString, KeyEventHashCode, KeyEventEqualsFunc > TKey2Commands
keys -> commands
std::unordered_map< OUString, TKeyList > TCommand2Keys
TCommand2Keys m_lCommand2Keys
map commands to keys in relation 1:n.
Own hash functions used for stl-structures ... e.g.
Definition: stdtypes.h:31