bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / accessibility / GraphCtlAccessibleContext.cxx
blobe0b8fc92e3d0d027dd68992e907f504acd335b0d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <com/sun/star/accessibility/AccessibleRole.hpp>
21 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
22 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
23 #include <com/sun/star/lang/DisposedException.hpp>
24 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
25 #include <com/sun/star/awt/XWindow.hpp>
26 #include <unotools/accessiblestatesethelper.hxx>
27 #include <cppuhelper/supportsservice.hxx>
28 #include <cppuhelper/typeprovider.hxx>
29 #include <toolkit/helper/vclunohelper.hxx>
30 #include <vcl/svapp.hxx>
31 #include <vcl/settings.hxx>
32 #include <osl/mutex.hxx>
33 #include <tools/gen.hxx>
34 #include <svl/smplhint.hxx>
35 #include <toolkit/helper/convert.hxx>
36 #include <svtools/colorcfg.hxx>
37 #include <comphelper/accessibleeventnotifier.hxx>
38 #include <svx/sdrpaintwindow.hxx>
40 #include <svx/ShapeTypeHandler.hxx>
41 #include <svx/AccessibleShapeInfo.hxx>
42 #include "GraphCtlAccessibleContext.hxx"
43 #include <svx/graphctl.hxx>
44 #include <svx/dialogs.hrc>
45 #include "accessibility.hrc"
46 #include <svx/svdpage.hxx>
47 #include <svx/unomod.hxx>
48 #include <svx/dialmgr.hxx>
49 #include <svx/svdetc.hxx>
50 #include <svx/sdrhittesthelper.hxx>
52 // namespaces
53 using namespace ::cppu;
54 using namespace ::osl;
55 using namespace ::accessibility;
56 using namespace ::com::sun::star;
57 using namespace ::com::sun::star::uno;
58 using namespace ::com::sun::star::drawing;
59 using namespace ::com::sun::star::lang;
60 using namespace ::com::sun::star::accessibility;
62 // internal
63 /** initialize this component and set default values */
64 SvxGraphCtrlAccessibleContext::SvxGraphCtrlAccessibleContext(
65 const Reference< XAccessible >& rxParent,
66 GraphCtrl& rRepr,
67 const OUString* pName,
68 const OUString* pDesc ) :
70 SvxGraphCtrlAccessibleContext_Base( m_aMutex ),
71 mxParent( rxParent ),
72 mpControl( &rRepr ),
73 mpModel (NULL),
74 mpPage (NULL),
75 mpView (NULL),
76 mnClientId( 0 ),
77 mbDisposed( false )
79 if (mpControl != nullptr)
81 mpModel = mpControl->GetSdrModel();
82 if (mpModel != NULL)
83 mpPage = mpModel->GetPage( 0 );
84 mpView = mpControl->GetSdrView();
86 if( mpModel == NULL || mpPage == NULL || mpView == NULL )
88 mbDisposed = true;
89 // Set all the pointers to NULL just in case they are used as
90 // a disposed flag.
91 mpModel = NULL;
92 mpPage = NULL;
93 mpView = NULL;
97 if( pName )
99 msName = *pName;
101 else
103 ::SolarMutexGuard aSolarGuard;
104 msName = SVX_RESSTR( RID_SVXSTR_GRAPHCTRL_ACC_NAME );
107 if( pDesc )
109 msDescription = *pDesc;
111 else
113 ::SolarMutexGuard aSolarGuard;
114 msDescription = SVX_RESSTR( RID_SVXSTR_GRAPHCTRL_ACC_DESCRIPTION );
117 maTreeInfo.SetSdrView( mpView );
118 maTreeInfo.SetWindow( mpControl );
119 maTreeInfo.SetViewForwarder( this );
124 /** on destruction, this component is disposed and all dispose listeners
125 are called, except if this component was already disposed */
126 SvxGraphCtrlAccessibleContext::~SvxGraphCtrlAccessibleContext()
128 disposing();
133 /** returns the XAccessible interface for a given SdrObject.
134 Multiple calls for the same SdrObject return the same XAccessible.
136 Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessible( const SdrObject* pObj )
138 Reference<XAccessible> xAccessibleShape;
140 if( pObj )
142 // see if we already created an XAccessible for the given SdrObject
143 ShapesMapType::iterator iter = mxShapes.find( pObj );
145 if( iter != mxShapes.end() )
147 // if we already have one, return it
148 xAccessibleShape = (*iter).second;
150 else
152 // create a new one and remember in our internal map
153 Reference< XShape > xShape( Reference< XShape >::query( (const_cast<SdrObject*>(pObj))->getUnoShape() ) );
155 AccessibleShapeInfo aShapeInfo (xShape,mxParent);
156 // Create accessible object that corresponds to the descriptor's shape.
157 AccessibleShape* pAcc = ShapeTypeHandler::Instance().CreateAccessibleObject(
158 aShapeInfo, maTreeInfo);
159 xAccessibleShape = pAcc;
160 if (pAcc != NULL)
162 pAcc->acquire();
163 // Now that we acquired the new accessible shape we can
164 // safely call its Init() method.
165 pAcc->Init ();
167 mxShapes[pObj] = pAcc;
169 // Create event and inform listeners of the object creation.
170 CommitChange( AccessibleEventId::CHILD, makeAny( xAccessibleShape ), makeAny( Reference<XAccessible>() ) );
174 return xAccessibleShape;
177 // XAccessible
178 Reference< XAccessibleContext > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleContext() throw( RuntimeException, std::exception )
180 return this;
183 // XAccessibleComponent
184 sal_Bool SAL_CALL SvxGraphCtrlAccessibleContext::containsPoint( const awt::Point& rPoint ) throw( RuntimeException, std::exception )
186 // no guard -> done in getSize()
187 awt::Size aSize (getSize());
188 return (rPoint.X >= 0)
189 && (rPoint.X < aSize.Width)
190 && (rPoint.Y >= 0)
191 && (rPoint.Y < aSize.Height);
196 Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleAtPoint( const awt::Point& rPoint ) throw( RuntimeException, std::exception )
198 ::osl::MutexGuard aGuard( m_aMutex );
200 Reference< XAccessible > xAccessible;
202 if( mpControl )
204 Point aPnt( rPoint.X, rPoint.Y );
205 mpControl->PixelToLogic( aPnt );
207 SdrObject* pObj = 0;
209 if(mpView && mpView->GetSdrPageView())
211 pObj = SdrObjListPrimitiveHit(*mpPage, aPnt, 1, *mpView->GetSdrPageView(), 0, false);
214 if( pObj )
215 xAccessible = getAccessible( pObj );
217 else
219 throw DisposedException();
222 return xAccessible;
227 awt::Rectangle SAL_CALL SvxGraphCtrlAccessibleContext::getBounds() throw( RuntimeException, std::exception )
229 // no guard -> done in GetBoundingBox()
230 Rectangle aCoreBounds( GetBoundingBox() );
231 awt::Rectangle aBounds;
232 aBounds.X = aCoreBounds.getX();
233 aBounds.Y = aCoreBounds.getY();
234 aBounds.Width = aCoreBounds.getWidth();
235 aBounds.Height = aCoreBounds.getHeight();
236 return aBounds;
241 awt::Point SAL_CALL SvxGraphCtrlAccessibleContext::getLocation() throw( RuntimeException, std::exception )
243 // no guard -> done in GetBoundingBox()
244 Rectangle aRect( GetBoundingBox() );
245 return awt::Point( aRect.getX(), aRect.getY() );
250 awt::Point SAL_CALL SvxGraphCtrlAccessibleContext::getLocationOnScreen() throw( RuntimeException, std::exception )
252 // no guard -> done in GetBoundingBoxOnScreen()
253 Rectangle aRect( GetBoundingBoxOnScreen() );
254 return awt::Point( aRect.getX(), aRect.getY() );
259 awt::Size SAL_CALL SvxGraphCtrlAccessibleContext::getSize() throw( RuntimeException, std::exception )
261 // no guard -> done in GetBoundingBox()
262 Rectangle aRect( GetBoundingBox() );
263 return awt::Size( aRect.getWidth(), aRect.getHeight() );
266 // XAccessibleContext
267 sal_Int32 SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleChildCount() throw( RuntimeException, std::exception )
269 ::SolarMutexGuard aGuard;
271 if( NULL == mpPage )
272 throw DisposedException();
274 return mpPage->GetObjCount();
279 /** returns the SdrObject at index nIndex from the model of this graph */
280 SdrObject* SvxGraphCtrlAccessibleContext::getSdrObject( sal_Int32 nIndex )
281 throw( RuntimeException, lang::IndexOutOfBoundsException )
283 ::SolarMutexGuard aGuard;
285 if( NULL == mpPage )
286 throw DisposedException();
288 if( (nIndex < 0) || ( static_cast<size_t>(nIndex) >= mpPage->GetObjCount() ) )
289 throw lang::IndexOutOfBoundsException();
291 return mpPage->GetObj( nIndex );
296 /** sends an AccessibleEventObject to all added XAccessibleEventListeners */
297 void SvxGraphCtrlAccessibleContext::CommitChange (
298 sal_Int16 nEventId,
299 const uno::Any& rNewValue,
300 const uno::Any& rOldValue)
302 AccessibleEventObject aEvent (
303 static_cast<uno::XWeak*>(this),
304 nEventId,
305 rNewValue,
306 rOldValue);
308 FireEvent (aEvent);
311 /** sends an AccessibleEventObject to all added XAccessibleEventListeners */
312 void SvxGraphCtrlAccessibleContext::FireEvent (const AccessibleEventObject& aEvent)
314 if (mnClientId)
315 comphelper::AccessibleEventNotifier::addEvent( mnClientId, aEvent );
320 Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleChild( sal_Int32 nIndex )
321 throw( RuntimeException, lang::IndexOutOfBoundsException, std::exception )
323 ::SolarMutexGuard aGuard;
325 return getAccessible( getSdrObject( nIndex ) );
330 Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleParent() throw( RuntimeException, std::exception )
332 return mxParent;
337 sal_Int32 SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleIndexInParent() throw( RuntimeException, std::exception )
339 ::SolarMutexGuard aGuard;
340 // Use a simple but slow solution for now. Optimize later.
342 // Iterate over all the parent's children and search for this object.
343 if( mxParent.is() )
345 Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() );
346 if( xParentContext.is() )
348 sal_Int32 nChildCount = xParentContext->getAccessibleChildCount();
349 for( sal_Int32 i = 0 ; i < nChildCount ; ++i )
351 Reference< XAccessible > xChild( xParentContext->getAccessibleChild( i ) );
352 if( xChild.is() )
354 Reference< XAccessibleContext > xChildContext = xChild->getAccessibleContext();
355 if( xChildContext == ( XAccessibleContext* ) this )
356 return i;
362 // Return -1 to indicate that this object's parent does not know about the
363 // object.
364 return -1;
369 sal_Int16 SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleRole() throw( RuntimeException, std::exception )
371 return AccessibleRole::PANEL;
376 OUString SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleDescription() throw( RuntimeException, std::exception )
378 ::SolarMutexGuard aGuard;
379 return msDescription;
384 OUString SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleName() throw( RuntimeException, std::exception )
386 ::SolarMutexGuard aGuard;
387 return msName;
392 /** Return empty reference to indicate that the relation set is not
393 supported.
395 Reference< XAccessibleRelationSet > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleRelationSet() throw( RuntimeException, std::exception )
397 return Reference< XAccessibleRelationSet >();
402 Reference< XAccessibleStateSet > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleStateSet() throw( RuntimeException, std::exception )
404 ::SolarMutexGuard aGuard;
406 utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
408 if ( rBHelper.bDisposed || mbDisposed )
410 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
412 else
414 pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
415 if( mpControl->HasFocus() )
416 pStateSetHelper->AddState( AccessibleStateType::FOCUSED );
417 pStateSetHelper->AddState( AccessibleStateType::OPAQUE );
418 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
419 pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
422 return pStateSetHelper;
427 lang::Locale SAL_CALL SvxGraphCtrlAccessibleContext::getLocale() throw( IllegalAccessibleComponentStateException, RuntimeException, std::exception )
429 ::SolarMutexGuard aGuard;
431 if( mxParent.is() )
433 Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() );
434 if( xParentContext.is() )
435 return xParentContext->getLocale();
438 // No parent. Therefore throw exception to indicate this cluelessness.
439 throw IllegalAccessibleComponentStateException();
442 // XAccessibleEventListener
443 void SAL_CALL SvxGraphCtrlAccessibleContext::addAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener )
444 throw( RuntimeException, std::exception )
446 if (xListener.is())
448 ::SolarMutexGuard aGuard;
449 if (!mnClientId)
450 mnClientId = comphelper::AccessibleEventNotifier::registerClient( );
451 comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener );
457 void SAL_CALL SvxGraphCtrlAccessibleContext::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener )
458 throw( RuntimeException, std::exception )
460 if (xListener.is())
462 ::SolarMutexGuard aGuard;
464 sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener );
465 if ( !nListenerCount )
467 // no listeners anymore
468 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
469 // and at least to us not firing any events anymore, in case somebody calls
470 // NotifyAccessibleEvent, again
471 comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
472 mnClientId = 0;
477 void SAL_CALL SvxGraphCtrlAccessibleContext::grabFocus() throw( RuntimeException, std::exception )
479 ::SolarMutexGuard aGuard;
481 if( nullptr == mpControl )
482 throw DisposedException();
484 mpControl->GrabFocus();
487 sal_Int32 SAL_CALL SvxGraphCtrlAccessibleContext::getForeground()
488 throw (::com::sun::star::uno::RuntimeException, std::exception)
490 svtools::ColorConfig aColorConfig;
491 sal_uInt32 nColor = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor;
492 return static_cast<sal_Int32>(nColor);
495 sal_Int32 SAL_CALL SvxGraphCtrlAccessibleContext::getBackground()
496 throw (::com::sun::star::uno::RuntimeException, std::exception)
498 sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
499 return static_cast<sal_Int32>(nColor);
502 // XServiceInfo
503 OUString SAL_CALL SvxGraphCtrlAccessibleContext::getImplementationName() throw( RuntimeException, std::exception )
505 return OUString( "com.sun.star.comp.ui.SvxGraphCtrlAccessibleContext" );
508 sal_Bool SAL_CALL SvxGraphCtrlAccessibleContext::supportsService( const OUString& sServiceName ) throw( RuntimeException, std::exception )
510 return cppu::supportsService(this, sServiceName);
513 Sequence< OUString > SAL_CALL SvxGraphCtrlAccessibleContext::getSupportedServiceNames() throw( RuntimeException, std::exception )
515 Sequence< OUString > aSNs( 3 );
517 aSNs[0] = "com.sun.star.accessibility.Accessible";
518 aSNs[1] = "com.sun.star.accessibility.AccessibleContext";
519 aSNs[2] = "com.sun.star.drawing.AccessibleGraphControl";
521 return aSNs;
524 // XTypeProvider
525 Sequence<sal_Int8> SAL_CALL SvxGraphCtrlAccessibleContext::getImplementationId() throw( RuntimeException, std::exception )
527 return css::uno::Sequence<sal_Int8>();
530 // XServiceName
531 OUString SvxGraphCtrlAccessibleContext::getServiceName() throw( RuntimeException, std::exception )
533 return OUString( "com.sun.star.accessibility.AccessibleContext" );
536 // XAccessibleSelection
537 void SAL_CALL SvxGraphCtrlAccessibleContext::selectAccessibleChild( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException, std::exception )
539 ::SolarMutexGuard aGuard;
541 if( NULL == mpView )
542 throw DisposedException();
544 SdrObject* pObj = getSdrObject( nIndex );
546 if( pObj )
547 mpView->MarkObj( pObj, mpView->GetSdrPageView());
552 sal_Bool SAL_CALL SvxGraphCtrlAccessibleContext::isAccessibleChildSelected( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException, std::exception )
554 ::SolarMutexGuard aGuard;
556 if( NULL == mpView )
557 throw DisposedException();
559 return mpView->IsObjMarked( getSdrObject( nIndex ) );
564 void SAL_CALL SvxGraphCtrlAccessibleContext::clearAccessibleSelection() throw( RuntimeException, std::exception )
566 ::SolarMutexGuard aGuard;
568 if( NULL == mpView )
569 throw DisposedException();
571 mpView->UnmarkAllObj();
576 void SAL_CALL SvxGraphCtrlAccessibleContext::selectAllAccessibleChildren() throw( RuntimeException, std::exception )
578 ::SolarMutexGuard aGuard;
580 if( NULL == mpView )
581 throw DisposedException();
583 mpView->MarkAllObj();
588 sal_Int32 SAL_CALL SvxGraphCtrlAccessibleContext::getSelectedAccessibleChildCount() throw( RuntimeException, std::exception )
590 ::SolarMutexGuard aGuard;
592 if( NULL == mpView )
593 throw DisposedException();
595 const SdrMarkList& rList = mpView->GetMarkedObjectList();
596 return static_cast<sal_Int32>(rList.GetMarkCount());
601 Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getSelectedAccessibleChild( sal_Int32 nIndex )
602 throw( lang::IndexOutOfBoundsException, RuntimeException, std::exception )
604 ::SolarMutexGuard aGuard;
606 checkChildIndexOnSelection( nIndex );
608 Reference< XAccessible > xAccessible;
610 const SdrMarkList& rList = mpView->GetMarkedObjectList();
611 SdrObject* pObj = rList.GetMark(static_cast<size_t>(nIndex))->GetMarkedSdrObj();
612 if( pObj )
613 xAccessible = getAccessible( pObj );
615 return xAccessible;
620 void SAL_CALL SvxGraphCtrlAccessibleContext::deselectAccessibleChild( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException, std::exception )
622 ::SolarMutexGuard aGuard;
624 checkChildIndexOnSelection( nIndex );
626 if( mpView )
628 const SdrMarkList& rList = mpView->GetMarkedObjectList();
630 SdrObject* pObj = getSdrObject( nIndex );
631 if( pObj )
633 SdrMarkList aRefList( rList );
635 SdrPageView* pPV = mpView->GetSdrPageView();
636 mpView->UnmarkAllObj( pPV );
638 const size_t nCount = aRefList.GetMarkCount();
639 for( size_t nMark = 0; nMark < nCount; ++nMark )
641 if( aRefList.GetMark(nMark)->GetMarkedSdrObj() != pObj )
642 mpView->MarkObj( aRefList.GetMark(nMark)->GetMarkedSdrObj(), pPV );
648 // internals
649 void SvxGraphCtrlAccessibleContext::checkChildIndexOnSelection( long nIndex ) throw( lang::IndexOutOfBoundsException )
651 if( nIndex < 0 || nIndex >= getSelectedAccessibleChildCount() )
652 throw lang::IndexOutOfBoundsException();
657 /** Replace the model, page, and view pointers by the ones provided
658 (explicitly and implicitly).
660 void SvxGraphCtrlAccessibleContext::setModelAndView (
661 SdrModel* pModel,
662 SdrView* pView)
664 ::SolarMutexGuard aGuard;
666 mpModel = pModel;
667 if (mpModel != NULL)
668 mpPage = mpModel->GetPage( 0 );
669 mpView = pView;
671 if (mpModel == NULL || mpPage == NULL || mpView == NULL)
673 mbDisposed = true;
675 // Set all the pointers to NULL just in case they are used as
676 // a disposed flag.
677 mpModel = NULL;
678 mpPage = NULL;
679 mpView = NULL;
682 maTreeInfo.SetSdrView (mpView);
689 void SAL_CALL SvxGraphCtrlAccessibleContext::disposing()
691 ::SolarMutexGuard aGuard;
693 if( mbDisposed )
694 return;
696 mbDisposed = true;
698 mpControl = NULL; // object dies with representation
699 mpView = NULL;
700 mpPage = NULL;
703 ShapesMapType::iterator I;
705 for (I=mxShapes.begin(); I!=mxShapes.end(); ++I)
707 XAccessible* pAcc = (*I).second;
708 Reference< XComponent > xComp( pAcc, UNO_QUERY );
709 if( xComp.is() )
710 xComp->dispose();
712 (*I).second->release();
715 mxShapes.clear();
718 // Send a disposing to all listeners.
719 if ( mnClientId )
721 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this );
722 mnClientId = 0;
728 Rectangle SvxGraphCtrlAccessibleContext::GetBoundingBoxOnScreen() throw( RuntimeException )
730 ::SolarMutexGuard aGuard;
732 if( nullptr == mpControl )
733 throw DisposedException();
735 return Rectangle(
736 mpControl->GetAccessibleParentWindow()->OutputToAbsoluteScreenPixel(
737 mpControl->GetPosPixel() ),
738 mpControl->GetSizePixel() );
743 /** Calculate the relative coordinates of the bounding box as difference
744 between the absolute coordinates of the bounding boxes of this control
745 and its parent in the accessibility tree.
747 Rectangle SvxGraphCtrlAccessibleContext::GetBoundingBox() throw( RuntimeException )
749 ::SolarMutexGuard aGuard;
751 Rectangle aBounds ( 0, 0, 0, 0 );
753 vcl::Window* pWindow = mpControl;
754 if (pWindow != NULL)
756 aBounds = pWindow->GetWindowExtentsRelative (NULL);
757 vcl::Window* pParent = pWindow->GetAccessibleParentWindow();
758 if (pParent != NULL)
760 Rectangle aParentRect = pParent->GetWindowExtentsRelative (NULL);
761 aBounds -= aParentRect.TopLeft();
764 else
765 throw DisposedException();
767 return aBounds;
770 void SvxGraphCtrlAccessibleContext::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
772 const SdrHint* pSdrHint = dynamic_cast<const SdrHint*>( &rHint );
774 if( pSdrHint )
776 switch( pSdrHint->GetKind() )
778 case HINT_OBJCHG:
780 ShapesMapType::iterator iter = mxShapes.find( pSdrHint->GetObject() );
782 if( iter != mxShapes.end() )
784 // if we already have one, return it
785 AccessibleShape* pShape = (*iter).second;
787 if( NULL != pShape )
788 pShape->CommitChange( AccessibleEventId::VISIBLE_DATA_CHANGED, uno::Any(), uno::Any() );
791 break;
793 case HINT_OBJINSERTED:
794 CommitChange( AccessibleEventId::CHILD, makeAny( getAccessible( pSdrHint->GetObject() ) ) , uno::Any());
795 break;
796 case HINT_OBJREMOVED:
797 CommitChange( AccessibleEventId::CHILD, uno::Any(), makeAny( getAccessible( pSdrHint->GetObject() ) ) );
798 break;
799 case HINT_MODELCLEARED:
800 dispose();
801 break;
802 default:
803 break;
806 else
808 const SfxSimpleHint* pSfxHint = dynamic_cast<const SfxSimpleHint*>( &rHint );
810 // Has our SdDrawDocument just died?
811 if(pSfxHint && pSfxHint->GetId() == SFX_HINT_DYING)
813 dispose();
818 // IAccessibleViewforwarder
819 bool SvxGraphCtrlAccessibleContext::IsValid() const
821 return true;
826 Rectangle SvxGraphCtrlAccessibleContext::GetVisibleArea() const
828 Rectangle aVisArea;
830 if( mpView && mpView->PaintWindowCount())
832 SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow(0L);
833 aVisArea = pPaintWindow->GetVisibleArea();
836 return aVisArea;
841 Point SvxGraphCtrlAccessibleContext::LogicToPixel (const Point& rPoint) const
843 if( mpControl )
845 Rectangle aBBox(mpControl->GetWindowExtentsRelative(NULL));
846 return mpControl->LogicToPixel (rPoint) + aBBox.TopLeft();
848 else
850 return rPoint;
856 Size SvxGraphCtrlAccessibleContext::LogicToPixel (const Size& rSize) const
858 if( mpControl )
859 return mpControl->LogicToPixel (rSize);
860 else
861 return rSize;
866 Point SvxGraphCtrlAccessibleContext::PixelToLogic (const Point& rPoint) const
868 if( mpControl )
869 return mpControl->PixelToLogic (rPoint);
870 else
871 return rPoint;
876 Size SvxGraphCtrlAccessibleContext::PixelToLogic (const Size& rSize) const
878 if( mpControl )
879 return mpControl->PixelToLogic (rSize);
880 else
881 return rSize;
884 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */