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 <extended/AccessibleBrowseBoxCheckBoxCell.hxx>
21 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
22 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
23 #include <vcl/accessibletableprovider.hxx>
24 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
26 namespace accessibility
28 using namespace com::sun::star::accessibility
;
29 using namespace com::sun::star::uno
;
31 AccessibleCheckBoxCell::AccessibleCheckBoxCell(const Reference
<XAccessible
>& _rxParent
,
32 vcl::IAccessibleTableProvider
& _rBrowseBox
,
35 ,const TriState
& _eState
,
37 :AccessibleBrowseBoxCell(_rxParent
, _rBrowseBox
, nullptr, _nRowPos
, _nColPos
, AccessibleBrowseBoxObjType::CheckBoxCell
)
39 ,m_bIsTriState(_bIsTriState
)
42 IMPLEMENT_FORWARD_XINTERFACE2( AccessibleCheckBoxCell
, AccessibleBrowseBoxCell
, AccessibleCheckBoxCell_BASE
)
44 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleCheckBoxCell
, AccessibleBrowseBoxCell
, AccessibleCheckBoxCell_BASE
)
46 Reference
< XAccessibleContext
> SAL_CALL
AccessibleCheckBoxCell::getAccessibleContext( )
48 osl::MutexGuard
aGuard( getMutex() );
53 sal_Int64
AccessibleCheckBoxCell::implCreateStateSet()
55 sal_Int64 nStateSet
= AccessibleBrowseBoxCell::implCreateStateSet();
58 nStateSet
|= AccessibleStateType::CHECKABLE
;
59 mpBrowseBox
->FillAccessibleStateSetForCell(
60 nStateSet
, getRowPos(), static_cast< sal_uInt16
>( getColumnPos() ) );
61 if ( m_eState
== TRISTATE_TRUE
)
62 nStateSet
|= AccessibleStateType::CHECKED
;
69 Any SAL_CALL
AccessibleCheckBoxCell::getCurrentValue( )
71 ::osl::MutexGuard
aGuard( getMutex() );
89 sal_Bool SAL_CALL
AccessibleCheckBoxCell::setCurrentValue( const Any
& )
94 Any SAL_CALL
AccessibleCheckBoxCell::getMaximumValue( )
96 ::osl::MutexGuard
aGuard( getMutex() );
101 aValue
<<= sal_Int32(2);
103 aValue
<<= sal_Int32(1);
108 Any SAL_CALL
AccessibleCheckBoxCell::getMinimumValue( )
111 aValue
<<= sal_Int32(0);
116 Any SAL_CALL
AccessibleCheckBoxCell::getMinimumIncrement( )
119 aValue
<<= sal_Int32(1);
124 // XAccessibleContext
125 sal_Int64 SAL_CALL
AccessibleCheckBoxCell::getAccessibleChildCount( )
130 css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
AccessibleCheckBoxCell::getAccessibleChild( sal_Int64
)
132 throw css::lang::IndexOutOfBoundsException();
135 OUString SAL_CALL
AccessibleCheckBoxCell::getImplementationName()
137 return u
"com.sun.star.comp.svtools.TableCheckBoxCell"_ustr
;
140 sal_Int64 SAL_CALL
AccessibleCheckBoxCell::getAccessibleIndexInParent()
142 ::osl::MutexGuard
aGuard( getMutex() );
145 return (static_cast<sal_Int64
>(getRowPos()) * static_cast<sal_Int64
>(mpBrowseBox
->GetColumnCount())) + getColumnPos();
148 void AccessibleCheckBoxCell::SetChecked( bool _bChecked
)
150 m_eState
= _bChecked
? TRISTATE_TRUE
: TRISTATE_FALSE
;
151 Any aOldValue
, aNewValue
;
153 aNewValue
<<= AccessibleStateType::CHECKED
;
155 aOldValue
<<= AccessibleStateType::CHECKED
;
156 commitEvent( AccessibleEventId::STATE_CHANGED
, aNewValue
, aOldValue
);
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */