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 SwXFrame : public cppu::WeakImplHelper
49<
50 css::lang::XServiceInfo,
51 css::lang::XUnoTunnel,
52 css::beans::XPropertySet,
53 css::beans::XPropertyState,
54 css::drawing::XShape,
55 css::container::XNamed,
56 css::text::XTextContent
57>,
58 public SvtListener
59{
60private:
61 class Impl;
64
67
69
70 // Descriptor-interface
71 std::unique_ptr<BaseFrameProperties_Impl> m_pProps;
73 OUString m_sName;
74
75 sal_Int64 m_nDrawAspect;
78 css::uno::Reference<css::text::XText> m_xParentText;
79 void DisposeInternal();
80
81protected:
82 css::uno::Reference< css::beans::XPropertySet > mxStyleData;
83 css::uno::Reference< css::container::XNameAccess > mxStyleFamily;
84 virtual void Notify(const SfxHint&) override;
85
86 virtual ~SwXFrame() override;
87
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 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
100
101 //XUnoTunnel
102 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
103
104
105 //XNamed
106 virtual OUString SAL_CALL getName() override;
107 virtual void SAL_CALL setName(const OUString& Name_) override;
108
109 //XPropertySet
110 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
111 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
112 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
113 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
114 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
115 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
116 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
117
118 //XPropertyState
119 virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
120 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
121 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
122 virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
123
124 //XShape
125 virtual css::awt::Point SAL_CALL getPosition( ) override;
126 virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override;
127 virtual css::awt::Size SAL_CALL getSize( ) override;
128 virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override;
129
130 //XShapeDescriptor
131 virtual OUString SAL_CALL getShapeType() override;
132
133 //Base implementation
134 //XComponent
135 virtual void SAL_CALL dispose() override;
136 virtual void SAL_CALL addEventListener(const css::uno::Reference<css::lang::XEventListener>& xListener) override;
137 virtual void SAL_CALL removeEventListener(const css::uno::Reference<css::lang::XEventListener>& xListener) override;
138
139 // XTextContent
140 virtual void SAL_CALL attach(const css::uno::Reference<css::text::XTextRange>& xTextRange) override;
141 virtual css::uno::Reference<css::text::XTextRange> SAL_CALL getAnchor() override;
142
143 //XServiceInfo
144 virtual OUString SAL_CALL getImplementationName() override;
145 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
146 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
147
150 void attachToRange(css::uno::Reference<css::text::XTextRange> const& xTextRange,
151 SwPaM const* pCopySource = nullptr);
152
154 { return m_pFrameFormat; }
156 { return m_pFrameFormat; }
157
159
160 bool IsDescriptor() const {return m_bIsDescriptor;}
161 void ResetDescriptor();
162 //copy text from a given source PaM
163 static SdrObject *GetOrCreateSdrObject(SwFlyFrameFormat &rFormat);
164};
165
166typedef cppu::ImplInheritanceHelper
167<
168 SwXFrame,
169 css::text::XTextFrame,
170 css::container::XEnumerationAccess,
171 css::document::XEventsSupplier
172>
174
175class SAL_DLLPUBLIC_RTTI SwXTextFrame final : public SwXTextFrameBaseClass,
176 public SwXText
177{
178 friend class SwXFrame; // just for CreateXFrame
179
180 virtual const SwStartNode *GetStartNode() const override;
181
182 virtual css::uno::Reference< css::text::XTextCursor >
183 CreateCursor() override;
184
185 virtual ~SwXTextFrame() override;
186
187 SwXTextFrame(SwDoc *pDoc);
188 SwXTextFrame(SwFrameFormat& rFormat);
189
190public:
192 CreateXTextFrame(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
193
194 // FIXME: EVIL HACK: make available for SwXFrame::attachToRange
195 using SwXText::SetDoc;
196
197 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
198 virtual void SAL_CALL acquire( ) noexcept override;
199 virtual SW_DLLPUBLIC void SAL_CALL release( ) noexcept override;
200
201 //XTypeProvider
202 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
203 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
204
205 //XTextFrame
206 virtual SW_DLLPUBLIC css::uno::Reference< css::text::XText > SAL_CALL getText() override;
207
208 //XText
209 virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override;
210 virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > & aTextPosition) override;
211
212 //XEnumerationAccess - frueher XParagraphEnumerationAccess
213 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
214
215 //XElementAccess
216 virtual css::uno::Type SAL_CALL getElementType( ) override;
217 virtual sal_Bool SAL_CALL hasElements( ) override;
218
219 //XTextContent
220 virtual void SAL_CALL attach( const css::uno::Reference< css::text::XTextRange >& xTextRange ) override;
221 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor( ) override;
222
223 //XComponent
224 virtual void SAL_CALL dispose( ) override;
225 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
226 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
227
228 //XServiceInfo
229 virtual OUString SAL_CALL getImplementationName() override;
230 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
231 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
232
233 // XEventsSupplier
234 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
235
236 //XUnoTunnel
237 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
238
239 //XPropertySet
240 virtual SW_DLLPUBLIC css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
242};
243
244typedef cppu::ImplInheritanceHelper
245< SwXFrame,
246 css::document::XEventsSupplier
247>
250{
251 friend class SwXFrame; // just for CreateXFrame
252
253 virtual ~SwXTextGraphicObject() override;
254
257
258public:
259
261 CreateXTextGraphicObject(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
262
263 //XServiceInfo
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;
267
268 // XEventsSupplier
269 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
270};
271
272typedef cppu::ImplInheritanceHelper
273< SwXFrame,
274 css::document::XEmbeddedObjectSupplier2,
275 css::document::XEventsSupplier
277
279{
280 css::uno::Reference<css::util::XModifyListener> m_xOLEListener;
281
282 friend class SwXFrame; // just for CreateXFrame
283
284 virtual ~SwXTextEmbeddedObject() override;
285
288
289public:
290
292 CreateXTextEmbeddedObject(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
293
294 //XEmbeddedObjectSupplier2
295 virtual css::uno::Reference< css::lang::XComponent > SAL_CALL getEmbeddedObject() override;
296 virtual css::uno::Reference< css::embed::XEmbeddedObject > SAL_CALL getExtendedControlOverEmbeddedObject() override;
297 virtual ::sal_Int64 SAL_CALL getAspect() override;
298 virtual void SAL_CALL setAspect( ::sal_Int64 _aspect ) override;
299 virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getReplacementGraphic() override;
300
301 //XServiceInfo
302 virtual OUString SAL_CALL getImplementationName() override;
303 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
304 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
305
306 // XEventsSupplier
307 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
308};
309
310class SwXOLEListener final : public cppu::WeakImplHelper<css::util::XModifyListener>, public SvtListener
311{
313 css::uno::Reference<css::frame::XModel> m_xOLEModel;
314
315public:
316 SwXOLEListener(SwFormat& rOLEFormat, css::uno::Reference< css::frame::XModel > xOLE);
317 virtual ~SwXOLEListener() override;
318
319// css::lang::XEventListener
320 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
321
322// css::util::XModifyListener
323 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
324
325 virtual void Notify( const SfxHint& ) override;
326};
327
328#endif
329
330/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void Notify(const SfxHint &rHint)
Definition: doc.hxx:192
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:325
SwXFrame(FlyCntType eSet, const SfxItemPropertySet *pPropSet, SwDoc *pDoc)
SwFrameFormat * GetFrameFormat()
Definition: unoframe.hxx:155
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoframe.cxx:1182
const SwFrameFormat * GetFrameFormat() const
Definition: unoframe.hxx:153
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unoframe.cxx:1999
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unoframe.cxx:2690
css::uno::Reference< css::text::XText > m_xParentText
Definition: unoframe.hxx:78
SwDoc * m_pDoc
Definition: unoframe.hxx:66
css::uno::Reference< css::container::XNameAccess > mxStyleFamily
Definition: unoframe.hxx:83
SwXFrame(SwFrameFormat &rFrameFormat, FlyCntType eSet, const SfxItemPropertySet *pPropSet)
bool IsDescriptor() const
Definition: unoframe.hxx:160
bool m_bIsDescriptor
Definition: unoframe.hxx:72
const FlyCntType m_eType
Definition: unoframe.hxx:68
FlyCntType GetFlyCntType() const
Definition: unoframe.hxx:158
sal_Int64 m_nDrawAspect
Definition: unoframe.hxx:75
static rtl::Reference< Impl > CreateXFrame(SwDoc &rDoc, SwFrameFormat *const pFrameFormat)
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unoframe.cxx:3139
const SfxItemPropertySet * m_pPropSet
Definition: unoframe.hxx:65
SwFrameFormat * m_pFrameFormat
Definition: unoframe.hxx:63
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unoframe.cxx:1389
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unoframe.cxx:2622
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unoframe.cxx:2629
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unoframe.cxx:1177
virtual OUString SAL_CALL getImplementationName() override
Definition: unoframe.cxx:1172
sal_Int64 m_nVisibleAreaWidth
Definition: unoframe.hxx:76
std::unique_ptr< BaseFrameProperties_Impl > m_pProps
Definition: unoframe.hxx:71
sal_Int64 m_nVisibleAreaHeight
Definition: unoframe.hxx:77
css::uno::Reference< css::beans::XPropertySet > mxStyleData
Definition: unoframe.hxx:82
OUString m_sName
Definition: unoframe.hxx:73
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unoframe.hxx:61
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unoframe.cxx:1166
SwFormat * m_pOLEFormat
Definition: unoframe.hxx:312
css::uno::Reference< css::frame::XModel > m_xOLEModel
Definition: unoframe.hxx:313
css::uno::Reference< css::util::XModifyListener > m_xOLEListener
Definition: unoframe.hxx:280
void SetDoc(SwDoc *const pDoc)
Definition: unotext.cxx:156
static SwNode * GetStartNode(SwOutlineNodes const *pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type *nOutl)
Definition: docglbl.cxx:89
const EnumerationType m_eType
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:3238
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:276
cppu::ImplInheritanceHelper< SwXFrame, css::document::XEventsSupplier > SwXTextGraphicObjectBaseClass
Definition: unoframe.hxx:248
cppu::ImplInheritanceHelper< SwXFrame, css::text::XTextFrame, css::container::XEnumerationAccess, css::document::XEventsSupplier > SwXTextFrameBaseClass
Definition: unoframe.hxx:173