1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: GraphCtlAccessibleContext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <com/sun/star/accessibility/AccessibleRole.hpp>
34 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
35 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
36 #include <com/sun/star/lang/DisposedException.hpp>
37 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
38 #include <com/sun/star/awt/XWindow.hpp>
39 #include <unotools/accessiblestatesethelper.hxx>
40 #include <cppuhelper/typeprovider.hxx>
41 #include <toolkit/helper/vclunohelper.hxx>
42 #include <vcl/svapp.hxx>
43 #include <osl/mutex.hxx>
45 #include <tools/debug.hxx>
46 #include <tools/gen.hxx>
47 #include <svtools/smplhint.hxx>
48 #include <toolkit/helper/convert.hxx>
49 #include <svtools/colorcfg.hxx>
50 #include <comphelper/accessibleeventnotifier.hxx>
51 #include <sdrpaintwindow.hxx>
53 //===== local includes ========================================================
54 #include <svx/ShapeTypeHandler.hxx>
55 #include <svx/AccessibleShapeInfo.hxx>
56 #include "GraphCtlAccessibleContext.hxx"
57 #include <svx/graphctl.hxx>
58 #ifndef _SVX_DIALOGS_HRC
59 #include <svx/dialogs.hrc>
61 #ifndef _SVX_ACCESSIBILITY_HRC
62 #include "accessibility.hrc"
64 #include <svx/svdpage.hxx>
65 #include <svx/unomod.hxx>
66 #include <svx/dialmgr.hxx>
67 #include <svx/svdetc.hxx>
68 #include <svx/sdrhittesthelper.hxx>
70 //===== namespaces ===========================================================
72 using namespace ::vos
;
73 using namespace ::cppu
;
74 using namespace ::osl
;
75 using ::rtl::OUString
;
76 using namespace ::accessibility
;
77 using namespace ::com::sun::star
;
78 using namespace ::com::sun::star::uno
;
79 using namespace ::com::sun::star::drawing
;
80 using namespace ::com::sun::star::lang
;
81 using namespace ::com::sun::star::accessibility
;
83 //===== internal ============================================================
85 /** initialize this component and set default values */
86 SvxGraphCtrlAccessibleContext::SvxGraphCtrlAccessibleContext(
87 const Reference
< XAccessible
>& rxParent
,
89 const OUString
* pName
,
90 const OUString
* pDesc
) :
92 SvxGraphCtrlAccessibleContext_Base( m_aMutex
),
99 mbDisposed( sal_False
)
101 if (mpControl
!= NULL
)
103 mpModel
= mpControl
->GetSdrModel();
105 mpPage
= (SdrPage
*)mpModel
->GetPage( 0 );
106 mpView
= mpControl
->GetSdrView();
108 if( mpModel
== NULL
|| mpPage
== NULL
|| mpView
== NULL
)
111 // Set all the pointers to NULL just in case they are used as
125 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
126 msName
= SVX_RESSTR( RID_SVXSTR_GRAPHCTRL_ACC_NAME
);
131 msDescription
= *pDesc
;
135 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
136 msDescription
= SVX_RESSTR( RID_SVXSTR_GRAPHCTRL_ACC_DESCRIPTION
);
139 maTreeInfo
.SetSdrView( mpView
);
140 maTreeInfo
.SetWindow( mpControl
);
141 maTreeInfo
.SetViewForwarder( const_cast<SvxGraphCtrlAccessibleContext
*>(this) );
144 //-----------------------------------------------------------------------------
146 /** on destruction, this component is disposed and all dispose listeners
147 are called, except if this component was already disposed */
148 SvxGraphCtrlAccessibleContext::~SvxGraphCtrlAccessibleContext()
153 //-----------------------------------------------------------------------------
155 /** returns the XAccessible interface for a given SdrObject.
156 Multiple calls for the same SdrObject return the same XAccessible.
158 Reference
< XAccessible
> SAL_CALL
SvxGraphCtrlAccessibleContext::getAccessible( const SdrObject
* pObj
)
160 Reference
<XAccessible
> xAccessibleShape
;
164 // see if we already created an XAccessible for the given SdrObject
165 ShapesMapType::iterator iter
= mxShapes
.find( pObj
);
167 if( iter
!= mxShapes
.end() )
169 // if we already have one, return it
170 xAccessibleShape
= (*iter
).second
;
174 // create a new one and remember in our internal map
175 Reference
< XShape
> xShape( Reference
< XShape
>::query( (const_cast<SdrObject
*>(pObj
))->getUnoShape() ) );
177 AccessibleShapeInfo
aShapeInfo (xShape
,mxParent
);
178 // Create accessible object that corresponds to the descriptor's shape.
179 AccessibleShape
* pAcc
= ShapeTypeHandler::Instance().CreateAccessibleObject(
180 aShapeInfo
, maTreeInfo
);
181 xAccessibleShape
= pAcc
;
185 // Now that we acquired the new accessible shape we can
186 // safely call its Init() method.
189 mxShapes
[pObj
] = pAcc
;
191 // Create event and inform listeners of the object creation.
192 CommitChange( AccessibleEventId::CHILD
, makeAny( xAccessibleShape
), makeAny( Reference
<XAccessible
>() ) );
196 return xAccessibleShape
;
199 //===== XAccessible =========================================================
201 Reference
< XAccessibleContext
> SAL_CALL
SvxGraphCtrlAccessibleContext::getAccessibleContext( void ) throw( RuntimeException
)
206 //===== XAccessibleComponent ================================================
208 sal_Bool SAL_CALL
SvxGraphCtrlAccessibleContext::containsPoint( const awt::Point
& rPoint
) throw( RuntimeException
)
210 // no guard -> done in getSize()
211 awt::Size
aSize (getSize());
212 return (rPoint
.X
>= 0)
213 && (rPoint
.X
< aSize
.Width
)
215 && (rPoint
.Y
< aSize
.Height
);
218 //-----------------------------------------------------------------------------
220 Reference
< XAccessible
> SAL_CALL
SvxGraphCtrlAccessibleContext::getAccessibleAtPoint( const awt::Point
& rPoint
) throw( RuntimeException
)
222 ::osl::MutexGuard
aGuard( m_aMutex
);
224 Reference
< XAccessible
> xAccessible
;
228 Point
aPnt( rPoint
.X
, rPoint
.Y
);
229 mpControl
->PixelToLogic( aPnt
);
233 if(mpView
&& mpView
->GetSdrPageView())
235 pObj
= SdrObjListPrimitiveHit(*mpPage
, aPnt
, 1, *mpView
->GetSdrPageView(), 0, false);
239 xAccessible
= getAccessible( pObj
);
243 throw DisposedException();
249 //-----------------------------------------------------------------------------
251 awt::Rectangle SAL_CALL
SvxGraphCtrlAccessibleContext::getBounds() throw( RuntimeException
)
253 // no guard -> done in GetBoundingBox()
254 Rectangle
aCoreBounds( GetBoundingBox() );
255 awt::Rectangle aBounds
;
256 aBounds
.X
= aCoreBounds
.getX();
257 aBounds
.Y
= aCoreBounds
.getY();
258 aBounds
.Width
= aCoreBounds
.getWidth();
259 aBounds
.Height
= aCoreBounds
.getHeight();
263 //-----------------------------------------------------------------------------
265 awt::Point SAL_CALL
SvxGraphCtrlAccessibleContext::getLocation() throw( RuntimeException
)
267 // no guard -> done in GetBoundingBox()
268 Rectangle
aRect( GetBoundingBox() );
269 return awt::Point( aRect
.getX(), aRect
.getY() );
272 //-----------------------------------------------------------------------------
274 awt::Point SAL_CALL
SvxGraphCtrlAccessibleContext::getLocationOnScreen() throw( RuntimeException
)
276 // no guard -> done in GetBoundingBoxOnScreen()
277 Rectangle
aRect( GetBoundingBoxOnScreen() );
278 return awt::Point( aRect
.getX(), aRect
.getY() );
281 //-----------------------------------------------------------------------------
283 awt::Size SAL_CALL
SvxGraphCtrlAccessibleContext::getSize() throw( RuntimeException
)
285 // no guard -> done in GetBoundingBox()
286 Rectangle
aRect( GetBoundingBox() );
287 return awt::Size( aRect
.getWidth(), aRect
.getHeight() );
291 //===== XAccessibleContext ==================================================
293 sal_Int32 SAL_CALL
SvxGraphCtrlAccessibleContext::getAccessibleChildCount( void ) throw( RuntimeException
)
295 OGuard
aGuard( Application::GetSolarMutex() );
298 throw DisposedException();
300 return mpPage
->GetObjCount();
303 //-----------------------------------------------------------------------------
305 /** returns the SdrObject at index nIndex from the model of this graph */
306 SdrObject
* SvxGraphCtrlAccessibleContext::getSdrObject( sal_Int32 nIndex
)
307 throw( RuntimeException
, lang::IndexOutOfBoundsException
)
309 OGuard
aGuard( Application::GetSolarMutex() );
312 throw DisposedException();
314 if( (nIndex
< 0) || ( static_cast<sal_uInt32
>(nIndex
) >= mpPage
->GetObjCount() ) )
315 throw lang::IndexOutOfBoundsException();
317 return mpPage
->GetObj( nIndex
);
320 //-----------------------------------------------------------------------------
322 /** sends an AccessibleEventObject to all added XAccessibleEventListeners */
323 void SvxGraphCtrlAccessibleContext::CommitChange (
325 const uno::Any
& rNewValue
,
326 const uno::Any
& rOldValue
)
328 AccessibleEventObject
aEvent (
329 static_cast<uno::XWeak
*>(this),
337 /** sends an AccessibleEventObject to all added XAccessibleEventListeners */
338 void SvxGraphCtrlAccessibleContext::FireEvent (const AccessibleEventObject
& aEvent
)
341 comphelper::AccessibleEventNotifier::addEvent( mnClientId
, aEvent
);
344 //-----------------------------------------------------------------------------
346 Reference
< XAccessible
> SAL_CALL
SvxGraphCtrlAccessibleContext::getAccessibleChild( sal_Int32 nIndex
)
347 throw( RuntimeException
, lang::IndexOutOfBoundsException
)
349 OGuard
aGuard( Application::GetSolarMutex() );
351 return getAccessible( getSdrObject( nIndex
) );
354 //-----------------------------------------------------------------------------
356 Reference
< XAccessible
> SAL_CALL
SvxGraphCtrlAccessibleContext::getAccessibleParent( void ) throw( RuntimeException
)
361 //-----------------------------------------------------------------------------
363 sal_Int32 SAL_CALL
SvxGraphCtrlAccessibleContext::getAccessibleIndexInParent( void ) throw( RuntimeException
)
365 OGuard
aGuard( Application::GetSolarMutex() );
366 // Use a simple but slow solution for now. Optimize later.
368 // Iterate over all the parent's children and search for this object.
371 Reference
< XAccessibleContext
> xParentContext( mxParent
->getAccessibleContext() );
372 if( xParentContext
.is() )
374 sal_Int32 nChildCount
= xParentContext
->getAccessibleChildCount();
375 for( sal_Int32 i
= 0 ; i
< nChildCount
; ++i
)
377 Reference
< XAccessible
> xChild( xParentContext
->getAccessibleChild( i
) );
380 Reference
< XAccessibleContext
> xChildContext
= xChild
->getAccessibleContext();
381 if( xChildContext
== ( XAccessibleContext
* ) this )
388 // Return -1 to indicate that this object's parent does not know about the
393 //-----------------------------------------------------------------------------
395 sal_Int16 SAL_CALL
SvxGraphCtrlAccessibleContext::getAccessibleRole( void ) throw( RuntimeException
)
397 return AccessibleRole::PANEL
;
400 //-----------------------------------------------------------------------------
402 OUString SAL_CALL
SvxGraphCtrlAccessibleContext::getAccessibleDescription( void ) throw( RuntimeException
)
404 OGuard
aGuard( Application::GetSolarMutex() );
405 return msDescription
;
408 //-----------------------------------------------------------------------------
410 OUString SAL_CALL
SvxGraphCtrlAccessibleContext::getAccessibleName( void ) throw( RuntimeException
)
412 OGuard
aGuard( Application::GetSolarMutex() );
416 //-----------------------------------------------------------------------------
418 /** Return empty reference to indicate that the relation set is not
421 Reference
< XAccessibleRelationSet
> SAL_CALL
SvxGraphCtrlAccessibleContext::getAccessibleRelationSet( void ) throw( RuntimeException
)
423 return Reference
< XAccessibleRelationSet
>();
426 //-----------------------------------------------------------------------------
428 Reference
< XAccessibleStateSet
> SAL_CALL
SvxGraphCtrlAccessibleContext::getAccessibleStateSet( void ) throw( RuntimeException
)
430 OGuard
aGuard( Application::GetSolarMutex() );
432 utl::AccessibleStateSetHelper
* pStateSetHelper
= new utl::AccessibleStateSetHelper
;
434 if ( rBHelper
.bDisposed
|| mbDisposed
)
436 pStateSetHelper
->AddState( AccessibleStateType::DEFUNC
);
440 // pStateSetHelper->AddState( AccessibleStateType::ENABLED );
441 // pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
442 pStateSetHelper
->AddState( AccessibleStateType::FOCUSABLE
);
443 if( mpControl
->HasFocus() )
444 pStateSetHelper
->AddState( AccessibleStateType::FOCUSED
);
445 pStateSetHelper
->AddState( AccessibleStateType::OPAQUE
);
446 pStateSetHelper
->AddState( AccessibleStateType::SHOWING
);
447 pStateSetHelper
->AddState( AccessibleStateType::VISIBLE
);
450 return pStateSetHelper
;
453 //-----------------------------------------------------------------------------
455 lang::Locale SAL_CALL
SvxGraphCtrlAccessibleContext::getLocale( void ) throw( IllegalAccessibleComponentStateException
, RuntimeException
)
457 OGuard
aGuard( Application::GetSolarMutex() );
461 Reference
< XAccessibleContext
> xParentContext( mxParent
->getAccessibleContext() );
462 if( xParentContext
.is() )
463 return xParentContext
->getLocale();
466 // No parent. Therefore throw exception to indicate this cluelessness.
467 throw IllegalAccessibleComponentStateException();
470 //===== XAccessibleEventListener ============================================
472 void SAL_CALL
SvxGraphCtrlAccessibleContext::addEventListener( const Reference
< XAccessibleEventListener
>& xListener
)
473 throw( RuntimeException
)
477 OGuard
aGuard( Application::GetSolarMutex() );
479 mnClientId
= comphelper::AccessibleEventNotifier::registerClient( );
480 comphelper::AccessibleEventNotifier::addEventListener( mnClientId
, xListener
);
484 //-----------------------------------------------------------------------------
486 void SAL_CALL
SvxGraphCtrlAccessibleContext::removeEventListener( const Reference
< XAccessibleEventListener
>& xListener
)
487 throw( RuntimeException
)
491 OGuard
aGuard( Application::GetSolarMutex() );
493 sal_Int32 nListenerCount
= comphelper::AccessibleEventNotifier::removeEventListener( mnClientId
, xListener
);
494 if ( !nListenerCount
)
496 // no listeners anymore
497 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
498 // and at least to us not firing any events anymore, in case somebody calls
499 // NotifyAccessibleEvent, again
500 comphelper::AccessibleEventNotifier::revokeClient( mnClientId
);
506 //-----------------------------------------------------------------------------
508 void SAL_CALL
SvxGraphCtrlAccessibleContext::addFocusListener( const Reference
< awt::XFocusListener
>& xListener
)
509 throw( RuntimeException
)
511 OGuard
aGuard( Application::GetSolarMutex() );
515 Reference
< ::com::sun::star::awt::XWindow
> xWindow( VCLUnoHelper::GetInterface( mpControl
) );
517 xWindow
->addFocusListener( xListener
);
521 //-----------------------------------------------------------------------------
523 void SAL_CALL
SvxGraphCtrlAccessibleContext::removeFocusListener( const Reference
< awt::XFocusListener
>& xListener
)
524 throw (RuntimeException
)
526 OGuard
aGuard( Application::GetSolarMutex() );
530 Reference
< ::com::sun::star::awt::XWindow
> xWindow
= VCLUnoHelper::GetInterface( mpControl
);
532 xWindow
->removeFocusListener( xListener
);
536 //-----------------------------------------------------------------------------
538 void SAL_CALL
SvxGraphCtrlAccessibleContext::grabFocus() throw( RuntimeException
)
540 OGuard
aGuard( Application::GetSolarMutex() );
542 if( NULL
== mpControl
)
543 throw DisposedException();
545 mpControl
->GrabFocus();
548 //-----------------------------------------------------------------------------
550 Any SAL_CALL
SvxGraphCtrlAccessibleContext::getAccessibleKeyBinding() throw( RuntimeException
)
552 // here is no implementation, because here are no KeyBindings for every object
560 sal_Int32 SAL_CALL
SvxGraphCtrlAccessibleContext::getForeground (void)
561 throw (::com::sun::star::uno::RuntimeException
)
563 svtools::ColorConfig aColorConfig
;
564 UINT32 nColor
= aColorConfig
.GetColorValue( svtools::FONTCOLOR
).nColor
;
565 return static_cast<sal_Int32
>(nColor
);
571 sal_Int32 SAL_CALL
SvxGraphCtrlAccessibleContext::getBackground (void)
572 throw (::com::sun::star::uno::RuntimeException
)
574 UINT32 nColor
= Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
575 return static_cast<sal_Int32
>(nColor
);
579 //===== XServiceInfo ========================================================
581 OUString SAL_CALL
SvxGraphCtrlAccessibleContext::getImplementationName( void ) throw( RuntimeException
)
583 return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.ui.SvxGraphCtrlAccessibleContext" ) );
586 //-----------------------------------------------------------------------------
588 sal_Bool SAL_CALL
SvxGraphCtrlAccessibleContext::supportsService( const OUString
& sServiceName
) throw( RuntimeException
)
590 OGuard
aGuard( Application::GetSolarMutex() );
591 // Iterate over all supported service names and return true if on of them
592 // matches the given name.
593 Sequence
< OUString
> aSupportedServices( getSupportedServiceNames() );
594 int nLenght
= aSupportedServices
.getLength();
596 for( int i
= 0 ; i
< nLenght
; ++i
)
598 if( sServiceName
== aSupportedServices
[ i
] )
605 //-----------------------------------------------------------------------------
607 Sequence
< OUString
> SAL_CALL
SvxGraphCtrlAccessibleContext::getSupportedServiceNames( void ) throw( RuntimeException
)
609 Sequence
< OUString
> aSNs( 3 );
611 aSNs
[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.Accessible" ) );
612 aSNs
[1] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" ) );
613 aSNs
[2] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.AccessibleGraphControl" ) );
618 //===== XTypeProvider =======================================================
620 Sequence
<sal_Int8
> SAL_CALL
SvxGraphCtrlAccessibleContext::getImplementationId( void ) throw( RuntimeException
)
622 OGuard
aGuard( Application::GetSolarMutex() );
623 return getUniqueId();
626 //===== XServiceName ========================================================
628 OUString
SvxGraphCtrlAccessibleContext::getServiceName( void ) throw( RuntimeException
)
630 return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" ) );
633 //===== XAccessibleSelection =============================================
635 void SAL_CALL
SvxGraphCtrlAccessibleContext::selectAccessibleChild( sal_Int32 nIndex
) throw( lang::IndexOutOfBoundsException
, RuntimeException
)
637 OGuard
aGuard( Application::GetSolarMutex() );
640 throw DisposedException();
642 SdrObject
* pObj
= getSdrObject( nIndex
);
645 mpView
->MarkObj( pObj
, mpView
->GetSdrPageView());
648 //-----------------------------------------------------------------------------
650 sal_Bool SAL_CALL
SvxGraphCtrlAccessibleContext::isAccessibleChildSelected( sal_Int32 nIndex
) throw( lang::IndexOutOfBoundsException
, RuntimeException
)
652 OGuard
aGuard( Application::GetSolarMutex() );
655 throw DisposedException();
657 return mpView
->IsObjMarked( getSdrObject( nIndex
) );
660 //-----------------------------------------------------------------------------
662 void SAL_CALL
SvxGraphCtrlAccessibleContext::clearAccessibleSelection() throw( RuntimeException
)
664 OGuard
aGuard( Application::GetSolarMutex() );
667 throw DisposedException();
669 mpView
->UnmarkAllObj();
672 //-----------------------------------------------------------------------------
674 void SAL_CALL
SvxGraphCtrlAccessibleContext::selectAllAccessibleChildren() throw( RuntimeException
)
676 OGuard
aGuard( Application::GetSolarMutex() );
679 throw DisposedException();
681 mpView
->MarkAllObj();
684 //-----------------------------------------------------------------------------
686 sal_Int32 SAL_CALL
SvxGraphCtrlAccessibleContext::getSelectedAccessibleChildCount() throw( RuntimeException
)
688 OGuard
aGuard( Application::GetSolarMutex() );
691 throw DisposedException();
693 const SdrMarkList
& rList
= mpView
->GetMarkedObjectList();
694 return rList
.GetMarkCount();
697 //-----------------------------------------------------------------------------
699 Reference
< XAccessible
> SAL_CALL
SvxGraphCtrlAccessibleContext::getSelectedAccessibleChild( sal_Int32 nIndex
)
700 throw( lang::IndexOutOfBoundsException
, RuntimeException
)
702 OGuard
aGuard( Application::GetSolarMutex() );
704 checkChildIndexOnSelection( nIndex
);
706 Reference
< XAccessible
> xAccessible
;
708 const SdrMarkList
& rList
= mpView
->GetMarkedObjectList();
709 SdrObject
* pObj
= rList
.GetMark(nIndex
)->GetMarkedSdrObj();
711 xAccessible
= getAccessible( pObj
);
716 //-----------------------------------------------------------------------------
718 void SAL_CALL
SvxGraphCtrlAccessibleContext::deselectAccessibleChild( sal_Int32 nIndex
) throw( lang::IndexOutOfBoundsException
, RuntimeException
)
720 OGuard
aGuard( Application::GetSolarMutex() );
722 checkChildIndexOnSelection( nIndex
);
726 const SdrMarkList
& rList
= mpView
->GetMarkedObjectList();
728 SdrObject
* pObj
= getSdrObject( nIndex
);
731 SdrMarkList
aRefList( rList
);
733 SdrPageView
* pPV
= mpView
->GetSdrPageView();
734 mpView
->UnmarkAllObj( pPV
);
736 sal_uInt32 nCount
= aRefList
.GetMarkCount();
738 for( nMark
= 0; nMark
< nCount
; nMark
++ )
740 if( aRefList
.GetMark(nMark
)->GetMarkedSdrObj() != pObj
)
741 mpView
->MarkObj( aRefList
.GetMark(nMark
)->GetMarkedSdrObj(), pPV
);
747 //===== internals ========================================================
749 void SvxGraphCtrlAccessibleContext::checkChildIndex( long nIndex
) throw( lang::IndexOutOfBoundsException
)
751 if( nIndex
< 0 || nIndex
>= getAccessibleChildCount() )
752 throw lang::IndexOutOfBoundsException();
755 //-----------------------------------------------------------------------------
757 void SvxGraphCtrlAccessibleContext::checkChildIndexOnSelection( long nIndex
) throw( lang::IndexOutOfBoundsException
)
759 if( nIndex
< 0 || nIndex
>= getSelectedAccessibleChildCount() )
760 throw lang::IndexOutOfBoundsException();
763 //-----------------------------------------------------------------------------
765 void SvxGraphCtrlAccessibleContext::setName( const OUString
& rName
)
767 OGuard
aGuard( Application::GetSolarMutex() );
772 //-----------------------------------------------------------------------------
774 void SvxGraphCtrlAccessibleContext::setDescription( const OUString
& rDescr
)
776 OGuard
aGuard( Application::GetSolarMutex() );
778 msDescription
= rDescr
;
784 /** Replace the model, page, and view pointers by the ones provided
785 (explicitly and implicitly).
787 void SvxGraphCtrlAccessibleContext::setModelAndView (
791 OGuard
aGuard (Application::GetSolarMutex());
795 mpPage
= (SdrPage
*)mpModel
->GetPage( 0 );
798 if (mpModel
== NULL
|| mpPage
== NULL
|| mpView
== NULL
)
802 // Set all the pointers to NULL just in case they are used as
809 maTreeInfo
.SetSdrView (mpView
);
814 //-----------------------------------------------------------------------------
816 void SAL_CALL
SvxGraphCtrlAccessibleContext::disposing()
818 OGuard
aGuard( Application::GetSolarMutex() );
823 mbDisposed
= sal_True
;
825 mpControl
= NULL
; // object dies with representation
830 ShapesMapType::iterator I
;
832 for (I
=mxShapes
.begin(); I
!=mxShapes
.end(); I
++)
834 XAccessible
* pAcc
= (*I
).second
;
835 Reference
< XComponent
> xComp( pAcc
, UNO_QUERY
);
839 (*I
).second
->release();
845 // Send a disposing to all listeners.
848 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId
, *this );
853 //-----------------------------------------------------------------------------
855 Rectangle
SvxGraphCtrlAccessibleContext::GetBoundingBoxOnScreen( void ) throw( RuntimeException
)
857 OGuard
aGuard( Application::GetSolarMutex() );
859 if( NULL
== mpControl
)
860 throw DisposedException();
863 mpControl
->GetAccessibleParentWindow()->OutputToAbsoluteScreenPixel(
864 mpControl
->GetPosPixel() ),
865 mpControl
->GetSizePixel() );
868 //-----------------------------------------------------------------------------
870 /** Calculate the relative coordinates of the bounding box as difference
871 between the absolute coordinates of the bounding boxes of this control
872 and its parent in the accessibility tree.
874 Rectangle
SvxGraphCtrlAccessibleContext::GetBoundingBox( void ) throw( RuntimeException
)
876 OGuard
aGuard( Application::GetSolarMutex() );
878 Rectangle
aBounds ( 0, 0, 0, 0 );
880 Window
* pWindow
= mpControl
;
883 aBounds
= pWindow
->GetWindowExtentsRelative (NULL
);
884 Window
* pParent
= pWindow
->GetAccessibleParentWindow();
887 Rectangle aParentRect
= pParent
->GetWindowExtentsRelative (NULL
);
888 aBounds
-= aParentRect
.TopLeft();
892 throw DisposedException();
897 //-----------------------------------------------------------------------------
899 Sequence
< sal_Int8
> SvxGraphCtrlAccessibleContext::getUniqueId( void )
901 // no guard because it's private -> has to guarded when using it!
902 static OImplementationId
* pId
= 0;
905 OGuard
aGuard( Application::GetSolarMutex() );
908 static OImplementationId aId
;
912 return pId
->getImplementationId();
915 //-----------------------------------------------------------------------------
917 void SvxGraphCtrlAccessibleContext::Notify( SfxBroadcaster
& /*rBC*/, const SfxHint
& rHint
)
919 const SdrHint
* pSdrHint
= PTR_CAST( SdrHint
, &rHint
);
923 switch( pSdrHint
->GetKind() )
927 ShapesMapType::iterator iter
= mxShapes
.find( pSdrHint
->GetObject() );
929 if( iter
!= mxShapes
.end() )
931 // if we already have one, return it
932 AccessibleShape
* pShape
= (*iter
).second
;
935 pShape
->CommitChange( AccessibleEventId::VISIBLE_DATA_CHANGED
, uno::Any(), uno::Any() );
940 case HINT_OBJINSERTED
:
941 CommitChange( AccessibleEventId::CHILD
, makeAny( getAccessible( pSdrHint
->GetObject() ) ) , uno::Any());
943 case HINT_OBJREMOVED
:
944 CommitChange( AccessibleEventId::CHILD
, uno::Any(), makeAny( getAccessible( pSdrHint
->GetObject() ) ) );
946 case HINT_MODELCLEARED
:
955 const SfxSimpleHint
* pSfxHint
= PTR_CAST(SfxSimpleHint
, &rHint
);
957 // ist unser SdDrawDocument gerade gestorben?
958 if(pSfxHint
&& pSfxHint
->GetId() == SFX_HINT_DYING
)
965 //===== IAccessibleViewforwarder ========================================
967 sal_Bool
SvxGraphCtrlAccessibleContext::IsValid (void) const
972 //-----------------------------------------------------------------------------
974 Rectangle
SvxGraphCtrlAccessibleContext::GetVisibleArea (void) const
978 if( mpView
&& mpView
->PaintWindowCount())
980 SdrPaintWindow
* pPaintWindow
= mpView
->GetPaintWindow(0L);
981 aVisArea
= pPaintWindow
->GetVisibleArea();
987 //-----------------------------------------------------------------------------
989 Point
SvxGraphCtrlAccessibleContext::LogicToPixel (const Point
& rPoint
) const
993 Rectangle
aBBox(mpControl
->GetWindowExtentsRelative(NULL
));
994 return mpControl
->LogicToPixel (rPoint
) + aBBox
.TopLeft();
1002 //-----------------------------------------------------------------------------
1004 Size
SvxGraphCtrlAccessibleContext::LogicToPixel (const Size
& rSize
) const
1007 return mpControl
->LogicToPixel (rSize
);
1012 //-----------------------------------------------------------------------------
1014 Point
SvxGraphCtrlAccessibleContext::PixelToLogic (const Point
& rPoint
) const
1017 return mpControl
->PixelToLogic (rPoint
);
1022 //-----------------------------------------------------------------------------
1024 Size
SvxGraphCtrlAccessibleContext::PixelToLogic (const Size
& rSize
) const
1027 return mpControl
->PixelToLogic (rSize
);