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
,
46 ,const TriState
& _eState
,
48 sal_Bool _bIsTriState
)
49 :AccessibleBrowseBoxCell(_rxParent
, _rBrowseBox
, _xFocusWindow
, _nRowPos
, _nColPos
, BBTYPE_CHECKBOXCELL
)
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
)
65 // -----------------------------------------------------------------------------
66 ::utl::AccessibleStateSetHelper
* AccessibleCheckBoxCell::implCreateStateSetHelper()
68 ::utl::AccessibleStateSetHelper
* pStateSetHelper
=
69 AccessibleBrowseBoxCell::implCreateStateSetHelper();
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 // -----------------------------------------------------------------------------
82 // -----------------------------------------------------------------------------
84 Any SAL_CALL
AccessibleCheckBoxCell::getCurrentValue( ) throw (RuntimeException
)
86 ::osl::MutexGuard
aGuard( getOslMutex() );
101 return makeAny(nValue
);
104 // -----------------------------------------------------------------------------
106 sal_Bool SAL_CALL
AccessibleCheckBoxCell::setCurrentValue( const Any
& ) throw (RuntimeException
)
111 // -----------------------------------------------------------------------------
113 Any SAL_CALL
AccessibleCheckBoxCell::getMaximumValue( ) throw (RuntimeException
)
115 ::osl::MutexGuard
aGuard( getOslMutex() );
120 aValue
<<= (sal_Int32
) 2;
122 aValue
<<= (sal_Int32
) 1;
127 // -----------------------------------------------------------------------------
129 Any SAL_CALL
AccessibleCheckBoxCell::getMinimumValue( ) throw (RuntimeException
)
132 aValue
<<= (sal_Int32
) 0;
136 // -----------------------------------------------------------------------------
137 // XAccessibleContext
138 sal_Int32 SAL_CALL
AccessibleCheckBoxCell::getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException
)
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
;
166 aNewValue
<<= AccessibleStateType::CHECKED
;
168 aOldValue
<<= AccessibleStateType::CHECKED
;
169 commitEvent( AccessibleEventId::STATE_CHANGED
, aNewValue
, aOldValue
);