Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/inc/unoframe.hxx
Line
Count
Source
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
29.8k
        { return m_pFrameFormat; }
155
    SwFrameFormat* GetFrameFormat()
156
911k
        { return m_pFrameFormat; }
157
158
0
    FlyCntType      GetFlyCntType()const {return m_eType;}
159
160
739k
    bool IsDescriptor() const {return m_bIsDescriptor;}
161
    void            ResetDescriptor();
162
    static SdrObject *GetOrCreateSdrObject(SwFlyFrameFormat &rFormat);
163
};
164
165
typedef cppu::ImplInheritanceHelper
166
<
167
    SwXFrame,
168
    css::text::XTextFrame,
169
    css::container::XEnumerationAccess,
170
    css::document::XEventsSupplier
171
>
172
SwXTextFrameBaseClass;
173
174
class SAL_DLLPUBLIC_RTTI SwXTextFrame final : public SwXTextFrameBaseClass,
175
    public SwXText
176
{
177
    friend class SwXFrame; // just for CreateXFrame
178
179
    virtual const SwStartNode *GetStartNode() const override;
180
181
    virtual ~SwXTextFrame() override;
182
183
    SwXTextFrame(SwDoc *pDoc);
184
    SwXTextFrame(SwFrameFormat& rFormat);
185
186
public:
187
    static SW_DLLPUBLIC rtl::Reference<SwXTextFrame>
188
            CreateXTextFrame(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
189
190
    // FIXME: EVIL HACK:  make available for SwXFrame::attachToRange
191
    using SwXText::SetDoc;
192
193
    virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
194
    virtual SW_DLLPUBLIC void SAL_CALL acquire(  ) noexcept override;
195
    virtual SW_DLLPUBLIC void SAL_CALL release(  ) noexcept override;
196
197
    //XTypeProvider
198
    virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes(  ) override;
199
    virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(  ) override;
200
201
    //XTextFrame
202
    virtual SW_DLLPUBLIC css::uno::Reference< css::text::XText >  SAL_CALL getText() override;
203
204
    //XText
205
    virtual rtl::Reference< SwXTextCursor > createXTextCursor() override;
206
    virtual rtl::Reference< SwXTextCursor > createXTextCursorByRange(
207
            const ::css::uno::Reference< ::css::text::XTextRange >& aTextPosition ) override;
208
209
    //XEnumerationAccess - was: XParagraphEnumerationAccess
210
    virtual css::uno::Reference< css::container::XEnumeration >  SAL_CALL createEnumeration() override;
211
212
    //XElementAccess
213
    virtual css::uno::Type SAL_CALL getElementType(  ) override;
214
    virtual sal_Bool SAL_CALL hasElements(  ) override;
215
216
    //XTextContent
217
    virtual void SAL_CALL attach( const css::uno::Reference< css::text::XTextRange >& xTextRange ) override;
218
    virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor(  ) override;
219
220
    //XComponent
221
    virtual void SAL_CALL dispose(  ) override;
222
    virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
223
    virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
224
225
    //XServiceInfo
226
    virtual OUString SAL_CALL getImplementationName() override;
227
    virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
228
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
229
230
    // XEventsSupplier
231
    virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents(  ) override;
232
233
    //XPropertySet
234
    virtual SW_DLLPUBLIC css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
235
    using SwXFrame::setPropertyValue;
236
private:
237
    rtl::Reference< SwXTextCursor > createXTextCursorByRangeImpl(SwFrameFormat& rFormat, SwUnoInternalPaM& rPam);
238
};
239
240
typedef cppu::ImplInheritanceHelper
241
<   SwXFrame,
242
    css::document::XEventsSupplier
243
>
244
SwXTextGraphicObjectBaseClass;
245
class SW_DLLPUBLIC SwXTextGraphicObject final : public SwXTextGraphicObjectBaseClass
246
{
247
    friend class SwXFrame; // just for CreateXFrame
248
249
    virtual ~SwXTextGraphicObject() override;
250
251
    SwXTextGraphicObject( SwDoc *pDoc );
252
    SwXTextGraphicObject(SwFrameFormat& rFormat);
253
254
public:
255
256
    static rtl::Reference<SwXTextGraphicObject>
257
        CreateXTextGraphicObject(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
258
259
    //XServiceInfo
260
    virtual OUString SAL_CALL getImplementationName() override;
261
    virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
262
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
263
264
    // XEventsSupplier
265
    virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents(  ) override;
266
};
267
268
typedef cppu::ImplInheritanceHelper
269
<   SwXFrame,
270
    css::document::XEmbeddedObjectSupplier2,
271
    css::document::XEventsSupplier
272
> SwXTextEmbeddedObjectBaseClass;
273
274
class SW_DLLPUBLIC SwXTextEmbeddedObject final : public SwXTextEmbeddedObjectBaseClass
275
{
276
    rtl::Reference<SwXOLEListener> m_xOLEListener;
277
278
    friend class SwXFrame; // just for CreateXFrame
279
280
    virtual ~SwXTextEmbeddedObject() override;
281
282
    SwXTextEmbeddedObject( SwDoc *pDoc );
283
    SwXTextEmbeddedObject(SwFrameFormat& rFormat);
284
285
public:
286
287
    static rtl::Reference<SwXTextEmbeddedObject>
288
        CreateXTextEmbeddedObject(SwDoc & rDoc, SwFrameFormat * pFrameFormat);
289
290
    //XEmbeddedObjectSupplier2
291
    virtual css::uno::Reference< css::lang::XComponent >  SAL_CALL getEmbeddedObject() override;
292
    virtual css::uno::Reference< css::embed::XEmbeddedObject > SAL_CALL getExtendedControlOverEmbeddedObject() override;
293
    virtual ::sal_Int64 SAL_CALL getAspect() override;
294
    virtual void SAL_CALL setAspect( ::sal_Int64 _aspect ) override;
295
    virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL getReplacementGraphic() override;
296
297
    //XServiceInfo
298
    virtual OUString SAL_CALL getImplementationName() override;
299
    virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
300
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
301
302
    // XEventsSupplier
303
    virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents(  ) override;
304
};
305
306
class SwXOLEListener final : public cppu::WeakImplHelper<css::util::XModifyListener>, public SvtListener
307
{
308
    SwFormat* m_pOLEFormat;
309
    css::uno::Reference<css::frame::XModel> m_xOLEModel;
310
311
public:
312
    SwXOLEListener(SwFormat& rOLEFormat, css::uno::Reference< css::frame::XModel > xOLE);
313
    virtual ~SwXOLEListener() override;
314
315
// css::lang::XEventListener
316
    virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
317
318
// css::util::XModifyListener
319
    virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
320
321
    virtual void Notify( const SfxHint& ) override;
322
};
323
324
#endif
325
326
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */