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 ~SwXTextFrame() override;
178
179 SwXTextFrame(SwDoc *pDoc);
180 SwXTextFrame(SwFrameFormat& rFormat);
181
182public:
184 CreateXTextFrame(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
185
186 // FIXME: EVIL HACK: make available for SwXFrame::attachToRange
187 using SwXText::SetDoc;
188
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;
192
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;
196
197 //XTextFrame
198 virtual SW_DLLPUBLIC css::uno::Reference< css::text::XText > SAL_CALL getText() override;
199
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;
204
205 //XEnumerationAccess - frueher XParagraphEnumerationAccess
206 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
207
208 //XElementAccess
209 virtual css::uno::Type SAL_CALL getElementType( ) override;
210 virtual sal_Bool SAL_CALL hasElements( ) override;
211
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;
215
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;
220
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;
225
226 // XEventsSupplier
227 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
228
229 //XPropertySet
230 virtual SW_DLLPUBLIC css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
231 using SwXFrame::setPropertyValue;
232};
233
234typedef cppu::ImplInheritanceHelper
235< SwXFrame,
236 css::document::XEventsSupplier
237>
240{
241 friend class SwXFrame; // just for CreateXFrame
242
243 virtual ~SwXTextGraphicObject() override;
244
247
248public:
249
251 CreateXTextGraphicObject(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
252
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;
257
258 // XEventsSupplier
259 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
260};
261
262typedef cppu::ImplInheritanceHelper
263< SwXFrame,
264 css::document::XEmbeddedObjectSupplier2,
265 css::document::XEventsSupplier
267
269{
270 css::uno::Reference<css::util::XModifyListener> m_xOLEListener;
271
272 friend class SwXFrame; // just for CreateXFrame
273
274 virtual ~SwXTextEmbeddedObject() override;
275
278
279public:
280
282 CreateXTextEmbeddedObject(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
283
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;
290
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;
295
296 // XEventsSupplier
297 virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
298};
299
300class SwXOLEListener final : public cppu::WeakImplHelper<css::util::XModifyListener>, public SvtListener
301{
303 css::uno::Reference<css::frame::XModel> m_xOLEModel;
304
305public:
306 SwXOLEListener(SwFormat& rOLEFormat, css::uno::Reference< css::frame::XModel > xOLE);
307 virtual ~SwXOLEListener() override;
308
309// css::lang::XEventListener
310 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
311
312// css::util::XModifyListener
313 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
314
315 virtual void Notify( const SfxHint& ) override;
316};
317
318#endif
319
320/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
virtual void Notify(const SfxHint &rHint)
Definition: doc.hxx:197
Base class for various Writer styles.
Definition: format.hxx:47
Style of a layout element.
Definition: frmfmt.hxx:72
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
Starts a section of nodes in the document model.
Definition: node.hxx:348
SwFormat * m_pOLEFormat
Definition: unoframe.hxx:302
css::uno::Reference< css::frame::XModel > m_xOLEModel
Definition: unoframe.hxx:303
css::uno::Reference< css::util::XModifyListener > m_xOLEListener
Definition: unoframe.hxx:270
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_DLLPUBLIC_RTTI 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:3254
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:266
cppu::ImplInheritanceHelper< SwXFrame, css::document::XEventsSupplier > SwXTextGraphicObjectBaseClass
Definition: unoframe.hxx:238
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