lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / accessibility / source / extended / AccessibleBrowseBoxCheckBoxCell.cxx
blob3ce5479b207e48a798617a4ddb1755966eea950b
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 <vcl/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 vcl::IAccessibleTableProvider& _rBrowseBox,
33 const css::uno::Reference< css::awt::XWindow >& _xFocusWindow,
34 sal_Int32 _nRowPos,
35 sal_uInt16 _nColPos
36 ,const TriState& _eState,
37 bool _bIsTriState)
38 :AccessibleBrowseBoxCell(_rxParent, _rBrowseBox, _xFocusWindow, _nRowPos, _nColPos, vcl::BBTYPE_CHECKBOXCELL)
39 ,m_eState(_eState)
40 ,m_bIsTriState(_bIsTriState)
43 IMPLEMENT_FORWARD_XINTERFACE2( AccessibleCheckBoxCell, AccessibleBrowseBoxCell, AccessibleCheckBoxCell_BASE )
45 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleCheckBoxCell, AccessibleBrowseBoxCell, AccessibleCheckBoxCell_BASE )
47 Reference< XAccessibleContext > SAL_CALL AccessibleCheckBoxCell::getAccessibleContext( )
49 osl::MutexGuard aGuard( getMutex() );
50 ensureIsAlive();
51 return this;
54 ::utl::AccessibleStateSetHelper* AccessibleCheckBoxCell::implCreateStateSetHelper()
56 ::utl::AccessibleStateSetHelper* pStateSetHelper =
57 AccessibleBrowseBoxCell::implCreateStateSetHelper();
58 if( isAlive() )
60 mpBrowseBox->FillAccessibleStateSetForCell(
61 *pStateSetHelper, getRowPos(), static_cast< sal_uInt16 >( getColumnPos() ) );
62 if ( m_eState == TRISTATE_TRUE )
63 pStateSetHelper->AddState( AccessibleStateType::CHECKED );
65 return pStateSetHelper;
68 // XAccessibleValue
70 Any SAL_CALL AccessibleCheckBoxCell::getCurrentValue( )
72 ::osl::MutexGuard aGuard( getMutex() );
74 sal_Int32 nValue = 0;
75 switch( m_eState )
77 case TRISTATE_FALSE:
78 nValue = 0;
79 break;
80 case TRISTATE_TRUE:
81 nValue = 1;
82 break;
83 case TRISTATE_INDET:
84 nValue = 2;
85 break;
87 return Any(nValue);
90 sal_Bool SAL_CALL AccessibleCheckBoxCell::setCurrentValue( const Any& )
92 return false;
95 Any SAL_CALL AccessibleCheckBoxCell::getMaximumValue( )
97 ::osl::MutexGuard aGuard( getMutex() );
99 Any aValue;
101 if ( m_bIsTriState )
102 aValue <<= sal_Int32(2);
103 else
104 aValue <<= sal_Int32(1);
106 return aValue;
109 Any SAL_CALL AccessibleCheckBoxCell::getMinimumValue( )
111 Any aValue;
112 aValue <<= sal_Int32(0);
114 return aValue;
117 // XAccessibleContext
118 sal_Int32 SAL_CALL AccessibleCheckBoxCell::getAccessibleChildCount( )
120 return 0;
123 css::uno::Reference< css::accessibility::XAccessible > SAL_CALL AccessibleCheckBoxCell::getAccessibleChild( sal_Int32 )
125 throw css::lang::IndexOutOfBoundsException();
128 OUString SAL_CALL AccessibleCheckBoxCell::getImplementationName()
130 return OUString( "com.sun.star.comp.svtools.TableCheckBoxCell" );
133 sal_Int32 SAL_CALL AccessibleCheckBoxCell::getAccessibleIndexInParent()
135 ::osl::MutexGuard aGuard( getMutex() );
136 ensureIsAlive();
138 return ( getRowPos() * mpBrowseBox->GetColumnCount() ) + getColumnPos();
141 void AccessibleCheckBoxCell::SetChecked( bool _bChecked )
143 m_eState = _bChecked ? TRISTATE_TRUE : TRISTATE_FALSE;
144 Any aOldValue, aNewValue;
145 if ( _bChecked )
146 aNewValue <<= AccessibleStateType::CHECKED;
147 else
148 aOldValue <<= AccessibleStateType::CHECKED;
149 commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue );
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */