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 : :
21 : : #include <accessibledialogwindow.hxx>
22 : : #include <accessibledialogcontrolshape.hxx>
23 : : #include <baside3.hxx>
24 : : #include <dlged.hxx>
25 : : #include <dlgedmod.hxx>
26 : : #include <dlgedpage.hxx>
27 : : #include <dlgedview.hxx>
28 : : #include <dlgedobj.hxx>
29 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
30 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
31 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
32 : : #include <unotools/accessiblestatesethelper.hxx>
33 : : #include <unotools/accessiblerelationsethelper.hxx>
34 : : #include <toolkit/awt/vclxfont.hxx>
35 : : #include <toolkit/helper/externallock.hxx>
36 : : #include <toolkit/helper/convert.hxx>
37 : : #include <vcl/svapp.hxx>
38 : :
39 : : using namespace ::com::sun::star;
40 : : using namespace ::com::sun::star::uno;
41 : : using namespace ::com::sun::star::lang;
42 : : using namespace ::com::sun::star::accessibility;
43 : : using namespace ::comphelper;
44 : :
45 : : DBG_NAME( AccessibleDialogWindow )
46 : :
47 : :
48 : : // -----------------------------------------------------------------------------
49 : : // class ChildDescriptor
50 : : // -----------------------------------------------------------------------------
51 : :
52 : 0 : AccessibleDialogWindow::ChildDescriptor::ChildDescriptor( DlgEdObj* _pDlgEdObj )
53 : : :pDlgEdObj( _pDlgEdObj )
54 : 0 : ,rxAccessible( 0 )
55 : : {
56 : 0 : }
57 : :
58 : : // -----------------------------------------------------------------------------
59 : :
60 : 0 : AccessibleDialogWindow::ChildDescriptor::~ChildDescriptor()
61 : : {
62 : 0 : }
63 : :
64 : : // -----------------------------------------------------------------------------
65 : :
66 : 0 : AccessibleDialogWindow::ChildDescriptor::ChildDescriptor( const ChildDescriptor& rDesc )
67 : : :pDlgEdObj( rDesc.pDlgEdObj )
68 : 0 : ,rxAccessible( rDesc.rxAccessible )
69 : : {
70 : 0 : }
71 : :
72 : : // -----------------------------------------------------------------------------
73 : :
74 : 0 : AccessibleDialogWindow::ChildDescriptor& AccessibleDialogWindow::ChildDescriptor::operator=( const ChildDescriptor& rDesc )
75 : : {
76 : 0 : pDlgEdObj = rDesc.pDlgEdObj;
77 : 0 : rxAccessible = rDesc.rxAccessible;
78 : :
79 : 0 : return *this;
80 : : }
81 : :
82 : : // -----------------------------------------------------------------------------
83 : :
84 : 0 : bool AccessibleDialogWindow::ChildDescriptor::operator==( const ChildDescriptor& rDesc )
85 : : {
86 : 0 : bool bRet = false;
87 : 0 : if ( pDlgEdObj == rDesc.pDlgEdObj )
88 : 0 : bRet = true;
89 : :
90 : 0 : return bRet;
91 : : }
92 : :
93 : : // -----------------------------------------------------------------------------
94 : :
95 : 0 : bool AccessibleDialogWindow::ChildDescriptor::operator<( const ChildDescriptor& rDesc ) const
96 : : {
97 : 0 : bool bRet = false;
98 : 0 : if ( pDlgEdObj && rDesc.pDlgEdObj && pDlgEdObj->GetOrdNum() < rDesc.pDlgEdObj->GetOrdNum() )
99 : 0 : bRet = true;
100 : :
101 : 0 : return bRet;
102 : : }
103 : :
104 : : // -----------------------------------------------------------------------------
105 : : // class AccessibleDialogWindow
106 : : // -----------------------------------------------------------------------------
107 : :
108 : 0 : AccessibleDialogWindow::AccessibleDialogWindow (basctl::DialogWindow* pDialogWindow)
109 : 0 : :AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() )
110 : 0 : ,m_pDialogWindow( pDialogWindow )
111 : : {
112 : : DBG_CTOR( AccessibleDialogWindow, NULL );
113 : 0 : m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
114 : :
115 : 0 : if ( m_pDialogWindow )
116 : : {
117 : 0 : SdrPage* pSdrPage = m_pDialogWindow->GetPage();
118 : 0 : if ( pSdrPage )
119 : : {
120 : 0 : sal_uLong nCount = pSdrPage->GetObjCount();
121 : :
122 : 0 : for ( sal_uLong i = 0; i < nCount; ++i )
123 : : {
124 : 0 : if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pSdrPage->GetObj(i)))
125 : : {
126 : 0 : ChildDescriptor aDesc( pDlgEdObj );
127 : 0 : if ( IsChildVisible( aDesc ) )
128 : 0 : m_aAccessibleChildren.push_back( aDesc );
129 : : }
130 : : }
131 : : }
132 : :
133 : 0 : m_pDialogWindow->AddEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
134 : :
135 : 0 : m_pDlgEditor = m_pDialogWindow->GetEditor();
136 : 0 : if ( m_pDlgEditor )
137 : 0 : StartListening( *m_pDlgEditor );
138 : :
139 : 0 : m_pDlgEdModel = m_pDialogWindow->GetModel();
140 : 0 : if ( m_pDlgEdModel )
141 : 0 : StartListening( *m_pDlgEdModel );
142 : : }
143 : 0 : }
144 : :
145 : : // -----------------------------------------------------------------------------
146 : :
147 : 0 : AccessibleDialogWindow::~AccessibleDialogWindow()
148 : : {
149 : : DBG_DTOR( AccessibleDialogWindow, NULL );
150 : 0 : if ( m_pDialogWindow )
151 : 0 : m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
152 : :
153 : 0 : if ( m_pDlgEditor )
154 : 0 : EndListening( *m_pDlgEditor );
155 : :
156 : 0 : if ( m_pDlgEdModel )
157 : 0 : EndListening( *m_pDlgEdModel );
158 : :
159 : 0 : delete m_pExternalLock;
160 : 0 : m_pExternalLock = NULL;
161 : 0 : }
162 : :
163 : : // -----------------------------------------------------------------------------
164 : :
165 : 0 : void AccessibleDialogWindow::UpdateFocused()
166 : : {
167 : 0 : for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
168 : : {
169 : 0 : Reference< XAccessible > xChild( m_aAccessibleChildren[i].rxAccessible );
170 : 0 : if ( xChild.is() )
171 : : {
172 : 0 : AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
173 : 0 : if ( pShape )
174 : 0 : pShape->SetFocused( pShape->IsFocused() );
175 : : }
176 : 0 : }
177 : 0 : }
178 : :
179 : : // -----------------------------------------------------------------------------
180 : :
181 : 0 : void AccessibleDialogWindow::UpdateSelected()
182 : : {
183 : 0 : NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
184 : :
185 : 0 : for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
186 : : {
187 : 0 : Reference< XAccessible > xChild( m_aAccessibleChildren[i].rxAccessible );
188 : 0 : if ( xChild.is() )
189 : : {
190 : 0 : AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
191 : 0 : if ( pShape )
192 : 0 : pShape->SetSelected( pShape->IsSelected() );
193 : : }
194 : 0 : }
195 : 0 : }
196 : :
197 : : // -----------------------------------------------------------------------------
198 : :
199 : 0 : void AccessibleDialogWindow::UpdateBounds()
200 : : {
201 : 0 : for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
202 : : {
203 : 0 : Reference< XAccessible > xChild( m_aAccessibleChildren[i].rxAccessible );
204 : 0 : if ( xChild.is() )
205 : : {
206 : 0 : AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
207 : 0 : if ( pShape )
208 : 0 : pShape->SetBounds( pShape->GetBounds() );
209 : : }
210 : 0 : }
211 : 0 : }
212 : :
213 : : // -----------------------------------------------------------------------------
214 : :
215 : 0 : bool AccessibleDialogWindow::IsChildVisible( const ChildDescriptor& rDesc )
216 : : {
217 : 0 : bool bVisible = false;
218 : :
219 : 0 : if ( m_pDialogWindow )
220 : : {
221 : : // first check, if the shape is in a visible layer
222 : 0 : SdrModel* pSdrModel = m_pDialogWindow->GetModel();
223 : 0 : if ( pSdrModel )
224 : : {
225 : 0 : SdrLayerAdmin& rLayerAdmin = pSdrModel->GetLayerAdmin();
226 : 0 : DlgEdObj* pDlgEdObj = rDesc.pDlgEdObj;
227 : 0 : if ( pDlgEdObj )
228 : : {
229 : 0 : SdrLayerID nLayerId = pDlgEdObj->GetLayer();
230 : 0 : const SdrLayer* pSdrLayer = rLayerAdmin.GetLayerPerID( nLayerId );
231 : 0 : if ( pSdrLayer )
232 : : {
233 : 0 : ::rtl::OUString aLayerName = pSdrLayer->GetName();
234 : 0 : SdrView* pSdrView = m_pDialogWindow->GetView();
235 : 0 : if ( pSdrView && pSdrView->IsLayerVisible( aLayerName ) )
236 : : {
237 : : // get the bounding box of the shape in logic units
238 : 0 : Rectangle aRect = pDlgEdObj->GetSnapRect();
239 : :
240 : : // transform coordinates relative to the parent
241 : 0 : MapMode aMap = m_pDialogWindow->GetMapMode();
242 : 0 : Point aOrg = aMap.GetOrigin();
243 : 0 : aRect.Move( aOrg.X(), aOrg.Y() );
244 : :
245 : : // convert logic units to pixel
246 : 0 : aRect = m_pDialogWindow->LogicToPixel( aRect, MapMode(MAP_100TH_MM) );
247 : :
248 : : // check, if the shape's bounding box intersects with the bounding box of its parent
249 : 0 : Rectangle aParentRect( Point( 0, 0 ), m_pDialogWindow->GetSizePixel() );
250 : 0 : if ( aParentRect.IsOver( aRect ) )
251 : 0 : bVisible = true;
252 : 0 : }
253 : : }
254 : : }
255 : : }
256 : : }
257 : :
258 : 0 : return bVisible;
259 : : }
260 : :
261 : : // -----------------------------------------------------------------------------
262 : :
263 : 0 : void AccessibleDialogWindow::InsertChild( const ChildDescriptor& rDesc )
264 : : {
265 : : // check, if object is already in child list
266 : 0 : AccessibleChildren::iterator aIter = ::std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
267 : :
268 : : // if not found, insert in child list
269 : 0 : if ( aIter == m_aAccessibleChildren.end() )
270 : : {
271 : : // insert entry in child list
272 : 0 : m_aAccessibleChildren.push_back( rDesc );
273 : :
274 : : // get the accessible of the inserted child
275 : 0 : Reference< XAccessible > xChild( getAccessibleChild( m_aAccessibleChildren.size() - 1 ) );
276 : :
277 : : // sort child list
278 : 0 : SortChildren();
279 : :
280 : : // send accessible child event
281 : 0 : if ( xChild.is() )
282 : : {
283 : 0 : Any aOldValue, aNewValue;
284 : 0 : aNewValue <<= xChild;
285 : 0 : NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
286 : 0 : }
287 : : }
288 : 0 : }
289 : :
290 : : // -----------------------------------------------------------------------------
291 : :
292 : 0 : void AccessibleDialogWindow::RemoveChild( const ChildDescriptor& rDesc )
293 : : {
294 : : // find object in child list
295 : 0 : AccessibleChildren::iterator aIter = ::std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
296 : :
297 : : // if found, remove from child list
298 : 0 : if ( aIter != m_aAccessibleChildren.end() )
299 : : {
300 : : // get the accessible of the removed child
301 : 0 : Reference< XAccessible > xChild( aIter->rxAccessible );
302 : :
303 : : // remove entry from child list
304 : 0 : m_aAccessibleChildren.erase( aIter );
305 : :
306 : : // send accessible child event
307 : 0 : if ( xChild.is() )
308 : : {
309 : 0 : Any aOldValue, aNewValue;
310 : 0 : aOldValue <<= xChild;
311 : 0 : NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
312 : :
313 : 0 : Reference< XComponent > xComponent( xChild, UNO_QUERY );
314 : 0 : if ( xComponent.is() )
315 : 0 : xComponent->dispose();
316 : 0 : }
317 : : }
318 : 0 : }
319 : :
320 : : // -----------------------------------------------------------------------------
321 : :
322 : 0 : void AccessibleDialogWindow::UpdateChild( const ChildDescriptor& rDesc )
323 : : {
324 : 0 : if ( IsChildVisible( rDesc ) )
325 : : {
326 : : // if the object is not in the child list, insert child
327 : 0 : InsertChild( rDesc );
328 : : }
329 : : else
330 : : {
331 : : // if the object is in the child list, remove child
332 : 0 : RemoveChild( rDesc );
333 : : }
334 : 0 : }
335 : :
336 : : // -----------------------------------------------------------------------------
337 : :
338 : 0 : void AccessibleDialogWindow::UpdateChildren()
339 : : {
340 : 0 : if ( m_pDialogWindow )
341 : : {
342 : 0 : if (SdrPage* pSdrPage = m_pDialogWindow->GetPage())
343 : : {
344 : 0 : for ( sal_uLong i = 0, nCount = pSdrPage->GetObjCount(); i < nCount; ++i )
345 : 0 : if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pSdrPage->GetObj(i)))
346 : 0 : UpdateChild( ChildDescriptor( pDlgEdObj ) );
347 : : }
348 : : }
349 : 0 : }
350 : :
351 : : // -----------------------------------------------------------------------------
352 : :
353 : 0 : void AccessibleDialogWindow::SortChildren()
354 : : {
355 : : // sort child list
356 : 0 : ::std::sort( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end() );
357 : 0 : }
358 : :
359 : : // -----------------------------------------------------------------------------
360 : :
361 : 0 : IMPL_LINK( AccessibleDialogWindow, WindowEventListener, VclSimpleEvent*, pEvent )
362 : : {
363 : : DBG_CHKTHIS( AccessibleDialogWindow, 0 );
364 : :
365 : 0 : if (VclWindowEvent* pWinEvent = dynamic_cast<VclWindowEvent*>(pEvent))
366 : : {
367 : : DBG_ASSERT(pWinEvent->GetWindow(), "AccessibleDialogWindow::WindowEventListener: no window!");
368 : 0 : if (!pWinEvent->GetWindow()->IsAccessibilityEventsSuppressed() || pEvent->GetId() == VCLEVENT_OBJECT_DYING)
369 : 0 : ProcessWindowEvent(*pWinEvent);
370 : : }
371 : : else
372 : : DBG_ASSERT(false, "AccessibleDialogWindow::WindowEventListener: unknown window event!");
373 : 0 : return 0;
374 : : }
375 : :
376 : : // -----------------------------------------------------------------------------
377 : :
378 : 0 : void AccessibleDialogWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
379 : : {
380 : 0 : Any aOldValue, aNewValue;
381 : :
382 : 0 : switch ( rVclWindowEvent.GetId() )
383 : : {
384 : : case VCLEVENT_WINDOW_ENABLED:
385 : : {
386 : 0 : aNewValue <<= AccessibleStateType::ENABLED;
387 : 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
388 : : }
389 : 0 : break;
390 : : case VCLEVENT_WINDOW_DISABLED:
391 : : {
392 : 0 : aOldValue <<= AccessibleStateType::ENABLED;
393 : 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
394 : : }
395 : 0 : break;
396 : : case VCLEVENT_WINDOW_ACTIVATE:
397 : : {
398 : 0 : aNewValue <<= AccessibleStateType::ACTIVE;
399 : 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
400 : : }
401 : 0 : break;
402 : : case VCLEVENT_WINDOW_DEACTIVATE:
403 : : {
404 : 0 : aOldValue <<= AccessibleStateType::ACTIVE;
405 : 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
406 : : }
407 : 0 : break;
408 : : case VCLEVENT_WINDOW_GETFOCUS:
409 : : {
410 : 0 : aNewValue <<= AccessibleStateType::FOCUSED;
411 : 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
412 : : }
413 : 0 : break;
414 : : case VCLEVENT_WINDOW_LOSEFOCUS:
415 : : {
416 : 0 : aOldValue <<= AccessibleStateType::FOCUSED;
417 : 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
418 : : }
419 : 0 : break;
420 : : case VCLEVENT_WINDOW_SHOW:
421 : : {
422 : 0 : aNewValue <<= AccessibleStateType::SHOWING;
423 : 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
424 : : }
425 : 0 : break;
426 : : case VCLEVENT_WINDOW_HIDE:
427 : : {
428 : 0 : aOldValue <<= AccessibleStateType::SHOWING;
429 : 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
430 : : }
431 : 0 : break;
432 : : case VCLEVENT_WINDOW_RESIZE:
433 : : {
434 : 0 : NotifyAccessibleEvent( AccessibleEventId::BOUNDRECT_CHANGED, aOldValue, aNewValue );
435 : 0 : UpdateChildren();
436 : 0 : UpdateBounds();
437 : : }
438 : 0 : break;
439 : : case VCLEVENT_OBJECT_DYING:
440 : : {
441 : 0 : if ( m_pDialogWindow )
442 : : {
443 : 0 : m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
444 : 0 : m_pDialogWindow = NULL;
445 : :
446 : 0 : if ( m_pDlgEditor )
447 : 0 : EndListening( *m_pDlgEditor );
448 : 0 : m_pDlgEditor = NULL;
449 : :
450 : 0 : if ( m_pDlgEdModel )
451 : 0 : EndListening( *m_pDlgEdModel );
452 : 0 : m_pDlgEdModel = NULL;
453 : :
454 : : // dispose all children
455 : 0 : for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
456 : : {
457 : 0 : Reference< XComponent > xComponent( m_aAccessibleChildren[i].rxAccessible, UNO_QUERY );
458 : 0 : if ( xComponent.is() )
459 : 0 : xComponent->dispose();
460 : 0 : }
461 : 0 : m_aAccessibleChildren.clear();
462 : : }
463 : : }
464 : 0 : break;
465 : : default:
466 : : {
467 : : }
468 : 0 : break;
469 : 0 : }
470 : 0 : }
471 : :
472 : : // -----------------------------------------------------------------------------
473 : :
474 : 0 : void AccessibleDialogWindow::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
475 : : {
476 : 0 : if ( m_pDialogWindow )
477 : : {
478 : 0 : if ( m_pDialogWindow->IsEnabled() )
479 : 0 : rStateSet.AddState( AccessibleStateType::ENABLED );
480 : :
481 : 0 : rStateSet.AddState( AccessibleStateType::FOCUSABLE );
482 : :
483 : 0 : if ( m_pDialogWindow->HasFocus() )
484 : 0 : rStateSet.AddState( AccessibleStateType::FOCUSED );
485 : :
486 : 0 : rStateSet.AddState( AccessibleStateType::VISIBLE );
487 : :
488 : 0 : if ( m_pDialogWindow->IsVisible() )
489 : 0 : rStateSet.AddState( AccessibleStateType::SHOWING );
490 : :
491 : 0 : rStateSet.AddState( AccessibleStateType::OPAQUE );
492 : :
493 : 0 : rStateSet.AddState( AccessibleStateType::RESIZABLE );
494 : : }
495 : 0 : }
496 : :
497 : : // -----------------------------------------------------------------------------
498 : : // OCommonAccessibleComponent
499 : : // -----------------------------------------------------------------------------
500 : :
501 : 0 : awt::Rectangle AccessibleDialogWindow::implGetBounds() throw (RuntimeException)
502 : : {
503 : 0 : awt::Rectangle aBounds;
504 : 0 : if ( m_pDialogWindow )
505 : 0 : aBounds = AWTRectangle( Rectangle( m_pDialogWindow->GetPosPixel(), m_pDialogWindow->GetSizePixel() ) );
506 : :
507 : 0 : return aBounds;
508 : : }
509 : :
510 : : // -----------------------------------------------------------------------------
511 : : // SfxListener
512 : : // -----------------------------------------------------------------------------
513 : :
514 : 0 : void AccessibleDialogWindow::Notify( SfxBroadcaster&, const SfxHint& rHint )
515 : : {
516 : 0 : if (SdrHint const* pSdrHint = dynamic_cast<SdrHint const*>(&rHint))
517 : : {
518 : 0 : switch ( pSdrHint->GetKind() )
519 : : {
520 : : case HINT_OBJINSERTED:
521 : : {
522 : 0 : if (DlgEdObj const* pDlgEdObj = dynamic_cast<DlgEdObj const*>(pSdrHint->GetObject()))
523 : : {
524 : 0 : ChildDescriptor aDesc(const_cast<DlgEdObj*>(pDlgEdObj));
525 : 0 : if ( IsChildVisible( aDesc ) )
526 : 0 : InsertChild( aDesc );
527 : : }
528 : : }
529 : 0 : break;
530 : : case HINT_OBJREMOVED:
531 : : {
532 : 0 : if (DlgEdObj const* pDlgEdObj = dynamic_cast<DlgEdObj const*>(pSdrHint->GetObject()))
533 : 0 : RemoveChild( ChildDescriptor(const_cast<DlgEdObj*>(pDlgEdObj)) );
534 : : }
535 : 0 : break;
536 : : default: ;
537 : : }
538 : : }
539 : 0 : else if (DlgEdHint const* pDlgEdHint = dynamic_cast<DlgEdHint const*>(&rHint))
540 : : {
541 : 0 : switch ( pDlgEdHint->GetKind() )
542 : : {
543 : : case DLGED_HINT_WINDOWSCROLLED:
544 : : {
545 : 0 : UpdateChildren();
546 : 0 : UpdateBounds();
547 : : }
548 : 0 : break;
549 : : case DLGED_HINT_LAYERCHANGED:
550 : : {
551 : 0 : if (DlgEdObj* pDlgEdObj = pDlgEdHint->GetObject())
552 : 0 : UpdateChild( ChildDescriptor( pDlgEdObj ) );
553 : : }
554 : 0 : break;
555 : : case DLGED_HINT_OBJORDERCHANGED:
556 : : {
557 : 0 : SortChildren();
558 : : }
559 : 0 : break;
560 : : case DLGED_HINT_SELECTIONCHANGED:
561 : : {
562 : 0 : UpdateFocused();
563 : 0 : UpdateSelected();
564 : : }
565 : 0 : break;
566 : : default: ;
567 : : }
568 : : }
569 : 0 : }
570 : :
571 : : // -----------------------------------------------------------------------------
572 : : // XInterface
573 : : // -----------------------------------------------------------------------------
574 : :
575 : 0 : IMPLEMENT_FORWARD_XINTERFACE2( AccessibleDialogWindow, AccessibleExtendedComponentHelper_BASE, AccessibleDialogWindow_BASE )
576 : :
577 : : // -----------------------------------------------------------------------------
578 : : // XTypeProvider
579 : : // -----------------------------------------------------------------------------
580 : :
581 : 0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleDialogWindow, AccessibleExtendedComponentHelper_BASE, AccessibleDialogWindow_BASE )
582 : :
583 : : // -----------------------------------------------------------------------------
584 : : // XComponent
585 : : // -----------------------------------------------------------------------------
586 : :
587 : 0 : void AccessibleDialogWindow::disposing()
588 : : {
589 : 0 : AccessibleExtendedComponentHelper_BASE::disposing();
590 : :
591 : 0 : if ( m_pDialogWindow )
592 : : {
593 : 0 : m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
594 : 0 : m_pDialogWindow = NULL;
595 : :
596 : 0 : if ( m_pDlgEditor )
597 : 0 : EndListening( *m_pDlgEditor );
598 : 0 : m_pDlgEditor = NULL;
599 : :
600 : 0 : if ( m_pDlgEdModel )
601 : 0 : EndListening( *m_pDlgEdModel );
602 : 0 : m_pDlgEdModel = NULL;
603 : :
604 : : // dispose all children
605 : 0 : for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
606 : : {
607 : 0 : Reference< XComponent > xComponent( m_aAccessibleChildren[i].rxAccessible, UNO_QUERY );
608 : 0 : if ( xComponent.is() )
609 : 0 : xComponent->dispose();
610 : 0 : }
611 : 0 : m_aAccessibleChildren.clear();
612 : : }
613 : 0 : }
614 : :
615 : : // -----------------------------------------------------------------------------
616 : : // XServiceInfo
617 : : // -----------------------------------------------------------------------------
618 : :
619 : 0 : ::rtl::OUString AccessibleDialogWindow::getImplementationName() throw (RuntimeException)
620 : : {
621 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.basctl.AccessibleWindow" ));
622 : : }
623 : :
624 : : // -----------------------------------------------------------------------------
625 : :
626 : 0 : sal_Bool AccessibleDialogWindow::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
627 : : {
628 : 0 : Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
629 : 0 : const ::rtl::OUString* pNames = aNames.getConstArray();
630 : 0 : const ::rtl::OUString* pEnd = pNames + aNames.getLength();
631 : 0 : for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
632 : : ;
633 : :
634 : 0 : return pNames != pEnd;
635 : : }
636 : :
637 : : // -----------------------------------------------------------------------------
638 : :
639 : 0 : Sequence< ::rtl::OUString > AccessibleDialogWindow::getSupportedServiceNames() throw (RuntimeException)
640 : : {
641 : 0 : Sequence< ::rtl::OUString > aNames(1);
642 : 0 : aNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.AccessibleWindow" ));
643 : 0 : return aNames;
644 : : }
645 : :
646 : : // -----------------------------------------------------------------------------
647 : : // XAccessible
648 : : // -----------------------------------------------------------------------------
649 : :
650 : 0 : Reference< XAccessibleContext > AccessibleDialogWindow::getAccessibleContext( ) throw (RuntimeException)
651 : : {
652 : 0 : OExternalLockGuard aGuard( this );
653 : :
654 : 0 : return this;
655 : : }
656 : :
657 : : // -----------------------------------------------------------------------------
658 : : // XAccessibleContext
659 : : // -----------------------------------------------------------------------------
660 : :
661 : 0 : sal_Int32 AccessibleDialogWindow::getAccessibleChildCount() throw (RuntimeException)
662 : : {
663 : 0 : OExternalLockGuard aGuard( this );
664 : :
665 : 0 : return m_aAccessibleChildren.size();
666 : : }
667 : :
668 : : // -----------------------------------------------------------------------------
669 : :
670 : 0 : Reference< XAccessible > AccessibleDialogWindow::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
671 : : {
672 : 0 : OExternalLockGuard aGuard( this );
673 : :
674 : 0 : if ( i < 0 || i >= getAccessibleChildCount() )
675 : 0 : throw IndexOutOfBoundsException();
676 : :
677 : 0 : Reference< XAccessible > xChild = m_aAccessibleChildren[i].rxAccessible;
678 : 0 : if ( !xChild.is() )
679 : : {
680 : 0 : if ( m_pDialogWindow )
681 : : {
682 : 0 : DlgEdObj* pDlgEdObj = m_aAccessibleChildren[i].pDlgEdObj;
683 : 0 : if ( pDlgEdObj )
684 : : {
685 : 0 : xChild = new AccessibleDialogControlShape( m_pDialogWindow, pDlgEdObj );
686 : :
687 : : // insert into child list
688 : 0 : m_aAccessibleChildren[i].rxAccessible = xChild;
689 : : }
690 : : }
691 : : }
692 : :
693 : 0 : return xChild;
694 : : }
695 : :
696 : : // -----------------------------------------------------------------------------
697 : :
698 : 0 : Reference< XAccessible > AccessibleDialogWindow::getAccessibleParent( ) throw (RuntimeException)
699 : : {
700 : 0 : OExternalLockGuard aGuard( this );
701 : :
702 : 0 : Reference< XAccessible > xParent;
703 : 0 : if ( m_pDialogWindow )
704 : : {
705 : 0 : Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
706 : 0 : if ( pParent )
707 : 0 : xParent = pParent->GetAccessible();
708 : : }
709 : :
710 : 0 : return xParent;
711 : : }
712 : :
713 : : // -----------------------------------------------------------------------------
714 : :
715 : 0 : sal_Int32 AccessibleDialogWindow::getAccessibleIndexInParent( ) throw (RuntimeException)
716 : : {
717 : 0 : OExternalLockGuard aGuard( this );
718 : :
719 : 0 : sal_Int32 nIndexInParent = -1;
720 : 0 : if ( m_pDialogWindow )
721 : : {
722 : 0 : Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
723 : 0 : if ( pParent )
724 : : {
725 : 0 : for ( sal_uInt16 i = 0, nCount = pParent->GetAccessibleChildWindowCount(); i < nCount; ++i )
726 : : {
727 : 0 : Window* pChild = pParent->GetAccessibleChildWindow( i );
728 : 0 : if ( pChild == static_cast< Window* >( m_pDialogWindow ) )
729 : : {
730 : 0 : nIndexInParent = i;
731 : 0 : break;
732 : : }
733 : : }
734 : : }
735 : : }
736 : :
737 : 0 : return nIndexInParent;
738 : : }
739 : :
740 : : // -----------------------------------------------------------------------------
741 : :
742 : 0 : sal_Int16 AccessibleDialogWindow::getAccessibleRole( ) throw (RuntimeException)
743 : : {
744 : 0 : OExternalLockGuard aGuard( this );
745 : :
746 : 0 : return AccessibleRole::PANEL;
747 : : }
748 : :
749 : : // -----------------------------------------------------------------------------
750 : :
751 : 0 : ::rtl::OUString AccessibleDialogWindow::getAccessibleDescription( ) throw (RuntimeException)
752 : : {
753 : 0 : OExternalLockGuard aGuard( this );
754 : :
755 : 0 : ::rtl::OUString sDescription;
756 : 0 : if ( m_pDialogWindow )
757 : 0 : sDescription = m_pDialogWindow->GetAccessibleDescription();
758 : :
759 : 0 : return sDescription;
760 : : }
761 : :
762 : : // -----------------------------------------------------------------------------
763 : :
764 : 0 : ::rtl::OUString AccessibleDialogWindow::getAccessibleName( ) throw (RuntimeException)
765 : : {
766 : 0 : OExternalLockGuard aGuard( this );
767 : :
768 : 0 : ::rtl::OUString sName;
769 : 0 : if ( m_pDialogWindow )
770 : 0 : sName = m_pDialogWindow->GetAccessibleName();
771 : :
772 : 0 : return sName;
773 : : }
774 : :
775 : : // -----------------------------------------------------------------------------
776 : :
777 : 0 : Reference< XAccessibleRelationSet > AccessibleDialogWindow::getAccessibleRelationSet( ) throw (RuntimeException)
778 : : {
779 : 0 : OExternalLockGuard aGuard( this );
780 : :
781 : 0 : utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
782 : 0 : Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
783 : 0 : return xSet;
784 : : }
785 : :
786 : : // -----------------------------------------------------------------------------
787 : :
788 : 0 : Reference< XAccessibleStateSet > AccessibleDialogWindow::getAccessibleStateSet( ) throw (RuntimeException)
789 : : {
790 : 0 : OExternalLockGuard aGuard( this );
791 : :
792 : 0 : utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
793 : 0 : Reference< XAccessibleStateSet > xSet = pStateSetHelper;
794 : :
795 : 0 : if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
796 : : {
797 : 0 : FillAccessibleStateSet( *pStateSetHelper );
798 : : }
799 : : else
800 : : {
801 : 0 : pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
802 : : }
803 : :
804 : 0 : return xSet;
805 : : }
806 : :
807 : : // -----------------------------------------------------------------------------
808 : :
809 : 0 : Locale AccessibleDialogWindow::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
810 : : {
811 : 0 : OExternalLockGuard aGuard( this );
812 : :
813 : 0 : return Application::GetSettings().GetLocale();
814 : : }
815 : :
816 : : // -----------------------------------------------------------------------------
817 : : // XAccessibleComponent
818 : : // -----------------------------------------------------------------------------
819 : :
820 : 0 : Reference< XAccessible > AccessibleDialogWindow::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException)
821 : : {
822 : 0 : OExternalLockGuard aGuard( this );
823 : :
824 : 0 : Reference< XAccessible > xChild;
825 : 0 : for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
826 : : {
827 : 0 : Reference< XAccessible > xAcc = getAccessibleChild( i );
828 : 0 : if ( xAcc.is() )
829 : : {
830 : 0 : Reference< XAccessibleComponent > xComp( xAcc->getAccessibleContext(), UNO_QUERY );
831 : 0 : if ( xComp.is() )
832 : : {
833 : 0 : Rectangle aRect = VCLRectangle( xComp->getBounds() );
834 : 0 : Point aPos = VCLPoint( rPoint );
835 : 0 : if ( aRect.IsInside( aPos ) )
836 : : {
837 : 0 : xChild = xAcc;
838 : : break;
839 : : }
840 : 0 : }
841 : : }
842 : 0 : }
843 : :
844 : 0 : return xChild;
845 : : }
846 : :
847 : : // -----------------------------------------------------------------------------
848 : :
849 : 0 : void AccessibleDialogWindow::grabFocus( ) throw (RuntimeException)
850 : : {
851 : 0 : OExternalLockGuard aGuard( this );
852 : :
853 : 0 : if ( m_pDialogWindow )
854 : 0 : m_pDialogWindow->GrabFocus();
855 : 0 : }
856 : :
857 : : // -----------------------------------------------------------------------------
858 : :
859 : 0 : sal_Int32 AccessibleDialogWindow::getForeground( ) throw (RuntimeException)
860 : : {
861 : 0 : OExternalLockGuard aGuard( this );
862 : :
863 : 0 : sal_Int32 nColor = 0;
864 : 0 : if ( m_pDialogWindow )
865 : : {
866 : 0 : if ( m_pDialogWindow->IsControlForeground() )
867 : 0 : nColor = m_pDialogWindow->GetControlForeground().GetColor();
868 : : else
869 : : {
870 : 0 : Font aFont;
871 : 0 : if ( m_pDialogWindow->IsControlFont() )
872 : 0 : aFont = m_pDialogWindow->GetControlFont();
873 : : else
874 : 0 : aFont = m_pDialogWindow->GetFont();
875 : 0 : nColor = aFont.GetColor().GetColor();
876 : : }
877 : : }
878 : :
879 : 0 : return nColor;
880 : : }
881 : :
882 : : // -----------------------------------------------------------------------------
883 : :
884 : 0 : sal_Int32 AccessibleDialogWindow::getBackground( ) throw (RuntimeException)
885 : : {
886 : 0 : OExternalLockGuard aGuard( this );
887 : :
888 : 0 : sal_Int32 nColor = 0;
889 : 0 : if ( m_pDialogWindow )
890 : : {
891 : 0 : if ( m_pDialogWindow->IsControlBackground() )
892 : 0 : nColor = m_pDialogWindow->GetControlBackground().GetColor();
893 : : else
894 : 0 : nColor = m_pDialogWindow->GetBackground().GetColor().GetColor();
895 : : }
896 : :
897 : 0 : return nColor;
898 : : }
899 : :
900 : : // -----------------------------------------------------------------------------
901 : : // XAccessibleExtendedComponent
902 : : // -----------------------------------------------------------------------------
903 : :
904 : 0 : Reference< awt::XFont > AccessibleDialogWindow::getFont( ) throw (RuntimeException)
905 : : {
906 : 0 : OExternalLockGuard aGuard( this );
907 : :
908 : 0 : Reference< awt::XFont > xFont;
909 : 0 : if ( m_pDialogWindow )
910 : : {
911 : 0 : Reference< awt::XDevice > xDev( m_pDialogWindow->GetComponentInterface(), UNO_QUERY );
912 : 0 : if ( xDev.is() )
913 : : {
914 : 0 : Font aFont;
915 : 0 : if ( m_pDialogWindow->IsControlFont() )
916 : 0 : aFont = m_pDialogWindow->GetControlFont();
917 : : else
918 : 0 : aFont = m_pDialogWindow->GetFont();
919 : 0 : VCLXFont* pVCLXFont = new VCLXFont;
920 : 0 : pVCLXFont->Init( *xDev.get(), aFont );
921 : 0 : xFont = pVCLXFont;
922 : 0 : }
923 : : }
924 : :
925 : 0 : return xFont;
926 : : }
927 : :
928 : : // -----------------------------------------------------------------------------
929 : :
930 : 0 : ::rtl::OUString AccessibleDialogWindow::getTitledBorderText( ) throw (RuntimeException)
931 : : {
932 : 0 : OExternalLockGuard aGuard( this );
933 : :
934 : 0 : return ::rtl::OUString();
935 : : }
936 : :
937 : : // -----------------------------------------------------------------------------
938 : :
939 : 0 : ::rtl::OUString AccessibleDialogWindow::getToolTipText( ) throw (RuntimeException)
940 : : {
941 : 0 : OExternalLockGuard aGuard( this );
942 : :
943 : 0 : ::rtl::OUString sText;
944 : 0 : if ( m_pDialogWindow )
945 : 0 : sText = m_pDialogWindow->GetQuickHelpText();
946 : :
947 : 0 : return sText;
948 : : }
949 : :
950 : : // -----------------------------------------------------------------------------
951 : : // XAccessibleSelection
952 : : // -----------------------------------------------------------------------------
953 : :
954 : 0 : void AccessibleDialogWindow::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
955 : : {
956 : 0 : OExternalLockGuard aGuard( this );
957 : :
958 : 0 : if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
959 : 0 : throw IndexOutOfBoundsException();
960 : :
961 : 0 : if ( m_pDialogWindow )
962 : : {
963 : 0 : DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj;
964 : 0 : if ( pDlgEdObj )
965 : : {
966 : 0 : SdrView* pSdrView = m_pDialogWindow->GetView();
967 : 0 : if ( pSdrView )
968 : : {
969 : 0 : SdrPageView* pPgView = pSdrView->GetSdrPageView();
970 : 0 : if ( pPgView )
971 : 0 : pSdrView->MarkObj( pDlgEdObj, pPgView );
972 : : }
973 : : }
974 : 0 : }
975 : 0 : }
976 : :
977 : : // -----------------------------------------------------------------------------
978 : :
979 : 0 : sal_Bool AccessibleDialogWindow::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
980 : : {
981 : 0 : OExternalLockGuard aGuard( this );
982 : :
983 : 0 : if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
984 : 0 : throw IndexOutOfBoundsException();
985 : :
986 : 0 : bool bSelected = false;
987 : 0 : if ( m_pDialogWindow )
988 : : {
989 : 0 : DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj;
990 : 0 : if ( pDlgEdObj )
991 : : {
992 : 0 : SdrView* pSdrView = m_pDialogWindow->GetView();
993 : 0 : if ( pSdrView )
994 : 0 : bSelected = pSdrView->IsObjMarked( pDlgEdObj );
995 : : }
996 : : }
997 : :
998 : 0 : return bSelected;
999 : : }
1000 : :
1001 : : // -----------------------------------------------------------------------------
1002 : :
1003 : 0 : void AccessibleDialogWindow::clearAccessibleSelection( ) throw (RuntimeException)
1004 : : {
1005 : 0 : OExternalLockGuard aGuard( this );
1006 : :
1007 : 0 : if ( m_pDialogWindow )
1008 : : {
1009 : 0 : SdrView* pSdrView = m_pDialogWindow->GetView();
1010 : 0 : if ( pSdrView )
1011 : 0 : pSdrView->UnmarkAll();
1012 : 0 : }
1013 : 0 : }
1014 : :
1015 : : // -----------------------------------------------------------------------------
1016 : :
1017 : 0 : void AccessibleDialogWindow::selectAllAccessibleChildren( ) throw (RuntimeException)
1018 : : {
1019 : 0 : OExternalLockGuard aGuard( this );
1020 : :
1021 : 0 : if ( m_pDialogWindow )
1022 : : {
1023 : 0 : SdrView* pSdrView = m_pDialogWindow->GetView();
1024 : 0 : if ( pSdrView )
1025 : 0 : pSdrView->MarkAll();
1026 : 0 : }
1027 : 0 : }
1028 : :
1029 : : // -----------------------------------------------------------------------------
1030 : :
1031 : 0 : sal_Int32 AccessibleDialogWindow::getSelectedAccessibleChildCount( ) throw (RuntimeException)
1032 : : {
1033 : 0 : OExternalLockGuard aGuard( this );
1034 : :
1035 : 0 : sal_Int32 nRet = 0;
1036 : :
1037 : 0 : for ( sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
1038 : : {
1039 : 0 : if ( isAccessibleChildSelected( i ) )
1040 : 0 : ++nRet;
1041 : : }
1042 : :
1043 : 0 : return nRet;
1044 : : }
1045 : :
1046 : : // -----------------------------------------------------------------------------
1047 : :
1048 : 0 : Reference< XAccessible > AccessibleDialogWindow::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
1049 : : {
1050 : 0 : OExternalLockGuard aGuard( this );
1051 : :
1052 : 0 : if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
1053 : 0 : throw IndexOutOfBoundsException();
1054 : :
1055 : 0 : Reference< XAccessible > xChild;
1056 : :
1057 : 0 : for ( sal_Int32 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
1058 : : {
1059 : 0 : if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
1060 : : {
1061 : 0 : xChild = getAccessibleChild( i );
1062 : 0 : break;
1063 : : }
1064 : : }
1065 : :
1066 : 0 : return xChild;
1067 : : }
1068 : :
1069 : : // -----------------------------------------------------------------------------
1070 : :
1071 : 0 : void AccessibleDialogWindow::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
1072 : : {
1073 : 0 : OExternalLockGuard aGuard( this );
1074 : :
1075 : 0 : if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
1076 : 0 : throw IndexOutOfBoundsException();
1077 : :
1078 : 0 : if ( m_pDialogWindow )
1079 : : {
1080 : 0 : DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj;
1081 : 0 : if ( pDlgEdObj )
1082 : : {
1083 : 0 : SdrView* pSdrView = m_pDialogWindow->GetView();
1084 : 0 : if ( pSdrView )
1085 : : {
1086 : 0 : SdrPageView* pPgView = pSdrView->GetSdrPageView();
1087 : 0 : if ( pPgView )
1088 : 0 : pSdrView->MarkObj( pDlgEdObj, pPgView, true );
1089 : : }
1090 : : }
1091 : 0 : }
1092 : 0 : }
1093 : :
1094 : : // -----------------------------------------------------------------------------
1095 : :
1096 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|