xref: /AOO41X/main/accessibility/source/extended/AccessibleBrowseBoxCheckBoxCell.cxx (revision 0841af799a0c15bc22ec7bb30da88488e7283293)
1*0841af79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*0841af79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*0841af79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*0841af79SAndrew Rist  * distributed with this work for additional information
6*0841af79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*0841af79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*0841af79SAndrew Rist  * "License"); you may not use this file except in compliance
9*0841af79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*0841af79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*0841af79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*0841af79SAndrew Rist  * software distributed under the License is distributed on an
15*0841af79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*0841af79SAndrew Rist  * KIND, either express or implied.  See the License for the
17*0841af79SAndrew Rist  * specific language governing permissions and limitations
18*0841af79SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*0841af79SAndrew Rist  *************************************************************/
21*0841af79SAndrew Rist 
22*0841af79SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_accessibility.hxx"
26cdf0e10cSrcweir #include <accessibility/extended/AccessibleBrowseBoxCheckBoxCell.hxx>
27cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
28cdf0e10cSrcweir #include <svtools/accessibletableprovider.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir namespace accessibility
31cdf0e10cSrcweir {
32cdf0e10cSrcweir 	using namespace com::sun::star::accessibility;
33cdf0e10cSrcweir 	using namespace com::sun::star::uno;
34cdf0e10cSrcweir 	using namespace com::sun::star::accessibility::AccessibleEventId;
35cdf0e10cSrcweir     using namespace ::svt;
36cdf0e10cSrcweir 
AccessibleCheckBoxCell(const Reference<XAccessible> & _rxParent,IAccessibleTableProvider & _rBrowseBox,const::com::sun::star::uno::Reference<::com::sun::star::awt::XWindow> & _xFocusWindow,sal_Int32 _nRowPos,sal_uInt16 _nColPos,const TriState & _eState,sal_Bool _bEnabled,sal_Bool _bIsTriState)37cdf0e10cSrcweir 	AccessibleCheckBoxCell::AccessibleCheckBoxCell(const Reference<XAccessible >& _rxParent,
38cdf0e10cSrcweir 								IAccessibleTableProvider& _rBrowseBox,
39cdf0e10cSrcweir 								const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow,
40cdf0e10cSrcweir 								sal_Int32 _nRowPos,
41cdf0e10cSrcweir 								sal_uInt16 _nColPos
42cdf0e10cSrcweir 								,const TriState& _eState,
43cdf0e10cSrcweir 								sal_Bool _bEnabled,
44cdf0e10cSrcweir 								sal_Bool _bIsTriState)
45cdf0e10cSrcweir         :AccessibleBrowseBoxCell(_rxParent, _rBrowseBox, _xFocusWindow, _nRowPos, _nColPos, BBTYPE_CHECKBOXCELL)
46cdf0e10cSrcweir 		,m_eState(_eState)
47cdf0e10cSrcweir 		,m_bEnabled(_bEnabled)
48cdf0e10cSrcweir 		,m_bIsTriState(_bIsTriState)
49cdf0e10cSrcweir 	{
50cdf0e10cSrcweir 	}
51cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
IMPLEMENT_FORWARD_XINTERFACE2(AccessibleCheckBoxCell,AccessibleBrowseBoxCell,AccessibleCheckBoxCell_BASE)52cdf0e10cSrcweir 	IMPLEMENT_FORWARD_XINTERFACE2( AccessibleCheckBoxCell, AccessibleBrowseBoxCell, AccessibleCheckBoxCell_BASE )
53cdf0e10cSrcweir 		// -----------------------------------------------------------------------------
54cdf0e10cSrcweir 	IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleCheckBoxCell, AccessibleBrowseBoxCell, AccessibleCheckBoxCell_BASE )
55cdf0e10cSrcweir 	//--------------------------------------------------------------------
56cdf0e10cSrcweir 	Reference< XAccessibleContext > SAL_CALL AccessibleCheckBoxCell::getAccessibleContext(  ) throw (RuntimeException)
57cdf0e10cSrcweir 	{
58cdf0e10cSrcweir 		ensureIsAlive();
59cdf0e10cSrcweir 		return this;
60cdf0e10cSrcweir 	}
61cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
implCreateStateSetHelper()62cdf0e10cSrcweir 	::utl::AccessibleStateSetHelper* AccessibleCheckBoxCell::implCreateStateSetHelper()
63cdf0e10cSrcweir 	{
64cdf0e10cSrcweir         ::utl::AccessibleStateSetHelper* pStateSetHelper =
65cdf0e10cSrcweir             AccessibleBrowseBoxCell::implCreateStateSetHelper();
66cdf0e10cSrcweir         if( isAlive() )
67cdf0e10cSrcweir         {
68cdf0e10cSrcweir             mpBrowseBox->FillAccessibleStateSetForCell(
69cdf0e10cSrcweir                 *pStateSetHelper, getRowPos(), static_cast< sal_uInt16 >( getColumnPos() ) );
70cdf0e10cSrcweir             if ( m_eState == STATE_CHECK )
71cdf0e10cSrcweir                 pStateSetHelper->AddState( AccessibleStateType::CHECKED );
72cdf0e10cSrcweir         }
73cdf0e10cSrcweir         return pStateSetHelper;
74cdf0e10cSrcweir 	}
75cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
76cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
77cdf0e10cSrcweir 	// XAccessibleValue
78cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
79cdf0e10cSrcweir 
getCurrentValue()80cdf0e10cSrcweir 	Any SAL_CALL AccessibleCheckBoxCell::getCurrentValue(  ) throw (RuntimeException)
81cdf0e10cSrcweir 	{
82cdf0e10cSrcweir 		::osl::MutexGuard aGuard( getOslMutex() );
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 		sal_Int32 nValue = 0;
85cdf0e10cSrcweir 		switch( m_eState )
86cdf0e10cSrcweir 		{
87cdf0e10cSrcweir 			case STATE_NOCHECK:
88cdf0e10cSrcweir 				nValue = 0;
89cdf0e10cSrcweir 				break;
90cdf0e10cSrcweir 			case STATE_CHECK:
91cdf0e10cSrcweir 				nValue = 1;
92cdf0e10cSrcweir 				break;
93cdf0e10cSrcweir 			case STATE_DONTKNOW:
94cdf0e10cSrcweir 				nValue = 2;
95cdf0e10cSrcweir 				break;
96cdf0e10cSrcweir 		}
97cdf0e10cSrcweir 		return makeAny(nValue);
98cdf0e10cSrcweir 	}
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
101cdf0e10cSrcweir 
setCurrentValue(const Any &)102cdf0e10cSrcweir 	sal_Bool SAL_CALL AccessibleCheckBoxCell::setCurrentValue( const Any& ) throw (RuntimeException)
103cdf0e10cSrcweir 	{
104cdf0e10cSrcweir 		return sal_False;
105cdf0e10cSrcweir 	}
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
108cdf0e10cSrcweir 
getMaximumValue()109cdf0e10cSrcweir 	Any SAL_CALL AccessibleCheckBoxCell::getMaximumValue(  ) throw (RuntimeException)
110cdf0e10cSrcweir 	{
111cdf0e10cSrcweir 		::osl::MutexGuard aGuard( getOslMutex() );
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 		Any aValue;
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 		if ( m_bIsTriState )
116cdf0e10cSrcweir 			aValue <<= (sal_Int32) 2;
117cdf0e10cSrcweir 		else
118cdf0e10cSrcweir 			aValue <<= (sal_Int32) 1;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 		return aValue;
121cdf0e10cSrcweir 	}
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
124cdf0e10cSrcweir 
getMinimumValue()125cdf0e10cSrcweir 	Any SAL_CALL AccessibleCheckBoxCell::getMinimumValue(  ) throw (RuntimeException)
126cdf0e10cSrcweir 	{
127cdf0e10cSrcweir 		Any aValue;
128cdf0e10cSrcweir 		aValue <<= (sal_Int32) 0;
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 		return aValue;
131cdf0e10cSrcweir 	}
132cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
133cdf0e10cSrcweir 	// XAccessibleContext
getAccessibleChildCount()134cdf0e10cSrcweir 	sal_Int32 SAL_CALL AccessibleCheckBoxCell::getAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException)
135cdf0e10cSrcweir 	{
136cdf0e10cSrcweir 		return 0;
137cdf0e10cSrcweir 	}
138cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
getAccessibleChild(sal_Int32)139cdf0e10cSrcweir 	::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)
140cdf0e10cSrcweir 	{
141cdf0e10cSrcweir 		throw ::com::sun::star::lang::IndexOutOfBoundsException();
142cdf0e10cSrcweir 	}
143cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
getImplementationName()144cdf0e10cSrcweir 	::rtl::OUString SAL_CALL AccessibleCheckBoxCell::getImplementationName() throw ( ::com::sun::star::uno::RuntimeException )
145cdf0e10cSrcweir 	{
146cdf0e10cSrcweir 		return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.TableCheckBoxCell" ) );
147cdf0e10cSrcweir 	}
148cdf0e10cSrcweir     // -----------------------------------------------------------------------------
getAccessibleIndexInParent()149cdf0e10cSrcweir     sal_Int32 SAL_CALL AccessibleCheckBoxCell::getAccessibleIndexInParent()
150cdf0e10cSrcweir             throw ( ::com::sun::star::uno::RuntimeException )
151cdf0e10cSrcweir     {
152cdf0e10cSrcweir         ::osl::MutexGuard aGuard( getOslMutex() );
153cdf0e10cSrcweir 
154cdf0e10cSrcweir         return ( getRowPos() * mpBrowseBox->GetColumnCount() ) + getColumnPos();
155cdf0e10cSrcweir     }
156cdf0e10cSrcweir     // -----------------------------------------------------------------------------
SetChecked(sal_Bool _bChecked)157cdf0e10cSrcweir     void AccessibleCheckBoxCell::SetChecked( sal_Bool _bChecked )
158cdf0e10cSrcweir     {
159cdf0e10cSrcweir         m_eState = _bChecked ? STATE_CHECK : STATE_NOCHECK;
160cdf0e10cSrcweir         Any aOldValue, aNewValue;
161cdf0e10cSrcweir         if ( _bChecked )
162cdf0e10cSrcweir             aNewValue <<= AccessibleStateType::CHECKED;
163cdf0e10cSrcweir         else
164cdf0e10cSrcweir             aOldValue <<= AccessibleStateType::CHECKED;
165cdf0e10cSrcweir         commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue );
166cdf0e10cSrcweir     }
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
169