Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / inc / unoframe.hxx
blob9bd1c03b8b7f944a4ccf37a1642ae855ecbfae26
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 <sal/types.h>
33 #include <svl/listener.hxx>
35 #include "flyenum.hxx"
36 #include "frmfmt.hxx"
37 #include "unotext.hxx"
39 #include <memory>
41 class SdrObject;
42 class SwDoc;
43 class SwFormat;
44 class SfxItemPropertySet;
45 namespace com::sun::star::frame { class XModel; }
47 class BaseFrameProperties_Impl;
48 class SAL_DLLPUBLIC_RTTI SAL_LOPLUGIN_ANNOTATE("crosscast") SwXFrame : public cppu::WeakImplHelper
50 css::lang::XServiceInfo,
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 css::uno::Reference< css::beans::XPropertySet > mxStyleData;
79 css::uno::Reference< css::container::XNameAccess > mxStyleFamily;
81 void DisposeInternal();
83 protected:
84 virtual void Notify(const SfxHint&) override;
86 virtual ~SwXFrame() override;
88 SwXFrame(FlyCntType eSet,
89 const SfxItemPropertySet* pPropSet,
90 SwDoc *pDoc ); //Descriptor-If
91 SwXFrame(SwFrameFormat& rFrameFormat, FlyCntType eSet,
92 const SfxItemPropertySet* pPropSet);
94 template<class Impl>
95 static rtl::Reference<Impl>
96 CreateXFrame(SwDoc & rDoc, SwFrameFormat *const pFrameFormat);
98 public:
100 //XNamed
101 virtual OUString SAL_CALL getName() override;
102 virtual void SAL_CALL setName(const OUString& Name_) override;
104 //XPropertySet
105 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
106 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
107 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
108 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
109 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
110 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
111 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
113 //XPropertyState
114 virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
115 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
116 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
117 virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
119 //XShape
120 virtual css::awt::Point SAL_CALL getPosition( ) override;
121 virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override;
122 virtual css::awt::Size SAL_CALL getSize( ) override;
123 virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override;
125 //XShapeDescriptor
126 virtual OUString SAL_CALL getShapeType() override;
128 //Base implementation
129 //XComponent
130 virtual void SAL_CALL dispose() override;
131 virtual void SAL_CALL addEventListener(const css::uno::Reference<css::lang::XEventListener>& xListener) override;
132 virtual void SAL_CALL removeEventListener(const css::uno::Reference<css::lang::XEventListener>& xListener) override;
134 // XTextContent
135 virtual void SAL_CALL attach(const css::uno::Reference<css::text::XTextRange>& xTextRange) override;
136 virtual css::uno::Reference<css::text::XTextRange> SAL_CALL getAnchor() override;
138 //XServiceInfo
139 virtual OUString SAL_CALL getImplementationName() override;
140 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
141 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
143 /// @throws css::lang::IllegalArgumentException
144 /// @throws css::uno::RuntimeException
145 void attachToRange(css::uno::Reference<css::text::XTextRange> const& xTextRange,
146 SwPaM const* pCopySource = nullptr);
148 const SwFrameFormat* GetFrameFormat() const
149 { return m_pFrameFormat; }
150 SwFrameFormat* GetFrameFormat()
151 { return m_pFrameFormat; }
153 FlyCntType GetFlyCntType()const {return m_eType;}
155 bool IsDescriptor() const {return m_bIsDescriptor;}
156 void ResetDescriptor();
157 //copy text from a given source PaM
158 static SdrObject *GetOrCreateSdrObject(SwFlyFrameFormat &rFormat);
161 typedef cppu::ImplInheritanceHelper
163 SwXFrame,
164 css::text::XTextFrame,
165 css::container::XEnumerationAccess,
166 css::document::XEventsSupplier
168 SwXTextFrameBaseClass;
170 class SAL_DLLPUBLIC_RTTI SwXTextFrame final : public SwXTextFrameBaseClass,
171 public SwXText
173 friend class SwXFrame; // just for CreateXFrame
175 virtual const SwStartNode *GetStartNode() const override;
177 virtual ~SwXTextFrame() override;
179 SwXTextFrame(SwDoc *pDoc);
180 SwXTextFrame(SwFrameFormat& rFormat);
182 public:
183 static SW_DLLPUBLIC rtl::Reference<SwXTextFrame>
184 CreateXTextFrame(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
186 // FIXME: EVIL HACK: make available for SwXFrame::attachToRange
187 using SwXText::SetDoc;
189 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
190 virtual void SAL_CALL acquire( ) noexcept override;
191 virtual SW_DLLPUBLIC void SAL_CALL release( ) noexcept override;
193 //XTypeProvider
194 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
195 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
197 //XTextFrame
198 virtual SW_DLLPUBLIC css::uno::Reference< css::text::XText > SAL_CALL getText() override;
200 //XText
201 virtual rtl::Reference< SwXTextCursor > createXTextCursor() override;
202 virtual rtl::Reference< SwXTextCursor > createXTextCursorByRange(
203 const ::css::uno::Reference< ::css::text::XTextRange >& aTextPosition ) override;
205 //XEnumerationAccess - frueher XParagraphEnumerationAccess
206 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
208 //XElementAccess
209 virtual css::uno::Type SAL_CALL getElementType( ) override;
210 virtual sal_Bool SAL_CALL hasElements( ) override;
212 //XTextContent
213 virtual void SAL_CALL attach( const css::uno::Reference< css::text::XTextRange >& xTextRange ) override;
214 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor( ) override;
216 //XComponent
217 virtual void SAL_CALL dispose( ) override;
218 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
219 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
221 //XServiceInfo
222 virtual OUString SAL_CALL getImplementationName() override;
223 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
224 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
226 // XEventsSupplier
227 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
229 //XPropertySet
230 virtual SW_DLLPUBLIC css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
231 using SwXFrame::setPropertyValue;
234 typedef cppu::ImplInheritanceHelper
235 < SwXFrame,
236 css::document::XEventsSupplier
238 SwXTextGraphicObjectBaseClass;
239 class SwXTextGraphicObject final : public SwXTextGraphicObjectBaseClass
241 friend class SwXFrame; // just for CreateXFrame
243 virtual ~SwXTextGraphicObject() override;
245 SwXTextGraphicObject( SwDoc *pDoc );
246 SwXTextGraphicObject(SwFrameFormat& rFormat);
248 public:
250 static rtl::Reference<SwXTextGraphicObject>
251 CreateXTextGraphicObject(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
253 //XServiceInfo
254 virtual OUString SAL_CALL getImplementationName() override;
255 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
256 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
258 // XEventsSupplier
259 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
262 typedef cppu::ImplInheritanceHelper
263 < SwXFrame,
264 css::document::XEmbeddedObjectSupplier2,
265 css::document::XEventsSupplier
266 > SwXTextEmbeddedObjectBaseClass;
268 class SwXTextEmbeddedObject final : public SwXTextEmbeddedObjectBaseClass
270 css::uno::Reference<css::util::XModifyListener> m_xOLEListener;
272 friend class SwXFrame; // just for CreateXFrame
274 virtual ~SwXTextEmbeddedObject() override;
276 SwXTextEmbeddedObject( SwDoc *pDoc );
277 SwXTextEmbeddedObject(SwFrameFormat& rFormat);
279 public:
281 static rtl::Reference<SwXTextEmbeddedObject>
282 CreateXTextEmbeddedObject(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
284 //XEmbeddedObjectSupplier2
285 virtual css::uno::Reference< css::lang::XComponent > SAL_CALL getEmbeddedObject() override;
286 virtual css::uno::Reference< css::embed::XEmbeddedObject > SAL_CALL getExtendedControlOverEmbeddedObject() override;
287 virtual ::sal_Int64 SAL_CALL getAspect() override;
288 virtual void SAL_CALL setAspect( ::sal_Int64 _aspect ) override;
289 virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getReplacementGraphic() override;
291 //XServiceInfo
292 virtual OUString SAL_CALL getImplementationName() override;
293 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
294 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
296 // XEventsSupplier
297 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
300 class SwXOLEListener final : public cppu::WeakImplHelper<css::util::XModifyListener>, public SvtListener
302 SwFormat* m_pOLEFormat;
303 css::uno::Reference<css::frame::XModel> m_xOLEModel;
305 public:
306 SwXOLEListener(SwFormat& rOLEFormat, css::uno::Reference< css::frame::XModel > xOLE);
307 virtual ~SwXOLEListener() override;
309 // css::lang::XEventListener
310 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
312 // css::util::XModifyListener
313 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
315 virtual void Notify( const SfxHint& ) override;
318 #endif
320 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */