LibreOffice Module sw (master) 1
unoframe.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_SW_INC_UNOFRAME_HXX
20#define INCLUDED_SW_INC_UNOFRAME_HXX
21
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>
30
32#include <sal/types.h>
33#include <svl/listener.hxx>
34
35#include "flyenum.hxx"
36#include "frmfmt.hxx"
37#include "unotext.hxx"
38
39#include <memory>
40
41class SdrObject;
42class SwDoc;
43class SwFormat;
45namespace com::sun::star::frame { class XModel; }
46
48class SAL_DLLPUBLIC_RTTI SAL_LOPLUGIN_ANNOTATE("crosscast") SwXFrame : public cppu::WeakImplHelper
49<
50 css::lang::XServiceInfo,
51 css::beans::XPropertySet,
52 css::beans::XPropertyState,
53 css::drawing::XShape,
54 css::container::XNamed,
55 css::text::XTextContent
56>,
57 public SvtListener
58{
59private:
60 class Impl;
62 SwFrameFormat* m_pFrameFormat;
63
64 const SfxItemPropertySet* m_pPropSet;
65 SwDoc* m_pDoc;
66
67 const FlyCntType m_eType;
68
69 // Descriptor-interface
70 std::unique_ptr<BaseFrameProperties_Impl> m_pProps;
71 bool m_bIsDescriptor;
72 OUString m_sName;
73
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;
80
81 void DisposeInternal();
82
83protected:
84 virtual void Notify(const SfxHint&) override;
85
86 virtual ~SwXFrame() override;
87
88 SwXFrame(FlyCntType eSet,
89 const SfxItemPropertySet* pPropSet,
90 SwDoc *pDoc ); //Descriptor-If
91 SwXFrame(SwFrameFormat& rFrameFormat, FlyCntType eSet,
92 const SfxItemPropertySet* pPropSet);
93
94 template<class Impl>
96 CreateXFrame(SwDoc & rDoc, SwFrameFormat *const pFrameFormat);
97
98public:
99
100 //XNamed
101 virtual OUString SAL_CALL getName() override;
102 virtual void SAL_CALL setName(const OUString& Name_) override;
103
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;
112
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;
118
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;
124
125 //XShapeDescriptor
126 virtual OUString SAL_CALL getShapeType() override;
127
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;
133
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;
137
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;
142
145 void attachToRange(css::uno::Reference<css::text::XTextRange> const& xTextRange,
146 SwPaM const* pCopySource = nullptr);
147
148 const SwFrameFormat* GetFrameFormat() const
149 { return m_pFrameFormat; }
150 SwFrameFormat* GetFrameFormat()
151 { return m_pFrameFormat; }
152
153 FlyCntType GetFlyCntType()const {return m_eType;}
154
155 bool IsDescriptor() const {return m_bIsDescriptor;}
156 void ResetDescriptor();
157 //copy text from a given source PaM
158 static SdrObject *GetOrCreateSdrObject(SwFlyFrameFormat &rFormat);
159};
160
161typedef cppu::ImplInheritanceHelper
162<
163 SwXFrame,
164 css::text::XTextFrame,
165 css::container::XEnumerationAccess,
166 css::document::XEventsSupplier
167>
169
170class SAL_DLLPUBLIC_RTTI SwXTextFrame final : public SwXTextFrameBaseClass,
171 public SwXText
172{
173 friend class SwXFrame; // just for CreateXFrame
174
175 virtual const SwStartNode *GetStartNode() const override;
176
177 virtual css::uno::Reference< css::text::XTextCursor >
178 CreateCursor() override;
179
180 virtual ~SwXTextFrame() override;
181
182 SwXTextFrame(SwDoc *pDoc);
183 SwXTextFrame(SwFrameFormat& rFormat);
184
185public:
187 CreateXTextFrame(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
188
189 // FIXME: EVIL HACK: make available for SwXFrame::attachToRange
190 using SwXText::SetDoc;
191
192 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
193 virtual void SAL_CALL acquire( ) noexcept override;
194 virtual SW_DLLPUBLIC void SAL_CALL release( ) noexcept override;
195
196 //XTypeProvider
197 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
198 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
199
200 //XTextFrame
201 virtual SW_DLLPUBLIC css::uno::Reference< css::text::XText > SAL_CALL getText() override;
202
203 //XText
204 virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override;
205 virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > & aTextPosition) override;
206
207 //XEnumerationAccess - frueher XParagraphEnumerationAccess
208 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
209
210 //XElementAccess
211 virtual css::uno::Type SAL_CALL getElementType( ) override;
212 virtual sal_Bool SAL_CALL hasElements( ) override;
213
214 //XTextContent
215 virtual void SAL_CALL attach( const css::uno::Reference< css::text::XTextRange >& xTextRange ) override;
216 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor( ) override;
217
218 //XComponent
219 virtual void SAL_CALL dispose( ) override;
220 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
221 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
222
223 //XServiceInfo
224 virtual OUString SAL_CALL getImplementationName() override;
225 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
226 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
227
228 // XEventsSupplier
229 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
230
231 //XPropertySet
232 virtual SW_DLLPUBLIC css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
233 using SwXFrame::setPropertyValue;
234};
235
236typedef cppu::ImplInheritanceHelper
237< SwXFrame,
238 css::document::XEventsSupplier
239>
242{
243 friend class SwXFrame; // just for CreateXFrame
244
245 virtual ~SwXTextGraphicObject() override;
246
249
250public:
251
253 CreateXTextGraphicObject(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
254
255 //XServiceInfo
256 virtual OUString SAL_CALL getImplementationName() override;
257 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
258 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
259
260 // XEventsSupplier
261 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
262};
263
264typedef cppu::ImplInheritanceHelper
265< SwXFrame,
266 css::document::XEmbeddedObjectSupplier2,
267 css::document::XEventsSupplier
269
271{
272 css::uno::Reference<css::util::XModifyListener> m_xOLEListener;
273
274 friend class SwXFrame; // just for CreateXFrame
275
276 virtual ~SwXTextEmbeddedObject() override;
277
280
281public:
282
284 CreateXTextEmbeddedObject(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
285
286 //XEmbeddedObjectSupplier2
287 virtual css::uno::Reference< css::lang::XComponent > SAL_CALL getEmbeddedObject() override;
288 virtual css::uno::Reference< css::embed::XEmbeddedObject > SAL_CALL getExtendedControlOverEmbeddedObject() override;
289 virtual ::sal_Int64 SAL_CALL getAspect() override;
290 virtual void SAL_CALL setAspect( ::sal_Int64 _aspect ) override;
291 virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getReplacementGraphic() override;
292
293 //XServiceInfo
294 virtual OUString SAL_CALL getImplementationName() override;
295 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
296 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
297
298 // XEventsSupplier
299 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
300};
301
302class SwXOLEListener final : public cppu::WeakImplHelper<css::util::XModifyListener>, public SvtListener
303{
305 css::uno::Reference<css::frame::XModel> m_xOLEModel;
306
307public:
308 SwXOLEListener(SwFormat& rOLEFormat, css::uno::Reference< css::frame::XModel > xOLE);
309 virtual ~SwXOLEListener() override;
310
311// css::lang::XEventListener
312 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
313
314// css::util::XModifyListener
315 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
316
317 virtual void Notify( const SfxHint& ) override;
318};
319
320#endif
321
322/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
virtual void Notify(const SfxHint &rHint)
Definition: doc.hxx:195
Base class for various Writer styles.
Definition: format.hxx:47
Style of a layout element.
Definition: frmfmt.hxx:62
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
Starts a section of nodes in the document model.
Definition: node.hxx:348
SwFormat * m_pOLEFormat
Definition: unoframe.hxx:304
css::uno::Reference< css::frame::XModel > m_xOLEModel
Definition: unoframe.hxx:305
css::uno::Reference< css::util::XModifyListener > m_xOLEListener
Definition: unoframe.hxx:272
void SetDoc(SwDoc *const pDoc)
Definition: unotext.cxx:154
static SwNode * GetStartNode(SwOutlineNodes const *pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type *nOutl)
Definition: docglbl.cxx:89
OUString m_sName
const EnumerationType m_eType
class SAL_LOPLUGIN_ANNOTATE("crosscast") SwFlowFrame
Base class that provides the general functionalities for frames that are allowed at page breaks (flow...
Definition: flowfrm.hxx:59
FlyCntType
Definition: flyenum.hxx:24
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldRect=nullptr)
Notify the background based on the difference between old and new rectangle.
Definition: frmtool.cxx:3249
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
Type
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
VBAHELPER_DLLPUBLIC bool setPropertyValue(css::uno::Sequence< css::beans::PropertyValue > &aProp, const OUString &aName, const css::uno::Any &aValue)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
std::unique_ptr< T, UnoImplPtrDeleter< T > > UnoImplPtr
Smart pointer class ensuring that the pointed object is deleted with a locked SolarMutex.
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
unsigned char sal_Bool
signed char sal_Int8
cppu::ImplInheritanceHelper< SwXFrame, css::document::XEmbeddedObjectSupplier2, css::document::XEventsSupplier > SwXTextEmbeddedObjectBaseClass
Definition: unoframe.hxx:268
cppu::ImplInheritanceHelper< SwXFrame, css::document::XEventsSupplier > SwXTextGraphicObjectBaseClass
Definition: unoframe.hxx:240
class SAL_DLLPUBLIC_RTTI SAL_LOPLUGIN_ANNOTATE("crosscast") SwXFrame typedef cppu::ImplInheritanceHelper< SwXFrame, css::text::XTextFrame, css::container::XEnumerationAccess, css::document::XEventsSupplier > SwXTextFrameBaseClass
Definition: unoframe.hxx:48