merged tag ooo/DEV300_m102
[LibreOffice.git] / accessibility / source / extended / AccessibleBrowseBoxCheckBoxCell.cxx
blob560878b544f3e925ebe8a21ccbab81a502433987
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_accessibility.hxx"
30 #include <accessibility/extended/AccessibleBrowseBoxCheckBoxCell.hxx>
31 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
32 #include <svtools/accessibletableprovider.hxx>
34 namespace accessibility
36 using namespace com::sun::star::accessibility;
37 using namespace com::sun::star::uno;
38 using namespace com::sun::star::accessibility::AccessibleEventId;
39 using namespace ::svt;
41 AccessibleCheckBoxCell::AccessibleCheckBoxCell(const Reference<XAccessible >& _rxParent,
42 IAccessibleTableProvider& _rBrowseBox,
43 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow,
44 sal_Int32 _nRowPos,
45 sal_uInt16 _nColPos
46 ,const TriState& _eState,
47 sal_Bool _bEnabled,
48 sal_Bool _bIsTriState)
49 :AccessibleBrowseBoxCell(_rxParent, _rBrowseBox, _xFocusWindow, _nRowPos, _nColPos, BBTYPE_CHECKBOXCELL)
50 ,m_eState(_eState)
51 ,m_bEnabled(_bEnabled)
52 ,m_bIsTriState(_bIsTriState)
55 // -----------------------------------------------------------------------------
56 IMPLEMENT_FORWARD_XINTERFACE2( AccessibleCheckBoxCell, AccessibleBrowseBoxCell, AccessibleCheckBoxCell_BASE )
57 // -----------------------------------------------------------------------------
58 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleCheckBoxCell, AccessibleBrowseBoxCell, AccessibleCheckBoxCell_BASE )
59 //--------------------------------------------------------------------
60 Reference< XAccessibleContext > SAL_CALL AccessibleCheckBoxCell::getAccessibleContext( ) throw (RuntimeException)
62 ensureIsAlive();
63 return this;
65 // -----------------------------------------------------------------------------
66 ::utl::AccessibleStateSetHelper* AccessibleCheckBoxCell::implCreateStateSetHelper()
68 ::utl::AccessibleStateSetHelper* pStateSetHelper =
69 AccessibleBrowseBoxCell::implCreateStateSetHelper();
70 if( isAlive() )
72 mpBrowseBox->FillAccessibleStateSetForCell(
73 *pStateSetHelper, getRowPos(), static_cast< sal_uInt16 >( getColumnPos() ) );
74 if ( m_eState == STATE_CHECK )
75 pStateSetHelper->AddState( AccessibleStateType::CHECKED );
77 return pStateSetHelper;
79 // -----------------------------------------------------------------------------
80 // -----------------------------------------------------------------------------
81 // XAccessibleValue
82 // -----------------------------------------------------------------------------
84 Any SAL_CALL AccessibleCheckBoxCell::getCurrentValue( ) throw (RuntimeException)
86 ::osl::MutexGuard aGuard( getOslMutex() );
88 sal_Int32 nValue = 0;
89 switch( m_eState )
91 case STATE_NOCHECK:
92 nValue = 0;
93 break;
94 case STATE_CHECK:
95 nValue = 1;
96 break;
97 case STATE_DONTKNOW:
98 nValue = 2;
99 break;
101 return makeAny(nValue);
104 // -----------------------------------------------------------------------------
106 sal_Bool SAL_CALL AccessibleCheckBoxCell::setCurrentValue( const Any& ) throw (RuntimeException)
108 return sal_False;
111 // -----------------------------------------------------------------------------
113 Any SAL_CALL AccessibleCheckBoxCell::getMaximumValue( ) throw (RuntimeException)
115 ::osl::MutexGuard aGuard( getOslMutex() );
117 Any aValue;
119 if ( m_bIsTriState )
120 aValue <<= (sal_Int32) 2;
121 else
122 aValue <<= (sal_Int32) 1;
124 return aValue;
127 // -----------------------------------------------------------------------------
129 Any SAL_CALL AccessibleCheckBoxCell::getMinimumValue( ) throw (RuntimeException)
131 Any aValue;
132 aValue <<= (sal_Int32) 0;
134 return aValue;
136 // -----------------------------------------------------------------------------
137 // XAccessibleContext
138 sal_Int32 SAL_CALL AccessibleCheckBoxCell::getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException)
140 return 0;
142 // -----------------------------------------------------------------------------
143 ::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)
145 throw ::com::sun::star::lang::IndexOutOfBoundsException();
147 // -----------------------------------------------------------------------------
148 ::rtl::OUString SAL_CALL AccessibleCheckBoxCell::getImplementationName() throw ( ::com::sun::star::uno::RuntimeException )
150 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.TableCheckBoxCell" ) );
152 // -----------------------------------------------------------------------------
153 sal_Int32 SAL_CALL AccessibleCheckBoxCell::getAccessibleIndexInParent()
154 throw ( ::com::sun::star::uno::RuntimeException )
156 ::osl::MutexGuard aGuard( getOslMutex() );
158 return ( getRowPos() * mpBrowseBox->GetColumnCount() ) + getColumnPos();
160 // -----------------------------------------------------------------------------
161 void AccessibleCheckBoxCell::SetChecked( sal_Bool _bChecked )
163 m_eState = _bChecked ? STATE_CHECK : STATE_NOCHECK;
164 Any aOldValue, aNewValue;
165 if ( _bChecked )
166 aNewValue <<= AccessibleStateType::CHECKED;
167 else
168 aOldValue <<= AccessibleStateType::CHECKED;
169 commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue );