Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/include/svx/svdoole2.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
20
#pragma once
21
22
#include <memory>
23
#include <svx/svdorect.hxx>
24
#include <svx/svxdllapi.h>
25
#include <sfx2/lnkbase.hxx>
26
27
#include <com/sun/star/uno/Reference.h>
28
29
namespace com::sun::star {
30
31
namespace awt { class XWindow; }
32
33
namespace embed { class XEmbeddedObject; }
34
35
namespace frame { class XModel; }
36
37
namespace io { class XInputStream; }
38
}
39
40
namespace svt { class EmbeddedObjectRef; }
41
42
class SdrOle2ObjImpl;
43
class SvxOle2Shape;
44
45
class SVXCORE_DLLPUBLIC SdrOle2Obj : public SdrRectObj
46
{
47
private:
48
    std::unique_ptr<SdrOle2ObjImpl> mpImpl;
49
50
private:
51
    SVX_DLLPRIVATE void Connect_Impl(SvxOle2Shape* pCreator = nullptr);
52
    SVX_DLLPRIVATE void Disconnect_Impl();
53
    SVX_DLLPRIVATE void AddListeners_Impl();
54
    SVX_DLLPRIVATE void RemoveListeners_Impl();
55
    SVX_DLLPRIVATE void GetObjRef_Impl();
56
57
    // #i118485# helper added
58
    SVX_DLLPRIVATE rtl::Reference<SdrObject> createSdrGrafObjReplacement(bool bAddText) const;
59
    SVX_DLLPRIVATE void ImpSetVisAreaSize();
60
61
    SVX_DLLPRIVATE void Init();
62
63
protected:
64
    virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
65
    virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() override;
66
67
    // protected destructor
68
    virtual ~SdrOle2Obj() override;
69
70
public:
71
    OUString GetStyleString();
72
73
    SdrOle2Obj(
74
        SdrModel& rSdrModel,
75
        bool bFrame_ = false);
76
    // Copy constructor
77
    SdrOle2Obj(SdrModel& rSdrModel, SdrOle2Obj const & rSource);
78
    SdrOle2Obj(
79
        SdrModel& rSdrModel,
80
        const svt::EmbeddedObjectRef& rNewObjRef,
81
        const OUString& rNewObjName,
82
        const tools::Rectangle& rNewRect);
83
84
    const svt::EmbeddedObjectRef& getEmbeddedObjectRef() const;
85
86
    sal_Int64 GetAspect() const;
87
    bool isInplaceActive() const;
88
    bool isUiActive() const;
89
    void SetAspect( sal_Int64 nAspect );
90
91
    // An OLE graphic object can contain a StarView graphic,
92
    // which will be displayed if the OLE object is empty.
93
    void        SetGraphic(const Graphic& rGrf);
94
    void        ClearGraphic();
95
    const       Graphic* GetGraphic() const;
96
    void        GetNewReplacement();
97
98
    // The original size of the object (size of the icon for iconified object)
99
    // no conversion is done if no target mode is provided
100
    Size        GetOrigObjSize( MapMode const * pTargetMapMode = nullptr ) const;
101
102
    // #i118524# Allow suppress SetVisAreaSize in changing methods when call
103
    // comes from OLE client
104
    void setSuppressSetVisAreaSize( bool bNew );
105
106
    // OLE object has got a separate PersistName member now;
107
    // !!! use ::SetPersistName( ... ) only, if you know what you do !!!
108
    const OUString& GetPersistName() const;
109
    void        SetPersistName( const OUString& rPersistName, SvxOle2Shape* pCreator = nullptr );
110
111
    // One can add an application name to a SdrOle2Obj, which can be queried for
112
    // later on (SD needs this for presentation objects).
113
    void SetProgName( const OUString& rName );
114
    const OUString& GetProgName() const;
115
    bool IsEmpty() const;
116
117
    void SetObjRef(const css::uno::Reference < css::embed::XEmbeddedObject >& rNewObjRef);
118
    css::uno::Reference < css::embed::XEmbeddedObject > const & GetObjRef() const;
119
120
    SVX_DLLPRIVATE css::uno::Reference < css::embed::XEmbeddedObject > const & GetObjRef_NoInit() const;
121
122
    void AbandonObject();
123
124
    // react on model/page change
125
    virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;
126
127
    /** Change the IsClosedObj attribute
128
129
        @param bIsClosed
130
        Whether the OLE object is closed, i.e. has opaque background
131
     */
132
    void SetClosedObj( bool bIsClosed );
133
134
    // FullDrag support
135
    virtual rtl::Reference<SdrObject> getFullDragClone() const override;
136
137
    virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
138
    virtual SdrObjKind GetObjIdentifier() const override;
139
    virtual OUString TakeObjNameSingul() const override;
140
    virtual OUString TakeObjNamePlural() const override;
141
142
    virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
143
144
    virtual void NbcMove(const Size& rSize) override;
145
    virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
146
    virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
147
    virtual void NbcSetLogicRect(const tools::Rectangle& rRect, bool bAdaptTextMinSize = true) override;
148
    virtual void SetGeoData(const SdrObjGeoData& rGeo) override;
149
150
    static bool CanUnloadRunningObj( const css::uno::Reference< css::embed::XEmbeddedObject >& xObj,
151
                                         sal_Int64 nAspect );
152
    static bool Unload( const css::uno::Reference< css::embed::XEmbeddedObject >& xObj, sal_Int64 nAspect );
153
    bool Unload();
154
    void Connect(SvxOle2Shape* pCreator = nullptr);
155
    void Disconnect();
156
    void ObjectLoaded();
157
158
    css::uno::Reference< css::frame::XModel > getXModel() const;
159
160
    bool IsChart() const;
161
    bool IsCalc() const;
162
163
    bool UpdateLinkURL_Impl();
164
    void BreakFileLink_Impl();
165
    void DisconnectFileLink_Impl();
166
    void CheckFileLink_Impl();
167
168
    // allows to transfer the graphics to the object helper
169
    void SetGraphicToObj( const Graphic& aGraphic );
170
    void SetGraphicToObj( const css::uno::Reference< css::io::XInputStream >& xGrStream,
171
                          const OUString& aMediaType );
172
173
    const css::uno::Reference< css::frame::XModel > & GetParentXModel()  const;
174
    bool CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHeight, Size& aObjAreaSize );
