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 #ifndef _SVX_ACCESSIBLE_IMAGE_BULLET_HXX 25 #define _SVX_ACCESSIBLE_IMAGE_BULLET_HXX 26 27 #include <tools/gen.hxx> 28 #include <cppuhelper/weakref.hxx> 29 #include <cppuhelper/implbase5.hxx> 30 31 #ifndef _CPPUHELPER_INTERFACECONTAINER_H_ 32 #include <cppuhelper/interfacecontainer.hxx> 33 #endif 34 #include <com/sun/star/uno/Reference.hxx> 35 #include <com/sun/star/lang/XServiceInfo.hpp> 36 #include <com/sun/star/accessibility/XAccessible.hpp> 37 #include <com/sun/star/accessibility/XAccessibleContext.hpp> 38 #include <com/sun/star/accessibility/XAccessibleComponent.hpp> 39 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> 40 #include "editeng/AccessibleParaManager.hxx" 41 #include <editeng/unoedsrc.hxx> 42 43 namespace accessibility 44 { 45 typedef ::cppu::WeakImplHelper5< ::com::sun::star::accessibility::XAccessible, 46 ::com::sun::star::accessibility::XAccessibleContext, 47 ::com::sun::star::accessibility::XAccessibleComponent, 48 ::com::sun::star::accessibility::XAccessibleEventBroadcaster, 49 ::com::sun::star::lang::XServiceInfo > AccessibleImageBulletInterfaceBase; 50 51 /** This class implements the image bullets for the EditEngine/Outliner UAA 52 */ 53 class AccessibleImageBullet : public AccessibleImageBulletInterfaceBase 54 { 55 56 public: 57 /// Create accessible object for given parent 58 AccessibleImageBullet ( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& rParent ); 59 60 virtual ~AccessibleImageBullet (); 61 62 // XInterface 63 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface (const ::com::sun::star::uno::Type & rType) throw (::com::sun::star::uno::RuntimeException); 64 65 // XAccessible 66 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException); 67 68 // XAccessibleContext 69 virtual sal_Int32 SAL_CALL getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException); 70 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 71 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent() throw (::com::sun::star::uno::RuntimeException); 72 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() throw (::com::sun::star::uno::RuntimeException); 73 virtual sal_Int16 SAL_CALL getAccessibleRole() throw (::com::sun::star::uno::RuntimeException); 74 /// Maximal length of text returned by getAccessibleDescription() 75 enum { MaxDescriptionLen = 40 }; 76 virtual ::rtl::OUString SAL_CALL getAccessibleDescription() throw (::com::sun::star::uno::RuntimeException); 77 virtual ::rtl::OUString SAL_CALL getAccessibleName() throw (::com::sun::star::uno::RuntimeException); 78 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() throw (::com::sun::star::uno::RuntimeException); 79 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() throw (::com::sun::star::uno::RuntimeException); 80 virtual ::com::sun::star::lang::Locale SAL_CALL getLocale() throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException); 81 82 // XAccessibleEventBroadcaster 83 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 84 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 85 86 // XAccessibleComponent 87 virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); 88 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); 89 virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( ) throw (::com::sun::star::uno::RuntimeException); 90 virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException); 91 virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException); 92 virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException); 93 virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException); 94 virtual sal_Int32 SAL_CALL getForeground( ) throw (::com::sun::star::uno::RuntimeException); 95 virtual sal_Int32 SAL_CALL getBackground( ) throw (::com::sun::star::uno::RuntimeException); 96 97 // XServiceInfo 98 virtual ::rtl::OUString SAL_CALL getImplementationName (void) throw (::com::sun::star::uno::RuntimeException); 99 virtual sal_Bool SAL_CALL supportsService (const ::rtl::OUString& sServiceName) throw (::com::sun::star::uno::RuntimeException); 100 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames (void) throw (::com::sun::star::uno::RuntimeException); 101 102 // XServiceName 103 virtual ::rtl::OUString SAL_CALL getServiceName (void) throw (::com::sun::star::uno::RuntimeException); 104 105 /** Set the current index in the accessibility parent 106 107 @attention This method does not lock the SolarMutex, 108 leaving that to the calling code. This is because only 109 there potential deadlock situations can be resolved. Thus, 110 make sure SolarMutex is locked when calling this. 111 */ 112 void SetIndexInParent( sal_Int32 nIndex ); 113 114 /** Get the current index in the accessibility parent 115 116 @attention This method does not lock the SolarMutex, 117 leaving that to the calling code. This is because only 118 there potential deadlock situations can be resolved. Thus, 119 make sure SolarMutex is locked when calling this. 120 */ 121 sal_Int32 GetIndexInParent() const; 122 123 /** Set the edit engine offset 124 125 @attention This method does not lock the SolarMutex, 126 leaving that to the calling code. This is because only 127 there potential deadlock situations can be resolved. Thus, 128 make sure SolarMutex is locked when calling this. 129 */ 130 void SetEEOffset( const Point& rOffset ); 131 132 /** Set the EditEngine offset 133 134 @attention This method does not lock the SolarMutex, 135 leaving that to the calling code. This is because only 136 there potential deadlock situations can be resolved. Thus, 137 make sure SolarMutex is locked when calling this. 138 */ 139 void SetEditSource( SvxEditSource* pEditSource ); 140 141 /** Dispose this object 142 143 Notifies and deregisters the listeners, drops all references. 144 */ 145 void Dispose(); 146 147 /** Set the current paragraph number 148 149 @attention This method does not lock the SolarMutex, 150 leaving that to the calling code. This is because only 151 there potential deadlock situations can be resolved. Thus, 152 make sure SolarMutex is locked when calling this. 153 */ 154 void SetParagraphIndex( sal_Int32 nIndex ); 155 156 /** Query the current paragraph number (0 - nParas-1) 157 158 @attention This method does not lock the SolarMutex, 159 leaving that to the calling code. This is because only 160 there potential deadlock situations can be resolved. Thus, 161 make sure SolarMutex is locked when calling this. 162 */ 163 sal_Int32 GetParagraphIndex() const SAL_THROW((::com::sun::star::uno::RuntimeException)); 164 165 /// Calls all Listener objects to tell them the change. Don't hold locks when calling this! 166 virtual void FireEvent(const sal_Int16 nEventId, const ::com::sun::star::uno::Any& rNewValue = ::com::sun::star::uno::Any(), const ::com::sun::star::uno::Any& rOldValue = ::com::sun::star::uno::Any() ) const; 167 168 private: 169 170 // declared, but not defined 171 AccessibleImageBullet( const AccessibleImageBullet& ); 172 AccessibleImageBullet& operator= ( const AccessibleImageBullet& ); 173 174 // syntactic sugar for FireEvent 175 void GotPropertyEvent( const ::com::sun::star::uno::Any& rNewValue, const sal_Int16 nEventId ) const; 176 void LostPropertyEvent( const ::com::sun::star::uno::Any& rOldValue, const sal_Int16 nEventId ) const; 177 178 // maintain state set and send STATE_CHANGE events 179 void SetState( const sal_Int16 nStateId ); 180 void UnSetState( const sal_Int16 nStateId ); 181 182 SvxEditSource& GetEditSource() const SAL_THROW((::com::sun::star::uno::RuntimeException)); 183 184 int getNotifierClientId() const; 185 186 /** Query the SvxTextForwarder for EditEngine access. 187 188 @attention This method does not lock the SolarMutex, 189 leaving that to the calling code. This is because only 190 there potential deadlock situations can be resolved. Thus, 191 make sure SolarMutex is locked when calling this. 192 */ 193 SvxTextForwarder& GetTextForwarder() const SAL_THROW((::com::sun::star::uno::RuntimeException)); 194 195 /** Query the SvxViewForwarder for EditEngine access. 196 197 @attention This method does not lock the SolarMutex, 198 leaving that to the calling code. This is because only 199 there potential deadlock situations can be resolved. Thus, 200 make sure SolarMutex is locked when calling this. 201 */ 202 SvxViewForwarder& GetViewForwarder() const SAL_THROW((::com::sun::star::uno::RuntimeException)); 203 204 const Point& GetEEOffset() const; 205 206 // the paragraph index in the edit engine (guarded by solar mutex) 207 sal_Int32 mnParagraphIndex; 208 209 // our current index in the parent (guarded by solar mutex) 210 sal_Int32 mnIndexInParent; 211 212 // the current edit source (guarded by solar mutex) 213 SvxEditSource* mpEditSource; 214 215 // the offset of the underlying EditEngine from the shape/cell (guarded by solar mutex) 216 Point maEEOffset; 217 218 // the current state set (updated from SetState/UnSetState and guarded by solar mutex) 219 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > mxStateSet; 220 221 mutable osl::Mutex maMutex; 222 223 /// The shape we're the accessible for (unguarded) 224 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > mxParent; 225 226 /// Our listeners (guarded by maMutex) 227 int mnNotifierClientId; 228 }; 229 230 } // end of namespace accessibility 231 232 #endif 233 234