Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/inc/ndole.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_NDOLE_HXX
20
#define INCLUDED_SW_INC_NDOLE_HXX
21
22
#include "ndnotxt.hxx"
23
#include <svtools/embedhlp.hxx>
24
#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
25
#include <rtl/ref.hxx>
26
#include <tools/link.hxx>
27
28
class SvxDrawPage;
29
class SwGrfFormatColl;
30
class SwDoc;
31
class SwOLENode;
32
class SwOLEListener_Impl;
33
namespace sfx2 { class SvBaseLink; }
34
class DeflateData;
35
36
class SW_DLLPUBLIC SwOLEObj
37
{
38
    friend class SwOLENode;
39
40
    const SwOLENode* m_pOLENode;
41
    rtl::Reference<SwOLEListener_Impl> m_xListener;
42
43
    /** Either ref or name are known. If only name is known, ref is obtained
44
       on demand by GetOleRef() from Sfx. */
45
    svt::EmbeddedObjectRef m_xOLERef;
46
    OUString m_aName;
47
48
    // eventually buffered data if it is a chart OLE
49
    drawinglayer::primitive2d::Primitive2DContainer     m_aPrimitive2DSequence;
50
    basegfx::B2DRange                                   m_aRange;
51
    sal_uInt32                                          m_nGraphicVersion;
52
    std::unique_ptr<DeflateData>                        m_pDeflateData;
53
54
    SwOLEObj( const SwOLEObj& rObj ) = delete;
55
56
    void SetNode( SwOLENode* pNode );
57
58
    DECL_LINK(IsProtectedHdl, LinkParamNone*, bool);
59
60
public:
61
    SwOLEObj( const svt::EmbeddedObjectRef& pObj );
62
    SwOLEObj( OUString aName, sal_Int64 nAspect );
63
    ~SwOLEObj() COVERITY_NOEXCEPT_FALSE;
64
65
    bool UnloadObject();
66
    static bool UnloadObject( css::uno::Reference< css::embed::XEmbeddedObject > const & xObj,
67
                                const SwDoc* pDoc,
68
                                sal_Int64 nAspect );
69
70
    OUString GetDescription();
71
72
    css::uno::Reference < css::embed::XEmbeddedObject > const & GetOleRef();
73
    svt::EmbeddedObjectRef& GetObject();
74
11
    const OUString& GetCurrentPersistName() const { return m_aName; }
75
    OUString GetStyleString();
76
    bool IsOleRef() const;  ///< To avoid unnecessary loading of object.
77
    bool IsProtected() const;
78
79
    // try to get OLE visualization in form of a Primitive2DSequence
80
    // and the corresponding B2DRange. This data may be locally buffered
81
    drawinglayer::primitive2d::Primitive2DContainer const & tryToGetChartContentAsPrimitive2DSequence(
82
        basegfx::B2DRange& rRange,
83
        bool bSynchron);
84
    void resetBufferedData();
85
86
    SvxDrawPage* tryToGetChartDrawPage() const;
87
88
    void dumpAsXml(xmlTextWriterPtr pWriter) const;
89
};
90
91
// SwOLENode
92
93
class SW_DLLPUBLIC SwOLENode final: public SwNoTextNode
94
{
95
    friend class SwNodes;
96
    mutable SwOLEObj maOLEObj;
97
    UIName msChartTableName;     ///< with chart objects: name of referenced table.
98
    bool   mbOLESizeInvalid; /**< Should be considered at SwDoc::PrtOLENotify
99
                                   (e.g. copied). Is not persistent. */
100
101
    sfx2::SvBaseLink*  mpObjectLink;
102
    OUString maLinkURL;
103
104
    SwOLENode(  const SwNode& rWhere,
105
                const svt::EmbeddedObjectRef&,
106
                SwGrfFormatColl *pGrfColl,
107
                SwAttrSet const * pAutoAttr );
108
109
    SwOLENode(  const SwNode& rWhere,
110
                const OUString &rName,
111
                sal_Int64 nAspect,
112
                SwGrfFormatColl *pGrfColl,
113
                SwAttrSet const * pAutoAttr );
114
115
    SwOLENode( const SwOLENode & ) = delete;
116
117
    using SwNoTextNode::GetGraphic;
118
119
public:
120
0
    const SwOLEObj& GetOLEObj() const { return maOLEObj; }
121
13.4k
          SwOLEObj& GetOLEObj()       { return maOLEObj; }
122
    virtual ~SwOLENode() override;
123
124
    /// Is in ndcopy.cxx.
125
    virtual SwContentNode* MakeCopy(SwDoc&, SwNode& rWhere, bool bNewFrames) const override;
126
127
    virtual Size GetTwipSize() const override;
128
129
    const Graphic* GetGraphic();
130
131
    void GetNewReplacement();
132
133
    virtual bool SavePersistentData() override;
134
    virtual bool RestorePersistentData() override;
135
136
    virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
137
138
    bool IsInGlobalDocSection() const;
139
    bool IsOLEObjectDeleted() const;
140
141
0
    bool IsOLESizeInvalid() const   { return mbOLESizeInvalid; }
142
346
    void SetOLESizeInvalid( bool b ){ mbOLESizeInvalid = b; }
143
144
692
    sal_Int64 GetAspect() const { return maOLEObj.GetObject().GetViewAspect(); }
145
346
    void SetAspect( sal_Int64 nAspect) { maOLEObj.GetObject().SetViewAspect( nAspect ); }
146
147
    /** Remove OLE-object from "memory".
148
       inline void Unload() { aOLEObj.Unload(); } */
149
346
    OUString GetDescription() const { return maOLEObj.GetDescription(); }
150
151
    bool UpdateLinkURL_Impl();
152
    void BreakFileLink_Impl();
153
    void DisconnectFileLink_Impl();
154
155
    void CheckFileLink_Impl();
156
157
    // #i99665#
158
    bool IsChart() const;
159
160
11.8k
    const UIName& GetChartTableName() const { return msChartTableName; }
161
346
    void SetChartTableName( const UIName& rNm ) { msChartTableName = rNm; }
162
163
164
    // react on visual change (invalidate)
165
    void SetChanged();
166
};
167
168
/// Inline methods from Node.hxx
169
inline SwOLENode *SwNode::GetOLENode()
170
366k
{
171
366k
     return SwNodeType::Ole == m_nNodeType ? static_cast<SwOLENode*>(this) : nullptr;
172
366k
}
173
174
inline const SwOLENode *SwNode::GetOLENode() const
175
135
{
176
135
     return SwNodeType::Ole == m_nNodeType ? static_cast<const SwOLENode*>(this) : nullptr;
177
135
}
178
179
namespace sw
180
{
181
    class DocumentSettingManager;
182
}
183
184
class PurgeGuard
185
{
186
private:
187
    ::sw::DocumentSettingManager &m_rManager;
188
    bool m_bOrigPurgeOle;
189
public:
190
    PurgeGuard(const SwDoc& rDoc);
191
    ~PurgeGuard() COVERITY_NOEXCEPT_FALSE;
192
};
193
194
#endif  // _ INCLUDED_SW_INC_NDOLE_HXX
195
196
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */