1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir 29*cdf0e10cSrcweir #ifndef _SVXGRAPHACCESSIBLECONTEXT_HXX 30*cdf0e10cSrcweir #define _SVXGRAPHACCESSIBLECONTEXT_HXX 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #ifndef _CPPUHELPER_IMPLBASE7_HXX_ 33*cdf0e10cSrcweir #include <cppuhelper/compbase7.hxx> 34*cdf0e10cSrcweir #endif 35*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx> 36*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleComponent.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleContext.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> 40*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_IllegalAccessibleComponentStateException_HPP_ 41*cdf0e10cSrcweir #include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp> 42*cdf0e10cSrcweir #endif 43*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleSelection.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyChangeListener.hpp> 45*cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 46*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceName.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> 50*cdf0e10cSrcweir #include <vos/mutex.hxx> 51*cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx> 52*cdf0e10cSrcweir #include <svl/lstner.hxx> 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir #include <set> 55*cdf0e10cSrcweir #include <map> 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir #include <comphelper/servicehelper.hxx> 58*cdf0e10cSrcweir #include <svx/rectenum.hxx> 59*cdf0e10cSrcweir #include <svx/AccessibleShapeTreeInfo.hxx> 60*cdf0e10cSrcweir #include <svx/IAccessibleViewForwarder.hxx> 61*cdf0e10cSrcweir #include <svx/AccessibleShape.hxx> 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace awt { 64*cdf0e10cSrcweir struct Point; 65*cdf0e10cSrcweir struct Rectangle; 66*cdf0e10cSrcweir struct Size; 67*cdf0e10cSrcweir class XFocusListener; 68*cdf0e10cSrcweir } } } } 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir class Rectangle; 71*cdf0e10cSrcweir class GraphCtrl; 72*cdf0e10cSrcweir class Window; 73*cdf0e10cSrcweir class SdrObject; 74*cdf0e10cSrcweir class SdrModel; 75*cdf0e10cSrcweir class SdrPage; 76*cdf0e10cSrcweir class SdrView; 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir /** @descr 79*cdf0e10cSrcweir This base class provides an implementation of the 80*cdf0e10cSrcweir <code>AccessibleContext</code> service. 81*cdf0e10cSrcweir */ 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir typedef ::cppu::WeakAggComponentImplHelper7< 84*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible, 85*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleComponent, 86*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleContext, 87*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleEventBroadcaster, 88*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleSelection, 89*cdf0e10cSrcweir ::com::sun::star::lang::XServiceInfo, 90*cdf0e10cSrcweir ::com::sun::star::lang::XServiceName > 91*cdf0e10cSrcweir SvxGraphCtrlAccessibleContext_Base; 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir class SvxGraphCtrlAccessibleContext : public SvxGraphCtrlAccessibleContext_Base, ::comphelper::OBaseMutex, SfxListener, ::accessibility::IAccessibleViewForwarder 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir public: 96*cdf0e10cSrcweir friend class GraphCtrl; 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir //===== internal ======================================================== 99*cdf0e10cSrcweir SvxGraphCtrlAccessibleContext( 100*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>& rxParent, 101*cdf0e10cSrcweir GraphCtrl& rRepresentation, 102*cdf0e10cSrcweir const ::rtl::OUString* pName = NULL, 103*cdf0e10cSrcweir const ::rtl::OUString* pDescription = NULL ); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir void Notify( SfxBroadcaster& aBC, const SfxHint& aHint ); 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir protected: 108*cdf0e10cSrcweir virtual ~SvxGraphCtrlAccessibleContext(); 109*cdf0e10cSrcweir public: 110*cdf0e10cSrcweir //===== XAccessible ===================================================== 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir /// Return the XAccessibleContext. 113*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL 114*cdf0e10cSrcweir getAccessibleContext (void) throw (::com::sun::star::uno::RuntimeException); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir //===== XAccessibleComponent ============================================ 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& rPoint ) throw (::com::sun::star::uno::RuntimeException); 119*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint ) throw (::com::sun::star::uno::RuntimeException); 120*cdf0e10cSrcweir virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds() throw (::com::sun::star::uno::RuntimeException); 121*cdf0e10cSrcweir virtual ::com::sun::star::awt::Point SAL_CALL getLocation() throw (::com::sun::star::uno::RuntimeException); 122*cdf0e10cSrcweir virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen() throw (::com::sun::star::uno::RuntimeException); 123*cdf0e10cSrcweir virtual ::com::sun::star::awt::Size SAL_CALL getSize() throw (::com::sun::star::uno::RuntimeException); 124*cdf0e10cSrcweir virtual void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 125*cdf0e10cSrcweir virtual void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 126*cdf0e10cSrcweir virtual void SAL_CALL grabFocus() throw (::com::sun::star::uno::RuntimeException); 127*cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding() throw (::com::sun::star::uno::RuntimeException); 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getForeground (void) 130*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getBackground (void) 133*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir //===== XAccessibleContext ============================================== 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getAccessibleChildCount (void) throw (::com::sun::star::uno::RuntimeException); 139*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL getAccessibleChild (sal_Int32 nIndex) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException); 140*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL getAccessibleParent (void) throw (::com::sun::star::uno::RuntimeException); 141*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getAccessibleIndexInParent (void) throw (::com::sun::star::uno::RuntimeException); 142*cdf0e10cSrcweir virtual sal_Int16 SAL_CALL getAccessibleRole (void) throw (::com::sun::star::uno::RuntimeException); 143*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getAccessibleDescription (void) throw (::com::sun::star::uno::RuntimeException); 144*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException); 145*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL getAccessibleRelationSet (void) throw (::com::sun::star::uno::RuntimeException); 146*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL getAccessibleStateSet (void) throw (::com::sun::star::uno::RuntimeException); 147*cdf0e10cSrcweir virtual ::com::sun::star::lang::Locale SAL_CALL getLocale (void) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::accessibility::IllegalAccessibleComponentStateException); 148*cdf0e10cSrcweir // virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) {} 149*cdf0e10cSrcweir // virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) {} 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir //===== XComponent ======================================================== 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir using ::cppu::WeakAggComponentImplHelperBase::addEventListener; 154*cdf0e10cSrcweir using ::cppu::WeakAggComponentImplHelperBase::removeEventListener; 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir //===== XAccessibleEventBroadcaster ===================================== 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener>& xListener) throw (com::sun::star::uno::RuntimeException); 159*cdf0e10cSrcweir virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener>& xListener) throw (com::sun::star::uno::RuntimeException); 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir //===== XServiceInfo ==================================================== 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName (void) throw (::com::sun::star::uno::RuntimeException); 164*cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService (const ::rtl::OUString& sServiceName) throw (::com::sun::star::uno::RuntimeException); 165*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames (void) throw (::com::sun::star::uno::RuntimeException); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir //===== XTypeProvider =================================================== 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId (void) throw (::com::sun::star::uno::RuntimeException); 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir //===== XServiceName ==================================================== 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getServiceName (void) throw (::com::sun::star::uno::RuntimeException); 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir //===== XAccessibleSelection ============================================= 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 178*cdf0e10cSrcweir virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 179*cdf0e10cSrcweir virtual void SAL_CALL clearAccessibleSelection() throw (::com::sun::star::uno::RuntimeException ); 180*cdf0e10cSrcweir virtual void SAL_CALL selectAllAccessibleChildren() throw (::com::sun::star::uno::RuntimeException ); 181*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException ); 182*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 183*cdf0e10cSrcweir virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir //===== IAccessibleViewforwarder ======================================== 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir virtual sal_Bool IsValid (void) const; 188*cdf0e10cSrcweir virtual Rectangle GetVisibleArea() const; 189*cdf0e10cSrcweir virtual Point LogicToPixel (const Point& rPoint) const; 190*cdf0e10cSrcweir virtual Size LogicToPixel (const Size& rSize) const; 191*cdf0e10cSrcweir virtual Point PixelToLogic (const Point& rPoint) const; 192*cdf0e10cSrcweir virtual Size PixelToLogic (const Size& rSize) const; 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir protected: 195*cdf0e10cSrcweir //===== internals ======================================================== 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir void checkChildIndex( long nIndexOfChild ) throw (::com::sun::star::lang::IndexOutOfBoundsException ); 198*cdf0e10cSrcweir void checkChildIndexOnSelection( long nIndexOfChild ) throw (::com::sun::star::lang::IndexOutOfBoundsException ); 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir public: 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir /// Sets the name 203*cdf0e10cSrcweir void setName( const ::rtl::OUString& rName ); 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir /// Sets the description 206*cdf0e10cSrcweir void setDescription( const ::rtl::OUString& rDescr ); 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir /** This method is used by the graph control to tell the 209*cdf0e10cSrcweir accessibility object about a new model and view. 210*cdf0e10cSrcweir */ 211*cdf0e10cSrcweir void setModelAndView (SdrModel* pModel, SdrView* pView); 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir private: 214*cdf0e10cSrcweir static ::com::sun::star::uno::Sequence< sal_Int8 > getUniqueId( void ); 215*cdf0e10cSrcweir protected: 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir /** Return the object's current bounding box relative to the desktop, 218*cdf0e10cSrcweir i.e in absolute pixel coordinates. 219*cdf0e10cSrcweir @return 220*cdf0e10cSrcweir The returned rectangle is a bounding box of the object given in 221*cdf0e10cSrcweir absolute screen coordinates. 222*cdf0e10cSrcweir @raise DisposedException 223*cdf0e10cSrcweir When the object is already disposed then a 224*cdf0e10cSrcweir <type>DisposedException</type> is thrown. 225*cdf0e10cSrcweir */ 226*cdf0e10cSrcweir virtual Rectangle GetBoundingBoxOnScreen(void) throw (::com::sun::star::uno::RuntimeException); 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir /// Return the object's current bounding box relative to the parent object. 229*cdf0e10cSrcweir virtual Rectangle GetBoundingBox(void) throw (::com::sun::star::uno::RuntimeException); 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir virtual void SAL_CALL disposing(); 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir private: 234*cdf0e10cSrcweir SdrObject* getSdrObject( sal_Int32 nIndex ) 235*cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException ); 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir void CommitChange (sal_Int16 aEventId, const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue); 238*cdf0e10cSrcweir void FireEvent (const ::com::sun::star::accessibility::AccessibleEventObject& aEvent); 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessible( const SdrObject* pObj ); 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir accessibility::AccessibleShapeTreeInfo maTreeInfo; 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir /// Reference to the parent object. 245*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 246*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> mxParent; 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir /** Description of this object. This is not a constant because it can 249*cdf0e10cSrcweir be set from the outside. 250*cdf0e10cSrcweir */ 251*cdf0e10cSrcweir ::rtl::OUString msDescription; 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir /** Name of this object. 254*cdf0e10cSrcweir */ 255*cdf0e10cSrcweir ::rtl::OUString msName; 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir /// map of accessible shapes 258*cdf0e10cSrcweir struct SdrObjectCompareLess 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir bool operator()(const SdrObject* p1, const SdrObject* p2) const 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir return p1 < p2; 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir }; 265*cdf0e10cSrcweir typedef ::std::map< const SdrObject*, ::accessibility::AccessibleShape*, SdrObjectCompareLess > ShapesMapType; 266*cdf0e10cSrcweir ShapesMapType mxShapes; 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir GraphCtrl* mpControl; 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir SdrModel* mpModel; 271*cdf0e10cSrcweir SdrPage* mpPage; 272*cdf0e10cSrcweir SdrView* mpView; 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir /// client id in the AccessibleEventNotifier queue 275*cdf0e10cSrcweir sal_uInt32 mnClientId; 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir sal_Bool mbDisposed; 278*cdf0e10cSrcweir }; 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir #endif 281*cdf0e10cSrcweir 282