1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "AccessibleBase.hxx"
21 #include "AccessibleChartShape.hxx"
22 #include "ObjectHierarchy.hxx"
23 #include "ObjectIdentifier.hxx"
24 #include "chartview/ExplicitValueProvider.hxx"
27 #include <com/sun/star/awt/XDevice.hpp>
28 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
29 #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
30 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
31 #include <com/sun/star/accessibility/AccessibleRole.hpp>
32 #include <com/sun/star/drawing/LineStyle.hpp>
33 #include <com/sun/star/drawing/FillStyle.hpp>
34 #include <rtl/ustrbuf.hxx>
35 #include <vcl/svapp.hxx>
37 #include <cppuhelper/queryinterface.hxx>
38 #include <cppuhelper/supportsservice.hxx>
39 #include <svl/itemset.hxx>
40 #include <editeng/unofdesc.hxx>
41 #include <editeng/outliner.hxx>
42 #include <svx/svdoutl.hxx>
43 #include <svx/svdetc.hxx>
44 #include <svx/unoshape.hxx>
45 #include <svx/unoprov.hxx>
46 #include <vcl/unohelp.hxx>
47 #include <toolkit/helper/vclunohelper.hxx>
48 #include <vcl/window.hxx>
49 #include <vcl/graph.hxx>
50 #include <vcl/settings.hxx>
53 #include <o3tl/compat_functional.hxx>
55 #include "ChartElementFactory.hxx"
57 using namespace ::com::sun::star
;
58 using namespace ::com::sun::star::accessibility
;
60 using ::com::sun::star::uno::UNO_QUERY
;
61 using ::com::sun::star::uno::Reference
;
62 using ::osl::MutexGuard
;
63 using ::osl::ClearableMutexGuard
;
64 using ::osl::ResettableMutexGuard
;
65 using ::com::sun::star::uno::RuntimeException
;
66 using ::com::sun::star::uno::Any
;
71 /** @param bMayHaveChildren is false per default
73 AccessibleBase::AccessibleBase(
74 const AccessibleElementInfo
& rAccInfo
,
75 bool bMayHaveChildren
,
76 bool bAlwaysTransparent
/* default: false */ ) :
77 impl::AccessibleBase_Base( m_aMutex
),
78 m_bIsDisposed( false ),
79 m_bMayHaveChildren( bMayHaveChildren
),
80 m_bChildrenInitialized( false ),
81 m_nEventNotifierId(0),
82 m_pStateSetHelper( new ::utl::AccessibleStateSetHelper() ),
83 m_aStateSet( m_pStateSetHelper
),
84 m_aAccInfo( rAccInfo
),
85 m_bAlwaysTransparent( bAlwaysTransparent
),
86 m_bStateSetInitialized( false )
88 // initialize some states
89 OSL_ASSERT( m_pStateSetHelper
);
90 m_pStateSetHelper
->AddState( AccessibleStateType::ENABLED
);
91 m_pStateSetHelper
->AddState( AccessibleStateType::SHOWING
);
92 m_pStateSetHelper
->AddState( AccessibleStateType::VISIBLE
);
93 m_pStateSetHelper
->AddState( AccessibleStateType::SELECTABLE
);
94 m_pStateSetHelper
->AddState( AccessibleStateType::FOCUSABLE
);
97 AccessibleBase::~AccessibleBase()
99 OSL_ASSERT( m_bIsDisposed
);
102 bool AccessibleBase::CheckDisposeState( bool bThrowException
/* default: true */ ) const
103 throw (lang::DisposedException
)
105 if( bThrowException
&&
108 throw lang::DisposedException("component has state DEFUNC",
109 static_cast< uno::XWeak
* >( const_cast< AccessibleBase
* >( this )));
111 return m_bIsDisposed
;
114 bool AccessibleBase::NotifyEvent( EventType eEventType
, const AccessibleUniqueId
& rId
)
118 // event is addressed to this object
120 ::com::sun::star::uno::Any aEmpty
;
121 ::com::sun::star::uno::Any aSelected
;
122 aSelected
<<= AccessibleStateType::SELECTED
;
127 BroadcastAccEvent( AccessibleEventId::VISIBLE_DATA_CHANGED
, aEmpty
, aEmpty
);
128 #if OSL_DEBUG_LEVEL > 1
131 OUString( "Visible data event sent by: " ) +
133 RTL_TEXTENCODING_ASCII_US
).getStr() );
140 AddState( AccessibleStateType::SELECTED
);
141 BroadcastAccEvent( AccessibleEventId::STATE_CHANGED
, aSelected
, aEmpty
);
143 AddState( AccessibleStateType::FOCUSED
);
144 aSelected
<<= AccessibleStateType::FOCUSED
;
145 BroadcastAccEvent( AccessibleEventId::STATE_CHANGED
, aSelected
, aEmpty
, true );
146 #if OSL_DEBUG_LEVEL > 1
149 OUString( "Selection acquired by: " ) +
151 RTL_TEXTENCODING_ASCII_US
).getStr() );
158 RemoveState( AccessibleStateType::SELECTED
);
159 BroadcastAccEvent( AccessibleEventId::STATE_CHANGED
, aEmpty
, aSelected
);
161 AddState( AccessibleStateType::FOCUSED
);
162 aSelected
<<= AccessibleStateType::FOCUSED
;
163 BroadcastAccEvent( AccessibleEventId::STATE_CHANGED
, aEmpty
, aSelected
, true );
164 #if OSL_DEBUG_LEVEL > 1
167 OUString( "Selection lost by: " ) +
169 RTL_TEXTENCODING_ASCII_US
).getStr() );
174 case PROPERTY_CHANGE
:
176 //not implemented --> rebuild all
182 else if( m_bMayHaveChildren
)
186 ClearableMutexGuard
aGuard( GetMutex() );
187 // make local copy for notification
188 ChildListVectorType
aLocalChildList( m_aChildList
);
191 ChildListVectorType::iterator aEndIter
= aLocalChildList
.end();
192 for( ChildListVectorType::iterator aIter
= aLocalChildList
.begin() ;
193 ( aIter
!= aEndIter
) && ( ! bStop
) ;
196 // Note: at this place we must be sure to have an AccessibleBase
197 // object in the UNO reference to XAccessible !
198 bStop
= (*static_cast< AccessibleBase
* >
199 ( (*aIter
).get() )).NotifyEvent( eEventType
, rId
);
207 void AccessibleBase::AddState( sal_Int16 aState
)
208 throw (RuntimeException
)
211 OSL_ASSERT( m_pStateSetHelper
);
212 m_pStateSetHelper
->AddState( aState
);
215 void AccessibleBase::RemoveState( sal_Int16 aState
)
216 throw (RuntimeException
)
219 OSL_ASSERT( m_pStateSetHelper
);
220 m_pStateSetHelper
->RemoveState( aState
);
223 bool AccessibleBase::UpdateChildren()
225 bool bMustUpdateChildren
= false;
227 MutexGuard
aGuard( GetMutex() );
228 if( ! m_bMayHaveChildren
||
232 bMustUpdateChildren
= ( m_bMayHaveChildren
&&
233 ! m_bChildrenInitialized
);
237 if( bMustUpdateChildren
)
238 m_bChildrenInitialized
= ImplUpdateChildren();
240 return m_bChildrenInitialized
;
243 bool AccessibleBase::ImplUpdateChildren()
245 bool bResult
= false;
247 if( m_aAccInfo
.m_spObjectHierarchy
)
249 ObjectHierarchy::tChildContainer
aModelChildren(
250 m_aAccInfo
.m_spObjectHierarchy
->getChildren( GetId() ));
251 ::std::vector
< ChildOIDMap::key_type
> aAccChildren
;
252 aAccChildren
.reserve( aModelChildren
.size());
253 ::std::transform( m_aChildOIDMap
.begin(), m_aChildOIDMap
.end(),
254 ::std::back_inserter( aAccChildren
),
255 ::o3tl::select1st
< ChildOIDMap::value_type
>());
257 ::std::sort( aModelChildren
.begin(), aModelChildren
.end());
259 ::std::vector
< ObjectHierarchy::tOID
> aChildrenToRemove
, aChildrenToAdd
;
260 ::std::set_difference( aModelChildren
.begin(), aModelChildren
.end(),
261 aAccChildren
.begin(), aAccChildren
.end(),
262 ::std::back_inserter( aChildrenToAdd
));
263 ::std::set_difference( aAccChildren
.begin(), aAccChildren
.end(),
264 aModelChildren
.begin(), aModelChildren
.end(),
265 ::std::back_inserter( aChildrenToRemove
));
267 ::std::vector
< ObjectHierarchy::tOID
>::const_iterator
aIt( aChildrenToRemove
.begin());
268 for( ; aIt
!= aChildrenToRemove
.end(); ++aIt
)
270 RemoveChildByOId( *aIt
);
273 AccessibleElementInfo
aAccInfo( GetInfo());
274 aAccInfo
.m_pParent
= this;
276 for( aIt
= aChildrenToAdd
.begin(); aIt
!= aChildrenToAdd
.end(); ++aIt
)
278 aAccInfo
.m_aOID
= *aIt
;
279 if ( aIt
->isAutoGeneratedObject() )
281 AddChild( ChartElementFactory::CreateChartElement( aAccInfo
) );
283 else if ( aIt
->isAdditionalShape() )
285 AddChild( new AccessibleChartShape( aAccInfo
, true, false ) );
294 void AccessibleBase::AddChild( AccessibleBase
* pChild
)
296 OSL_ENSURE( pChild
!= NULL
, "Invalid Child" );
299 ClearableMutexGuard
aGuard( GetMutex() );
301 Reference
< XAccessible
> xChild( pChild
);
302 m_aChildList
.push_back( xChild
);
304 m_aChildOIDMap
[ pChild
->GetId() ] = xChild
;
306 // inform listeners of new child
307 if( m_bChildrenInitialized
)
313 BroadcastAccEvent( AccessibleEventId::CHILD
, aNew
, aEmpty
);
318 /** in this method we imply that the Reference< XAccessible > elements in the
319 vector are AccessibleBase objects !
321 void AccessibleBase::RemoveChildByOId( const ObjectIdentifier
& rOId
)
323 ClearableMutexGuard
aGuard( GetMutex() );
325 ChildOIDMap::iterator
aIt( m_aChildOIDMap
.find( rOId
));
326 if( aIt
!= m_aChildOIDMap
.end())
328 Reference
< XAccessible
> xChild( aIt
->second
);
331 m_aChildOIDMap
.erase( aIt
);
333 // search child in vector
334 ChildListVectorType::iterator aVecIter
=
335 ::std::find( m_aChildList
.begin(), m_aChildList
.end(), xChild
);
337 OSL_ENSURE( aVecIter
!= m_aChildList
.end(),
338 "Inconsistent ChildMap" );
340 // remove child from vector
341 m_aChildList
.erase( aVecIter
);
342 bool bInitialized
= m_bChildrenInitialized
;
344 // call listeners unguarded
347 // inform listeners of removed child
353 BroadcastAccEvent( AccessibleEventId::CHILD
, aEmpty
, aOld
);
357 Reference
< lang::XComponent
> xComp( xChild
, UNO_QUERY
);
363 awt::Point
AccessibleBase::GetUpperLeftOnScreen() const
366 if( m_aAccInfo
.m_pParent
)
368 ClearableMutexGuard
aGuard( GetMutex() );
369 AccessibleBase
* pParent
= m_aAccInfo
.m_pParent
;
374 aResult
= pParent
->GetUpperLeftOnScreen();
377 OSL_FAIL( "Default position used is probably incorrect." );
383 void AccessibleBase::BroadcastAccEvent(
387 bool bSendGlobally
) const
389 ClearableMutexGuard
aGuard( GetMutex() );
391 if ( !m_nEventNotifierId
&& !bSendGlobally
)
393 // if we don't have a client id for the notifier, then we don't have listeners, then
394 // we don't need to notify anything
395 //except SendGlobally for focus handling?
397 // the const cast is needed, because UNO parameters are never const
398 const AccessibleEventObject
aEvent(
399 const_cast< uno::XWeak
* >( static_cast< const uno::XWeak
* >( this )),
402 if ( m_nEventNotifierId
) // let the notifier handle this event
403 ::comphelper::AccessibleEventNotifier::addEvent( m_nEventNotifierId
, aEvent
);
407 // send event to global message queue
410 vcl::unohelper::NotifyAccessibleStateEventGlobally( aEvent
);
414 void AccessibleBase::KillAllChildren()
416 ClearableMutexGuard
aGuard( GetMutex() );
418 // make local copy for notification
419 ChildListVectorType
aLocalChildList( m_aChildList
);
421 // remove all children
422 m_aChildList
.clear();
423 m_aChildOIDMap
.clear();
427 // call dispose for all children
428 // and notify listeners
429 Reference
< lang::XComponent
> xComp
;
431 ChildListVectorType::const_iterator aEndIter
= aLocalChildList
.end();
432 for( ChildListVectorType::const_iterator aIter
= aLocalChildList
.begin();
433 aIter
!= aEndIter
; ++aIter
)
436 BroadcastAccEvent( AccessibleEventId::CHILD
, aEmpty
, aOld
);
438 xComp
.set( *aIter
, UNO_QUERY
);
442 m_bChildrenInitialized
= false;
445 void AccessibleBase::SetInfo( const AccessibleElementInfo
& rNewInfo
)
447 m_aAccInfo
= rNewInfo
;
448 if( m_bMayHaveChildren
)
452 BroadcastAccEvent( AccessibleEventId::INVALIDATE_ALL_CHILDREN
, uno::Any(), uno::Any(),
453 true /* global notification */ );
456 // ________ (XComponent::dispose) ________
457 void SAL_CALL
AccessibleBase::disposing()
459 ClearableMutexGuard
aGuard( GetMutex() );
460 OSL_ENSURE( ! m_bIsDisposed
, "dispose() called twice" );
462 // notify disposing to all AccessibleEvent listeners asynchron
463 if ( m_nEventNotifierId
)
465 ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( m_nEventNotifierId
, *this );
466 m_nEventNotifierId
= 0;
470 m_aAccInfo
.m_pParent
= NULL
;
472 // invalidate implementation for helper, but keep UNO reference to still
473 // allow a tool to query the DEFUNC state.
474 // Note: The object will be deleted when the last reference is released
475 m_pStateSetHelper
= NULL
;
477 // attach new empty state set helper to member reference
478 ::utl::AccessibleStateSetHelper
* pHelper
= new ::utl::AccessibleStateSetHelper();
479 pHelper
->AddState( AccessibleStateType::DEFUNC
);
480 // release old helper and attach new one
481 m_aStateSet
.set( pHelper
);
483 m_bIsDisposed
= true;
485 // call listeners unguarded
488 if( m_bMayHaveChildren
)
493 OSL_ENSURE( m_aChildList
.empty(), "Child list should be empty" );
496 // ________ XAccessible ________
497 Reference
< XAccessibleContext
> SAL_CALL
AccessibleBase::getAccessibleContext()
498 throw (RuntimeException
, std::exception
)
503 // ________ AccessibleBase::XAccessibleContext ________
504 sal_Int32 SAL_CALL
AccessibleBase::getAccessibleChildCount()
505 throw (RuntimeException
, std::exception
)
507 ClearableMutexGuard
aGuard( GetMutex() );
508 if( ! m_bMayHaveChildren
||
512 bool bMustUpdateChildren
= ( m_bMayHaveChildren
&&
513 ! m_bChildrenInitialized
);
518 if( bMustUpdateChildren
)
521 return ImplGetAccessibleChildCount();
524 sal_Int32
AccessibleBase::ImplGetAccessibleChildCount() const
525 throw (RuntimeException
)
527 return m_aChildList
.size();
530 Reference
< XAccessible
> SAL_CALL
AccessibleBase::getAccessibleChild( sal_Int32 i
)
531 throw (lang::IndexOutOfBoundsException
, RuntimeException
, std::exception
)
534 Reference
< XAccessible
> xResult
;
536 ResettableMutexGuard
aGuard( GetMutex() );
537 bool bMustUpdateChildren
= ( m_bMayHaveChildren
&&
538 ! m_bChildrenInitialized
);
542 if( bMustUpdateChildren
)
545 xResult
.set( ImplGetAccessibleChildById( i
));
550 Reference
< XAccessible
> AccessibleBase::ImplGetAccessibleChildById( sal_Int32 i
) const
551 throw (lang::IndexOutOfBoundsException
, RuntimeException
)
553 Reference
< XAccessible
> xResult
;
555 MutexGuard
aGuard( GetMutex());
556 if( ! m_bMayHaveChildren
||
558 static_cast< ChildListVectorType::size_type
>( i
) >= m_aChildList
.size() )
560 OUString aBuf
= "Index " + OUString::number( i
) + " is invalid for range [ 0, " +
561 OUString::number( m_aChildList
.size() - 1 ) +
563 lang::IndexOutOfBoundsException
aEx( aBuf
,
564 const_cast< ::cppu::OWeakObject
* >(
565 static_cast< const ::cppu::OWeakObject
* >( this )));
569 xResult
.set( m_aChildList
[ i
] );
574 Reference
< XAccessible
> SAL_CALL
AccessibleBase::getAccessibleParent()
575 throw (RuntimeException
, std::exception
)
578 Reference
< XAccessible
> aResult
;
579 if( m_aAccInfo
.m_pParent
)
580 aResult
.set( m_aAccInfo
.m_pParent
);
585 sal_Int32 SAL_CALL
AccessibleBase::getAccessibleIndexInParent()
586 throw (RuntimeException
, std::exception
)
590 if( m_aAccInfo
.m_spObjectHierarchy
)
591 return m_aAccInfo
.m_spObjectHierarchy
->getIndexInParent( GetId() );
595 sal_Int16 SAL_CALL
AccessibleBase::getAccessibleRole()
596 throw (RuntimeException
, std::exception
)
598 return AccessibleRole::SHAPE
;
601 Reference
< XAccessibleRelationSet
> SAL_CALL
AccessibleBase::getAccessibleRelationSet()
602 throw (RuntimeException
, std::exception
)
604 Reference
< XAccessibleRelationSet
> aResult
;
608 Reference
< XAccessibleStateSet
> SAL_CALL
AccessibleBase::getAccessibleStateSet()
609 throw (RuntimeException
, std::exception
)
611 if( ! m_bStateSetInitialized
)
613 Reference
< view::XSelectionSupplier
> xSelSupp( GetInfo().m_xSelectionSupplier
);
616 ObjectIdentifier
aOID( xSelSupp
->getSelection() );
617 if ( aOID
.isValid() && GetId() == aOID
)
619 AddState( AccessibleStateType::SELECTED
);
620 AddState( AccessibleStateType::FOCUSED
);
623 m_bStateSetInitialized
= true;
629 lang::Locale SAL_CALL
AccessibleBase::getLocale()
630 throw (IllegalAccessibleComponentStateException
, RuntimeException
, std::exception
)
634 return Application::GetSettings().GetLanguageTag().getLocale();
637 // ________ AccessibleBase::XAccessibleComponent ________
638 sal_Bool SAL_CALL
AccessibleBase::containsPoint( const awt::Point
& aPoint
)
639 throw (RuntimeException
, std::exception
)
641 awt::Rectangle
aRect( getBounds() );
643 // contains() works with relative coordinates
647 return ( aPoint
.X
>= aRect
.X
&&
648 aPoint
.Y
>= aRect
.Y
&&
649 aPoint
.X
< (aRect
.X
+ aRect
.Width
) &&
650 aPoint
.Y
< (aRect
.Y
+ aRect
.Height
) );
653 Reference
< XAccessible
> SAL_CALL
AccessibleBase::getAccessibleAtPoint( const awt::Point
& aPoint
)
654 throw (RuntimeException
, std::exception
)
657 Reference
< XAccessible
> aResult
;
658 awt::Rectangle
aRect( getBounds());
660 // children are positioned relative to this object, so translate bound rect
664 // children must be inside the own bound rect
665 if( ( aRect
.X
<= aPoint
.X
&& aPoint
.X
<= (aRect
.X
+ aRect
.Width
) ) &&
666 ( aRect
.Y
<= aPoint
.Y
&& aPoint
.Y
<= (aRect
.Y
+ aRect
.Height
)))
668 ClearableMutexGuard
aGuard( GetMutex() );
669 ChildListVectorType
aLocalChildList( m_aChildList
);
672 Reference
< XAccessibleComponent
> aComp
;
673 for( ChildListVectorType::const_iterator aIter
= aLocalChildList
.begin();
674 aIter
!= aLocalChildList
.end(); ++aIter
)
676 aComp
.set( *aIter
, UNO_QUERY
);
679 aRect
= aComp
->getBounds();
680 if( ( aRect
.X
<= aPoint
.X
&& aPoint
.X
<= (aRect
.X
+ aRect
.Width
) ) &&
681 ( aRect
.Y
<= aPoint
.Y
&& aPoint
.Y
<= (aRect
.Y
+ aRect
.Height
)))
693 awt::Rectangle SAL_CALL
AccessibleBase::getBounds()
694 throw (RuntimeException
, std::exception
)
696 ExplicitValueProvider
*pExplicitValueProvider(
697 ExplicitValueProvider::getExplicitValueProvider( m_aAccInfo
.m_xView
));
698 if( pExplicitValueProvider
)
700 vcl::Window
* pWindow( VCLUnoHelper::GetWindow( m_aAccInfo
.m_xWindow
));
701 awt::Rectangle
aLogicRect( pExplicitValueProvider
->getRectangleOfObject( m_aAccInfo
.m_aOID
.getObjectCID() ));
704 Rectangle
aRect( aLogicRect
.X
, aLogicRect
.Y
,
705 aLogicRect
.X
+ aLogicRect
.Width
,
706 aLogicRect
.Y
+ aLogicRect
.Height
);
707 SolarMutexGuard aSolarGuard
;
708 aRect
= pWindow
->LogicToPixel( aRect
);
710 // aLogicRect is relative to the page, but we need a value relative
711 // to the parent object
712 awt::Point aParentLocOnScreen
;
713 uno::Reference
< XAccessibleComponent
> xParent( getAccessibleParent(), uno::UNO_QUERY
);
715 aParentLocOnScreen
= xParent
->getLocationOnScreen();
717 awt::Point aULOnScreen
= GetUpperLeftOnScreen();
718 awt::Point
aOffset( aParentLocOnScreen
.X
- aULOnScreen
.X
,
719 aParentLocOnScreen
.Y
- aULOnScreen
.Y
);
721 return awt::Rectangle( aRect
.getX() - aOffset
.X
, aRect
.getY() - aOffset
.Y
,
722 aRect
.getWidth(), aRect
.getHeight());
726 return awt::Rectangle();
729 awt::Point SAL_CALL
AccessibleBase::getLocation()
730 throw (RuntimeException
, std::exception
)
733 awt::Rectangle
aBBox( getBounds() );
734 return awt::Point( aBBox
.X
, aBBox
.Y
);
737 awt::Point SAL_CALL
AccessibleBase::getLocationOnScreen()
738 throw (RuntimeException
, std::exception
)
742 if( m_aAccInfo
.m_pParent
!= NULL
)
744 AccessibleBase
* pParent
= m_aAccInfo
.m_pParent
;
745 awt::Point
aLocThisRel( getLocation());
746 awt::Point aUpperLeft
;
748 if( pParent
!= NULL
)
749 aUpperLeft
= pParent
->getLocationOnScreen();
751 return awt::Point( aUpperLeft
.X
+ aLocThisRel
.X
,
752 aUpperLeft
.Y
+ aLocThisRel
.Y
);
755 return getLocation();
758 awt::Size SAL_CALL
AccessibleBase::getSize()
759 throw (RuntimeException
, std::exception
)
762 awt::Rectangle
aBBox( getBounds() );
763 return awt::Size( aBBox
.Width
, aBBox
.Height
);
766 void SAL_CALL
AccessibleBase::grabFocus()
767 throw (RuntimeException
, std::exception
)
771 Reference
< view::XSelectionSupplier
> xSelSupp( GetInfo().m_xSelectionSupplier
);
774 xSelSupp
->select( GetId().getAny() );
778 sal_Int32 SAL_CALL
AccessibleBase::getForeground()
779 throw (RuntimeException
, std::exception
)
781 return getColor( ACC_BASE_FOREGROUND
);
784 sal_Int32 SAL_CALL
AccessibleBase::getBackground()
785 throw (RuntimeException
, std::exception
)
787 return getColor( ACC_BASE_BACKGROUND
);
790 sal_Int32
AccessibleBase::getColor( eColorType eColType
)
792 sal_Int32 nResult
= static_cast< sal_Int32
>( Color( COL_TRANSPARENT
).GetColor());
793 if( m_bAlwaysTransparent
)
796 ObjectIdentifier
aOID( m_aAccInfo
.m_aOID
);
797 ObjectType
eType( aOID
.getObjectType() );
798 Reference
< beans::XPropertySet
> xObjProp
;
799 OUString aObjectCID
= aOID
.getObjectCID();
800 if( eType
== OBJECTTYPE_LEGEND_ENTRY
)
802 // for colors get the data series/point properties
803 OUString
aParentParticle( ObjectIdentifier::getFullParentParticle( aObjectCID
));
804 aObjectCID
= ObjectIdentifier::createClassifiedIdentifierForParticle( aParentParticle
);
808 ObjectIdentifier::getObjectPropertySet(
809 aObjectCID
, Reference
< chart2::XChartDocument
>( m_aAccInfo
.m_xChartDocument
)), uno::UNO_QUERY
);
815 OUString aStylePropName
;
819 case OBJECTTYPE_LEGEND_ENTRY
:
820 case OBJECTTYPE_DATA_SERIES
:
821 case OBJECTTYPE_DATA_POINT
:
822 if( eColType
== ACC_BASE_FOREGROUND
)
824 aPropName
= "BorderColor";
825 aStylePropName
= "BorderTransparency";
830 aStylePropName
= "Transparency";
834 if( eColType
== ACC_BASE_FOREGROUND
)
836 aPropName
= "LineColor";
837 aStylePropName
= "LineTransparence";
841 aPropName
= "FillColor";
842 aStylePropName
= "FillTransparence";
847 bool bTransparent
= m_bAlwaysTransparent
;
848 Reference
< beans::XPropertySetInfo
> xInfo( xObjProp
->getPropertySetInfo(), uno::UNO_QUERY
);
850 xInfo
->hasPropertyByName( aStylePropName
))
852 if( eColType
== ACC_BASE_FOREGROUND
)
854 drawing::LineStyle aLStyle
;
855 if( xObjProp
->getPropertyValue( aStylePropName
) >>= aLStyle
)
856 bTransparent
= (aLStyle
== drawing::LineStyle_NONE
);
860 drawing::FillStyle aFStyle
;
861 if( xObjProp
->getPropertyValue( aStylePropName
) >>= aFStyle
)
862 bTransparent
= (aFStyle
== drawing::FillStyle_NONE
);
868 xInfo
->hasPropertyByName( aPropName
))
870 xObjProp
->getPropertyValue( aPropName
) >>= nResult
;
873 catch( const uno::Exception
& ex
)
875 ASSERT_EXCEPTION( ex
);
882 // ________ AccessibleBase::XServiceInfo ________
883 OUString SAL_CALL
AccessibleBase::getImplementationName()
884 throw (RuntimeException
, std::exception
)
886 return OUString( "AccessibleBase" );
889 sal_Bool SAL_CALL
AccessibleBase::supportsService( const OUString
& ServiceName
)
890 throw (RuntimeException
, std::exception
)
892 return cppu::supportsService( this, ServiceName
);
895 uno::Sequence
< OUString
> SAL_CALL
AccessibleBase::getSupportedServiceNames()
896 throw (RuntimeException
, std::exception
)
898 uno::Sequence
< OUString
> aSeq( 2 );
899 OUString
* pStr
= aSeq
.getArray();
900 pStr
[ 0 ] = "com.sun.star.accessibility.Accessible";
901 pStr
[ 1 ] = "com.sun.star.accessibility.AccessibleContext";
906 // ________ AccessibleBase::XEventListener ________
907 void SAL_CALL
AccessibleBase::disposing( const lang::EventObject
& /*Source*/ )
908 throw (RuntimeException
, std::exception
)
912 // ________ XAccessibleEventBroadcasters ________
913 void SAL_CALL
AccessibleBase::addAccessibleEventListener( const Reference
< XAccessibleEventListener
>& xListener
)
914 throw (RuntimeException
, std::exception
)
916 MutexGuard
aGuard( GetMutex() );
918 if ( xListener
.is() )
920 if ( !m_nEventNotifierId
)
921 m_nEventNotifierId
= ::comphelper::AccessibleEventNotifier::registerClient();
923 ::comphelper::AccessibleEventNotifier::addEventListener( m_nEventNotifierId
, xListener
);
927 void SAL_CALL
AccessibleBase::removeAccessibleEventListener( const Reference
< XAccessibleEventListener
>& xListener
)
928 throw (RuntimeException
, std::exception
)
930 MutexGuard
aGuard( GetMutex() );
932 if ( xListener
.is() )
934 sal_Int32 nListenerCount
= ::comphelper::AccessibleEventNotifier::removeEventListener( m_nEventNotifierId
, xListener
);
935 if ( !nListenerCount
)
937 // no listeners anymore
938 ::comphelper::AccessibleEventNotifier::revokeClient( m_nEventNotifierId
);
939 m_nEventNotifierId
= 0;
946 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */