1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
19 #ifndef INCLUDED_SW_INC_UNOFRAME_HXX
20 #define INCLUDED_SW_INC_UNOFRAME_HXX
22 #include <com/sun/star/beans/XPropertyState.hpp>
23 #include <com/sun/star/container/XNamed.hpp>
24 #include <com/sun/star/container/XEnumerationAccess.hpp>
25 #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
26 #include <com/sun/star/text/XTextFrame.hpp>
27 #include <com/sun/star/drawing/XShape.hpp>
28 #include <com/sun/star/util/XModifyListener.hpp>
29 #include <com/sun/star/frame/XModel.hpp>
30 #include <com/sun/star/document/XEventsSupplier.hpp>
32 #include <cppuhelper/implbase.hxx>
34 #include <sfx2/objsh.hxx>
36 #include <flyenum.hxx>
38 #include <unotext.hxx>
43 class SwFlyFrameFormat
;
45 class BaseFrameProperties_Impl
;
46 class SwXFrame
: public cppu::WeakImplHelper
48 css::lang::XServiceInfo
,
49 css::lang::XUnoTunnel
,
50 css::beans::XPropertySet
,
51 css::beans::XPropertyState
,
53 css::container::XNamed
,
54 css::text::XTextContent
60 ::sw::UnoImplPtr
<Impl
> m_pImpl
;
62 const SfxItemPropertySet
* m_pPropSet
;
65 const FlyCntType eType
;
67 // Descriptor-interface
68 BaseFrameProperties_Impl
* pProps
;
75 css::uno::Reference
< css::beans::XPropertySet
> mxStyleData
;
76 css::uno::Reference
< css::container::XNameAccess
> mxStyleFamily
;
77 virtual void Modify( const SfxPoolItem
* pOld
, const SfxPoolItem
*pNew
) override
;
79 virtual ~SwXFrame() override
;
81 SwXFrame(FlyCntType eSet
,
82 const SfxItemPropertySet
* pPropSet
,
83 SwDoc
*pDoc
); //Descriptor-If
84 SwXFrame(SwFrameFormat
& rFrameFormat
, FlyCntType eSet
,
85 const SfxItemPropertySet
* pPropSet
);
87 template<class Interface
, class Impl
>
88 static css::uno::Reference
<Interface
>
89 CreateXFrame(SwDoc
& rDoc
, SwFrameFormat
*const pFrameFormat
);
92 static const css::uno::Sequence
< sal_Int8
> & getUnoTunnelId();
95 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
) override
;
99 virtual OUString SAL_CALL
getName() override
;
100 virtual void SAL_CALL
setName(const OUString
& Name_
) override
;
103 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
104 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
) override
;
105 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
106 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
107 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
108 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
109 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
112 virtual css::beans::PropertyState SAL_CALL
getPropertyState( const OUString
& PropertyName
) override
;
113 virtual css::uno::Sequence
< css::beans::PropertyState
> SAL_CALL
getPropertyStates( const css::uno::Sequence
< OUString
>& aPropertyName
) override
;
114 virtual void SAL_CALL
setPropertyToDefault( const OUString
& PropertyName
) override
;
115 virtual css::uno::Any SAL_CALL
getPropertyDefault( const OUString
& aPropertyName
) override
;
118 virtual css::awt::Point SAL_CALL
getPosition( ) override
;
119 virtual void SAL_CALL
setPosition( const css::awt::Point
& aPosition
) override
;
120 virtual css::awt::Size SAL_CALL
getSize( ) override
;
121 virtual void SAL_CALL
setSize( const css::awt::Size
& aSize
) override
;
124 virtual OUString SAL_CALL
getShapeType() override
;
126 //Base implementation
128 virtual void SAL_CALL
dispose() override
;
129 virtual void SAL_CALL
addEventListener(const css::uno::Reference
<css::lang::XEventListener
>& xListener
) override
;
130 virtual void SAL_CALL
removeEventListener(const css::uno::Reference
<css::lang::XEventListener
>& xListener
) override
;
133 virtual void SAL_CALL
attach(const css::uno::Reference
<css::text::XTextRange
>& xTextRange
) override
;
134 virtual css::uno::Reference
<css::text::XTextRange
> SAL_CALL
getAnchor() override
;
137 virtual OUString SAL_CALL
getImplementationName() override
;
138 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
139 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
141 /// @throws css::lang::IllegalArgumentException
142 /// @throws css::uno::RuntimeException
143 void attachToRange(const css::uno::Reference
< css::text::XTextRange
> & xTextRange
);
145 const SwFrameFormat
* GetFrameFormat() const
147 return dynamic_cast<const SwFrameFormat
*>( GetRegisteredIn() );
149 SwFrameFormat
* GetFrameFormat()
151 return dynamic_cast< SwFrameFormat
*>( GetRegisteredIn() );
153 FlyCntType
GetFlyCntType()const {return eType
;}
155 bool IsDescriptor() const {return bIsDescriptor
;}
156 void ResetDescriptor();
157 //copy text from a given source PaM
158 void SetSelection(SwPaM
& rCopySource
);
159 static SW_DLLPUBLIC SdrObject
*GetOrCreateSdrObject(SwFlyFrameFormat
&rFormat
);
162 typedef cppu::WeakImplHelper
164 css::text::XTextFrame
,
165 css::container::XEnumerationAccess
,
166 css::document::XEventsSupplier
168 SwXTextFrameBaseClass
;
170 class SwXTextFrame
: public SwXTextFrameBaseClass
,
175 friend class SwXFrame
; // just for CreateXFrame
177 virtual const SwStartNode
*GetStartNode() const override
;
179 virtual css::uno::Reference
< css::text::XTextCursor
>
180 CreateCursor() override
;
182 virtual ~SwXTextFrame() override
;
184 SwXTextFrame(SwDoc
*pDoc
);
185 SwXTextFrame(SwFrameFormat
& rFormat
);
188 static SW_DLLPUBLIC
css::uno::Reference
<css::text::XTextFrame
>
189 CreateXTextFrame(SwDoc
& rDoc
, SwFrameFormat
* pFrameFormat
);
191 // FIXME: EVIL HACK: make available for SwXFrame::attachToRange
192 using SwXText::SetDoc
;
194 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
195 virtual void SAL_CALL
acquire( ) throw() override
;
196 virtual void SAL_CALL
release( ) throw() override
;
199 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) override
;
200 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId( ) override
;
203 virtual css::uno::Reference
< css::text::XText
> SAL_CALL
getText() override
;
206 virtual css::uno::Reference
< css::text::XTextCursor
> SAL_CALL
createTextCursor() override
;
207 virtual css::uno::Reference
< css::text::XTextCursor
> SAL_CALL
createTextCursorByRange(const css::uno::Reference
< css::text::XTextRange
> & aTextPosition
) override
;
209 //XEnumerationAccess - frueher XParagraphEnumerationAccess
210 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
createEnumeration() override
;
213 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
214 virtual sal_Bool SAL_CALL
hasElements( ) override
;
217 virtual void SAL_CALL
attach( const css::uno::Reference
< css::text::XTextRange
>& xTextRange
) override
;
218 virtual css::uno::Reference
< css::text::XTextRange
> SAL_CALL
getAnchor( ) override
;
221 virtual void SAL_CALL
dispose( ) override
;
222 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
223 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
226 virtual OUString SAL_CALL
getImplementationName() override
;
227 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
228 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
231 virtual css::uno::Reference
< css::container::XNameReplace
> SAL_CALL
getEvents( ) override
;
234 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
) override
;
237 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
239 void * SAL_CALL
operator new( size_t ) throw();
240 void SAL_CALL
operator delete( void * ) throw();
243 typedef cppu::ImplInheritanceHelper
245 css::document::XEventsSupplier
247 SwXTextGraphicObjectBaseClass
;
248 class SwXTextGraphicObject
: public SwXTextGraphicObjectBaseClass
251 friend class SwXFrame
; // just for CreateXFrame
253 virtual ~SwXTextGraphicObject() override
;
255 SwXTextGraphicObject( SwDoc
*pDoc
);
256 SwXTextGraphicObject(SwFrameFormat
& rFormat
);
260 static css::uno::Reference
<css::text::XTextContent
>
261 CreateXTextGraphicObject(SwDoc
& rDoc
, SwFrameFormat
* pFrameFormat
);
264 virtual OUString SAL_CALL
getImplementationName() override
;
265 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
266 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
269 virtual css::uno::Reference
< css::container::XNameReplace
> SAL_CALL
getEvents( ) override
;
271 void * SAL_CALL
operator new( size_t ) throw();
272 void SAL_CALL
operator delete( void * ) throw();
276 typedef cppu::ImplInheritanceHelper
278 css::document::XEmbeddedObjectSupplier2
,
279 css::document::XEventsSupplier
280 > SwXTextEmbeddedObjectBaseClass
;
282 class SwXTextEmbeddedObject
: public SwXTextEmbeddedObjectBaseClass
284 css::uno::Reference
<css::util::XModifyListener
> m_xOLEListener
;
286 friend class SwXFrame
; // just for CreateXFrame
288 virtual ~SwXTextEmbeddedObject() override
;
290 SwXTextEmbeddedObject( SwDoc
*pDoc
);
291 SwXTextEmbeddedObject(SwFrameFormat
& rFormat
);
295 static css::uno::Reference
<css::text::XTextContent
>
296 CreateXTextEmbeddedObject(SwDoc
& rDoc
, SwFrameFormat
* pFrameFormat
);
298 //XEmbeddedObjectSupplier2
299 virtual css::uno::Reference
< css::lang::XComponent
> SAL_CALL
getEmbeddedObject() override
;
300 virtual css::uno::Reference
< css::embed::XEmbeddedObject
> SAL_CALL
getExtendedControlOverEmbeddedObject() override
;
301 virtual ::sal_Int64 SAL_CALL
getAspect() override
;
302 virtual void SAL_CALL
setAspect( ::sal_Int64 _aspect
) override
;
303 virtual css::uno::Reference
< css::graphic::XGraphic
> SAL_CALL
getReplacementGraphic() override
;
306 virtual OUString SAL_CALL
getImplementationName() override
;
307 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
308 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
311 virtual css::uno::Reference
< css::container::XNameReplace
> SAL_CALL
getEvents( ) override
;
312 void * SAL_CALL
operator new( size_t ) throw();
313 void SAL_CALL
operator delete( void * ) throw();
316 class SwXOLEListener
: public cppu::WeakImplHelper
<css::util::XModifyListener
>,
319 css::uno::Reference
< css::frame::XModel
> xOLEModel
;
322 SwXOLEListener(SwFormat
& rOLEFormat
, css::uno::Reference
< css::frame::XModel
> const & xOLE
);
323 virtual ~SwXOLEListener() override
;
325 // css::lang::XEventListener
326 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
328 // css::util::XModifyListener
329 virtual void SAL_CALL
modified( const css::lang::EventObject
& aEvent
) override
;
332 virtual void Modify( const SfxPoolItem
* pOld
, const SfxPoolItem
*pNew
) override
;
337 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */