LibreOffice Module accessibility (master) 1
AccessibleBrowseBoxCheckBoxCell.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21#include <com/sun/star/accessibility/AccessibleEventId.hpp>
22#include <com/sun/star/accessibility/AccessibleStateType.hpp>
24#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
25
26namespace accessibility
27{
28 using namespace com::sun::star::accessibility;
29 using namespace com::sun::star::uno;
30 using namespace com::sun::star::accessibility::AccessibleEventId;
31
34 const css::uno::Reference< css::awt::XWindow >& _xFocusWindow,
35 sal_Int32 _nRowPos,
36 sal_uInt16 _nColPos
37 ,const TriState& _eState,
38 bool _bIsTriState)
39 :AccessibleBrowseBoxCell(_rxParent, _rBrowseBox, _xFocusWindow, _nRowPos, _nColPos, AccessibleBrowseBoxObjType::CheckBoxCell)
40 ,m_eState(_eState)
41 ,m_bIsTriState(_bIsTriState)
42 {
43 }
45
47
48 Reference< XAccessibleContext > SAL_CALL AccessibleCheckBoxCell::getAccessibleContext( )
49 {
50 osl::MutexGuard aGuard( getMutex() );
51 ensureIsAlive();
52 return this;
53 }
54
56 {
57 sal_Int64 nStateSet = AccessibleBrowseBoxCell::implCreateStateSet();
58 if( isAlive() )
59 {
61 nStateSet, getRowPos(), static_cast< sal_uInt16 >( getColumnPos() ) );
62 if ( m_eState == TRISTATE_TRUE )
63 nStateSet |= AccessibleStateType::CHECKED;
64 }
65 return nStateSet;
66 }
67
68 // XAccessibleValue
69
71 {
72 ::osl::MutexGuard aGuard( getMutex() );
73
74 sal_Int32 nValue = 0;
75 switch( m_eState )
76 {
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;
86 }
87 return Any(nValue);
88 }
89
91 {
92 return false;
93 }
94
96 {
97 ::osl::MutexGuard aGuard( getMutex() );
98
99 Any aValue;
100
101 if ( m_bIsTriState )
102 aValue <<= sal_Int32(2);
103 else
104 aValue <<= sal_Int32(1);
105
106 return aValue;
107 }
108
110 {
111 Any aValue;
112 aValue <<= sal_Int32(0);
113
114 return aValue;
115 }
116
118 {
119 Any aValue;
120 aValue <<= sal_Int32(1);
121
122 return aValue;
123 }
124
125 // XAccessibleContext
127 {
128 return 0;
129 }
130
131 css::uno::Reference< css::accessibility::XAccessible > SAL_CALL AccessibleCheckBoxCell::getAccessibleChild( sal_Int64 )
132 {
133 throw css::lang::IndexOutOfBoundsException();
134 }
135
137 {
138 return "com.sun.star.comp.svtools.TableCheckBoxCell";
139 }
140
142 {
143 ::osl::MutexGuard aGuard( getMutex() );
145
146 return (static_cast<sal_Int64>(getRowPos()) * static_cast<sal_Int64>(mpBrowseBox->GetColumnCount())) + getColumnPos();
147 }
148
150 {
151 m_eState = _bChecked ? TRISTATE_TRUE : TRISTATE_FALSE;
152 Any aOldValue, aNewValue;
153 if ( _bChecked )
154 aNewValue <<= AccessibleStateType::CHECKED;
155 else
156 aOldValue <<= AccessibleStateType::CHECKED;
157 commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue );
158 }
159}
160
161/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AccessibleBrowseBoxObjType
::vcl::IAccessibleTableProvider * mpBrowseBox
The VCL BrowseBox control.
virtual sal_Int64 implCreateStateSet()
Creates a bitset of states of the current object.
void commitEvent(sal_Int16 nEventId, const css::uno::Any &rNewValue, const css::uno::Any &rOldValue)
Commits an event to all listeners.
common accessibility-functionality for browse box elements which occupy a cell
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 i) override
virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override
virtual css::uno::Any SAL_CALL getMinimumValue() override
virtual css::uno::Any SAL_CALL getMaximumValue() override
virtual css::uno::Any SAL_CALL getMinimumIncrement() override
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Any SAL_CALL getCurrentValue() override
AccessibleCheckBoxCell(const css::uno::Reference< css::accessibility::XAccessible > &_rxParent, ::vcl::IAccessibleTableProvider &_rBrowseBox, const css::uno::Reference< css::awt::XWindow > &_xFocusWindow, sal_Int32 _nRowPos, sal_uInt16 _nColPos, const TriState &_eState, bool _bIsTriState)
virtual sal_Bool SAL_CALL setCurrentValue(const css::uno::Any &aNumber) override
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
virtual sal_Int64 implCreateStateSet() override
Creates a bitset of states of the current object.
virtual void FillAccessibleStateSetForCell(sal_Int64 &_rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos) const=0
virtual sal_uInt16 GetColumnCount() const=0
sal_Int16 nValue
TriState
TRISTATE_FALSE
TRISTATE_INDET
TRISTATE_TRUE
::osl::Mutex & getMutex()
IMPLEMENT_FORWARD_XTYPEPROVIDER2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
IMPLEMENT_FORWARD_XINTERFACE2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
unsigned char sal_Bool