Coverage Report

Created: 2025-12-31 10:39

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