LibreOffice Module comphelper (master)  1
accessiblekeybindinghelper.cxx
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 #include <sal/config.h>
21 
22 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
24 
25 
26 namespace comphelper
27 {
28 
29 
30  using namespace ::com::sun::star; // MT 04/2003: was ::drafts::com::sun::star - otherwise too many changes
31  using namespace ::com::sun::star::uno;
32  using namespace ::com::sun::star::lang;
33  using namespace ::com::sun::star::accessibility;
34 
35 
36  // OAccessibleKeyBindingHelper
37 
38 
40  {
41  }
42 
43 
45  : cppu::WeakImplHelper<XAccessibleKeyBinding>( rHelper )
46  , m_aKeyBindings( rHelper.m_aKeyBindings )
47  {
48  }
49 
50 
52  {
53  }
54 
55 
56  void OAccessibleKeyBindingHelper::AddKeyBinding( const Sequence< awt::KeyStroke >& rKeyBinding )
57  {
58  ::osl::MutexGuard aGuard( m_aMutex );
59 
60  m_aKeyBindings.push_back( rKeyBinding );
61  }
62 
63 
64  void OAccessibleKeyBindingHelper::AddKeyBinding( const awt::KeyStroke& rKeyStroke )
65  {
66  ::osl::MutexGuard aGuard( m_aMutex );
67 
68  Sequence< awt::KeyStroke > aSeq(1);
69  aSeq[0] = rKeyStroke;
70  m_aKeyBindings.push_back( aSeq );
71  }
72 
73 
74  // XAccessibleKeyBinding
75 
76 
78  {
79  ::osl::MutexGuard aGuard( m_aMutex );
80 
81  return m_aKeyBindings.size();
82  }
83 
84 
85  Sequence< awt::KeyStroke > OAccessibleKeyBindingHelper::getAccessibleKeyBinding( sal_Int32 nIndex )
86  {
87  ::osl::MutexGuard aGuard( m_aMutex );
88 
89  if ( nIndex < 0 || nIndex >= static_cast<sal_Int32>(m_aKeyBindings.size()) )
90  throw IndexOutOfBoundsException();
91 
92  return m_aKeyBindings[nIndex];
93  }
94 
95 
96 } // namespace comphelper
97 
98 
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_Int32 SAL_CALL getAccessibleKeyBindingCount() override
void AddKeyBinding(const css::uno::Sequence< css::awt::KeyStroke > &rKeyBinding)
a helper class for implementing an accessible keybinding
virtual css::uno::Sequence< css::awt::KeyStroke > SAL_CALL getAccessibleKeyBinding(sal_Int32 nIndex) override
Sequence< sal_Int8 > aSeq