Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "AccessibleTreeNode.hxx"
31 : :
32 : : #include "taskpane/TaskPaneTreeNode.hxx"
33 : : #include "taskpane/ControlContainer.hxx"
34 : :
35 : : #include "sdresid.hxx"
36 : : #include "accessibility.hrc"
37 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
38 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
39 : : #include <comphelper/accessibleeventnotifier.hxx>
40 : :
41 : : #include <vcl/svapp.hxx>
42 : : #include <vcl/window.hxx>
43 : : #include <svtools/colorcfg.hxx>
44 : :
45 : : using ::rtl::OUString;
46 : : using namespace ::com::sun::star;
47 : : using namespace ::com::sun::star::uno;
48 : : using namespace ::com::sun::star::accessibility;
49 : : using namespace ::sd::toolpanel;
50 : :
51 : : namespace accessibility {
52 : :
53 : :
54 : :
55 : : //===== AccessibleTreeNode =============================================
56 : :
57 : 0 : AccessibleTreeNode::AccessibleTreeNode(
58 : : ::sd::toolpanel::TreeNode& rNode,
59 : : const OUString& rsName,
60 : : const OUString& rsDescription,
61 : : sal_Int16 eRole)
62 : : : AccessibleTreeNodeBase(MutexOwner::maMutex),
63 : : mxParent(NULL),
64 : : mrTreeNode(rNode),
65 : 0 : mrStateSet(new ::utl::AccessibleStateSetHelper()),
66 : : msName(rsName),
67 : : msDescription(rsDescription),
68 : : meRole(eRole),
69 [ # # ][ # # ]: 0 : mnClientId(0)
70 : : {
71 [ # # ]: 0 : ::Window* pWindow = mrTreeNode.GetWindow();
72 [ # # ]: 0 : if (pWindow != NULL)
73 : : {
74 [ # # ]: 0 : ::Window* pParentWindow = pWindow->GetAccessibleParentWindow();
75 [ # # ][ # # ]: 0 : if (pParentWindow != NULL && pParentWindow != pWindow)
76 [ # # ][ # # ]: 0 : mxParent = pParentWindow->GetAccessible();
77 : : }
78 [ # # ]: 0 : CommonConstructor();
79 : 0 : }
80 : :
81 : :
82 : :
83 : :
84 : 0 : void AccessibleTreeNode::CommonConstructor (void)
85 : : {
86 [ # # ]: 0 : UpdateStateSet();
87 : :
88 [ # # ]: 0 : Link aStateChangeLink (LINK(this,AccessibleTreeNode,StateChangeListener));
89 [ # # ]: 0 : mrTreeNode.AddStateChangeListener(aStateChangeLink);
90 : :
91 [ # # ][ # # ]: 0 : if (mrTreeNode.GetWindow() != NULL)
92 : : {
93 [ # # ]: 0 : Link aWindowEventLink (LINK(this,AccessibleTreeNode,WindowEventListener));
94 [ # # ][ # # ]: 0 : mrTreeNode.GetWindow()->AddEventListener(aWindowEventLink);
95 : : }
96 : 0 : }
97 : :
98 : :
99 : :
100 : :
101 [ # # ]: 0 : AccessibleTreeNode::~AccessibleTreeNode (void)
102 : : {
103 : : OSL_ASSERT(IsDisposed());
104 [ # # ]: 0 : }
105 : :
106 : :
107 : :
108 : :
109 : 0 : void AccessibleTreeNode::FireAccessibleEvent (
110 : : short nEventId,
111 : : const uno::Any& rOldValue,
112 : : const uno::Any& rNewValue )
113 : : {
114 [ # # ]: 0 : if (mnClientId != 0)
115 : : {
116 [ # # ]: 0 : AccessibleEventObject aEventObject;
117 : :
118 [ # # ][ # # ]: 0 : aEventObject.Source = Reference<XWeak>(this);
119 : 0 : aEventObject.EventId = nEventId;
120 : 0 : aEventObject.NewValue = rNewValue;
121 : 0 : aEventObject.OldValue = rOldValue;
122 : :
123 [ # # ][ # # ]: 0 : comphelper::AccessibleEventNotifier::addEvent (mnClientId, aEventObject);
124 : : }
125 : 0 : }
126 : :
127 : :
128 : :
129 : :
130 : 0 : void SAL_CALL AccessibleTreeNode::disposing (void)
131 : : {
132 : : // We are still listening to the tree node and its window. Both
133 : : // probably are by now more or less dead and we must not call them to
134 : : // unregister.
135 : :
136 [ # # ]: 0 : comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this );
137 : 0 : mnClientId = 0;
138 : 0 : }
139 : :
140 : :
141 : :
142 : :
143 : : //===== XAccessible =========================================================
144 : :
145 : : Reference<XAccessibleContext > SAL_CALL
146 : 0 : AccessibleTreeNode::getAccessibleContext (void)
147 : : throw (uno::RuntimeException)
148 : : {
149 : 0 : ThrowIfDisposed ();
150 : 0 : return this;
151 : : }
152 : :
153 : :
154 : :
155 : :
156 : : //===== XAccessibleContext ==================================================
157 : :
158 : 0 : sal_Int32 SAL_CALL AccessibleTreeNode::getAccessibleChildCount (void)
159 : : throw (RuntimeException)
160 : : {
161 [ # # ]: 0 : ThrowIfDisposed();
162 [ # # ]: 0 : const SolarMutexGuard aSolarGuard;
163 [ # # ][ # # ]: 0 : return mrTreeNode.GetControlContainer().GetControlCount();
[ # # ]
164 : : }
165 : :
166 : :
167 : :
168 : :
169 : : Reference<XAccessible > SAL_CALL
170 : 0 : AccessibleTreeNode::getAccessibleChild (sal_Int32 nIndex)
171 : : throw (lang::IndexOutOfBoundsException, RuntimeException)
172 : : {
173 [ # # ]: 0 : ThrowIfDisposed();
174 [ # # ]: 0 : const SolarMutexGuard aSolarGuard;
175 : :
176 [ # # ][ # # ]: 0 : if (nIndex<0 || (sal_uInt32)nIndex>=mrTreeNode.GetControlContainer().GetControlCount())
[ # # ][ # # ]
[ # # ]
177 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
178 : :
179 : 0 : Reference<XAccessible> xChild;
180 : :
181 [ # # ][ # # ]: 0 : ::sd::toolpanel::TreeNode* pNode = mrTreeNode.GetControlContainer().GetControl(nIndex);
182 [ # # ]: 0 : if (pNode != NULL)
183 [ # # ][ # # ]: 0 : xChild = pNode->GetAccessibleObject();
184 : :
185 [ # # ]: 0 : return xChild;
186 : : }
187 : :
188 : :
189 : :
190 : :
191 : 0 : Reference<XAccessible > SAL_CALL AccessibleTreeNode::getAccessibleParent (void)
192 : : throw (uno::RuntimeException)
193 : : {
194 [ # # ]: 0 : ThrowIfDisposed();
195 [ # # ]: 0 : const SolarMutexGuard aSolarGuard;
196 [ # # ]: 0 : return mxParent;
197 : : }
198 : :
199 : :
200 : :
201 : :
202 : 0 : sal_Int32 SAL_CALL AccessibleTreeNode::getAccessibleIndexInParent (void)
203 : : throw (uno::RuntimeException)
204 : : {
205 : : OSL_ASSERT(getAccessibleParent().is());
206 [ # # ]: 0 : ThrowIfDisposed();
207 [ # # ]: 0 : const SolarMutexGuard aSolarGuard;
208 : 0 : sal_Int32 nIndexInParent(-1);
209 : :
210 : :
211 [ # # ][ # # ]: 0 : Reference<XAccessibleContext> xParentContext (getAccessibleParent()->getAccessibleContext());
[ # # ]
212 [ # # ]: 0 : if (xParentContext.is())
213 : : {
214 [ # # ][ # # ]: 0 : sal_Int32 nChildCount (xParentContext->getAccessibleChildCount());
215 [ # # ]: 0 : for (sal_Int32 i=0; i<nChildCount; ++i)
216 [ # # ][ # # ]: 0 : if (xParentContext->getAccessibleChild(i).get()
[ # # ][ # # ]
217 : : == static_cast<XAccessible*>(this))
218 : : {
219 : 0 : nIndexInParent = i;
220 : 0 : break;
221 : : }
222 : : }
223 : :
224 [ # # ]: 0 : return nIndexInParent;
225 : : }
226 : :
227 : :
228 : :
229 : :
230 : 0 : sal_Int16 SAL_CALL AccessibleTreeNode::getAccessibleRole (void)
231 : : throw (uno::RuntimeException)
232 : : {
233 : 0 : ThrowIfDisposed();
234 : 0 : return meRole;
235 : : }
236 : :
237 : :
238 : :
239 : :
240 : 0 : ::rtl::OUString SAL_CALL AccessibleTreeNode::getAccessibleDescription (void)
241 : : throw (uno::RuntimeException)
242 : : {
243 : 0 : ThrowIfDisposed();
244 : 0 : return msDescription;
245 : : }
246 : :
247 : :
248 : :
249 : :
250 : 0 : ::rtl::OUString SAL_CALL AccessibleTreeNode::getAccessibleName (void)
251 : : throw (uno::RuntimeException)
252 : : {
253 : 0 : ThrowIfDisposed();
254 : 0 : return msName;
255 : : }
256 : :
257 : :
258 : :
259 : :
260 : : Reference<XAccessibleRelationSet> SAL_CALL
261 : 0 : AccessibleTreeNode::getAccessibleRelationSet (void)
262 : : throw (uno::RuntimeException)
263 : : {
264 : 0 : ThrowIfDisposed();
265 : 0 : return Reference<XAccessibleRelationSet>();
266 : : }
267 : :
268 : :
269 : :
270 : :
271 : : Reference<XAccessibleStateSet > SAL_CALL
272 : 0 : AccessibleTreeNode::getAccessibleStateSet (void)
273 : : throw (uno::RuntimeException)
274 : : {
275 [ # # ]: 0 : ThrowIfDisposed();
276 [ # # ]: 0 : const SolarMutexGuard aSolarGuard;
277 [ # # ][ # # ]: 0 : return mrStateSet.get();
[ # # ]
278 : : }
279 : :
280 : :
281 : :
282 : :
283 : 0 : void AccessibleTreeNode::UpdateStateSet (void)
284 : : {
285 [ # # ]: 0 : if (mrTreeNode.IsExpandable())
286 : : {
287 : 0 : UpdateState(AccessibleStateType::EXPANDABLE, true);
288 : 0 : UpdateState(AccessibleStateType::EXPANDED, mrTreeNode.IsExpanded());
289 : : }
290 : :
291 : 0 : UpdateState(AccessibleStateType::FOCUSABLE, true);
292 : :
293 : 0 : ::Window* pWindow = mrTreeNode.GetWindow();
294 [ # # ]: 0 : if (pWindow != NULL)
295 : : {
296 : 0 : UpdateState(AccessibleStateType::ENABLED, pWindow->IsEnabled());
297 : 0 : UpdateState(AccessibleStateType::FOCUSED, pWindow->HasFocus());
298 : 0 : UpdateState(AccessibleStateType::VISIBLE, pWindow->IsVisible());
299 : 0 : UpdateState(AccessibleStateType::SHOWING, pWindow->IsReallyVisible());
300 : : }
301 : 0 : }
302 : :
303 : :
304 : :
305 : :
306 : 0 : void AccessibleTreeNode::UpdateState(
307 : : sal_Int16 aState,
308 : : bool bValue)
309 : : {
310 [ # # ]: 0 : if ((mrStateSet->contains(aState)!=sal_False) != bValue)
311 : : {
312 [ # # ]: 0 : if (bValue)
313 : : {
314 : 0 : mrStateSet->AddState(aState);
315 [ # # ]: 0 : FireAccessibleEvent(AccessibleEventId::STATE_CHANGED, Any(),Any(aState));
316 : : }
317 : : else
318 : : {
319 : 0 : mrStateSet->RemoveState(aState);
320 [ # # ][ # # ]: 0 : FireAccessibleEvent(AccessibleEventId::STATE_CHANGED, Any(aState),Any());
321 : : }
322 : : }
323 : 0 : }
324 : :
325 : :
326 : :
327 : :
328 : 0 : lang::Locale SAL_CALL AccessibleTreeNode::getLocale (void)
329 : : throw (IllegalAccessibleComponentStateException,
330 : : RuntimeException)
331 : : {
332 [ # # ]: 0 : ThrowIfDisposed ();
333 : 0 : Reference<XAccessibleContext> xParentContext;
334 [ # # ]: 0 : Reference<XAccessible> xParent (getAccessibleParent());
335 [ # # ]: 0 : if (xParent.is())
336 [ # # ][ # # ]: 0 : xParentContext = xParent->getAccessibleContext();
[ # # ]
337 : :
338 [ # # ]: 0 : if (xParentContext.is())
339 [ # # ][ # # ]: 0 : return xParentContext->getLocale();
340 : : else
341 : : // Strange, no parent! Anyway, return the default locale.
342 [ # # ][ # # ]: 0 : return Application::GetSettings().GetLocale();
343 : : }
344 : :
345 : :
346 : :
347 : :
348 : 0 : void SAL_CALL AccessibleTreeNode::addEventListener(
349 : : const Reference<XAccessibleEventListener >& rxListener)
350 : : throw (RuntimeException)
351 : : {
352 [ # # ]: 0 : if (rxListener.is())
353 : : {
354 [ # # ]: 0 : const osl::MutexGuard aGuard(maMutex);
355 : :
356 [ # # ]: 0 : if (IsDisposed())
357 : : {
358 [ # # ]: 0 : uno::Reference<uno::XInterface> x ((lang::XComponent *)this, uno::UNO_QUERY);
359 [ # # ][ # # ]: 0 : rxListener->disposing (lang::EventObject (x));
[ # # ][ # # ]
360 : : }
361 : : else
362 : : {
363 [ # # ]: 0 : if ( ! mnClientId)
364 [ # # ]: 0 : mnClientId = comphelper::AccessibleEventNotifier::registerClient();
365 [ # # ]: 0 : comphelper::AccessibleEventNotifier::addEventListener(mnClientId, rxListener);
366 [ # # ]: 0 : }
367 : : }
368 : 0 : }
369 : :
370 : :
371 : :
372 : :
373 : 0 : void SAL_CALL AccessibleTreeNode::removeEventListener(
374 : : const Reference<XAccessibleEventListener >& rxListener)
375 : : throw (RuntimeException)
376 : : {
377 : 0 : ThrowIfDisposed();
378 [ # # ]: 0 : if (rxListener.is())
379 : : {
380 [ # # ]: 0 : const osl::MutexGuard aGuard(maMutex);
381 : :
382 [ # # ]: 0 : sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, rxListener );
383 [ # # ]: 0 : if ( !nListenerCount )
384 : : {
385 : : // no listeners anymore
386 : : // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
387 : : // and at least to us not firing any events anymore, in case somebody calls
388 : : // NotifyAccessibleEvent, again
389 [ # # ]: 0 : comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
390 : 0 : mnClientId = 0;
391 [ # # ]: 0 : }
392 : : }
393 : 0 : }
394 : :
395 : :
396 : :
397 : :
398 : : //===== XAccessibleComponent ==================================================
399 : :
400 : 0 : sal_Bool SAL_CALL AccessibleTreeNode::containsPoint (const awt::Point& aPoint)
401 : : throw (RuntimeException)
402 : : {
403 [ # # ]: 0 : ThrowIfDisposed();
404 [ # # ]: 0 : const awt::Rectangle aBBox (getBounds());
405 : : return (aPoint.X >= 0)
406 : : && (aPoint.X < aBBox.Width)
407 : : && (aPoint.Y >= 0)
408 [ # # ][ # # ]: 0 : && (aPoint.Y < aBBox.Height);
[ # # ][ # # ]
409 : : }
410 : :
411 : :
412 : :
413 : :
414 : : Reference<XAccessible> SAL_CALL
415 : 0 : AccessibleTreeNode::getAccessibleAtPoint (const awt::Point& aPoint)
416 : : throw (RuntimeException)
417 : : {
418 [ # # ]: 0 : ThrowIfDisposed();
419 : 0 : Reference<XAccessible> xChildAtPoint;
420 [ # # ]: 0 : const SolarMutexGuard aSolarGuard;
421 : :
422 [ # # ]: 0 : sal_Int32 nChildCount = getAccessibleChildCount();
423 [ # # ]: 0 : for (sal_Int32 nIndex=0; nIndex<nChildCount; ++nIndex)
424 : : {
425 : : Reference<XAccessibleComponent> xChildComponent(
426 [ # # ][ # # ]: 0 : getAccessibleChild(nIndex), UNO_QUERY);
427 [ # # ]: 0 : if (xChildComponent.is())
428 : : {
429 : 0 : awt::Point aChildPoint(aPoint);
430 [ # # ][ # # ]: 0 : awt::Point aChildOrigin(xChildComponent->getLocation());
431 : 0 : aChildPoint.X -= aChildOrigin.X;
432 : 0 : aChildPoint.Y -= aChildOrigin.Y;
433 [ # # ][ # # ]: 0 : if (xChildComponent->containsPoint(aChildPoint))
[ # # ]
434 : : {
435 [ # # ][ # # ]: 0 : xChildAtPoint = getAccessibleChild(nIndex);
436 : : break;
437 : : }
438 : : }
439 [ # # ]: 0 : }
440 : :
441 [ # # ]: 0 : return xChildAtPoint;
442 : : }
443 : :
444 : :
445 : :
446 : :
447 : 0 : awt::Rectangle SAL_CALL AccessibleTreeNode::getBounds (void)
448 : : throw (RuntimeException)
449 : : {
450 : 0 : ThrowIfDisposed ();
451 : :
452 : 0 : awt::Rectangle aBBox;
453 : :
454 : 0 : ::Window* pWindow = mrTreeNode.GetWindow();
455 [ # # ]: 0 : if (pWindow != NULL)
456 : : {
457 : 0 : Point aPosition;
458 [ # # ]: 0 : if (mxParent.is())
459 : : {
460 [ # # ]: 0 : aPosition = pWindow->OutputToAbsoluteScreenPixel(Point(0,0));
461 : : Reference<XAccessibleComponent> xParentComponent (
462 [ # # ][ # # ]: 0 : mxParent->getAccessibleContext(), UNO_QUERY);
[ # # ]
463 [ # # ]: 0 : if (xParentComponent.is())
464 : : {
465 [ # # ][ # # ]: 0 : awt::Point aParentPosition (xParentComponent->getLocationOnScreen());
466 : 0 : aPosition.X() -= aParentPosition.X;
467 : 0 : aPosition.Y() -= aParentPosition.Y;
468 : 0 : }
469 : : }
470 : : else
471 [ # # ]: 0 : aPosition = pWindow->GetPosPixel();
472 : 0 : aBBox.X = aPosition.X();
473 : 0 : aBBox.Y = aPosition.Y();
474 : :
475 [ # # ]: 0 : Size aSize (pWindow->GetSizePixel());
476 : 0 : aBBox.Width = aSize.Width();
477 : 0 : aBBox.Height = aSize.Height();
478 : : }
479 : :
480 : 0 : return aBBox;
481 : : }
482 : :
483 : :
484 : :
485 : :
486 : 0 : awt::Point SAL_CALL AccessibleTreeNode::getLocation (void)
487 : : throw (uno::RuntimeException)
488 : : {
489 [ # # ]: 0 : ThrowIfDisposed();
490 [ # # ]: 0 : const awt::Rectangle aBBox (getBounds());
491 : 0 : return awt::Point(aBBox.X,aBBox.Y);
492 : : }
493 : :
494 : :
495 : :
496 : :
497 : : /** Calculate the location on screen from the parent's location on screen
498 : : and our own relative location.
499 : : */
500 : 0 : awt::Point SAL_CALL AccessibleTreeNode::getLocationOnScreen()
501 : : throw (uno::RuntimeException)
502 : : {
503 [ # # ]: 0 : ThrowIfDisposed();
504 [ # # ]: 0 : const SolarMutexGuard aSolarGuard;
505 : 0 : awt::Point aLocationOnScreen;
506 : :
507 [ # # ]: 0 : ::Window* pWindow = mrTreeNode.GetWindow();
508 [ # # ]: 0 : if (pWindow != NULL)
509 : : {
510 [ # # ]: 0 : Point aPoint (pWindow->OutputToAbsoluteScreenPixel(Point(0,0)));
511 : 0 : aLocationOnScreen.X = aPoint.X();
512 : 0 : aLocationOnScreen.Y = aPoint.Y();
513 : : }
514 : :
515 [ # # ]: 0 : return aLocationOnScreen;
516 : : }
517 : :
518 : :
519 : :
520 : :
521 : 0 : awt::Size SAL_CALL AccessibleTreeNode::getSize (void)
522 : : throw (uno::RuntimeException)
523 : : {
524 [ # # ]: 0 : ThrowIfDisposed();
525 [ # # ]: 0 : const awt::Rectangle aBBox (getBounds());
526 : 0 : return awt::Size(aBBox.Width,aBBox.Height);
527 : : }
528 : :
529 : :
530 : :
531 : :
532 : 0 : void SAL_CALL AccessibleTreeNode::grabFocus (void)
533 : : throw (uno::RuntimeException)
534 : : {
535 [ # # ]: 0 : ThrowIfDisposed();
536 [ # # ]: 0 : const SolarMutexGuard aSolarGuard;
537 : :
538 [ # # ][ # # ]: 0 : if (mrTreeNode.GetWindow() != NULL)
539 [ # # ][ # # ]: 0 : mrTreeNode.GetWindow()->GrabFocus();
[ # # ]
540 : 0 : }
541 : :
542 : :
543 : :
544 : :
545 : 0 : sal_Int32 SAL_CALL AccessibleTreeNode::getForeground (void)
546 : : throw (RuntimeException)
547 : : {
548 [ # # ]: 0 : ThrowIfDisposed();
549 [ # # ]: 0 : svtools::ColorConfig aColorConfig;
550 [ # # ]: 0 : sal_uInt32 nColor = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor;
551 [ # # ]: 0 : return static_cast<sal_Int32>(nColor);
552 : : }
553 : :
554 : :
555 : :
556 : :
557 : 0 : sal_Int32 SAL_CALL AccessibleTreeNode::getBackground (void)
558 : : throw (RuntimeException)
559 : : {
560 : 0 : ThrowIfDisposed();
561 : 0 : sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
562 : 0 : return static_cast<sal_Int32>(nColor);
563 : : }
564 : :
565 : :
566 : :
567 : :
568 : : //===== XServiceInfo ========================================================
569 : :
570 : : ::rtl::OUString SAL_CALL
571 : 0 : AccessibleTreeNode::getImplementationName (void)
572 : : throw (::com::sun::star::uno::RuntimeException)
573 : : {
574 : 0 : return OUString("AccessibleTreeNode");
575 : : }
576 : :
577 : :
578 : :
579 : :
580 : : sal_Bool SAL_CALL
581 : 0 : AccessibleTreeNode::supportsService (const OUString& sServiceName)
582 : : throw (::com::sun::star::uno::RuntimeException)
583 : : {
584 [ # # ]: 0 : ThrowIfDisposed ();
585 : :
586 : : // Iterate over all supported service names and return true if on of them
587 : : // matches the given name.
588 : : uno::Sequence< ::rtl::OUString> aSupportedServices (
589 [ # # ]: 0 : getSupportedServiceNames ());
590 [ # # ]: 0 : for (int i=0; i<aSupportedServices.getLength(); i++)
591 [ # # ][ # # ]: 0 : if (sServiceName == aSupportedServices[i])
592 : 0 : return sal_True;
593 [ # # ]: 0 : return sal_False;
594 : : }
595 : :
596 : :
597 : :
598 : :
599 : : uno::Sequence< ::rtl::OUString> SAL_CALL
600 : 0 : AccessibleTreeNode::getSupportedServiceNames (void)
601 : : throw (::com::sun::star::uno::RuntimeException)
602 : : {
603 : 0 : ThrowIfDisposed ();
604 : : static const OUString sServiceNames[2] = {
605 : : OUString("com.sun.star.accessibility.Accessible"),
606 : : OUString("com.sun.star.accessibility.AccessibleContext"),
607 [ # # ][ # # ]: 0 : };
[ # # ]
608 : 0 : return uno::Sequence<OUString> (sServiceNames, 2);
609 : : }
610 : :
611 : :
612 : :
613 : :
614 : 0 : void AccessibleTreeNode::ThrowIfDisposed (void)
615 : : throw (lang::DisposedException)
616 : : {
617 [ # # ][ # # ]: 0 : if (rBHelper.bDisposed || rBHelper.bInDispose)
618 : : {
619 : : OSL_TRACE ("Calling disposed object. Throwing exception:");
620 : : throw lang::DisposedException ("object has been already disposed",
621 [ # # ][ # # ]: 0 : static_cast<uno::XWeak*>(this));
622 : : }
623 : 0 : }
624 : :
625 : :
626 : :
627 : 0 : sal_Bool AccessibleTreeNode::IsDisposed (void)
628 : : {
629 [ # # ][ # # ]: 0 : return (rBHelper.bDisposed || rBHelper.bInDispose);
630 : : }
631 : :
632 : :
633 : :
634 : :
635 : 0 : IMPL_LINK(AccessibleTreeNode, StateChangeListener, TreeNodeStateChangeEvent*, pEvent)
636 : : {
637 [ # # ][ # # ]: 0 : if (rBHelper.bDisposed || rBHelper.bInDispose)
638 : 0 : return 1; // mrTreeNode is probably dead
639 : :
640 : : OSL_ASSERT(pEvent!=NULL);
641 : : OSL_ASSERT(&pEvent->mrSource==&mrTreeNode);
642 : :
643 [ # # # # ]: 0 : switch(pEvent->meEventId)
644 : : {
645 : : case EID_CHILD_ADDED:
646 [ # # ]: 0 : if (pEvent->mpChild != NULL)
647 : : FireAccessibleEvent(AccessibleEventId::CHILD,
648 : : Any(),
649 [ # # ][ # # ]: 0 : Any(pEvent->mpChild->GetAccessibleObject()));
650 : : else
651 [ # # ]: 0 : FireAccessibleEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN,Any(),Any());
652 : 0 : break;
653 : :
654 : : case EID_ALL_CHILDREN_REMOVED:
655 [ # # ]: 0 : FireAccessibleEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN,Any(),Any());
656 : 0 : break;
657 : :
658 : : case EID_EXPANSION_STATE_CHANGED:
659 : : case EID_FOCUSED_STATE_CHANGED:
660 : : case EID_SHOWING_STATE_CHANGED:
661 : 0 : UpdateStateSet();
662 : 0 : break;
663 : : }
664 : 0 : return 1;
665 : : }
666 : :
667 : :
668 : :
669 : :
670 : 0 : IMPL_LINK(AccessibleTreeNode, WindowEventListener, VclWindowEvent*, pEvent)
671 : : {
672 [ # # ][ # # ]: 0 : if (rBHelper.bDisposed || rBHelper.bInDispose)
673 : 0 : return 1; // mrTreeNode is probably dead
674 : :
675 [ # # # # : 0 : switch (pEvent->GetId())
# ]
676 : : {
677 : : case VCLEVENT_WINDOW_HIDE:
678 : : // This event may be sent while the window is destroyed so do
679 : : // not call UpdateStateSet() which calls back to the window but
680 : : // just set the two states VISIBLE and SHOWING to false.
681 : 0 : UpdateState(AccessibleStateType::VISIBLE, false);
682 : 0 : UpdateState(AccessibleStateType::SHOWING, false);
683 : 0 : break;
684 : :
685 : : case VCLEVENT_WINDOW_SHOW:
686 : : case VCLEVENT_WINDOW_DATACHANGED:
687 : 0 : UpdateStateSet();
688 : 0 : break;
689 : :
690 : : case VCLEVENT_WINDOW_MOVE:
691 : : case VCLEVENT_WINDOW_RESIZE:
692 [ # # ]: 0 : FireAccessibleEvent(AccessibleEventId::BOUNDRECT_CHANGED,Any(),Any());
693 : 0 : break;
694 : :
695 : : case VCLEVENT_WINDOW_GETFOCUS:
696 : : case VCLEVENT_WINDOW_LOSEFOCUS:
697 : 0 : UpdateStateSet();
698 : 0 : break;
699 : : }
700 : 0 : return 1;
701 : : }
702 : :
703 : : } // end of namespace ::accessibility
704 : :
705 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|