Bump version to 21.06.18.1
[LibreOffice.git] / sw / inc / unoframe.hxx
blob592c97378a0ac697368e5ed1f795f9c544e096b6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/document/XEventsSupplier.hpp>
31 #include <cppuhelper/implbase.hxx>
32 #include <svl/listener.hxx>
34 #include "flyenum.hxx"
35 #include "frmfmt.hxx"
36 #include "unotext.hxx"
38 #include <memory>
40 class SdrObject;
41 class SwDoc;
42 class SwFormat;
43 class SfxItemPropertySet;
44 namespace com::sun::star::frame { class XModel; }
46 class BaseFrameProperties_Impl;
47 class SwXFrame : public cppu::WeakImplHelper
49 css::lang::XServiceInfo,
50 css::lang::XUnoTunnel,
51 css::beans::XPropertySet,
52 css::beans::XPropertyState,
53 css::drawing::XShape,
54 css::container::XNamed,
55 css::text::XTextContent
57 public SvtListener
59 private:
60 class Impl;
61 ::sw::UnoImplPtr<Impl> m_pImpl;
62 SwFrameFormat* m_pFrameFormat;
64 const SfxItemPropertySet* m_pPropSet;
65 SwDoc* m_pDoc;
67 const FlyCntType m_eType;
69 // Descriptor-interface
70 std::unique_ptr<BaseFrameProperties_Impl> m_pProps;
71 bool m_bIsDescriptor;
72 OUString m_sName;
74 sal_Int64 m_nDrawAspect;
75 sal_Int64 m_nVisibleAreaWidth;
76 sal_Int64 m_nVisibleAreaHeight;
77 css::uno::Reference<css::text::XText> m_xParentText;
78 void DisposeInternal();
80 protected:
81 css::uno::Reference< css::beans::XPropertySet > mxStyleData;
82 css::uno::Reference< css::container::XNameAccess > mxStyleFamily;
83 virtual void Notify(const SfxHint&) override;
85 virtual ~SwXFrame() override;
87 SwXFrame(FlyCntType eSet,
88 const SfxItemPropertySet* pPropSet,
89 SwDoc *pDoc ); //Descriptor-If
90 SwXFrame(SwFrameFormat& rFrameFormat, FlyCntType eSet,
91 const SfxItemPropertySet* pPropSet);
93 template<class Interface, class Impl>
94 static css::uno::Reference<Interface>
95 CreateXFrame(SwDoc & rDoc, SwFrameFormat *const pFrameFormat);
97 public:
98 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
100 //XUnoTunnel
101 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
104 //XNamed
105 virtual OUString SAL_CALL getName() override;
106 virtual void SAL_CALL setName(const OUString& Name_) override;
108 //XPropertySet
109 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
110 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
111 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
112 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
113 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
114 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
115 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
117 //XPropertyState
118 virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
119 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
120 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
121 virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
123 //XShape
124 virtual css::awt::Point SAL_CALL getPosition( ) override;
125 virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override;
126 virtual css::awt::Size SAL_CALL getSize( ) override;
127 virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override;
129 //XShapeDescriptor
130 virtual OUString SAL_CALL getShapeType() override;
132 //Base implementation
133 //XComponent
134 virtual void SAL_CALL dispose() override;
135 virtual void SAL_CALL addEventListener(const css::uno::Reference<css::lang::XEventListener>& xListener) override;
136 virtual void SAL_CALL removeEventListener(const css::uno::Reference<css::lang::XEventListener>& xListener) override;
138 // XTextContent
139 virtual void SAL_CALL attach(const css::uno::Reference<css::text::XTextRange>& xTextRange) override;
140 virtual css::uno::Reference<css::text::XTextRange> SAL_CALL getAnchor() override;
142 //XServiceInfo
143 virtual OUString SAL_CALL getImplementationName() override;
144 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
145 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
147 /// @throws css::lang::IllegalArgumentException
148 /// @throws css::uno::RuntimeException
149 void attachToRange(css::uno::Reference<css::text::XTextRange> const& xTextRange,
150 SwPaM const* pCopySource = nullptr);
152 const SwFrameFormat* GetFrameFormat() const
153 { return m_pFrameFormat; }
154 SwFrameFormat* GetFrameFormat()
155 { return m_pFrameFormat; }
157 FlyCntType GetFlyCntType()const {return m_eType;}
159 bool IsDescriptor() const {return m_bIsDescriptor;}
160 void ResetDescriptor();
161 //copy text from a given source PaM
162 static SdrObject *GetOrCreateSdrObject(SwFlyFrameFormat &rFormat);
165 typedef cppu::WeakImplHelper
167 css::text::XTextFrame,
168 css::container::XEnumerationAccess,
169 css::document::XEventsSupplier
171 SwXTextFrameBaseClass;
173 class SwXTextFrame final : public SwXTextFrameBaseClass,
174 public SwXText,
175 public SwXFrame
177 friend class SwXFrame; // just for CreateXFrame
179 virtual const SwStartNode *GetStartNode() const override;
181 virtual css::uno::Reference< css::text::XTextCursor >
182 CreateCursor() override;
184 virtual ~SwXTextFrame() override;
186 SwXTextFrame(SwDoc *pDoc);
187 SwXTextFrame(SwFrameFormat& rFormat);
189 public:
190 static SW_DLLPUBLIC css::uno::Reference<css::text::XTextFrame>
191 CreateXTextFrame(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
193 // FIXME: EVIL HACK: make available for SwXFrame::attachToRange
194 using SwXText::SetDoc;
196 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
197 virtual void SAL_CALL acquire( ) throw() override;
198 virtual void SAL_CALL release( ) throw() override;
200 //XTypeProvider
201 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
202 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
204 //XTextFrame
205 virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override;
207 //XText
208 virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override;
209 virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > & aTextPosition) override;
211 //XEnumerationAccess - frueher XParagraphEnumerationAccess
212 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
214 //XElementAccess
215 virtual css::uno::Type SAL_CALL getElementType( ) override;
216 virtual sal_Bool SAL_CALL hasElements( ) override;
218 //XTextContent
219 virtual void SAL_CALL attach( const css::uno::Reference< css::text::XTextRange >& xTextRange ) override;
220 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor( ) override;
222 //XComponent
223 virtual void SAL_CALL dispose( ) override;
224 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
225 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
227 //XServiceInfo
228 virtual OUString SAL_CALL getImplementationName() override;
229 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
230 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
232 // XEventsSupplier
233 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
235 //XUnoTunnel
236 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
238 //XPropertySet
239 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
242 typedef cppu::ImplInheritanceHelper
243 < SwXFrame,
244 css::document::XEventsSupplier
246 SwXTextGraphicObjectBaseClass;
247 class SwXTextGraphicObject final : public SwXTextGraphicObjectBaseClass
249 friend class SwXFrame; // just for CreateXFrame
251 virtual ~SwXTextGraphicObject() override;
253 SwXTextGraphicObject( SwDoc *pDoc );
254 SwXTextGraphicObject(SwFrameFormat& rFormat);
256 public:
258 static css::uno::Reference<css::text::XTextContent>
259 CreateXTextGraphicObject(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
261 //XServiceInfo
262 virtual OUString SAL_CALL getImplementationName() override;
263 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
264 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
266 // XEventsSupplier
267 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
270 typedef cppu::ImplInheritanceHelper
271 < SwXFrame,
272 css::document::XEmbeddedObjectSupplier2,
273 css::document::XEventsSupplier
274 > SwXTextEmbeddedObjectBaseClass;
276 class SwXTextEmbeddedObject final : public SwXTextEmbeddedObjectBaseClass
278 css::uno::Reference<css::util::XModifyListener> m_xOLEListener;
280 friend class SwXFrame; // just for CreateXFrame
282 virtual ~SwXTextEmbeddedObject() override;
284 SwXTextEmbeddedObject( SwDoc *pDoc );
285 SwXTextEmbeddedObject(SwFrameFormat& rFormat);
287 public:
289 static css::uno::Reference<css::text::XTextContent>
290 CreateXTextEmbeddedObject(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
292 //XEmbeddedObjectSupplier2
293 virtual css::uno::Reference< css::lang::XComponent > SAL_CALL getEmbeddedObject() override;
294 virtual css::uno::Reference< css::embed::XEmbeddedObject > SAL_CALL getExtendedControlOverEmbeddedObject() override;
295 virtual ::sal_Int64 SAL_CALL getAspect() override;
296 virtual void SAL_CALL setAspect( ::sal_Int64 _aspect ) override;
297 virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getReplacementGraphic() override;
299 //XServiceInfo
300 virtual OUString SAL_CALL getImplementationName() override;
301 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
302 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
304 // XEventsSupplier
305 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
308 class SwXOLEListener final : public cppu::WeakImplHelper<css::util::XModifyListener>, public SvtListener
310 SwFormat* m_pOLEFormat;
311 css::uno::Reference<css::frame::XModel> m_xOLEModel;
313 public:
314 SwXOLEListener(SwFormat& rOLEFormat, css::uno::Reference< css::frame::XModel > const & xOLE);
315 virtual ~SwXOLEListener() override;
317 // css::lang::XEventListener
318 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
320 // css::util::XModifyListener
321 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
323 virtual void Notify( const SfxHint& ) override;
326 #endif
328 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */