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