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 #ifndef _UNOFRAME_HXX 24 #define _UNOFRAME_HXX 25 26 #include <com/sun/star/beans/XPropertyState.hpp> 27 #include <com/sun/star/container/XNamed.hpp> 28 #include <com/sun/star/container/XEnumerationAccess.hpp> 29 #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp> 30 #include <com/sun/star/text/XTextFrame.hpp> 31 #include <com/sun/star/drawing/XShape.hpp> 32 #include <com/sun/star/util/XModifyListener.hpp> 33 #include <com/sun/star/frame/XModel.hpp> 34 #include <com/sun/star/document/XEventsSupplier.hpp> 35 36 #include <cppuhelper/implbase1.hxx> 37 #include <cppuhelper/implbase3.hxx> 38 #include <cppuhelper/implbase6.hxx> 39 40 #include <sfx2/objsh.hxx> 41 42 #include <flyenum.hxx> 43 #include <frmfmt.hxx> 44 #include <unoevtlstnr.hxx> 45 #include <unotext.hxx> 46 47 48 class SfxItemPropertSet; 49 class SdrObject; 50 class SwDoc; 51 class SwFmt; 52 class SwFlyFrmFmt; 53 54 class BaseFrameProperties_Impl; 55 class SwXFrame : public cppu::WeakImplHelper6 56 < 57 ::com::sun::star::lang::XServiceInfo, 58 ::com::sun::star::beans::XPropertySet, 59 ::com::sun::star::beans::XPropertyState, 60 ::com::sun::star::drawing::XShape, 61 ::com::sun::star::container::XNamed, 62 ::com::sun::star::lang::XUnoTunnel 63 >, 64 public SwClient 65 { 66 SwEventListenerContainer aLstnrCntnr; 67 const SfxItemPropertySet* m_pPropSet; 68 SwDoc* m_pDoc; 69 70 const FlyCntType eType; 71 72 // Descriptor-interface 73 BaseFrameProperties_Impl* pProps; 74 sal_Bool bIsDescriptor; 75 String sName; 76 77 SwPaM* m_pCopySource; 78 79 protected: 80 com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > mxStyleData; 81 com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > mxStyleFamily; 82 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew); 83 84 virtual ~SwXFrame(); 85 public: 86 SwXFrame(FlyCntType eSet, 87 const SfxItemPropertySet* pPropSet, 88 SwDoc *pDoc ); //Descriptor-If 89 SwXFrame(SwFrmFmt& rFrmFmt, FlyCntType eSet, 90 const SfxItemPropertySet* pPropSet); 91 92 93 static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); 94 95 //XUnoTunnel 96 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); 97 98 TYPEINFO(); 99 100 //XNamed 101 virtual rtl::OUString SAL_CALL getName(void) throw( ::com::sun::star::uno::RuntimeException ); 102 virtual void SAL_CALL setName(const rtl::OUString& Name_) throw( ::com::sun::star::uno::RuntimeException ); 103 104 //XPropertySet 105 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 106 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 107 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 108 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 109 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 110 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 111 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 112 113 //XPropertyState 114 virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 115 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 116 virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 117 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 118 119 //XShape 120 virtual ::com::sun::star::awt::Point SAL_CALL getPosition( ) throw(::com::sun::star::uno::RuntimeException); 121 virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition ) throw(::com::sun::star::uno::RuntimeException); 122 virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw(::com::sun::star::uno::RuntimeException); 123 virtual void SAL_CALL setSize( const ::com::sun::star::awt::Size& aSize ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException); 124 125 //XShapeDescriptor 126 virtual rtl::OUString SAL_CALL getShapeType(void) throw( ::com::sun::star::uno::RuntimeException ); 127 128 //Basisimplementierung 129 //XComponent 130 virtual void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); 131 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); 132 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException); 133 134 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor(void) throw( ::com::sun::star::uno::RuntimeException ); 135 136 //XServiceInfo 137 virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); 138 virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); 139 virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); 140 141 void attachToRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange)throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 142 void attach( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xTextRange ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 143 GetFrmFmt() const144 SwFrmFmt* GetFrmFmt() const 145 { 146 return PTR_CAST ( SwFrmFmt, GetRegisteredIn() ); 147 } GetFlyCntType() const148 FlyCntType GetFlyCntType()const {return eType;} 149 IsDescriptor() const150 sal_Bool IsDescriptor() const {return bIsDescriptor;} 151 void ResetDescriptor(); 152 //copy text from a given source PaM 153 void SetSelection(SwPaM& rCopySource); 154 static SW_DLLPUBLIC SdrObject *GetOrCreateSdrObject( SwFlyFrmFmt *pFmt ); 155 }; 156 157 typedef cppu::WeakImplHelper3 158 < 159 ::com::sun::star::text::XTextFrame, 160 ::com::sun::star::container::XEnumerationAccess, 161 ::com::sun::star::document::XEventsSupplier 162 > 163 SwXTextFrameBaseClass; 164 165 class SwXTextFrame : public SwXTextFrameBaseClass, 166 public SwXText, 167 public SwXFrame 168 { 169 const SfxItemPropertSet* _pPropSet; 170 171 protected: 172 virtual const SwStartNode *GetStartNode() const; 173 174 virtual ::com::sun::star::uno::Reference< 175 ::com::sun::star::text::XTextCursor > 176 CreateCursor() 177 throw (::com::sun::star::uno::RuntimeException); 178 179 virtual ~SwXTextFrame(); 180 public: 181 SwXTextFrame(SwDoc *pDoc); 182 SwXTextFrame(SwFrmFmt& rFmt); 183 184 // FIXME: EVIL HACK: make available for SwXFrame::attachToRange SetDoc(SwDoc * const pDoc)185 void SetDoc(SwDoc *const pDoc) { SwXText::SetDoc(pDoc); }; 186 187 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); 188 virtual void SAL_CALL acquire( ) throw(); 189 virtual void SAL_CALL release( ) throw(); 190 191 //XTypeProvider 192 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); 193 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); 194 195 //XTextFrame 196 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException ); 197 198 //XText 199 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursor(void) throw( ::com::sun::star::uno::RuntimeException ); 200 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursorByRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & aTextPosition) throw( ::com::sun::star::uno::RuntimeException ); 201 202 //XEnumerationAccess - frueher XParagraphEnumerationAccess 203 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); 204 205 //XElementAccess 206 virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); 207 virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); 208 209 //XTextContent 210 virtual void SAL_CALL attach( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xTextRange ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 211 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor( ) throw(::com::sun::star::uno::RuntimeException); 212 213 //XComponent 214 virtual void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); 215 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); 216 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException); 217 218 //XServiceInfo 219 virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); 220 virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); 221 virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); 222 223 // XEventsSupplier 224 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw(::com::sun::star::uno::RuntimeException); 225 226 //XUnoTunnel 227 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); 228 229 //XPropertySet 230 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 231 232 void * SAL_CALL operator new( size_t ) throw(); 233 void SAL_CALL operator delete( void * ) throw(); 234 }; 235 236 typedef cppu::WeakImplHelper2 237 < 238 ::com::sun::star::text::XTextContent, 239 ::com::sun::star::document::XEventsSupplier 240 > 241 SwXTextGraphicObjectBaseClass; 242 class SwXTextGraphicObject : public SwXTextGraphicObjectBaseClass, 243 public SwXFrame 244 { 245 protected: 246 virtual ~SwXTextGraphicObject(); 247 public: 248 SwXTextGraphicObject( SwDoc *pDoc ); 249 SwXTextGraphicObject(SwFrmFmt& rFmt); 250 251 252 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); 253 virtual void SAL_CALL acquire( ) throw(); 254 virtual void SAL_CALL release( ) throw(); 255 256 //XTypeProvider 257 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); 258 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); 259 260 //XTextContent 261 virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 262 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor(void) throw( ::com::sun::star::uno::RuntimeException ); 263 264 //XComponent 265 virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); 266 virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); 267 virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); 268 269 //XServiceInfo 270 virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); 271 virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); 272 virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); 273 274 // XEventsSupplier 275 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw(::com::sun::star::uno::RuntimeException); 276 void * SAL_CALL operator new( size_t ) throw(); 277 void SAL_CALL operator delete( void * ) throw(); 278 }; 279 /*-----------------20.02.98 11:28------------------- 280 281 --------------------------------------------------*/ 282 class SwOLENode; 283 typedef cppu::WeakImplHelper3 284 < 285 ::com::sun::star::text::XTextContent, 286 ::com::sun::star::document::XEmbeddedObjectSupplier2, 287 ::com::sun::star::document::XEventsSupplier 288 >SwXTextEmbeddedObjectBaseClass; 289 290 class SwXTextEmbeddedObject : public SwXTextEmbeddedObjectBaseClass, 291 public SwXFrame 292 { 293 protected: 294 virtual ~SwXTextEmbeddedObject(); 295 296 public: 297 SwXTextEmbeddedObject( SwDoc *pDoc ); 298 SwXTextEmbeddedObject(SwFrmFmt& rFmt); 299 300 301 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); 302 virtual void SAL_CALL acquire( ) throw(); 303 virtual void SAL_CALL release( ) throw(); 304 305 //XTypeProvider 306 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); 307 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); 308 309 //XTextContent 310 virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 311 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor(void) throw( ::com::sun::star::uno::RuntimeException ); 312 313 //XComponent 314 virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); 315 virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); 316 virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); 317 318 //XEmbeddedObjectSupplier2 319 virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL getEmbeddedObject(void) throw( ::com::sun::star::uno::RuntimeException ); 320 virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject > SAL_CALL getExtendedControlOverEmbeddedObject(void) throw( ::com::sun::star::uno::RuntimeException ); 321 virtual ::sal_Int64 SAL_CALL getAspect() throw (::com::sun::star::uno::RuntimeException); 322 virtual void SAL_CALL setAspect( ::sal_Int64 _aspect ) throw (::com::sun::star::uno::RuntimeException); 323 virtual ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > SAL_CALL getReplacementGraphic() throw (::com::sun::star::uno::RuntimeException); 324 325 //XServiceInfo 326 virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); 327 virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); 328 virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); 329 330 // XEventsSupplier 331 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw(::com::sun::star::uno::RuntimeException); 332 void * SAL_CALL operator new( size_t ) throw(); 333 void SAL_CALL operator delete( void * ) throw(); 334 }; 335 336 337 338 class SwXOLEListener : public cppu::WeakImplHelper1 339 < 340 ::com::sun::star::util::XModifyListener 341 >, 342 public SwClient 343 { 344 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xOLEModel; 345 // SfxObjectShell* GetObjShell( const SwFmt& rFmt, 346 // SwOLENode** ppNd = 0 ) const; GetFmt() const347 SwFmt* GetFmt() const { return (SwFmt*)GetRegisteredIn(); } 348 public: 349 SwXOLEListener(SwFmt& rOLEFmt, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xOLE); 350 ~SwXOLEListener(); 351 TYPEINFO(); 352 353 // ::com::sun::star::lang::XEventListener 354 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); 355 356 // ::com::sun::star::util::XModifyListener 357 virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException); 358 359 protected: 360 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew); 361 }; 362 363 364 365 #endif 366 367