Impress Remote 1.0.5, tag sdremote-1.0.5
[LibreOffice.git] / accessibility / source / extended / accessibleeditbrowseboxcell.cxx
blob8232bd99011fc32d68417600c68b312119685e31
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>
27 // .................................................................................
28 namespace accessibility
30 // .................................................................................
32 using namespace com::sun::star::accessibility;
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::lang;
35 using namespace ::com::sun::star::awt;
36 using namespace ::comphelper;
37 using namespace ::svt;
39 // -----------------------------------------------------------------------------
40 EditBrowseBoxTableCell::EditBrowseBoxTableCell(
41 const com::sun::star::uno::Reference< XAccessible >& _rxParent,
42 const com::sun::star::uno::Reference< XAccessible >& _rxOwningAccessible,
43 const com::sun::star::uno::Reference< XAccessibleContext >& _xControlChild,
44 IAccessibleTableProvider& _rBrowseBox,
45 const Reference< XWindow >& _xFocusWindow,
46 sal_Int32 _nRowPos,
47 sal_uInt16 _nColPos)
48 :AccessibleBrowseBoxCell( _rxParent, _rBrowseBox, _xFocusWindow, _nRowPos, _nColPos )
49 ,OAccessibleContextWrapperHelper( ::comphelper::getProcessComponentContext(), rBHelper, _xControlChild, _rxOwningAccessible, _rxParent )
51 aggregateProxy( m_refCount, *this );
54 // -----------------------------------------------------------------------------
55 EditBrowseBoxTableCell::~EditBrowseBoxTableCell()
57 if ( !rBHelper.bDisposed )
59 acquire(); // to prevent duplicate dtor calls
60 dispose();
64 // -----------------------------------------------------------------------------
65 OUString SAL_CALL EditBrowseBoxTableCell::getImplementationName() throw ( ::com::sun::star::uno::RuntimeException )
67 return OUString( "com.sun.star.comp.svtools.TableCellProxy" );
70 // -----------------------------------------------------------------------------
71 IMPLEMENT_FORWARD_XINTERFACE2( EditBrowseBoxTableCell, AccessibleBrowseBoxCell, OAccessibleContextWrapperHelper )
73 // -----------------------------------------------------------------------------
74 IMPLEMENT_FORWARD_XTYPEPROVIDER2( EditBrowseBoxTableCell, AccessibleBrowseBoxCell, OAccessibleContextWrapperHelper )
76 // -----------------------------------------------------------------------------
77 void EditBrowseBoxTableCell::notifyTranslatedEvent( const AccessibleEventObject& _rEvent ) throw (RuntimeException)
79 commitEvent( _rEvent.EventId, _rEvent.NewValue, _rEvent.OldValue );
82 // XAccessibleComponent
83 // -----------------------------------------------------------------------------
84 sal_Int32 SAL_CALL EditBrowseBoxTableCell::getForeground( ) throw (RuntimeException)
86 SolarMethodGuard aGuard( *this );
87 Reference< XAccessibleComponent > xAccComp( m_xInnerContext, UNO_QUERY );
88 if ( xAccComp.is() )
89 return xAccComp->getForeground();
90 return 0;
93 // -----------------------------------------------------------------------------
94 sal_Int32 SAL_CALL EditBrowseBoxTableCell::getBackground( ) throw (RuntimeException)
96 SolarMethodGuard aGuard( *this );
97 Reference< XAccessibleComponent > xAccComp( m_xInnerContext, UNO_QUERY );
98 if ( xAccComp.is() )
99 return xAccComp->getBackground();
100 return 0;
103 // -----------------------------------------------------------------------------
104 Reference< XAccessible > SAL_CALL EditBrowseBoxTableCell::getAccessibleParent( ) throw (RuntimeException)
106 return m_xParentAccessible;
109 // -----------------------------------------------------------------------------
110 OUString SAL_CALL EditBrowseBoxTableCell::getAccessibleDescription() throw ( RuntimeException )
112 SolarMethodGuard aGuard( *this );
113 return m_xInnerContext->getAccessibleDescription();
116 // -----------------------------------------------------------------------------
117 OUString SAL_CALL EditBrowseBoxTableCell::getAccessibleName() throw ( RuntimeException )
119 SolarMethodGuard aGuard( *this );
121 // TODO: localize this!
122 OUStringBuffer sName(mpBrowseBox->GetColumnDescription( ::sal::static_int_cast< sal_uInt16 >( getColumnPos() ) ));
123 if ( 0 == sName.getLength() )
125 sName.appendAscii("Column ");
126 sName.append(getColumnPos());
129 sName.appendAscii(", Row ");
130 sName.append(getRowPos());
132 return sName.makeStringAndClear();
135 // -----------------------------------------------------------------------------
136 Reference< XAccessibleRelationSet > SAL_CALL EditBrowseBoxTableCell::getAccessibleRelationSet() throw ( RuntimeException )
138 SolarMethodGuard aGuard( *this );
139 return OAccessibleContextWrapperHelper::getAccessibleRelationSet( );
142 // -----------------------------------------------------------------------------
143 Reference<XAccessibleStateSet > SAL_CALL EditBrowseBoxTableCell::getAccessibleStateSet() throw ( RuntimeException )
145 SolarMethodGuard aGuard( *this );
146 return m_xInnerContext->getAccessibleStateSet();
147 // TODO: shouldn't we add an ACTIVE here? Isn't the EditBrowseBoxTableCell always ACTIVE?
150 // -----------------------------------------------------------------------------
151 sal_Int32 SAL_CALL EditBrowseBoxTableCell::getAccessibleChildCount( ) throw (RuntimeException)
153 SolarMethodGuard aGuard( *this );
154 return OAccessibleContextWrapperHelper::getAccessibleChildCount();
157 // -----------------------------------------------------------------------------
158 Reference< XAccessible > SAL_CALL EditBrowseBoxTableCell::getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException)
160 SolarMethodGuard aGuard( *this );
161 return OAccessibleContextWrapperHelper::getAccessibleChild( i );
164 // -----------------------------------------------------------------------------
165 sal_Int16 SAL_CALL EditBrowseBoxTableCell::getAccessibleRole() throw ( RuntimeException )
167 SolarMethodGuard aGuard( *this );
168 return m_xInnerContext->getAccessibleRole( );
170 // -----------------------------------------------------------------------------
171 void SAL_CALL EditBrowseBoxTableCell::dispose() throw( RuntimeException )
173 // simply disambiguate. Note that the OComponentHelper base in AccessibleBrowseBoxCell
174 // will call our "disposing()", which will call "dispose()" on the OAccessibleContextWrapperHelper
175 // so there is no need to do this here.
176 AccessibleBrowseBoxCell::dispose();
178 // -----------------------------------------------------------------------------
179 void SAL_CALL EditBrowseBoxTableCell::disposing( const EventObject& _rSource ) throw (RuntimeException)
181 AccessibleBrowseBoxCell::disposing( _rSource );
182 OAccessibleContextWrapperHelper::disposing( _rSource );
184 // -----------------------------------------------------------------------------
185 void SAL_CALL EditBrowseBoxTableCell::disposing()
187 SolarMethodGuard aGuard( *this, false );
188 OAccessibleContextWrapperHelper::dispose();
189 // TODO: do we need to dispose our inner object? The base class does this, but is it a good idea?
190 AccessibleBrowseBoxCell::disposing();
192 // =============================================================================
193 // = EditBrowseBoxTableCell
194 // =============================================================================
195 EditBrowseBoxTableCellAccess::EditBrowseBoxTableCellAccess(
196 const Reference< XAccessible >& _rxParent, const Reference< XAccessible > _rxControlAccessible,
197 const Reference< XWindow >& _rxFocusWindow,
198 IAccessibleTableProvider& _rBrowseBox, sal_Int32 _nRowPos, sal_uInt16 _nColPos )
199 :EditBrowseBoxTableCellAccess_Base( m_aMutex )
200 ,m_xParent( _rxParent )
201 ,m_xControlAccessible( _rxControlAccessible )
202 ,m_xFocusWindow( _rxFocusWindow )
203 ,m_pBrowseBox( &_rBrowseBox )
204 ,m_nRowPos( _nRowPos )
205 ,m_nColPos( _nColPos )
208 // -----------------------------------------------------------------------------
209 EditBrowseBoxTableCellAccess::~EditBrowseBoxTableCellAccess( )
212 //--------------------------------------------------------------------
213 Reference< XAccessibleContext > SAL_CALL EditBrowseBoxTableCellAccess::getAccessibleContext( ) throw (RuntimeException)
215 if ( !m_pBrowseBox || !m_xControlAccessible.is() )
216 throw DisposedException();
217 Reference< XAccessibleContext > xMyContext( m_aContext );
218 if ( !xMyContext.is() )
220 Reference< XAccessibleContext > xInnerContext = m_xControlAccessible->getAccessibleContext();
221 Reference< XAccessible > xMe( this );
223 xMyContext = new EditBrowseBoxTableCell( m_xParent, xMe, xInnerContext, *m_pBrowseBox, m_xFocusWindow, m_nRowPos, m_nColPos );
224 m_aContext = xMyContext;
226 return xMyContext;
228 //--------------------------------------------------------------------
229 void SAL_CALL EditBrowseBoxTableCellAccess::disposing()
231 // dispose our context, if it still alive
232 Reference< XComponent > xMyContext( (Reference< XAccessibleContext >)m_aContext, UNO_QUERY );
233 if ( xMyContext.is() )
237 xMyContext->dispose();
239 catch( const Exception& e )
241 (void)e;
242 OSL_FAIL( "EditBrowseBoxTableCellAccess::disposing: caught an exception while disposing the context!" );
246 m_pBrowseBox = NULL;
247 m_xControlAccessible.clear();
248 m_aContext = Reference< XAccessibleContext >( );
249 // NO dispose of the inner object there: it is the XAccessible of an window, and disposing
250 // it would delete the respective VCL window
252 // .................................................................................
253 } // namespace accessibility
254 // .................................................................................
256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */