1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <accessibility/extended/AccessibleBrowseBoxCheckBoxCell.hxx>
21 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
22 #include <svtools/accessibletableprovider.hxx>
24 namespace accessibility
26 using namespace com::sun::star::accessibility
;
27 using namespace com::sun::star::uno
;
28 using namespace com::sun::star::accessibility::AccessibleEventId
;
29 using namespace ::svt
;
31 AccessibleCheckBoxCell::AccessibleCheckBoxCell(const Reference
<XAccessible
>& _rxParent
,
32 IAccessibleTableProvider
& _rBrowseBox
,
33 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
>& _xFocusWindow
,
36 ,const TriState
& _eState
,
37 sal_Bool _bIsTriState
)
38 :AccessibleBrowseBoxCell(_rxParent
, _rBrowseBox
, _xFocusWindow
, _nRowPos
, _nColPos
, BBTYPE_CHECKBOXCELL
)
40 ,m_bIsTriState(_bIsTriState
)
43 // -----------------------------------------------------------------------------
44 IMPLEMENT_FORWARD_XINTERFACE2( AccessibleCheckBoxCell
, AccessibleBrowseBoxCell
, AccessibleCheckBoxCell_BASE
)
45 // -----------------------------------------------------------------------------
46 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleCheckBoxCell
, AccessibleBrowseBoxCell
, AccessibleCheckBoxCell_BASE
)
47 //--------------------------------------------------------------------
48 Reference
< XAccessibleContext
> SAL_CALL
AccessibleCheckBoxCell::getAccessibleContext( ) throw (RuntimeException
)
53 // -----------------------------------------------------------------------------
54 ::utl::AccessibleStateSetHelper
* AccessibleCheckBoxCell::implCreateStateSetHelper()
56 ::utl::AccessibleStateSetHelper
* pStateSetHelper
=
57 AccessibleBrowseBoxCell::implCreateStateSetHelper();
60 mpBrowseBox
->FillAccessibleStateSetForCell(
61 *pStateSetHelper
, getRowPos(), static_cast< sal_uInt16
>( getColumnPos() ) );
62 if ( m_eState
== STATE_CHECK
)
63 pStateSetHelper
->AddState( AccessibleStateType::CHECKED
);
65 return pStateSetHelper
;
67 // -----------------------------------------------------------------------------
68 // -----------------------------------------------------------------------------
70 // -----------------------------------------------------------------------------
72 Any SAL_CALL
AccessibleCheckBoxCell::getCurrentValue( ) throw (RuntimeException
)
74 ::osl::MutexGuard
aGuard( getOslMutex() );
89 return makeAny(nValue
);
92 // -----------------------------------------------------------------------------
94 sal_Bool SAL_CALL
AccessibleCheckBoxCell::setCurrentValue( const Any
& ) throw (RuntimeException
)
99 // -----------------------------------------------------------------------------
101 Any SAL_CALL
AccessibleCheckBoxCell::getMaximumValue( ) throw (RuntimeException
)
103 ::osl::MutexGuard
aGuard( getOslMutex() );
108 aValue
<<= (sal_Int32
) 2;
110 aValue
<<= (sal_Int32
) 1;
115 // -----------------------------------------------------------------------------
117 Any SAL_CALL
AccessibleCheckBoxCell::getMinimumValue( ) throw (RuntimeException
)
120 aValue
<<= (sal_Int32
) 0;
124 // -----------------------------------------------------------------------------
125 // XAccessibleContext
126 sal_Int32 SAL_CALL
AccessibleCheckBoxCell::getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException
)
130 // -----------------------------------------------------------------------------
131 ::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
)
133 throw ::com::sun::star::lang::IndexOutOfBoundsException();
135 // -----------------------------------------------------------------------------
136 OUString SAL_CALL
AccessibleCheckBoxCell::getImplementationName() throw ( ::com::sun::star::uno::RuntimeException
)
138 return OUString( "com.sun.star.comp.svtools.TableCheckBoxCell" );
140 // -----------------------------------------------------------------------------
141 sal_Int32 SAL_CALL
AccessibleCheckBoxCell::getAccessibleIndexInParent()
142 throw ( ::com::sun::star::uno::RuntimeException
)
144 ::osl::MutexGuard
aGuard( getOslMutex() );
146 return ( getRowPos() * mpBrowseBox
->GetColumnCount() ) + getColumnPos();
148 // -----------------------------------------------------------------------------
149 void AccessibleCheckBoxCell::SetChecked( sal_Bool _bChecked
)
151 m_eState
= _bChecked
? STATE_CHECK
: STATE_NOCHECK
;
152 Any aOldValue
, aNewValue
;
154 aNewValue
<<= AccessibleStateType::CHECKED
;
156 aOldValue
<<= AccessibleStateType::CHECKED
;
157 commitEvent( AccessibleEventId::STATE_CHANGED
, aNewValue
, aOldValue
);
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */