1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_comphelper.hxx"
26 
27 // includes --------------------------------------------------------------
28 #include <comphelper/accessiblekeybindinghelper.hxx>
29 
30 
31 //..............................................................................
32 namespace comphelper
33 {
34 //..............................................................................
35 
36 	using namespace ::com::sun::star; // MT 04/2003: was ::drafts::com::sun::star - otherwise to many changes
37 	using namespace ::com::sun::star::uno;
38 	using namespace ::com::sun::star::lang;
39 	using namespace ::com::sun::star::accessibility;
40 
41 	//==============================================================================
42 	// OAccessibleKeyBindingHelper
43 	//==============================================================================
44 
OAccessibleKeyBindingHelper()45 	OAccessibleKeyBindingHelper::OAccessibleKeyBindingHelper()
46 	{
47 	}
48 
49 	// -----------------------------------------------------------------------------
50 
OAccessibleKeyBindingHelper(const OAccessibleKeyBindingHelper & rHelper)51 	OAccessibleKeyBindingHelper::OAccessibleKeyBindingHelper( const OAccessibleKeyBindingHelper& rHelper )
52 		: cppu::WeakImplHelper1<XAccessibleKeyBinding>( rHelper )
53         , m_aKeyBindings( rHelper.m_aKeyBindings )
54 	{
55 	}
56 
57 	// -----------------------------------------------------------------------------
58 
~OAccessibleKeyBindingHelper()59 	OAccessibleKeyBindingHelper::~OAccessibleKeyBindingHelper()
60 	{
61 	}
62 
63 	// -----------------------------------------------------------------------------
64 
AddKeyBinding(const Sequence<awt::KeyStroke> & rKeyBinding)65 	void OAccessibleKeyBindingHelper::AddKeyBinding( const Sequence< awt::KeyStroke >& rKeyBinding ) throw (RuntimeException)
66 	{
67 		::osl::MutexGuard aGuard( m_aMutex );
68 
69 		m_aKeyBindings.push_back( rKeyBinding );
70 	}
71 
72 	// -----------------------------------------------------------------------------
73 
AddKeyBinding(const awt::KeyStroke & rKeyStroke)74 	void OAccessibleKeyBindingHelper::AddKeyBinding( const awt::KeyStroke& rKeyStroke ) throw (RuntimeException)
75 	{
76 		::osl::MutexGuard aGuard( m_aMutex );
77 
78 		Sequence< awt::KeyStroke > aSeq(1);
79 		aSeq[0] = rKeyStroke;
80 		m_aKeyBindings.push_back( aSeq );
81 	}
82 
83 	// -----------------------------------------------------------------------------
84 	// XAccessibleKeyBinding
85 	// -----------------------------------------------------------------------------
86 
getAccessibleKeyBindingCount()87 	sal_Int32 OAccessibleKeyBindingHelper::getAccessibleKeyBindingCount() throw (RuntimeException)
88 	{
89 		::osl::MutexGuard aGuard( m_aMutex );
90 
91 		return m_aKeyBindings.size();
92 	}
93 
94 	// -----------------------------------------------------------------------------
95 
getAccessibleKeyBinding(sal_Int32 nIndex)96 	Sequence< awt::KeyStroke > OAccessibleKeyBindingHelper::getAccessibleKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
97 	{
98 		::osl::MutexGuard aGuard( m_aMutex );
99 
100 		if ( nIndex < 0 || nIndex >= (sal_Int32)m_aKeyBindings.size() )
101 			throw IndexOutOfBoundsException();
102 
103 		return m_aKeyBindings[nIndex];
104 	}
105 
106 	// -----------------------------------------------------------------------------
107 
108 //..............................................................................
109 }	// namespace comphelper
110 //..............................................................................
111