175
    bool AddOwnLightClient();
176
177
    // handy to get the empty replacement graphic without accessing all the old stuff
178
    static Graphic GetEmptyOLEReplacementGraphic();
179
180
    void SetWindow(const css::uno::Reference < css::awt::XWindow >& _xWindow);
181
182
    // #i118485# missing converter added
183
    virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
184
185
0
    virtual bool IsSdrOle2Obj() const final { return true; }
186
187
    void SetIgnoreOLEObjectScale(bool val);
188
};
189
190
class SVXCORE_DLLPUBLIC SdrEmbedObjectLink final : public sfx2::SvBaseLink
191
{
192
    SdrOle2Obj*         m_pObj;
193
194
public:
195
    SAL_DLLPRIVATE explicit            SdrEmbedObjectLink(SdrOle2Obj* pObj);
196
    SAL_DLLPRIVATE virtual             ~SdrEmbedObjectLink() override;
197
198
    SAL_DLLPRIVATE virtual void        Closed() override;
199
    SAL_DLLPRIVATE virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
200
        const OUString& rMimeType, const css::uno::Any & rValue ) override;
201
202
0
    void                Connect() { GetRealObject(); }
203
};
204
205
class SVXCORE_DLLPUBLIC SdrIFrameLink final : public sfx2::SvBaseLink
206
{
207
    SdrOle2Obj* m_pObject;
208
209
public:
210
    explicit SdrIFrameLink(SdrOle2Obj* pObject);
211
    virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
212
        const OUString& rMimeType, const css::uno::Any & rValue ) override;
213
};
214
215
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */