1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleBrowseBoxCheckBoxCell.cxx,v $
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
,
49 ,const TriState
& _eState
,
51 sal_Bool _bIsTriState
)
52 :AccessibleBrowseBoxCell(_rxParent
, _rBrowseBox
, _xFocusWindow
, _nRowPos
, _nColPos
, BBTYPE_CHECKBOXCELL
)
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
)
68 // -----------------------------------------------------------------------------
69 ::utl::AccessibleStateSetHelper
* AccessibleCheckBoxCell::implCreateStateSetHelper()
71 ::utl::AccessibleStateSetHelper
* pStateSetHelper
=
72 AccessibleBrowseBoxCell::implCreateStateSetHelper();
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 // -----------------------------------------------------------------------------
85 // -----------------------------------------------------------------------------
87 Any SAL_CALL
AccessibleCheckBoxCell::getCurrentValue( ) throw (RuntimeException
)
89 ::osl::MutexGuard
aGuard( getOslMutex() );
104 return makeAny(nValue
);
107 // -----------------------------------------------------------------------------
109 sal_Bool SAL_CALL
AccessibleCheckBoxCell::setCurrentValue( const Any
& ) throw (RuntimeException
)
114 // -----------------------------------------------------------------------------
116 Any SAL_CALL
AccessibleCheckBoxCell::getMaximumValue( ) throw (RuntimeException
)
118 ::osl::MutexGuard
aGuard( getOslMutex() );
123 aValue
<<= (sal_Int32
) 2;
125 aValue
<<= (sal_Int32
) 1;
130 // -----------------------------------------------------------------------------
132 Any SAL_CALL
AccessibleCheckBoxCell::getMinimumValue( ) throw (RuntimeException
)
135 aValue
<<= (sal_Int32
) 0;
139 // -----------------------------------------------------------------------------
140 // XAccessibleContext
141 sal_Int32 SAL_CALL
AccessibleCheckBoxCell::getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException
)
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
;
169 aNewValue
<<= AccessibleStateType::CHECKED
;
171 aOldValue
<<= AccessibleStateType::CHECKED
;
172 commitEvent( AccessibleEventId::STATE_CHANGED
, aNewValue
, aOldValue
);