update dev300-m58
[ooovba.git] / accessibility / source / extended / AccessibleBrowseBoxCheckBoxCell.cxx
blob8f2499794040e04c455654d9ffe7c2401e0e77b1
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: AccessibleBrowseBoxCheckBoxCell.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/AccessibleBrowseBoxCheckBoxCell.hxx>
34 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
35 #include <svtools/accessibletableprovider.hxx>
37 namespace accessibility
39 using namespace com::sun::star::accessibility;
40 using namespace com::sun::star::uno;
41 using namespace com::sun::star::accessibility::AccessibleEventId;
42 using namespace ::svt;
44 AccessibleCheckBoxCell::AccessibleCheckBoxCell(const Reference<XAccessible >& _rxParent,
45 IAccessibleTableProvider& _rBrowseBox,
46 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow,
47 sal_Int32 _nRowPos,
48 sal_uInt16 _nColPos
49 ,const TriState& _eState,
50 sal_Bool _bEnabled,
51 sal_Bool _bIsTriState)
52 :AccessibleBrowseBoxCell(_rxParent, _rBrowseBox, _xFocusWindow, _nRowPos, _nColPos, BBTYPE_CHECKBOXCELL)
53 ,m_eState(_eState)
54 ,m_bEnabled(_bEnabled)
55 ,m_bIsTriState(_bIsTriState)
58 // -----------------------------------------------------------------------------
59 IMPLEMENT_FORWARD_XINTERFACE2( AccessibleCheckBoxCell, AccessibleBrowseBoxCell, AccessibleCheckBoxCell_BASE )
60 // -----------------------------------------------------------------------------
61 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleCheckBoxCell, AccessibleBrowseBoxCell, AccessibleCheckBoxCell_BASE )
62 //--------------------------------------------------------------------
63 Reference< XAccessibleContext > SAL_CALL AccessibleCheckBoxCell::getAccessibleContext( ) throw (RuntimeException)
65 ensureIsAlive();
66 return this;
68 // -----------------------------------------------------------------------------
69 ::utl::AccessibleStateSetHelper* AccessibleCheckBoxCell::implCreateStateSetHelper()
71 ::utl::AccessibleStateSetHelper* pStateSetHelper =
72 AccessibleBrowseBoxCell::implCreateStateSetHelper();
73 if( isAlive() )
75 mpBrowseBox->FillAccessibleStateSetForCell(
76 *pStateSetHelper, getRowPos(), static_cast< sal_uInt16 >( getColumnPos() ) );
77 if ( m_eState == STATE_CHECK )
78 pStateSetHelper->AddState( AccessibleStateType::CHECKED );
80 return pStateSetHelper;
82 // -----------------------------------------------------------------------------
83 // -----------------------------------------------------------------------------
84 // XAccessibleValue
85 // -----------------------------------------------------------------------------
87 Any SAL_CALL AccessibleCheckBoxCell::getCurrentValue( ) throw (RuntimeException)
89 ::osl::MutexGuard aGuard( getOslMutex() );
91 sal_Int32 nValue = 0;
92 switch( m_eState )
94 case STATE_NOCHECK:
95 nValue = 0;
96 break;
97 case STATE_CHECK:
98 nValue = 1;
99 break;
100 case STATE_DONTKNOW:
101 nValue = 2;
102 break;
104 return makeAny(nValue);
107 // -----------------------------------------------------------------------------
109 sal_Bool SAL_CALL AccessibleCheckBoxCell::setCurrentValue( const Any& ) throw (RuntimeException)
111 return sal_False;
114 // -----------------------------------------------------------------------------
116 Any SAL_CALL AccessibleCheckBoxCell::getMaximumValue( ) throw (RuntimeException)
118 ::osl::MutexGuard aGuard( getOslMutex() );
120 Any aValue;
122 if ( m_bIsTriState )
123 aValue <<= (sal_Int32) 2;
124 else
125 aValue <<= (sal_Int32) 1;
127 return aValue;
130 // -----------------------------------------------------------------------------
132 Any SAL_CALL AccessibleCheckBoxCell::getMinimumValue( ) throw (RuntimeException)
134 Any aValue;
135 aValue <<= (sal_Int32) 0;
137 return aValue;
139 // -----------------------------------------------------------------------------
140 // XAccessibleContext
141 sal_Int32 SAL_CALL AccessibleCheckBoxCell::getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException)
143 return 0;
145 // -----------------------------------------------------------------------------
146 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL AccessibleCheckBoxCell::getAccessibleChild( sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
148 throw ::com::sun::star::lang::IndexOutOfBoundsException();
150 // -----------------------------------------------------------------------------
151 ::rtl::OUString SAL_CALL AccessibleCheckBoxCell::getImplementationName() throw ( ::com::sun::star::uno::RuntimeException )
153 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.TableCheckBoxCell" ) );
155 // -----------------------------------------------------------------------------
156 sal_Int32 SAL_CALL AccessibleCheckBoxCell::getAccessibleIndexInParent()
157 throw ( ::com::sun::star::uno::RuntimeException )
159 ::osl::MutexGuard aGuard( getOslMutex() );
161 return ( getRowPos() * mpBrowseBox->GetColumnCount() ) + getColumnPos();
163 // -----------------------------------------------------------------------------
164 void AccessibleCheckBoxCell::SetChecked( sal_Bool _bChecked )
166 m_eState = _bChecked ? STATE_CHECK : STATE_NOCHECK;
167 Any aOldValue, aNewValue;
168 if ( _bChecked )
169 aNewValue <<= AccessibleStateType::CHECKED;
170 else
171 aOldValue <<= AccessibleStateType::CHECKED;
172 commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue );