1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "accessibility/extended/AccessibleBrowseBox.hxx"
#include "accessibility/extended/AccessibleBrowseBoxTable.hxx"
#include "accessibility/extended/AccessibleBrowseBoxHeaderBar.hxx"
#include <svtools/accessibletableprovider.hxx>
#include <comphelper/types.hxx>
#include <toolkit/helper/vclunohelper.hxx>
namespace accessibility
{
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::accessibility;
using namespace ::svt;
class AccessibleBrowseBoxImpl
{
public:
/// the XAccessible which created the AccessibleBrowseBox
WeakReference< XAccessible > m_aCreator;
/** The data table child. */
Reference<
::com::sun::star::accessibility::XAccessible > mxTable;
AccessibleBrowseBoxTable* m_pTable;
/** The header bar for rows ("handle column"). */
Reference<
::com::sun::star::accessibility::XAccessible > mxRowHeaderBar;
AccessibleBrowseBoxHeaderBar* m_pRowHeaderBar;
/** The header bar for columns (first row of the table). */
Reference<
::com::sun::star::accessibility::XAccessible > mxColumnHeaderBar;
AccessibleBrowseBoxHeaderBar* m_pColumnHeaderBar;
};
// Ctor/Dtor/disposing --------------------------------------------------------
AccessibleBrowseBox::AccessibleBrowseBox(
const Reference< XAccessible >& _rxParent, const Reference< XAccessible >& _rxCreator,
IAccessibleTableProvider& _rBrowseBox )
: AccessibleBrowseBoxBase( _rxParent, _rBrowseBox,NULL, BBTYPE_BROWSEBOX )
{
m_pImpl.reset( new AccessibleBrowseBoxImpl() );
m_pImpl->m_aCreator = _rxCreator;
m_xFocusWindow = VCLUnoHelper::GetInterface(mpBrowseBox->GetWindowInstance());
}
void AccessibleBrowseBox::setCreator( const Reference< XAccessible >& _rxCreator )
{
#if OSL_DEBUG_LEVEL > 0
Reference< XAccessible > xCreator = (Reference< XAccessible >)m_pImpl->m_aCreator;
OSL_ENSURE( !xCreator.is(), "accessibility/extended/AccessibleBrowseBox::setCreator: creator already set!" );
#endif
m_pImpl->m_aCreator = _rxCreator;
}
AccessibleBrowseBox::~AccessibleBrowseBox()
{
}
void SAL_CALL AccessibleBrowseBox::disposing()
{
::osl::MutexGuard aGuard( getOslMutex() );
m_pImpl->m_pTable = NULL;
m_pImpl->m_pColumnHeaderBar = NULL;
m_pImpl->m_pRowHeaderBar = NULL;
m_pImpl->m_aCreator.clear();
Reference< XAccessible > xTable = m_pImpl->mxTable;
Reference< XComponent > xComp( m_pImpl->mxTable, UNO_QUERY );
if ( xComp.is() )
{
xComp->dispose();
}
//! ::comphelper::disposeComponent(m_pImpl->mxTable);
::comphelper::disposeComponent(m_pImpl->mxRowHeaderBar);
::comphelper::disposeComponent(m_pImpl->mxColumnHeaderBar);
AccessibleBrowseBoxBase::disposing();
}
// XAccessibleContext ---------------------------------------------------------
sal_Int32 SAL_CALL AccessibleBrowseBox::getAccessibleChildCount()
throw ( uno::RuntimeException, std::exception )
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( getOslMutex() );
ensureIsAlive();
return BBINDEX_FIRSTCONTROL + mpBrowseBox->GetAccessibleControlCount();
}
Reference< XAccessible > SAL_CALL
AccessibleBrowseBox::getAccessibleChild( sal_Int32 nChildIndex )
throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( getOslMutex() );
ensureIsAlive();
Reference< XAccessible > xRet;
if( nChildIndex >= 0 )
{
if( nChildIndex < BBINDEX_FIRSTCONTROL )
xRet = implGetFixedChild( nChildIndex );
else
{
// additional controls
nChildIndex -= BBINDEX_FIRSTCONTROL;
if( nChildIndex < mpBrowseBox->GetAccessibleControlCount() )
xRet = mpBrowseBox->CreateAccessibleControl( nChildIndex );
}
}
if( !xRet.is() )
throw lang::IndexOutOfBoundsException();
return xRet;
}
// XAccessibleComponent -------------------------------------------------------
Reference< XAccessible > SAL_CALL
AccessibleBrowseBox::getAccessibleAtPoint( const awt::Point& rPoint )
throw ( uno::RuntimeException, std::exception )
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( getOslMutex() );
ensureIsAlive();
Reference< XAccessible > xChild;
sal_Int32 nIndex = 0;
if( mpBrowseBox->ConvertPointToControlIndex( nIndex, VCLPoint( rPoint ) ) )
xChild = mpBrowseBox->CreateAccessibleControl( nIndex );
else
{
// try whether point is in one of the fixed children
// (table, header bars, corner control)
Point aPoint( VCLPoint( rPoint ) );
for( nIndex = 0; (nIndex < BBINDEX_FIRSTCONTROL) && !xChild.is(); ++nIndex )
{
Reference< XAccessible > xCurrChild( implGetFixedChild( nIndex ) );
Reference< XAccessibleComponent >
xCurrChildComp( xCurrChild, uno::UNO_QUERY );
if( xCurrChildComp.is() &&
VCLRectangle( xCurrChildComp->getBounds() ).IsInside( aPoint ) )
xChild = xCurrChild;
}
}
return xChild;
}
void SAL_CALL AccessibleBrowseBox::grabFocus()
throw ( uno::RuntimeException, std::exception )
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( getOslMutex() );
ensureIsAlive();
mpBrowseBox->GrabFocus();
}
// XServiceInfo ---------------------------------------------------------------
OUString SAL_CALL AccessibleBrowseBox::getImplementationName()
throw ( uno::RuntimeException, std::exception )
{
return OUString( "com.sun.star.comp.svtools.AccessibleBrowseBox" );
}
// internal virtual methods ---------------------------------------------------
Rectangle AccessibleBrowseBox::implGetBoundingBox()
{
Window* pParent = mpBrowseBox->GetAccessibleParentWindow();
OSL_ENSURE( pParent, "implGetBoundingBox - missing parent window" );
return mpBrowseBox->GetWindowExtentsRelative( pParent );
}
Rectangle AccessibleBrowseBox::implGetBoundingBoxOnScreen()
{
return mpBrowseBox->GetWindowExtentsRelative( NULL );
}
// internal helper methods ----------------------------------------------------
Reference< XAccessible > AccessibleBrowseBox::implGetTable()
{
if( !m_pImpl->mxTable.is() )
{
m_pImpl->m_pTable = createAccessibleTable();
m_pImpl->mxTable = m_pImpl->m_pTable;
}
return m_pImpl->mxTable;
}
Reference< XAccessible >
AccessibleBrowseBox::implGetHeaderBar( AccessibleBrowseBoxObjType eObjType )
{
Reference< XAccessible > xRet;
Reference< XAccessible >* pxMember = NULL;
if( eObjType == BBTYPE_ROWHEADERBAR )
pxMember = &m_pImpl->mxRowHeaderBar;
else if( eObjType == BBTYPE_COLUMNHEADERBAR )
pxMember = &m_pImpl->mxColumnHeaderBar;
if( pxMember )
{
if( !pxMember->is() )
{
AccessibleBrowseBoxHeaderBar* pHeaderBar = new AccessibleBrowseBoxHeaderBar(
(Reference< XAccessible >)m_pImpl->m_aCreator, *mpBrowseBox, eObjType );
if ( BBTYPE_COLUMNHEADERBAR == eObjType)
m_pImpl->m_pColumnHeaderBar = pHeaderBar;
else
m_pImpl->m_pRowHeaderBar = pHeaderBar;
*pxMember = pHeaderBar;
}
xRet = *pxMember;
}
return xRet;
}
Reference< XAccessible >
AccessibleBrowseBox::implGetFixedChild( sal_Int32 nChildIndex )
{
Reference< XAccessible > xRet;
switch( nChildIndex )
{
case BBINDEX_COLUMNHEADERBAR:
xRet = implGetHeaderBar( BBTYPE_COLUMNHEADERBAR );
break;
case BBINDEX_ROWHEADERBAR:
xRet = implGetHeaderBar( BBTYPE_ROWHEADERBAR );
break;
case BBINDEX_TABLE:
xRet = implGetTable();
break;
}
return xRet;
}
AccessibleBrowseBoxTable* AccessibleBrowseBox::createAccessibleTable()
{
Reference< XAccessible > xCreator = (Reference< XAccessible >)m_pImpl->m_aCreator;
OSL_ENSURE( xCreator.is(), "accessibility/extended/AccessibleBrowseBox::createAccessibleTable: my creator died - how this?" );
return new AccessibleBrowseBoxTable( xCreator, *mpBrowseBox );
}
void AccessibleBrowseBox::commitTableEvent(sal_Int16 _nEventId,const Any& _rNewValue,const Any& _rOldValue)
{
if ( m_pImpl->mxTable.is() )
{
m_pImpl->m_pTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
}
}
void AccessibleBrowseBox::commitHeaderBarEvent( sal_Int16 _nEventId,
const Any& _rNewValue,
const Any& _rOldValue,sal_Bool _bColumnHeaderBar)
{
Reference< XAccessible > xHeaderBar = _bColumnHeaderBar ? m_pImpl->mxColumnHeaderBar : m_pImpl->mxRowHeaderBar;
AccessibleBrowseBoxHeaderBar* pHeaderBar = _bColumnHeaderBar ? m_pImpl->m_pColumnHeaderBar : m_pImpl->m_pRowHeaderBar;
if ( xHeaderBar.is() )
pHeaderBar->commitEvent(_nEventId,_rNewValue,_rOldValue);
}
// = AccessibleBrowseBoxAccess
AccessibleBrowseBoxAccess::AccessibleBrowseBoxAccess( const Reference< XAccessible >& _rxParent, IAccessibleTableProvider& _rBrowseBox )
:m_xParent( _rxParent )
,m_rBrowseBox( _rBrowseBox )
,m_pContext( NULL )
{
}
AccessibleBrowseBoxAccess::~AccessibleBrowseBoxAccess()
{
}
void AccessibleBrowseBoxAccess::dispose()
{
::osl::MutexGuard aGuard( m_aMutex );
m_pContext = NULL;
::comphelper::disposeComponent( m_xContext );
}
Reference< XAccessibleContext > SAL_CALL AccessibleBrowseBoxAccess::getAccessibleContext() throw ( RuntimeException, std::exception )
{
::osl::MutexGuard aGuard( m_aMutex );
OSL_ENSURE( ( m_pContext && m_xContext.is() ) || ( !m_pContext && !m_xContext.is() ),
"accessibility/extended/AccessibleBrowseBoxAccess::getAccessibleContext: inconsistency!" );
// if the context died meanwhile (there is no listener, so it won't tell us explicitily when this happens),
// then reset and re-create.
if ( m_pContext && !m_pContext->isAlive() )
m_xContext = m_pContext = NULL;
if ( !m_xContext.is() )
m_xContext = m_pContext = new AccessibleBrowseBox( m_xParent, this, m_rBrowseBox );
return m_xContext;
}
bool AccessibleBrowseBoxAccess::isContextAlive() const
{
return ( NULL != m_pContext ) && m_pContext->isAlive();
}
} // namespace accessibility
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|