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 : : #include <editeng/AccessibleContextBase.hxx>
30 : :
31 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
32 : : #include <com/sun/star/beans/PropertyChangeEvent.hpp>
33 : : #include <com/sun/star/accessibility/XAccessibleEventListener.hpp>
34 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
35 : : #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
36 : :
37 : : #include <unotools/accessiblestatesethelper.hxx>
38 : : #include <unotools/accessiblerelationsethelper.hxx>
39 : : #include <comphelper/accessibleeventnotifier.hxx>
40 : : #include <comphelper/servicehelper.hxx>
41 : : #include <osl/mutex.hxx>
42 : :
43 : : #include <utility>
44 : :
45 : : using namespace ::rtl;
46 : : using namespace ::com::sun::star;
47 : : using namespace ::com::sun::star::accessibility;
48 : : using ::com::sun::star::uno::Reference;
49 : :
50 : : namespace accessibility {
51 : :
52 : : //===== internal ============================================================
53 : :
54 : : // Define a shortcut for the somewhot longish base class name.
55 : : typedef ::cppu::PartialWeakComponentImplHelper4<
56 : : ::com::sun::star::accessibility::XAccessible,
57 : : ::com::sun::star::accessibility::XAccessibleContext,
58 : : ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
59 : : ::com::sun::star::lang::XServiceInfo> BaseClass;
60 : :
61 : 28 : AccessibleContextBase::AccessibleContextBase (
62 : : const uno::Reference<XAccessible>& rxParent,
63 : : const sal_Int16 aRole)
64 : : : BaseClass (MutexOwner::maMutex),
65 : : mxStateSet (NULL),
66 : : mxRelationSet (NULL),
67 : : mxParent(rxParent),
68 : : msDescription(),
69 : : meDescriptionOrigin(NotSet),
70 : : msName(),
71 : : meNameOrigin(NotSet),
72 : : mnClientId(0),
73 [ + - ][ + - ]: 28 : maRole(aRole)
74 : : {
75 : : // Create the state set.
76 [ + - ]: 28 : ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper ();
77 [ + - ][ + - ]: 28 : mxStateSet = pStateSet;
78 : :
79 : : // Set some states. Don't use the SetState method because no events
80 : : // shall be broadcastet (that is not yet initialized anyway).
81 [ + - ]: 28 : if (pStateSet != NULL)
82 : : {
83 [ + - ]: 28 : pStateSet->AddState (AccessibleStateType::ENABLED);
84 [ + - ]: 28 : pStateSet->AddState (AccessibleStateType::SENSITIVE);
85 [ + - ]: 28 : pStateSet->AddState (AccessibleStateType::SHOWING);
86 [ + - ]: 28 : pStateSet->AddState (AccessibleStateType::VISIBLE);
87 [ + - ]: 28 : pStateSet->AddState (AccessibleStateType::FOCUSABLE);
88 [ + - ]: 28 : pStateSet->AddState (AccessibleStateType::SELECTABLE);
89 : : }
90 : :
91 : : // Create the relation set.
92 [ + - ]: 28 : ::utl::AccessibleRelationSetHelper* pRelationSet = new ::utl::AccessibleRelationSetHelper ();
93 [ + - ][ + - ]: 28 : mxRelationSet = pRelationSet;
94 : 28 : }
95 : :
96 : :
97 : :
98 : :
99 [ + - ]: 28 : AccessibleContextBase::~AccessibleContextBase(void)
100 : : {
101 [ - + ]: 28 : }
102 : :
103 : :
104 : :
105 : :
106 : 42 : sal_Bool AccessibleContextBase::SetState (sal_Int16 aState)
107 : : {
108 [ + - ]: 42 : ::osl::ClearableMutexGuard aGuard (maMutex);
109 : : ::utl::AccessibleStateSetHelper* pStateSet =
110 [ + - ][ + - ]: 42 : static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
111 [ + - ][ + - ]: 42 : if ((pStateSet != NULL) && !pStateSet->contains(aState))
[ + + ][ + + ]
112 : : {
113 [ + - ]: 8 : pStateSet->AddState (aState);
114 : : // Clear the mutex guard so that it is not locked during calls to
115 : : // listeners.
116 [ + - ]: 8 : aGuard.clear();
117 : :
118 : : // Send event for all states except the DEFUNC state.
119 [ + + ]: 8 : if (aState != AccessibleStateType::DEFUNC)
120 : : {
121 : 2 : uno::Any aNewValue;
122 [ + - ]: 2 : aNewValue <<= aState;
123 : : CommitChange(
124 : : AccessibleEventId::STATE_CHANGED,
125 : : aNewValue,
126 [ + - ]: 2 : uno::Any());
127 : : }
128 : 8 : return sal_True;
129 : : }
130 : : else
131 [ + - ]: 42 : return sal_False;
132 : : }
133 : :
134 : :
135 : :
136 : :
137 : 0 : sal_Bool AccessibleContextBase::ResetState (sal_Int16 aState)
138 : : {
139 [ # # ]: 0 : ::osl::ClearableMutexGuard aGuard (maMutex);
140 : : ::utl::AccessibleStateSetHelper* pStateSet =
141 [ # # ][ # # ]: 0 : static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
142 [ # # ][ # # ]: 0 : if ((pStateSet != NULL) && pStateSet->contains(aState))
[ # # ][ # # ]
143 : : {
144 [ # # ]: 0 : pStateSet->RemoveState (aState);
145 : : // Clear the mutex guard so that it is not locked during calls to listeners.
146 [ # # ]: 0 : aGuard.clear();
147 : :
148 : 0 : uno::Any aOldValue;
149 [ # # ]: 0 : aOldValue <<= aState;
150 : : CommitChange(
151 : : AccessibleEventId::STATE_CHANGED,
152 : : uno::Any(),
153 [ # # ]: 0 : aOldValue);
154 : 0 : return sal_True;
155 : : }
156 : : else
157 [ # # ]: 0 : return sal_False;
158 : : }
159 : :
160 : :
161 : :
162 : :
163 : 0 : sal_Bool AccessibleContextBase::GetState (sal_Int16 aState)
164 : : {
165 [ # # ]: 0 : ::osl::MutexGuard aGuard (maMutex);
166 : : ::utl::AccessibleStateSetHelper* pStateSet =
167 [ # # ][ # # ]: 0 : static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
168 [ # # ]: 0 : if (pStateSet != NULL)
169 [ # # ]: 0 : return pStateSet->contains(aState);
170 : : else
171 : : // If there is no state set then return false as a default value.
172 [ # # ]: 0 : return sal_False;
173 : : }
174 : :
175 : :
176 : :
177 : :
178 : 0 : void AccessibleContextBase::SetRelationSet (
179 : : const uno::Reference<XAccessibleRelationSet>& rxNewRelationSet)
180 : : throw (::com::sun::star::uno::RuntimeException)
181 : : {
182 : : OSL_TRACE ("setting relation set");
183 : :
184 : : // Try to emit some meaningfull events indicating differing relations in
185 : : // both sets.
186 : : typedef std::pair<short int,short int> RD;
187 : : const RD aRelationDescriptors[] = {
188 : : RD(AccessibleRelationType::CONTROLLED_BY, AccessibleEventId::CONTROLLED_BY_RELATION_CHANGED),
189 : : RD(AccessibleRelationType::CONTROLLER_FOR, AccessibleEventId::CONTROLLER_FOR_RELATION_CHANGED),
190 : : RD(AccessibleRelationType::LABELED_BY, AccessibleEventId::LABELED_BY_RELATION_CHANGED),
191 : : RD(AccessibleRelationType::LABEL_FOR, AccessibleEventId::LABEL_FOR_RELATION_CHANGED),
192 : : RD(AccessibleRelationType::MEMBER_OF, AccessibleEventId::MEMBER_OF_RELATION_CHANGED),
193 : : RD(AccessibleRelationType::INVALID, -1),
194 [ # # ][ # # ]: 0 : };
[ # # ][ # # ]
[ # # ][ # # ]
195 [ # # ]: 0 : for (int i=0; aRelationDescriptors[i].first!=AccessibleRelationType::INVALID; i++)
196 [ # # ][ # # ]: 0 : if (mxRelationSet->containsRelation(aRelationDescriptors[i].first)
[ # # ]
197 [ # # ][ # # ]: 0 : != rxNewRelationSet->containsRelation(aRelationDescriptors[i].first))
198 [ # # ]: 0 : CommitChange (aRelationDescriptors[i].second, uno::Any(), uno::Any());
199 : :
200 [ # # ]: 0 : mxRelationSet = rxNewRelationSet;
201 : 0 : }
202 : :
203 : :
204 : :
205 : :
206 : : //===== XAccessible =========================================================
207 : :
208 : : uno::Reference< XAccessibleContext> SAL_CALL
209 : 80 : AccessibleContextBase::getAccessibleContext (void)
210 : : throw (uno::RuntimeException)
211 : : {
212 : 80 : ThrowIfDisposed ();
213 : 80 : return this;
214 : : }
215 : :
216 : :
217 : :
218 : :
219 : : //===== XAccessibleContext ==================================================
220 : :
221 : : /** No children.
222 : : */
223 : : sal_Int32 SAL_CALL
224 : 0 : AccessibleContextBase::getAccessibleChildCount (void)
225 : : throw (uno::RuntimeException)
226 : : {
227 : 0 : ThrowIfDisposed ();
228 : 0 : return 0;
229 : : }
230 : :
231 : :
232 : :
233 : :
234 : : /** Forward the request to the shape. Return the requested shape or throw
235 : : an exception for a wrong index.
236 : : */
237 : : uno::Reference<XAccessible> SAL_CALL
238 : 0 : AccessibleContextBase::getAccessibleChild (sal_Int32 nIndex)
239 : : throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
240 : : {
241 : 0 : ThrowIfDisposed ();
242 : : throw lang::IndexOutOfBoundsException (
243 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("no child with index ") + nIndex),
244 [ # # ][ # # ]: 0 : NULL);
[ # # ]
245 : : }
246 : :
247 : :
248 : :
249 : :
250 : : uno::Reference<XAccessible> SAL_CALL
251 : 532 : AccessibleContextBase::getAccessibleParent (void)
252 : : throw (::com::sun::star::uno::RuntimeException)
253 : : {
254 : 532 : ThrowIfDisposed ();
255 : 532 : return mxParent;
256 : : }
257 : :
258 : :
259 : :
260 : :
261 : : sal_Int32 SAL_CALL
262 : 2 : AccessibleContextBase::getAccessibleIndexInParent (void)
263 : : throw (::com::sun::star::uno::RuntimeException)
264 : : {
265 : 2 : ThrowIfDisposed ();
266 : : // Use a simple but slow solution for now. Optimize later.
267 : :
268 : : // Iterate over all the parent's children and search for this object.
269 [ + - ]: 2 : if (mxParent.is())
270 : : {
271 : : uno::Reference<XAccessibleContext> xParentContext (
272 [ + - ][ + - ]: 2 : mxParent->getAccessibleContext());
273 [ + - ]: 2 : if (xParentContext.is())
274 : : {
275 [ + - ][ + - ]: 2 : sal_Int32 nChildCount = xParentContext->getAccessibleChildCount();
276 [ + - ]: 4 : for (sal_Int32 i=0; i<nChildCount; i++)
277 : : {
278 [ + - ][ + - ]: 2 : uno::Reference<XAccessible> xChild (xParentContext->getAccessibleChild (i));
279 [ + - ]: 2 : if (xChild.is())
280 : : {
281 [ + - ][ + - ]: 2 : uno::Reference<XAccessibleContext> xChildContext = xChild->getAccessibleContext();
282 [ + - ][ + - ]: 2 : if (xChildContext == (XAccessibleContext*)this)
283 [ - + ]: 2 : return i;
284 : : }
285 [ - + ]: 2 : }
286 [ - + ]: 2 : }
287 : : }
288 : :
289 : : // Return -1 to indicate that this object's parent does not know about the
290 : : // object.
291 : 2 : return -1;
292 : : }
293 : :
294 : :
295 : :
296 : :
297 : : sal_Int16 SAL_CALL
298 : 34 : AccessibleContextBase::getAccessibleRole (void)
299 : : throw (::com::sun::star::uno::RuntimeException)
300 : : {
301 : 34 : ThrowIfDisposed ();
302 : 34 : return maRole;
303 : : }
304 : :
305 : :
306 : :
307 : :
308 : : ::rtl::OUString SAL_CALL
309 : 28 : AccessibleContextBase::getAccessibleDescription (void)
310 : : throw (::com::sun::star::uno::RuntimeException)
311 : : {
312 : 28 : ThrowIfDisposed ();
313 : :
314 : 28 : return msDescription;
315 : : }
316 : :
317 : :
318 : :
319 : :
320 : : OUString SAL_CALL
321 : 34 : AccessibleContextBase::getAccessibleName (void)
322 : : throw (::com::sun::star::uno::RuntimeException)
323 : : {
324 : 34 : ThrowIfDisposed ();
325 : :
326 [ + + ]: 34 : if (meNameOrigin == NotSet)
327 : : {
328 : : // Do not send an event because this is the first time it has been
329 : : // requested.
330 : 8 : msName = CreateAccessibleName();
331 : 8 : meNameOrigin = AutomaticallyCreated;
332 : : }
333 : :
334 : 34 : return msName;
335 : : }
336 : :
337 : :
338 : :
339 : :
340 : : /** Return a copy of the relation set.
341 : : */
342 : : uno::Reference<XAccessibleRelationSet> SAL_CALL
343 : 4 : AccessibleContextBase::getAccessibleRelationSet (void)
344 : : throw (::com::sun::star::uno::RuntimeException)
345 : : {
346 : 4 : ThrowIfDisposed ();
347 : :
348 : : // Create a copy of the relation set and return it.
349 : : ::utl::AccessibleRelationSetHelper* pRelationSet =
350 [ + - ]: 4 : static_cast< ::utl::AccessibleRelationSetHelper*>(mxRelationSet.get());
351 [ + - ]: 4 : if (pRelationSet != NULL)
352 : : {
353 : : return uno::Reference<XAccessibleRelationSet> (
354 [ + - ][ + - ]: 4 : new ::utl::AccessibleRelationSetHelper (*pRelationSet));
355 : : }
356 : : else
357 : 4 : return uno::Reference<XAccessibleRelationSet>(NULL);
358 : : }
359 : :
360 : :
361 : :
362 : :
363 : : /** Return a copy of the state set.
364 : : Possible states are:
365 : : ENABLED
366 : : SHOWING
367 : : VISIBLE
368 : : */
369 : : uno::Reference<XAccessibleStateSet> SAL_CALL
370 : 14 : AccessibleContextBase::getAccessibleStateSet (void)
371 : : throw (::com::sun::star::uno::RuntimeException)
372 : : {
373 : 14 : ::utl::AccessibleStateSetHelper* pStateSet = NULL;
374 : :
375 [ - + ]: 14 : if (rBHelper.bDisposed)
376 : : {
377 : : // We are already disposed!
378 : : // Create a new state set that has only set the DEFUNC state.
379 [ # # ]: 0 : pStateSet = new ::utl::AccessibleStateSetHelper ();
380 [ # # ]: 0 : if (pStateSet != NULL)
381 : 0 : pStateSet->AddState (AccessibleStateType::DEFUNC);
382 : : }
383 : : else
384 : : {
385 : : // Create a copy of the state set and return it.
386 [ + - ]: 14 : pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
387 : :
388 : : // Merge current focused state from edit engine.
389 : : #if 0
390 : : if (aState == AccessibleStateType::FOCUSED
391 : : && pStateSet != NULL
392 : : && mpText != NULL)
393 : : {
394 : : if (mpText->GetFocusedState ())
395 : : pStateSet->AddState (aState);
396 : : else
397 : : pStateSet->RemoveState (aState);
398 : : }
399 : : #endif
400 [ + - ]: 14 : if (pStateSet != NULL)
401 [ + - ]: 14 : pStateSet = new ::utl::AccessibleStateSetHelper (*pStateSet);
402 : : }
403 : :
404 [ + - ]: 14 : return uno::Reference<XAccessibleStateSet>(pStateSet);
405 : : }
406 : :
407 : :
408 : :
409 : :
410 : : lang::Locale SAL_CALL
411 : 6 : AccessibleContextBase::getLocale (void)
412 : : throw (IllegalAccessibleComponentStateException,
413 : : ::com::sun::star::uno::RuntimeException)
414 : : {
415 : 6 : ThrowIfDisposed ();
416 : : // Delegate request to parent.
417 [ + - ]: 6 : if (mxParent.is())
418 : : {
419 : : uno::Reference<XAccessibleContext> xParentContext (
420 [ + - ][ + - ]: 6 : mxParent->getAccessibleContext());
421 [ + - ]: 6 : if (xParentContext.is())
422 [ + - ][ + - ]: 6 : return xParentContext->getLocale ();
[ - + ]
423 : : }
424 : :
425 : : // No locale and no parent. Therefore throw exception to indicate this
426 : : // cluelessness.
427 [ # # ]: 0 : throw IllegalAccessibleComponentStateException ();
428 : : }
429 : :
430 : :
431 : :
432 : :
433 : : //===== XAccessibleEventListener ============================================
434 : :
435 : : void SAL_CALL
436 : 4 : AccessibleContextBase::addEventListener (
437 : : const uno::Reference<XAccessibleEventListener >& rxListener)
438 : : throw (uno::RuntimeException)
439 : : {
440 [ + - ]: 4 : if (rxListener.is())
441 : : {
442 [ + - ][ - + ]: 4 : if (rBHelper.bDisposed || rBHelper.bInDispose)
443 : : {
444 [ # # ]: 0 : uno::Reference<uno::XInterface> x ((lang::XComponent *)this, uno::UNO_QUERY);
445 [ # # ][ # # ]: 0 : rxListener->disposing (lang::EventObject (x));
[ # # ][ # # ]
446 : : }
447 : : else
448 : : {
449 [ + - ]: 4 : if (!mnClientId)
450 : 4 : mnClientId = comphelper::AccessibleEventNotifier::registerClient( );
451 : 4 : comphelper::AccessibleEventNotifier::addEventListener( mnClientId, rxListener );
452 : : }
453 : : }
454 : 4 : }
455 : :
456 : :
457 : :
458 : :
459 : : void SAL_CALL
460 : 4 : AccessibleContextBase::removeEventListener (
461 : : const uno::Reference<XAccessibleEventListener >& rxListener )
462 : : throw (uno::RuntimeException)
463 : : {
464 : 4 : ThrowIfDisposed ();
465 [ + - ]: 4 : if (rxListener.is())
466 : : {
467 : 4 : sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, rxListener );
468 [ + - ]: 4 : if ( !nListenerCount )
469 : : {
470 : : // no listeners anymore
471 : : // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
472 : : // and at least to us not firing any events anymore, in case somebody calls
473 : : // NotifyAccessibleEvent, again
474 : 4 : comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
475 : 4 : mnClientId = 0;
476 : : }
477 : : }
478 : 4 : }
479 : :
480 : :
481 : :
482 : :
483 : : //===== XServiceInfo ========================================================
484 : :
485 : : ::rtl::OUString SAL_CALL
486 : 0 : AccessibleContextBase::getImplementationName (void)
487 : : throw (::com::sun::star::uno::RuntimeException)
488 : : {
489 : 0 : ThrowIfDisposed ();
490 : 0 : return OUString("AccessibleContextBase");
491 : : }
492 : :
493 : :
494 : :
495 : :
496 : : sal_Bool SAL_CALL
497 : 0 : AccessibleContextBase::supportsService (const OUString& sServiceName)
498 : : throw (::com::sun::star::uno::RuntimeException)
499 : : {
500 [ # # ]: 0 : ThrowIfDisposed ();
501 : : // Iterate over all supported service names and return true if on of them
502 : : // matches the given name.
503 : : uno::Sequence< ::rtl::OUString> aSupportedServices (
504 [ # # ]: 0 : getSupportedServiceNames ());
505 [ # # ]: 0 : for (int i=0; i<aSupportedServices.getLength(); i++)
506 [ # # ][ # # ]: 0 : if (sServiceName == aSupportedServices[i])
507 : 0 : return sal_True;
508 [ # # ]: 0 : return sal_False;
509 : : }
510 : :
511 : :
512 : :
513 : :
514 : : uno::Sequence< ::rtl::OUString> SAL_CALL
515 : 0 : AccessibleContextBase::getSupportedServiceNames (void)
516 : : throw (::com::sun::star::uno::RuntimeException)
517 : : {
518 : 0 : ThrowIfDisposed ();
519 : : static const OUString sServiceNames[2] = {
520 : : OUString(
521 : : "com.sun.star.accessibility.Accessible"),
522 : : OUString(
523 : : "com.sun.star.accessibility.AccessibleContext")
524 [ # # ][ # # ]: 0 : };
[ # # ]
525 : 0 : return uno::Sequence<OUString> (sServiceNames, 2);
526 : : }
527 : :
528 : :
529 : :
530 : :
531 : : //===== XTypeProvider =======================================================
532 : :
533 : : uno::Sequence< ::com::sun::star::uno::Type>
534 : 0 : AccessibleContextBase::getTypes (void)
535 : : throw (::com::sun::star::uno::RuntimeException)
536 : : {
537 : 0 : ThrowIfDisposed ();
538 : :
539 : : // This class supports no interfaces on its own. Just return those
540 : : // supported by the base class.
541 : 0 : return BaseClass::getTypes();
542 : : }
543 : :
544 : : namespace
545 : : {
546 : : class theAccessibleContextBaseImplementationId : public rtl::Static< UnoTunnelIdInit, theAccessibleContextBaseImplementationId > {};
547 : : }
548 : :
549 : : uno::Sequence<sal_Int8> SAL_CALL
550 : 0 : AccessibleContextBase::getImplementationId (void)
551 : : throw (::com::sun::star::uno::RuntimeException)
552 : : {
553 : 0 : return theAccessibleContextBaseImplementationId::get().getSeq();
554 : : }
555 : :
556 : : //===== internal ============================================================
557 : :
558 : 6 : void SAL_CALL AccessibleContextBase::disposing (void)
559 : : {
560 [ + - ]: 6 : SetState (AccessibleStateType::DEFUNC);
561 : :
562 [ + - ]: 6 : ::osl::MutexGuard aGuard (maMutex);
563 : :
564 : : // Send a disposing to all listeners.
565 [ - + ]: 6 : if ( mnClientId )
566 : : {
567 [ # # ][ # # ]: 0 : comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this );
568 : 0 : mnClientId = 0;
569 [ + - ]: 6 : }
570 : 6 : }
571 : :
572 : :
573 : :
574 : :
575 : 0 : void AccessibleContextBase::SetAccessibleDescription (
576 : : const ::rtl::OUString& rDescription,
577 : : StringOrigin eDescriptionOrigin)
578 : : throw (uno::RuntimeException)
579 : : {
580 [ # # ]: 0 : if (eDescriptionOrigin < meDescriptionOrigin
[ # # # # ]
[ # # ]
581 : 0 : || (eDescriptionOrigin == meDescriptionOrigin && msDescription != rDescription))
582 : : {
583 : 0 : uno::Any aOldValue, aNewValue;
584 [ # # ]: 0 : aOldValue <<= msDescription;
585 [ # # ]: 0 : aNewValue <<= rDescription;
586 : :
587 : 0 : msDescription = rDescription;
588 : 0 : meDescriptionOrigin = eDescriptionOrigin;
589 : :
590 : : CommitChange(
591 : : AccessibleEventId::DESCRIPTION_CHANGED,
592 : : aNewValue,
593 [ # # ]: 0 : aOldValue);
594 : : }
595 : 0 : }
596 : :
597 : :
598 : :
599 : :
600 : 14 : void AccessibleContextBase::SetAccessibleName (
601 : : const ::rtl::OUString& rName,
602 : : StringOrigin eNameOrigin)
603 : : throw (uno::RuntimeException)
604 : : {
605 [ + + ]: 22 : if (eNameOrigin < meNameOrigin
[ + - + - ]
[ + - ]
606 : 8 : || (eNameOrigin == meNameOrigin && msName != rName))
607 : : {
608 : 14 : uno::Any aOldValue, aNewValue;
609 [ + - ]: 14 : aOldValue <<= msName;
610 [ + - ]: 14 : aNewValue <<= rName;
611 : :
612 : 14 : msName = rName;
613 : 14 : meNameOrigin = eNameOrigin;
614 : :
615 : : CommitChange(
616 : : AccessibleEventId::NAME_CHANGED,
617 : : aNewValue,
618 [ + - ]: 14 : aOldValue);
619 : : }
620 : 14 : }
621 : :
622 : :
623 : :
624 : :
625 : 0 : ::rtl::OUString AccessibleContextBase::CreateAccessibleDescription (void)
626 : : throw (::com::sun::star::uno::RuntimeException)
627 : : {
628 : 0 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("Empty Description"));
629 : : }
630 : :
631 : :
632 : :
633 : :
634 : 0 : ::rtl::OUString AccessibleContextBase::CreateAccessibleName (void)
635 : : throw (::com::sun::star::uno::RuntimeException)
636 : : {
637 : 0 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("Empty Name"));
638 : : }
639 : :
640 : :
641 : :
642 : :
643 : 48 : void AccessibleContextBase::CommitChange (
644 : : sal_Int16 nEventId,
645 : : const uno::Any& rNewValue,
646 : : const uno::Any& rOldValue)
647 : : {
648 : : // Do not call FireEvent and do not even create the event object when no
649 : : // listener has been registered yet. Creating the event object can
650 : : // otherwise lead to a crash. See issue 93419 for details.
651 [ + + ]: 48 : if (mnClientId != 0)
652 : : {
653 : : AccessibleEventObject aEvent (
654 : : static_cast<XAccessibleContext*>(this),
655 : : nEventId,
656 : : rNewValue,
657 [ + - ][ + - ]: 18 : rOldValue);
658 : :
659 [ + - ][ + - ]: 18 : FireEvent (aEvent);
660 : : }
661 : 48 : }
662 : :
663 : :
664 : :
665 : :
666 : 18 : void AccessibleContextBase::FireEvent (const AccessibleEventObject& aEvent)
667 : : {
668 [ + - ]: 18 : if (mnClientId)
669 : 18 : comphelper::AccessibleEventNotifier::addEvent( mnClientId, aEvent );
670 : 18 : }
671 : :
672 : :
673 : :
674 : :
675 : 2868 : void AccessibleContextBase::ThrowIfDisposed (void)
676 : : throw (::com::sun::star::lang::DisposedException)
677 : : {
678 [ + + ][ - + ]: 2868 : if (rBHelper.bDisposed || rBHelper.bInDispose)
679 : : {
680 : : OSL_TRACE ("Calling disposed object. Throwing exception:");
681 : : throw lang::DisposedException (
682 : : OUString("object has been already disposed"),
683 [ + - ][ + - ]: 6 : static_cast<uno::XWeak*>(this));
684 : : }
685 : 2862 : }
686 : :
687 : :
688 : :
689 : 0 : sal_Bool AccessibleContextBase::IsDisposed (void)
690 : : {
691 [ # # ][ # # ]: 0 : return (rBHelper.bDisposed || rBHelper.bInDispose);
692 : : }
693 : :
694 : :
695 : :
696 : 0 : void AccessibleContextBase::SetAccessibleRole( sal_Int16 _nRole )
697 : : {
698 : 0 : maRole = _nRole;
699 : 0 : }
700 : :
701 : :
702 : : } // end of namespace accessibility
703 : :
704 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|