10841af79SAndrew Rist /************************************************************** 2*d69df039Smseidel * 30841af79SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 40841af79SAndrew Rist * or more contributor license agreements. See the NOTICE file 50841af79SAndrew Rist * distributed with this work for additional information 60841af79SAndrew Rist * regarding copyright ownership. The ASF licenses this file 70841af79SAndrew Rist * to you under the Apache License, Version 2.0 (the 80841af79SAndrew Rist * "License"); you may not use this file except in compliance 90841af79SAndrew Rist * with the License. You may obtain a copy of the License at 10*d69df039Smseidel * 110841af79SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*d69df039Smseidel * 130841af79SAndrew Rist * Unless required by applicable law or agreed to in writing, 140841af79SAndrew Rist * software distributed under the License is distributed on an 150841af79SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 160841af79SAndrew Rist * KIND, either express or implied. See the License for the 170841af79SAndrew Rist * specific language governing permissions and limitations 180841af79SAndrew Rist * under the License. 19*d69df039Smseidel * 200841af79SAndrew Rist *************************************************************/ 210841af79SAndrew Rist 220841af79SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_accessibility.hxx" 26cdf0e10cSrcweir #include <accessibility/extended/accessibleeditbrowseboxcell.hxx> 27cdf0e10cSrcweir #include <svtools/editbrowsebox.hxx> 28cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 29cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleText.hpp> 30cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 31cdf0e10cSrcweir 32cdf0e10cSrcweir 33cdf0e10cSrcweir // ................................................................................. 34cdf0e10cSrcweir namespace accessibility 35cdf0e10cSrcweir { 36cdf0e10cSrcweir // ................................................................................. 37cdf0e10cSrcweir 38cdf0e10cSrcweir using namespace com::sun::star::accessibility; 39cdf0e10cSrcweir using namespace ::com::sun::star::uno; 40cdf0e10cSrcweir using namespace ::com::sun::star::lang; 41cdf0e10cSrcweir using namespace ::com::sun::star::awt; 42cdf0e10cSrcweir using namespace ::comphelper; 43cdf0e10cSrcweir using namespace ::svt; 44cdf0e10cSrcweir DBG_NAME(acc_EditBrowseBoxTableCell)45cdf0e10cSrcweir DBG_NAME( acc_EditBrowseBoxTableCell ) 46cdf0e10cSrcweir // ----------------------------------------------------------------------------- 47cdf0e10cSrcweir EditBrowseBoxTableCell::EditBrowseBoxTableCell( 48cdf0e10cSrcweir const com::sun::star::uno::Reference< XAccessible >& _rxParent, 49cdf0e10cSrcweir const com::sun::star::uno::Reference< XAccessible >& _rxOwningAccessible, 50cdf0e10cSrcweir const com::sun::star::uno::Reference< XAccessibleContext >& _xControlChild, 51cdf0e10cSrcweir IAccessibleTableProvider& _rBrowseBox, 52cdf0e10cSrcweir const Reference< XWindow >& _xFocusWindow, 53cdf0e10cSrcweir sal_Int32 _nRowPos, 54cdf0e10cSrcweir sal_uInt16 _nColPos) 55cdf0e10cSrcweir :AccessibleBrowseBoxCell( _rxParent, _rBrowseBox, _xFocusWindow, _nRowPos, _nColPos ) 56cdf0e10cSrcweir ,OAccessibleContextWrapperHelper( ::comphelper::getProcessServiceFactory(), rBHelper, _xControlChild, _rxOwningAccessible, _rxParent ) 57cdf0e10cSrcweir { 58cdf0e10cSrcweir DBG_CTOR( acc_EditBrowseBoxTableCell, NULL ); 59cdf0e10cSrcweir 60cdf0e10cSrcweir aggregateProxy( m_refCount, *this ); 61cdf0e10cSrcweir } 62cdf0e10cSrcweir 63cdf0e10cSrcweir // ----------------------------------------------------------------------------- ~EditBrowseBoxTableCell()64cdf0e10cSrcweir EditBrowseBoxTableCell::~EditBrowseBoxTableCell() 65cdf0e10cSrcweir { 66cdf0e10cSrcweir if ( !rBHelper.bDisposed ) 67cdf0e10cSrcweir { 68cdf0e10cSrcweir acquire(); // to prevent duplicate dtor calls 69cdf0e10cSrcweir dispose(); 70cdf0e10cSrcweir } 71cdf0e10cSrcweir 72cdf0e10cSrcweir DBG_DTOR( acc_EditBrowseBoxTableCell, NULL ); 73cdf0e10cSrcweir } 74cdf0e10cSrcweir 75cdf0e10cSrcweir // ----------------------------------------------------------------------------- getImplementationName()76cdf0e10cSrcweir ::rtl::OUString SAL_CALL EditBrowseBoxTableCell::getImplementationName() throw ( ::com::sun::star::uno::RuntimeException ) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.TableCellProxy" ) ); 79cdf0e10cSrcweir } 80cdf0e10cSrcweir 81cdf0e10cSrcweir // ----------------------------------------------------------------------------- IMPLEMENT_FORWARD_XINTERFACE2(EditBrowseBoxTableCell,AccessibleBrowseBoxCell,OAccessibleContextWrapperHelper)82cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( EditBrowseBoxTableCell, AccessibleBrowseBoxCell, OAccessibleContextWrapperHelper ) 83cdf0e10cSrcweir 84cdf0e10cSrcweir // ----------------------------------------------------------------------------- 85cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( EditBrowseBoxTableCell, AccessibleBrowseBoxCell, OAccessibleContextWrapperHelper ) 86cdf0e10cSrcweir 87cdf0e10cSrcweir // ----------------------------------------------------------------------------- 88cdf0e10cSrcweir void EditBrowseBoxTableCell::notifyTranslatedEvent( const AccessibleEventObject& _rEvent ) throw (RuntimeException) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir commitEvent( _rEvent.EventId, _rEvent.NewValue, _rEvent.OldValue ); 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir // XAccessibleComponent 94cdf0e10cSrcweir // ----------------------------------------------------------------------------- getForeground()95cdf0e10cSrcweir sal_Int32 SAL_CALL EditBrowseBoxTableCell::getForeground( ) throw (RuntimeException) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir SolarMethodGuard aGuard( *this ); 98cdf0e10cSrcweir Reference< XAccessibleComponent > xAccComp( m_xInnerContext, UNO_QUERY ); 99cdf0e10cSrcweir if ( xAccComp.is() ) 100cdf0e10cSrcweir return xAccComp->getForeground(); 101cdf0e10cSrcweir return 0; 102cdf0e10cSrcweir } 103cdf0e10cSrcweir 104cdf0e10cSrcweir // ----------------------------------------------------------------------------- getBackground()105cdf0e10cSrcweir sal_Int32 SAL_CALL EditBrowseBoxTableCell::getBackground( ) throw (RuntimeException) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir SolarMethodGuard aGuard( *this ); 108cdf0e10cSrcweir Reference< XAccessibleComponent > xAccComp( m_xInnerContext, UNO_QUERY ); 109cdf0e10cSrcweir if ( xAccComp.is() ) 110cdf0e10cSrcweir return xAccComp->getBackground(); 111cdf0e10cSrcweir return 0; 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleParent()115cdf0e10cSrcweir Reference< XAccessible > SAL_CALL EditBrowseBoxTableCell::getAccessibleParent( ) throw (RuntimeException) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir return m_xParentAccessible; 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleDescription()121cdf0e10cSrcweir ::rtl::OUString SAL_CALL EditBrowseBoxTableCell::getAccessibleDescription() throw ( RuntimeException ) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir SolarMethodGuard aGuard( *this ); 124cdf0e10cSrcweir return m_xInnerContext->getAccessibleDescription(); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleName()128cdf0e10cSrcweir ::rtl::OUString SAL_CALL EditBrowseBoxTableCell::getAccessibleName() throw ( RuntimeException ) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir SolarMethodGuard aGuard( *this ); 131cdf0e10cSrcweir 132*d69df039Smseidel // TODO: localize this! 133*d69df039Smseidel //String sName = mpBrowseBox->GetColumnDescription( getColumnPos( ) ); 134cdf0e10cSrcweir 135*d69df039Smseidel //if ( 0 == sName.Len() ) 136*d69df039Smseidel //{ 137*d69df039Smseidel // sName = String::CreateFromAscii( "Column " ); 138*d69df039Smseidel String sName = String::CreateFromAscii( "Column " ); 139*d69df039Smseidel sName += String::CreateFromInt32( getColumnPos( ) - 1 ); 140*d69df039Smseidel //} 141*d69df039Smseidel sName += String::CreateFromAscii( ", Row " ); 142*d69df039Smseidel sName += String::CreateFromInt32( getRowPos( ) ); 143*d69df039Smseidel 144*d69df039Smseidel return ::rtl::OUString( sName ); 145cdf0e10cSrcweir } 146cdf0e10cSrcweir 147cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleRelationSet()148cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL EditBrowseBoxTableCell::getAccessibleRelationSet() throw ( RuntimeException ) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir SolarMethodGuard aGuard( *this ); 151cdf0e10cSrcweir return OAccessibleContextWrapperHelper::getAccessibleRelationSet( ); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir 154cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleStateSet()155cdf0e10cSrcweir Reference<XAccessibleStateSet > SAL_CALL EditBrowseBoxTableCell::getAccessibleStateSet() throw ( RuntimeException ) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir SolarMethodGuard aGuard( *this ); 158cdf0e10cSrcweir return m_xInnerContext->getAccessibleStateSet(); 159cdf0e10cSrcweir // TODO: shouldn't we add an ACTIVE here? Isn't the EditBrowseBoxTableCell always ACTIVE? 160cdf0e10cSrcweir } 161cdf0e10cSrcweir 162cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleChildCount()163cdf0e10cSrcweir sal_Int32 SAL_CALL EditBrowseBoxTableCell::getAccessibleChildCount( ) throw (RuntimeException) 164cdf0e10cSrcweir { 165cdf0e10cSrcweir SolarMethodGuard aGuard( *this ); 166cdf0e10cSrcweir return OAccessibleContextWrapperHelper::getAccessibleChildCount(); 167cdf0e10cSrcweir } 168cdf0e10cSrcweir 169cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleChild(sal_Int32 i)170cdf0e10cSrcweir Reference< XAccessible > SAL_CALL EditBrowseBoxTableCell::getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException) 171cdf0e10cSrcweir { 172cdf0e10cSrcweir SolarMethodGuard aGuard( *this ); 173cdf0e10cSrcweir return OAccessibleContextWrapperHelper::getAccessibleChild( i ); 174cdf0e10cSrcweir } 175cdf0e10cSrcweir 176cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleRole()177cdf0e10cSrcweir sal_Int16 SAL_CALL EditBrowseBoxTableCell::getAccessibleRole() throw ( RuntimeException ) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir SolarMethodGuard aGuard( *this ); 180cdf0e10cSrcweir return m_xInnerContext->getAccessibleRole( ); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir // ----------------------------------------------------------------------------- dispose()183cdf0e10cSrcweir void SAL_CALL EditBrowseBoxTableCell::dispose() throw( RuntimeException ) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir // simply disambiguate. Note that the OComponentHelper base in AccessibleBrowseBoxCell 186cdf0e10cSrcweir // will call our "disposing()", which will call "dispose()" on the OAccessibleContextWrapperHelper 187cdf0e10cSrcweir // so there is no need to do this here. 188cdf0e10cSrcweir AccessibleBrowseBoxCell::dispose(); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir // ----------------------------------------------------------------------------- disposing(const EventObject & _rSource)191cdf0e10cSrcweir void SAL_CALL EditBrowseBoxTableCell::disposing( const EventObject& _rSource ) throw (RuntimeException) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir AccessibleBrowseBoxCell::disposing( _rSource ); 194cdf0e10cSrcweir OAccessibleContextWrapperHelper::disposing( _rSource ); 195cdf0e10cSrcweir } 196cdf0e10cSrcweir // ----------------------------------------------------------------------------- disposing()197cdf0e10cSrcweir void SAL_CALL EditBrowseBoxTableCell::disposing() 198cdf0e10cSrcweir { 199cdf0e10cSrcweir SolarMethodGuard aGuard( *this, false ); 200cdf0e10cSrcweir OAccessibleContextWrapperHelper::dispose(); 201cdf0e10cSrcweir // TODO: do we need to dispose our inner object? The base class does this, but is it a good idea? 202cdf0e10cSrcweir AccessibleBrowseBoxCell::disposing(); 203cdf0e10cSrcweir } 204cdf0e10cSrcweir // ============================================================================= 205cdf0e10cSrcweir // = EditBrowseBoxTableCell 206cdf0e10cSrcweir // ============================================================================= DBG_NAME(EditBrowseBoxTableCellAccess)207cdf0e10cSrcweir DBG_NAME( EditBrowseBoxTableCellAccess ) 208cdf0e10cSrcweir // ----------------------------------------------------------------------------- 209cdf0e10cSrcweir EditBrowseBoxTableCellAccess::EditBrowseBoxTableCellAccess( 210cdf0e10cSrcweir const Reference< XAccessible >& _rxParent, const Reference< XAccessible > _rxControlAccessible, 211cdf0e10cSrcweir const Reference< XWindow >& _rxFocusWindow, 212cdf0e10cSrcweir IAccessibleTableProvider& _rBrowseBox, sal_Int32 _nRowPos, sal_uInt16 _nColPos ) 213cdf0e10cSrcweir :EditBrowseBoxTableCellAccess_Base( m_aMutex ) 214cdf0e10cSrcweir ,m_xParent( _rxParent ) 215cdf0e10cSrcweir ,m_xControlAccessible( _rxControlAccessible ) 216cdf0e10cSrcweir ,m_xFocusWindow( _rxFocusWindow ) 217cdf0e10cSrcweir ,m_pBrowseBox( &_rBrowseBox ) 218cdf0e10cSrcweir ,m_nRowPos( _nRowPos ) 219cdf0e10cSrcweir ,m_nColPos( _nColPos ) 220cdf0e10cSrcweir { 221cdf0e10cSrcweir DBG_CTOR( EditBrowseBoxTableCellAccess, NULL ); 222cdf0e10cSrcweir } 223cdf0e10cSrcweir // ----------------------------------------------------------------------------- ~EditBrowseBoxTableCellAccess()224cdf0e10cSrcweir EditBrowseBoxTableCellAccess::~EditBrowseBoxTableCellAccess( ) 225cdf0e10cSrcweir { 226cdf0e10cSrcweir DBG_DTOR( EditBrowseBoxTableCellAccess, NULL ); 227cdf0e10cSrcweir } 228cdf0e10cSrcweir //-------------------------------------------------------------------- getAccessibleContext()229cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL EditBrowseBoxTableCellAccess::getAccessibleContext( ) throw (RuntimeException) 230cdf0e10cSrcweir { 231cdf0e10cSrcweir if ( !m_pBrowseBox || !m_xControlAccessible.is() ) 232cdf0e10cSrcweir throw DisposedException(); 233*d69df039Smseidel Reference< XAccessibleContext > xMyContext( m_aContext ); 234*d69df039Smseidel if ( !xMyContext.is() ) 235*d69df039Smseidel { 236*d69df039Smseidel Reference< XAccessibleContext > xInnerContext = m_xControlAccessible->getAccessibleContext(); 237*d69df039Smseidel Reference< XAccessible > xMe( this ); 238cdf0e10cSrcweir 239*d69df039Smseidel xMyContext = new EditBrowseBoxTableCell( m_xParent, xMe, xInnerContext, *m_pBrowseBox, m_xFocusWindow, m_nRowPos, m_nColPos ); 240*d69df039Smseidel m_aContext = xMyContext; 241*d69df039Smseidel } 242cdf0e10cSrcweir return xMyContext; 243cdf0e10cSrcweir } 244cdf0e10cSrcweir //-------------------------------------------------------------------- disposing()245cdf0e10cSrcweir void SAL_CALL EditBrowseBoxTableCellAccess::disposing() 246cdf0e10cSrcweir { 247*d69df039Smseidel // dispose our context, if it is still alive 248*d69df039Smseidel Reference< XComponent > xMyContext( (Reference< XAccessibleContext >)m_aContext, UNO_QUERY ); 249*d69df039Smseidel if ( xMyContext.is() ) 250*d69df039Smseidel { 251*d69df039Smseidel try 252*d69df039Smseidel { 253*d69df039Smseidel xMyContext->dispose(); 254*d69df039Smseidel } 255*d69df039Smseidel catch( const Exception& e ) 256*d69df039Smseidel { 257*d69df039Smseidel (void)e; 258*d69df039Smseidel OSL_ENSURE( false, "EditBrowseBoxTableCellAccess::disposing: caught an exception while disposing the context!" ); 259*d69df039Smseidel } 260*d69df039Smseidel } 261cdf0e10cSrcweir 262*d69df039Smseidel m_pBrowseBox = NULL; 263*d69df039Smseidel m_xControlAccessible.clear(); 264*d69df039Smseidel m_aContext = Reference< XAccessibleContext >( ); 265*d69df039Smseidel // NO dispose of the inner object there: it is the XAccessible of an window, and disposing 266*d69df039Smseidel // it would delete the respective VCL window 267cdf0e10cSrcweir } 268*d69df039Smseidel 269cdf0e10cSrcweir // ................................................................................. 270cdf0e10cSrcweir } // namespace accessibility 271cdf0e10cSrcweir // ................................................................................. 272