tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / accessibility / source / extended / AccessibleBrowseBoxCheckBoxCell.cxx
blobe0a36478b0a22e83c3d05d3234983510f43a87ad
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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,
33 sal_Int32 _nRowPos,
34 sal_uInt16 _nColPos
35 ,const TriState& _eState,
36 bool _bIsTriState)
37 :AccessibleBrowseBoxCell(_rxParent, _rBrowseBox, nullptr, _nRowPos, _nColPos, AccessibleBrowseBoxObjType::CheckBoxCell)
38 ,m_eState(_eState)
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() );
49 ensureIsAlive();
50 return this;
53 sal_Int64 AccessibleCheckBoxCell::implCreateStateSet()
55 sal_Int64 nStateSet = AccessibleBrowseBoxCell::implCreateStateSet();
56 if( isAlive() )
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;
64 return nStateSet;
67 // XAccessibleValue
69 Any SAL_CALL AccessibleCheckBoxCell::getCurrentValue( )
71 ::osl::MutexGuard aGuard( getMutex() );
73 sal_Int32 nValue = 0;
74 switch( m_eState )
76 case TRISTATE_FALSE:
77 nValue = 0;
78 break;
79 case TRISTATE_TRUE:
80 nValue = 1;
81 break;
82 case TRISTATE_INDET:
83 nValue = 2;
84 break;
86 return Any(nValue);
89 sal_Bool SAL_CALL AccessibleCheckBoxCell::setCurrentValue( const Any& )
91 return false;
94 Any SAL_CALL AccessibleCheckBoxCell::getMaximumValue( )
96 ::osl::MutexGuard aGuard( getMutex() );
98 Any aValue;
100 if ( m_bIsTriState )
101 aValue <<= sal_Int32(2);
102 else
103 aValue <<= sal_Int32(1);
105 return aValue;
108 Any SAL_CALL AccessibleCheckBoxCell::getMinimumValue( )
110 Any aValue;
111 aValue <<= sal_Int32(0);
113 return aValue;
116 Any SAL_CALL AccessibleCheckBoxCell::getMinimumIncrement( )
118 Any aValue;
119 aValue <<= sal_Int32(1);
121 return aValue;
124 // XAccessibleContext
125 sal_Int64 SAL_CALL AccessibleCheckBoxCell::getAccessibleChildCount( )
127 return 0;
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() );
143 ensureIsAlive();
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;
152 if ( _bChecked )
153 aNewValue <<= AccessibleStateType::CHECKED;
154 else
155 aOldValue <<= AccessibleStateType::CHECKED;
156 commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue );
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */