Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/sw/inc/unoframe.hxx
Line
Count
Source (jump to first uncovered line)
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 "swdllapi.h"
23
#include <com/sun/star/beans/XPropertyState.hpp>
24
#include <com/sun/star/container/XNamed.hpp>
25
#include <com/sun/star/container/XEnumerationAccess.hpp>
26
#include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
27
#include <com/sun/star/text/XTextFrame.hpp>
28
#include <com/sun/star/drawing/XShape.hpp>
29
#include <com/sun/star/util/XModifyListener.hpp>
30
#include <com/sun/star/document/XEventsSupplier.hpp>
31
32
#include <comphelper/interfacecontainer4.hxx>
33
#include <cppuhelper/implbase.hxx>
34
#include <sal/types.h>
35
#include <svl/listener.hxx>
36
37
#include "flyenum.hxx"
38
#include "frmfmt.hxx"
39
#include "unotext.hxx"
40
41
#include <memory>
42
#include <mutex>
43
44
class SdrObject;
45
class SwDoc;
46
class SwFormat;
47
class SwUnoInternalPaM;
48
class SfxItemPropertySet;
49
class SwXOLEListener;
50
namespace com::sun::star::frame { class XModel; }
51
52
class BaseFrameProperties_Impl;
53
class SAL_DLLPUBLIC_RTTI SAL_LOPLUGIN_ANNOTATE("crosscast") SwXFrame : public cppu::WeakImplHelper
54
<
55
    css::lang::XServiceInfo,
56
    css::beans::XPropertySet,
57
    css::beans::XPropertyState,
58
    css::drawing::XShape,
59
    css::container::XNamed,
60
    css::text::XTextContent
61
>,
62
    public SvtListener
63
{
64
private:
65
    std::mutex m_Mutex; // just for OInterfaceContainerHelper4
66
    ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_EventListeners;
67
    SwFrameFormat* m_pFrameFormat;
68
69
    const SfxItemPropertySet*       m_pPropSet;
70
    SwDoc*                          m_pDoc;
71
72
    const FlyCntType                m_eType;
73
74
    // Descriptor-interface
75
    std::unique_ptr<BaseFrameProperties_Impl> m_pProps;
76
    bool m_bIsDescriptor;
77
    UIName                          m_sName;
78
79
    sal_Int64                       m_nDrawAspect;
80
    sal_Int64                       m_nVisibleAreaWidth;
81
    sal_Int64                       m_nVisibleAreaHeight;
82
    css::uno::Reference<css::text::XText> m_xParentText;
83
    css::uno::Reference< css::beans::XPropertySet > mxStyleData;
84
    css::uno::Reference< css::container::XNameAccess >  mxStyleFamily;
85
86
    void DisposeInternal();
87
88
protected:
89
    virtual void Notify(const SfxHint&) override;
90
91
    virtual ~SwXFrame() override;
92
93
    SwXFrame(FlyCntType eSet,
94
                const SfxItemPropertySet*    pPropSet,
95
                SwDoc *pDoc ); //Descriptor-If
96
    SwXFrame(SwFrameFormat& rFrameFormat, FlyCntType eSet,
97
                const SfxItemPropertySet*    pPropSet);
98
99
    template<class Impl>
100
    static rtl::Reference<Impl>
101
    CreateXFrame(SwDoc & rDoc, SwFrameFormat *const pFrameFormat);
102
103
public:
104
105
    //XNamed
106
    SW_DLLPUBLIC virtual OUString SAL_CALL getName() override;
107
    SW_DLLPUBLIC 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
    SW_DLLPUBLIC 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
148
    /// @throws css::lang::IllegalArgumentException
149
    /// @throws css::uno::RuntimeException
150
    void attachToRange(css::uno::Reference<css::text::XTextRange> const& xTextRange,
151
            SwPaM const* pCopySource = nullptr);
152
153
    const SwFrameFormat* GetFrameFormat() const
154
30.4k
        { return m_pFrameFormat; }
155
    SwFrameFormat* GetFrameFormat()
156
843k
        { return m_pFrameFormat; }
157
158
0
    FlyCntType      GetFlyCntType()const {return m_eType;}
159
160
683k
    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
166
typedef cppu::ImplInheritanceHelper
167
<
168
    SwXFrame,
169
    css::text::XTextFrame,
170
    css::container::XEnumerationAccess,
171
    css::document::XEventsSupplier
172
>
173
SwXTextFrameBaseClass;
174
175
class 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 ~SwXTextFrame() override;
183
184
    SwXTextFrame(SwDoc *pDoc);
185
    SwXTextFrame(SwFrameFormat& rFormat);
186
187
public:
188
    static SW_DLLPUBLIC rtl::Reference<SwXTextFrame>
189
            CreateXTextFrame(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
190
191
    // FIXME: EVIL HACK:  make available for SwXFrame::attachToRange
192
    using SwXText::SetDoc;
193
194
    virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
195
    virtual SW_DLLPUBLIC void SAL_CALL acquire(  ) noexcept override;
196
    virtual SW_DLLPUBLIC void SAL_CALL release(  ) noexcept override;
197
198
    //XTypeProvider
199
    virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes(  ) override;
200
    virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(  ) override;
201
202
    //XTextFrame
203
    virtual SW_DLLPUBLIC css::uno::Reference< css::text::XText >  SAL_CALL getText() override;
204
205
    //XText
206
    virtual rtl::Reference< SwXTextCursor > createXTextCursor() override;
207
    virtual rtl::Reference< SwXTextCursor > createXTextCursorByRange(
208
            const ::css::uno::Reference< ::css::text::XTextRange >& aTextPosition ) override;
209
210
    //XEnumerationAccess - was: XParagraphEnumerationAccess
211
    virtual css::uno::Reference< css::container::XEnumeration >  SAL_CALL createEnumeration() override;
212
213
    //XElementAccess
214
    virtual css::uno::Type SAL_CALL getElementType(  ) override;
215
    virtual sal_Bool SAL_CALL hasElements(  ) override;
216
217
    //XTextContent
218
    virtual void SAL_CALL attach( const css::uno::Reference< css::text::XTextRange >& xTextRange ) override;
219
    virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor(  ) override;
220
221
    //XComponent
222
    virtual void SAL_CALL dispose(  ) override;
223
    virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
224
    virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
225
226
    //XServiceInfo
227
    virtual OUString SAL_CALL getImplementationName() override;
228
    virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
229
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
230
231
    // XEventsSupplier
232
    virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents(  ) override;
233
234
    //XPropertySet
235
    virtual SW_DLLPUBLIC css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
236
    using SwXFrame::setPropertyValue;
237
private:
238
    rtl::Reference< SwXTextCursor > createXTextCursorByRangeImpl(SwFrameFormat& rFormat, SwUnoInternalPaM& rPam);
239
};
240
241
typedef cppu::ImplInheritanceHelper
242
<   SwXFrame,
243
    css::document::XEventsSupplier
244
>
245
SwXTextGraphicObjectBaseClass;
246
class SW_DLLPUBLIC SwXTextGraphicObject final : public SwXTextGraphicObjectBaseClass
247
{
248
    friend class SwXFrame; // just for CreateXFrame
249
250
    virtual ~SwXTextGraphicObject() override;
251
252
    SwXTextGraphicObject( SwDoc *pDoc );
253
    SwXTextGraphicObject(SwFrameFormat& rFormat);
254
255
public:
256
257
    static rtl::Reference<SwXTextGraphicObject>
258
        CreateXTextGraphicObject(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
259
260
    //XServiceInfo
261
    virtual OUString SAL_CALL getImplementationName() override;
262
    virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
263
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
264
265
    // XEventsSupplier
266
    virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents(  ) override;
267
};
268
269
typedef cppu::ImplInheritanceHelper
270
<   SwXFrame,
271
    css::document::XEmbeddedObjectSupplier2,
272
    css::document::XEventsSupplier
273
> SwXTextEmbeddedObjectBaseClass;
274
275
class SW_DLLPUBLIC SwXTextEmbeddedObject final : public SwXTextEmbeddedObjectBaseClass
276
{
277
    rtl::Reference<SwXOLEListener> m_xOLEListener;
278
279
    friend class SwXFrame; // just for CreateXFrame
280
281
    virtual ~SwXTextEmbeddedObject() override;
282
283
    SwXTextEmbeddedObject( SwDoc *pDoc );
284
    SwXTextEmbeddedObject(SwFrameFormat& rFormat);
285
286
public:
287
288
    static rtl::Reference<SwXTextEmbeddedObject>
289
        CreateXTextEmbeddedObject(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
290
291
    //XEmbeddedObjectSupplier2
292
    virtual css::uno::Reference< css::lang::XComponent >  SAL_CALL getEmbeddedObject() override;
293
    virtual css::uno::Reference< css::embed::XEmbeddedObject > SAL_CALL getExtendedControlOverEmbeddedObject() override;
294
    virtual ::sal_Int64 SAL_CALL getAspect() override;
295
    virtual void SAL_CALL setAspect( ::sal_Int64 _aspect ) override;
296
    virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getReplacementGraphic() override;
297
298
    //XServiceInfo
299
    virtual OUString SAL_CALL getImplementationName() override;
300
    virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
301
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
302
303
    // XEventsSupplier
304
    virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents(  ) override;
305
};
306
307
class SwXOLEListener final : public cppu::WeakImplHelper<css::util::XModifyListener>, public SvtListener
308
{
309
    SwFormat* m_pOLEFormat;
310
    css::uno::Reference<css::frame::XModel> m_xOLEModel;
311
312
public:
313
    SwXOLEListener(SwFormat& rOLEFormat, css::uno::Reference< css::frame::XModel > xOLE);
314
    virtual ~SwXOLEListener() override;
315
316
// css::lang::XEventListener
317
    virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
318
319
// css::util::XModifyListener
320
    virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
321
322
    virtual void Notify( const SfxHint& ) override;
323
};
324
325
#endif
326
327
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */