Branch libreoffice-5-0-4
[LibreOffice.git] / accessibility / source / extended / accessibleeditbrowseboxcell.cxx
bloba535109669dd634f37416d6ecd8c98bce8ff1a38
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 #include <accessibility/extended/accessibleeditbrowseboxcell.hxx>
21 #include <svtools/editbrowsebox.hxx>
22 #include <comphelper/processfactory.hxx>
23 #include <com/sun/star/accessibility/XAccessibleText.hpp>
24 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
26 namespace accessibility
28 using namespace com::sun::star::accessibility;
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::lang;
31 using namespace ::com::sun::star::awt;
32 using namespace ::comphelper;
33 using namespace ::svt;
35 EditBrowseBoxTableCell::EditBrowseBoxTableCell(
36 const com::sun::star::uno::Reference< XAccessible >& _rxParent,
37 const com::sun::star::uno::Reference< XAccessible >& _rxOwningAccessible,
38 const com::sun::star::uno::Reference< XAccessibleContext >& _xControlChild,
39 IAccessibleTableProvider& _rBrowseBox,
40 const Reference< XWindow >& _xFocusWindow,
41 sal_Int32 _nRowPos,
42 sal_uInt16 _nColPos)
43 :AccessibleBrowseBoxCell( _rxParent, _rBrowseBox, _xFocusWindow, _nRowPos, _nColPos )
44 ,OAccessibleContextWrapperHelper( ::comphelper::getProcessComponentContext(), rBHelper, _xControlChild, _rxOwningAccessible, _rxParent )
46 aggregateProxy( m_refCount, *this );
49 EditBrowseBoxTableCell::~EditBrowseBoxTableCell()
51 if ( !rBHelper.bDisposed )
53 acquire(); // to prevent duplicate dtor calls
54 dispose();
58 OUString SAL_CALL EditBrowseBoxTableCell::getImplementationName() throw ( ::com::sun::star::uno::RuntimeException, std::exception )
60 return OUString( "com.sun.star.comp.svtools.TableCellProxy" );
63 IMPLEMENT_FORWARD_XINTERFACE2( EditBrowseBoxTableCell, AccessibleBrowseBoxCell, OAccessibleContextWrapperHelper )
65 IMPLEMENT_FORWARD_XTYPEPROVIDER2( EditBrowseBoxTableCell, AccessibleBrowseBoxCell, OAccessibleContextWrapperHelper )
67 void EditBrowseBoxTableCell::notifyTranslatedEvent( const AccessibleEventObject& _rEvent ) throw (RuntimeException)
69 commitEvent( _rEvent.EventId, _rEvent.NewValue, _rEvent.OldValue );
72 // XAccessibleComponent
73 sal_Int32 SAL_CALL EditBrowseBoxTableCell::getForeground( ) throw (RuntimeException, std::exception)
75 SolarMethodGuard aGuard( *this );
76 Reference< XAccessibleComponent > xAccComp( m_xInnerContext, UNO_QUERY );
77 if ( xAccComp.is() )
78 return xAccComp->getForeground();
79 return 0;
82 sal_Int32 SAL_CALL EditBrowseBoxTableCell::getBackground( ) throw (RuntimeException, std::exception)
84 SolarMethodGuard aGuard( *this );
85 Reference< XAccessibleComponent > xAccComp( m_xInnerContext, UNO_QUERY );
86 if ( xAccComp.is() )
87 return xAccComp->getBackground();
88 return 0;
91 Reference< XAccessible > SAL_CALL EditBrowseBoxTableCell::getAccessibleParent( ) throw (RuntimeException, std::exception)
93 return m_xParentAccessible;
96 OUString SAL_CALL EditBrowseBoxTableCell::getAccessibleDescription() throw ( RuntimeException, std::exception )
98 SolarMethodGuard aGuard( *this );
99 return m_xInnerContext->getAccessibleDescription();
102 OUString SAL_CALL EditBrowseBoxTableCell::getAccessibleName() throw ( RuntimeException, std::exception )
104 SolarMethodGuard aGuard( *this );
106 // TODO: localize this!
107 return "Column " + OUString::number(getColumnPos()-1) + ", Row " + OUString::number(getRowPos());
110 Reference< XAccessibleRelationSet > SAL_CALL EditBrowseBoxTableCell::getAccessibleRelationSet() throw ( RuntimeException, std::exception )
112 SolarMethodGuard aGuard( *this );
113 return baseGetAccessibleRelationSet( );
116 Reference<XAccessibleStateSet > SAL_CALL EditBrowseBoxTableCell::getAccessibleStateSet() throw ( RuntimeException, std::exception )
118 SolarMethodGuard aGuard( *this );
119 return m_xInnerContext->getAccessibleStateSet();
120 // TODO: shouldn't we add an ACTIVE here? Isn't the EditBrowseBoxTableCell always ACTIVE?
123 sal_Int32 SAL_CALL EditBrowseBoxTableCell::getAccessibleChildCount( ) throw (RuntimeException, std::exception)
125 SolarMethodGuard aGuard( *this );
126 return baseGetAccessibleChildCount();
129 Reference< XAccessible > SAL_CALL EditBrowseBoxTableCell::getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException, std::exception)
131 SolarMethodGuard aGuard( *this );
132 return baseGetAccessibleChild( i );
135 sal_Int16 SAL_CALL EditBrowseBoxTableCell::getAccessibleRole() throw ( RuntimeException, std::exception )
137 SolarMethodGuard aGuard( *this );
138 return m_xInnerContext->getAccessibleRole( );
141 void SAL_CALL EditBrowseBoxTableCell::dispose() throw( RuntimeException, std::exception )
143 // simply disambiguate. Note that the OComponentHelper base in AccessibleBrowseBoxCell
144 // will call our "disposing()", which will call "dispose()" on the OAccessibleContextWrapperHelper
145 // so there is no need to do this here.
146 AccessibleBrowseBoxCell::dispose();
149 void SAL_CALL EditBrowseBoxTableCell::disposing( const EventObject& _rSource ) throw (RuntimeException, std::exception)
151 AccessibleBrowseBoxCell::disposing( _rSource );
152 OAccessibleContextWrapperHelper::disposing( _rSource );
155 void SAL_CALL EditBrowseBoxTableCell::disposing()
157 SolarMethodGuard aGuard( *this, false );
158 OAccessibleContextWrapperHelper::dispose();
159 // TODO: do we need to dispose our inner object? The base class does this, but is it a good idea?
160 AccessibleBrowseBoxCell::disposing();
163 // EditBrowseBoxTableCell
164 EditBrowseBoxTableCellAccess::EditBrowseBoxTableCellAccess(
165 const Reference< XAccessible >& _rxParent, const Reference< XAccessible >& _rxControlAccessible,
166 const Reference< XWindow >& _rxFocusWindow,
167 IAccessibleTableProvider& _rBrowseBox, sal_Int32 _nRowPos, sal_uInt16 _nColPos )
168 :EditBrowseBoxTableCellAccess_Base( m_aMutex )
169 ,m_xParent( _rxParent )
170 ,m_xControlAccessible( _rxControlAccessible )
171 ,m_xFocusWindow( _rxFocusWindow )
172 ,m_pBrowseBox( &_rBrowseBox )
173 ,m_nRowPos( _nRowPos )
174 ,m_nColPos( _nColPos )
178 EditBrowseBoxTableCellAccess::~EditBrowseBoxTableCellAccess( )
182 Reference< XAccessibleContext > SAL_CALL EditBrowseBoxTableCellAccess::getAccessibleContext( ) throw (RuntimeException, std::exception)
184 if ( !m_pBrowseBox || !m_xControlAccessible.is() )
185 throw DisposedException();
186 Reference< XAccessibleContext > xMyContext( m_aContext );
187 if ( !xMyContext.is() )
189 Reference< XAccessibleContext > xInnerContext = m_xControlAccessible->getAccessibleContext();
190 Reference< XAccessible > xMe( this );
192 xMyContext = new EditBrowseBoxTableCell( m_xParent, xMe, xInnerContext, *m_pBrowseBox, m_xFocusWindow, m_nRowPos, m_nColPos );
193 m_aContext = xMyContext;
195 return xMyContext;
198 void SAL_CALL EditBrowseBoxTableCellAccess::disposing()
200 // dispose our context, if it still alive
201 Reference< XComponent > xMyContext( m_aContext.get(), UNO_QUERY );
202 if ( xMyContext.is() )
206 xMyContext->dispose();
208 catch( const Exception& e )
210 (void)e;
211 OSL_FAIL( "EditBrowseBoxTableCellAccess::disposing: caught an exception while disposing the context!" );
215 m_pBrowseBox = NULL;
216 m_xControlAccessible.clear();
217 m_aContext.clear();
218 // NO dispose of the inner object there: it is the XAccessible of an window, and disposing
219 // it would delete the respective VCL window
221 } // namespace accessibility
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */