Branch data Line data Source code
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 <comphelper/accimplaccess.hxx>
21 : : #include <com/sun/star/accessibility/XAccessible.hpp>
22 : : #include <com/sun/star/accessibility/XAccessibleContext.hpp>
23 : : #include <cppuhelper/typeprovider.hxx>
24 : :
25 : : #include <set>
26 : :
27 : : //.........................................................................
28 : : namespace comphelper
29 : : {
30 : : //.........................................................................
31 : :
32 : : #define BITFIELDSIZE ( sizeof( sal_Int64 ) * 8 )
33 : : // maximum number of bits we have in a sal_Int64
34 : :
35 : : using ::com::sun::star::uno::Reference;
36 : : using ::com::sun::star::uno::Sequence;
37 : : using ::com::sun::star::uno::Exception;
38 : : using ::com::sun::star::uno::UNO_QUERY;
39 : : using ::com::sun::star::uno::RuntimeException;
40 : : using ::com::sun::star::lang::XUnoTunnel;
41 : : using ::com::sun::star::accessibility::XAccessible;
42 : : using ::com::sun::star::accessibility::XAccessibleContext;
43 : :
44 : : //=====================================================================
45 : : //= OAccImpl_Impl
46 : : //=====================================================================
47 : 1032 : struct OAccImpl_Impl
48 : : {
49 : : Reference< XAccessible > m_xAccParent;
50 : : sal_Int64 m_nForeignControlledStates;
51 : : };
52 : :
53 : :
54 : : //=====================================================================
55 : : //= OAccessibleImplementationAccess
56 : : //=====================================================================
57 : : //---------------------------------------------------------------------
58 : 535 : OAccessibleImplementationAccess::OAccessibleImplementationAccess( )
59 [ + - ][ + - ]: 535 : :m_pImpl( new OAccImpl_Impl )
60 : : {
61 : 535 : }
62 : :
63 : : //---------------------------------------------------------------------
64 : 497 : OAccessibleImplementationAccess::~OAccessibleImplementationAccess( )
65 : : {
66 [ + - ][ + - ]: 497 : delete m_pImpl;
67 : 497 : m_pImpl = NULL;
68 [ - + ]: 497 : }
69 : :
70 : : //---------------------------------------------------------------------
71 : 14131 : Reference< XAccessible > OAccessibleImplementationAccess::implGetForeignControlledParent( ) const
72 : : {
73 : 14131 : return m_pImpl->m_xAccParent;
74 : : }
75 : :
76 : : //---------------------------------------------------------------------
77 : 0 : void OAccessibleImplementationAccess::setAccessibleParent( const Reference< XAccessible >& _rxAccParent )
78 : : {
79 : 0 : m_pImpl->m_xAccParent = _rxAccParent;
80 : 0 : }
81 : :
82 : : //---------------------------------------------------------------------
83 : 0 : sal_Int64 OAccessibleImplementationAccess::implGetForeignControlledStates( ) const
84 : : {
85 : 0 : return m_pImpl->m_nForeignControlledStates;
86 : : }
87 : :
88 : : //---------------------------------------------------------------------
89 : 0 : void OAccessibleImplementationAccess::setStateBit( const sal_Int16 _nState, const sal_Bool _bSet )
90 : : {
91 : : OSL_ENSURE( _nState >= 0 && static_cast< sal_uInt16 >(_nState) < BITFIELDSIZE, "OAccessibleImplementationAccess::setStateBit: no more bits (shutting down the universe now)!" );
92 : :
93 : 0 : sal_uInt64 nBitMask( 1 );
94 : 0 : nBitMask <<= _nState;
95 [ # # ]: 0 : if ( _bSet )
96 : 0 : m_pImpl->m_nForeignControlledStates |= nBitMask;
97 : : else
98 : 0 : m_pImpl->m_nForeignControlledStates &= ~nBitMask;
99 : 0 : }
100 : :
101 : : namespace { struct lcl_ImplId : public rtl::Static< ::cppu::OImplementationId, lcl_ImplId > {}; }
102 : :
103 : : //---------------------------------------------------------------------
104 : 0 : const Sequence< sal_Int8 > OAccessibleImplementationAccess::getUnoTunnelImplementationId()
105 : : {
106 : 0 : ::cppu::OImplementationId &rID = lcl_ImplId::get();
107 : 0 : return rID.getImplementationId();
108 : : }
109 : :
110 : : //---------------------------------------------------------------------
111 : 0 : sal_Int64 SAL_CALL OAccessibleImplementationAccess::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) throw (RuntimeException)
112 : : {
113 : 0 : sal_Int64 nReturn( 0 );
114 : :
115 [ # # ][ # # ]: 0 : if ( ( _rIdentifier.getLength() == 16 )
[ # # ]
116 [ # # ][ # # ]: 0 : && ( 0 == rtl_compareMemory( getUnoTunnelImplementationId().getConstArray(), _rIdentifier.getConstArray(), 16 ) )
[ # # ][ # # ]
117 : : )
118 : 0 : nReturn = reinterpret_cast< sal_Int64 >( this );
119 : :
120 : 0 : return nReturn;
121 : : }
122 : :
123 : : //---------------------------------------------------------------------
124 : 0 : OAccessibleImplementationAccess* OAccessibleImplementationAccess::getImplementation( const Reference< XAccessibleContext >& _rxComponent )
125 : : {
126 : 0 : OAccessibleImplementationAccess* pImplementation = NULL;
127 : : try
128 : : {
129 [ # # ]: 0 : Reference< XUnoTunnel > xTunnel( _rxComponent, UNO_QUERY );
130 [ # # ]: 0 : if ( xTunnel.is() )
131 : : {
132 : : pImplementation = reinterpret_cast< OAccessibleImplementationAccess* >(
133 [ # # ][ # # ]: 0 : xTunnel->getSomething( getUnoTunnelImplementationId() ) );
[ # # ][ # # ]
134 [ # # ]: 0 : }
135 : : }
136 : 0 : catch( const Exception& )
137 : : {
138 : : OSL_FAIL( "OAccessibleImplementationAccess::setAccessibleParent: caught an exception while retrieving the implementation!" );
139 : : }
140 : 0 : return pImplementation;
141 : : }
142 : :
143 : : //---------------------------------------------------------------------
144 : 0 : sal_Bool OAccessibleImplementationAccess::setAccessibleParent(
145 : : const Reference< XAccessibleContext >& _rxComponent, const Reference< XAccessible >& _rxNewParent )
146 : : {
147 : 0 : OAccessibleImplementationAccess* pImplementation = getImplementation( _rxComponent );
148 : :
149 [ # # ]: 0 : if ( pImplementation )
150 : 0 : pImplementation->setAccessibleParent( _rxNewParent );
151 : :
152 : 0 : return ( NULL != pImplementation );
153 : : }
154 : :
155 : : //.........................................................................
156 : : } // namespace comphelper
157 : : //.........................................................................
158 : :
159 : :
160 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|