update dev300-m58
[ooovba.git] / accessibility / source / extended / accessibleeditbrowseboxcell.cxx
blobba5ba90cad5f8c7282e6b6a4010c29f4ab7ba9a4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: accessibleeditbrowseboxcell.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_accessibility.hxx"
33 #include <accessibility/extended/accessibleeditbrowseboxcell.hxx>
34 #include <svtools/editbrowsebox.hxx>
35 #include <comphelper/processfactory.hxx>
36 #include <com/sun/star/accessibility/XAccessibleText.hpp>
37 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
40 // .................................................................................
41 namespace accessibility
43 // .................................................................................
45 using namespace com::sun::star::accessibility;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::lang;
48 using namespace ::com::sun::star::awt;
49 using namespace ::comphelper;
50 using namespace ::svt;
52 DBG_NAME( acc_EditBrowseBoxTableCell )
53 // -----------------------------------------------------------------------------
54 EditBrowseBoxTableCell::EditBrowseBoxTableCell(
55 const com::sun::star::uno::Reference< XAccessible >& _rxParent,
56 const com::sun::star::uno::Reference< XAccessible >& _rxOwningAccessible,
57 const com::sun::star::uno::Reference< XAccessibleContext >& _xControlChild,
58 IAccessibleTableProvider& _rBrowseBox,
59 const Reference< XWindow >& _xFocusWindow,
60 sal_Int32 _nRowPos,
61 sal_uInt16 _nColPos)
62 :AccessibleBrowseBoxCell( _rxParent, _rBrowseBox, _xFocusWindow, _nRowPos, _nColPos )
63 ,OAccessibleContextWrapperHelper( ::comphelper::getProcessServiceFactory(), rBHelper, _xControlChild, _rxOwningAccessible, _rxParent )
65 DBG_CTOR( acc_EditBrowseBoxTableCell, NULL );
67 aggregateProxy( m_refCount, *this );
70 // -----------------------------------------------------------------------------
71 EditBrowseBoxTableCell::~EditBrowseBoxTableCell()
73 if ( !rBHelper.bDisposed )
75 acquire(); // to prevent duplicate dtor calls
76 dispose();
79 DBG_DTOR( acc_EditBrowseBoxTableCell, NULL );
82 // -----------------------------------------------------------------------------
83 ::rtl::OUString SAL_CALL EditBrowseBoxTableCell::getImplementationName() throw ( ::com::sun::star::uno::RuntimeException )
85 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.TableCellProxy" ) );
88 // -----------------------------------------------------------------------------
89 IMPLEMENT_FORWARD_XINTERFACE2( EditBrowseBoxTableCell, AccessibleBrowseBoxCell, OAccessibleContextWrapperHelper )
91 // -----------------------------------------------------------------------------
92 IMPLEMENT_FORWARD_XTYPEPROVIDER2( EditBrowseBoxTableCell, AccessibleBrowseBoxCell, OAccessibleContextWrapperHelper )
94 // -----------------------------------------------------------------------------
95 void EditBrowseBoxTableCell::notifyTranslatedEvent( const AccessibleEventObject& _rEvent ) throw (RuntimeException)
97 commitEvent( _rEvent.EventId, _rEvent.NewValue, _rEvent.OldValue );
100 // XAccessibleComponent
101 // -----------------------------------------------------------------------------
102 sal_Int32 SAL_CALL EditBrowseBoxTableCell::getForeground( ) throw (RuntimeException)
104 SolarMethodGuard aGuard( *this );
105 Reference< XAccessibleComponent > xAccComp( m_xInnerContext, UNO_QUERY );
106 if ( xAccComp.is() )
107 return xAccComp->getForeground();
108 return 0;
111 // -----------------------------------------------------------------------------
112 sal_Int32 SAL_CALL EditBrowseBoxTableCell::getBackground( ) throw (RuntimeException)
114 SolarMethodGuard aGuard( *this );
115 Reference< XAccessibleComponent > xAccComp( m_xInnerContext, UNO_QUERY );
116 if ( xAccComp.is() )
117 return xAccComp->getBackground();
118 return 0;
121 // -----------------------------------------------------------------------------
122 Reference< XAccessible > SAL_CALL EditBrowseBoxTableCell::getAccessibleParent( ) throw (RuntimeException)
124 return m_xParentAccessible;
127 // -----------------------------------------------------------------------------
128 ::rtl::OUString SAL_CALL EditBrowseBoxTableCell::getAccessibleDescription() throw ( RuntimeException )
130 SolarMethodGuard aGuard( *this );
131 return m_xInnerContext->getAccessibleDescription();
134 // -----------------------------------------------------------------------------
135 ::rtl::OUString SAL_CALL EditBrowseBoxTableCell::getAccessibleName() throw ( RuntimeException )
137 SolarMethodGuard aGuard( *this );
139 // TODO: localize this!
140 String sName = mpBrowseBox->GetColumnDescription( ::sal::static_int_cast< sal_uInt16 >( getColumnPos() ) );
141 if ( 0 == sName.Len() )
143 sName = String::CreateFromAscii( "Column " );
144 sName += String::CreateFromInt32( getColumnPos( ) );
147 sName += String::CreateFromAscii( ", Row " );
148 sName += String::CreateFromInt32( getRowPos( ) );
150 return ::rtl::OUString( sName );
153 // -----------------------------------------------------------------------------
154 Reference< XAccessibleRelationSet > SAL_CALL EditBrowseBoxTableCell::getAccessibleRelationSet() throw ( RuntimeException )
156 SolarMethodGuard aGuard( *this );
157 return OAccessibleContextWrapperHelper::getAccessibleRelationSet( );
160 // -----------------------------------------------------------------------------
161 Reference<XAccessibleStateSet > SAL_CALL EditBrowseBoxTableCell::getAccessibleStateSet() throw ( RuntimeException )
163 SolarMethodGuard aGuard( *this );
164 return m_xInnerContext->getAccessibleStateSet();
165 // TODO: shouldn't we add an ACTIVE here? Isn't the EditBrowseBoxTableCell always ACTIVE?
168 // -----------------------------------------------------------------------------
169 sal_Int32 SAL_CALL EditBrowseBoxTableCell::getAccessibleChildCount( ) throw (RuntimeException)
171 SolarMethodGuard aGuard( *this );
172 return OAccessibleContextWrapperHelper::getAccessibleChildCount();
175 // -----------------------------------------------------------------------------
176 Reference< XAccessible > SAL_CALL EditBrowseBoxTableCell::getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException)
178 SolarMethodGuard aGuard( *this );
179 return OAccessibleContextWrapperHelper::getAccessibleChild( i );
182 // -----------------------------------------------------------------------------
183 sal_Int16 SAL_CALL EditBrowseBoxTableCell::getAccessibleRole() throw ( RuntimeException )
185 SolarMethodGuard aGuard( *this );
186 return m_xInnerContext->getAccessibleRole( );
188 // -----------------------------------------------------------------------------
189 void SAL_CALL EditBrowseBoxTableCell::dispose() throw( RuntimeException )
191 // simply disambiguate. Note that the OComponentHelper base in AccessibleBrowseBoxCell
192 // will call our "disposing()", which will call "dispose()" on the OAccessibleContextWrapperHelper
193 // so there is no need to do this here.
194 AccessibleBrowseBoxCell::dispose();
196 // -----------------------------------------------------------------------------
197 void SAL_CALL EditBrowseBoxTableCell::disposing( const EventObject& _rSource ) throw (RuntimeException)
199 AccessibleBrowseBoxCell::disposing( _rSource );
200 OAccessibleContextWrapperHelper::disposing( _rSource );
202 // -----------------------------------------------------------------------------
203 void SAL_CALL EditBrowseBoxTableCell::disposing()
205 SolarMethodGuard aGuard( *this, false );
206 OAccessibleContextWrapperHelper::dispose();
207 // TODO: do we need to dispose our inner object? The base class does this, but is it a good idea?
208 AccessibleBrowseBoxCell::disposing();
210 // =============================================================================
211 // = EditBrowseBoxTableCell
212 // =============================================================================
213 DBG_NAME( EditBrowseBoxTableCellAccess )
214 // -----------------------------------------------------------------------------
215 EditBrowseBoxTableCellAccess::EditBrowseBoxTableCellAccess(
216 const Reference< XAccessible >& _rxParent, const Reference< XAccessible > _rxControlAccessible,
217 const Reference< XWindow >& _rxFocusWindow,
218 IAccessibleTableProvider& _rBrowseBox, sal_Int32 _nRowPos, sal_uInt16 _nColPos )
219 :EditBrowseBoxTableCellAccess_Base( m_aMutex )
220 ,m_xParent( _rxParent )
221 ,m_xControlAccessible( _rxControlAccessible )
222 ,m_xFocusWindow( _rxFocusWindow )
223 ,m_pBrowseBox( &_rBrowseBox )
224 ,m_nRowPos( _nRowPos )
225 ,m_nColPos( _nColPos )
227 DBG_CTOR( EditBrowseBoxTableCellAccess, NULL );
229 // -----------------------------------------------------------------------------
230 EditBrowseBoxTableCellAccess::~EditBrowseBoxTableCellAccess( )
232 DBG_DTOR( EditBrowseBoxTableCellAccess, NULL );
234 //--------------------------------------------------------------------
235 Reference< XAccessibleContext > SAL_CALL EditBrowseBoxTableCellAccess::getAccessibleContext( ) throw (RuntimeException)
237 if ( !m_pBrowseBox || !m_xControlAccessible.is() )
238 throw DisposedException();
239 Reference< XAccessibleContext > xMyContext( m_aContext );
240 if ( !xMyContext.is() )
242 Reference< XAccessibleContext > xInnerContext = m_xControlAccessible->getAccessibleContext();
243 Reference< XAccessible > xMe( this );
245 xMyContext = new EditBrowseBoxTableCell( m_xParent, xMe, xInnerContext, *m_pBrowseBox, m_xFocusWindow, m_nRowPos, m_nColPos );
246 m_aContext = xMyContext;
248 return xMyContext;
250 //--------------------------------------------------------------------
251 void SAL_CALL EditBrowseBoxTableCellAccess::disposing()
253 // dispose our context, if it still alive
254 Reference< XComponent > xMyContext( (Reference< XAccessibleContext >)m_aContext, UNO_QUERY );
255 if ( xMyContext.is() )
259 xMyContext->dispose();
261 catch( const Exception& e )
263 (void)e;
264 OSL_ENSURE( false, "EditBrowseBoxTableCellAccess::disposing: caught an exception while disposing the context!" );
268 m_pBrowseBox = NULL;
269 m_xControlAccessible.clear();
270 m_aContext = Reference< XAccessibleContext >( );
271 // NO dispose of the inner object there: it is the XAccessible of an window, and disposing
272 // it would delete the respective VCL window
274 // .................................................................................
275 } // namespace accessibility
276 // .................................................................................