Branch data Line data Source code
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 : :
20 : : #include <accessibility/extended/AccessibleBrowseBoxCheckBoxCell.hxx>
21 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
22 : : #include <svtools/accessibletableprovider.hxx>
23 : :
24 : : namespace accessibility
25 : : {
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;
30 : :
31 : 0 : AccessibleCheckBoxCell::AccessibleCheckBoxCell(const Reference<XAccessible >& _rxParent,
32 : : IAccessibleTableProvider& _rBrowseBox,
33 : : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow,
34 : : sal_Int32 _nRowPos,
35 : : sal_uInt16 _nColPos
36 : : ,const TriState& _eState,
37 : : sal_Bool _bEnabled,
38 : : sal_Bool _bIsTriState)
39 : : :AccessibleBrowseBoxCell(_rxParent, _rBrowseBox, _xFocusWindow, _nRowPos, _nColPos, BBTYPE_CHECKBOXCELL)
40 : : ,m_eState(_eState)
41 : : ,m_bEnabled(_bEnabled)
42 : 0 : ,m_bIsTriState(_bIsTriState)
43 : : {
44 : 0 : }
45 : : // -----------------------------------------------------------------------------
46 [ # # ][ # # ]: 0 : IMPLEMENT_FORWARD_XINTERFACE2( AccessibleCheckBoxCell, AccessibleBrowseBoxCell, AccessibleCheckBoxCell_BASE )
47 : : // -----------------------------------------------------------------------------
48 [ # # ][ # # ]: 0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleCheckBoxCell, AccessibleBrowseBoxCell, AccessibleCheckBoxCell_BASE )
[ # # ]
49 : : //--------------------------------------------------------------------
50 : 0 : Reference< XAccessibleContext > SAL_CALL AccessibleCheckBoxCell::getAccessibleContext( ) throw (RuntimeException)
51 : : {
52 : 0 : ensureIsAlive();
53 : 0 : return this;
54 : : }
55 : : // -----------------------------------------------------------------------------
56 : 0 : ::utl::AccessibleStateSetHelper* AccessibleCheckBoxCell::implCreateStateSetHelper()
57 : : {
58 : : ::utl::AccessibleStateSetHelper* pStateSetHelper =
59 : 0 : AccessibleBrowseBoxCell::implCreateStateSetHelper();
60 [ # # ]: 0 : if( isAlive() )
61 : : {
62 : : mpBrowseBox->FillAccessibleStateSetForCell(
63 : 0 : *pStateSetHelper, getRowPos(), static_cast< sal_uInt16 >( getColumnPos() ) );
64 [ # # ]: 0 : if ( m_eState == STATE_CHECK )
65 : 0 : pStateSetHelper->AddState( AccessibleStateType::CHECKED );
66 : : }
67 : 0 : return pStateSetHelper;
68 : : }
69 : : // -----------------------------------------------------------------------------
70 : : // -----------------------------------------------------------------------------
71 : : // XAccessibleValue
72 : : // -----------------------------------------------------------------------------
73 : :
74 : 0 : Any SAL_CALL AccessibleCheckBoxCell::getCurrentValue( ) throw (RuntimeException)
75 : : {
76 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
77 : :
78 : 0 : sal_Int32 nValue = 0;
79 [ # # # # ]: 0 : switch( m_eState )
80 : : {
81 : : case STATE_NOCHECK:
82 : 0 : nValue = 0;
83 : 0 : break;
84 : : case STATE_CHECK:
85 : 0 : nValue = 1;
86 : 0 : break;
87 : : case STATE_DONTKNOW:
88 : 0 : nValue = 2;
89 : 0 : break;
90 : : }
91 [ # # ][ # # ]: 0 : return makeAny(nValue);
92 : : }
93 : :
94 : : // -----------------------------------------------------------------------------
95 : :
96 : 0 : sal_Bool SAL_CALL AccessibleCheckBoxCell::setCurrentValue( const Any& ) throw (RuntimeException)
97 : : {
98 : 0 : return sal_False;
99 : : }
100 : :
101 : : // -----------------------------------------------------------------------------
102 : :
103 : 0 : Any SAL_CALL AccessibleCheckBoxCell::getMaximumValue( ) throw (RuntimeException)
104 : : {
105 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
106 : :
107 : 0 : Any aValue;
108 : :
109 [ # # ]: 0 : if ( m_bIsTriState )
110 [ # # ]: 0 : aValue <<= (sal_Int32) 2;
111 : : else
112 [ # # ]: 0 : aValue <<= (sal_Int32) 1;
113 : :
114 [ # # ]: 0 : return aValue;
115 : : }
116 : :
117 : : // -----------------------------------------------------------------------------
118 : :
119 : 0 : Any SAL_CALL AccessibleCheckBoxCell::getMinimumValue( ) throw (RuntimeException)
120 : : {
121 : 0 : Any aValue;
122 [ # # ]: 0 : aValue <<= (sal_Int32) 0;
123 : :
124 : 0 : return aValue;
125 : : }
126 : : // -----------------------------------------------------------------------------
127 : : // XAccessibleContext
128 : 0 : sal_Int32 SAL_CALL AccessibleCheckBoxCell::getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException)
129 : : {
130 : 0 : return 0;
131 : : }
132 : : // -----------------------------------------------------------------------------
133 : 0 : ::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)
134 : : {
135 [ # # ]: 0 : throw ::com::sun::star::lang::IndexOutOfBoundsException();
136 : : }
137 : : // -----------------------------------------------------------------------------
138 : 0 : ::rtl::OUString SAL_CALL AccessibleCheckBoxCell::getImplementationName() throw ( ::com::sun::star::uno::RuntimeException )
139 : : {
140 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.TableCheckBoxCell" ) );
141 : : }
142 : : // -----------------------------------------------------------------------------
143 : 0 : sal_Int32 SAL_CALL AccessibleCheckBoxCell::getAccessibleIndexInParent()
144 : : throw ( ::com::sun::star::uno::RuntimeException )
145 : : {
146 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
147 : :
148 [ # # ][ # # ]: 0 : return ( getRowPos() * mpBrowseBox->GetColumnCount() ) + getColumnPos();
149 : : }
150 : : // -----------------------------------------------------------------------------
151 : 0 : void AccessibleCheckBoxCell::SetChecked( sal_Bool _bChecked )
152 : : {
153 [ # # ]: 0 : m_eState = _bChecked ? STATE_CHECK : STATE_NOCHECK;
154 : 0 : Any aOldValue, aNewValue;
155 [ # # ]: 0 : if ( _bChecked )
156 [ # # ]: 0 : aNewValue <<= AccessibleStateType::CHECKED;
157 : : else
158 [ # # ]: 0 : aOldValue <<= AccessibleStateType::CHECKED;
159 [ # # ]: 0 : commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue );
160 : 0 : }
161 : : }
162 : :
163 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|