Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/svdograf.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
20
#pragma once
21
22
#include <com/sun/star/io/XInputStream.hpp>
23
#include <com/sun/star/graphic/XGraphic.hpp>
24
#include <com/sun/star/drawing/BarCode.hpp>
25
#include <vcl/graph.hxx>
26
#include <svx/svdorect.hxx>
27
#include <vcl/GraphicObject.hxx>
28
#include <svx/svxdllapi.h>
29
#include <o3tl/typed_flags_set.hxx>
30
#include <memory>
31
32
namespace sdr::properties { class GraphicProperties; }
33
namespace sdr::contact { class ViewObjectContactOfGraphic; }
34
35
/**
36
 * Options for GetTransformedGraphic()
37
 */
38
enum class SdrGrafObjTransformsAttrs
39
{
40
    NONE       = 0x00,
41
    MIRROR     = 0x01,
42
    ROTATE     = 0x02,
43
    ALL        = 0x03,
44
};
45
namespace o3tl
46
{
47
    template<> struct typed_flags<SdrGrafObjTransformsAttrs> : is_typed_flags<SdrGrafObjTransformsAttrs, 0x03> {};
48
}
49
50
class SdrGrafObjGeoData final : public SdrTextObjGeoData
51
{
52
public:
53
    bool                    bMirrored;
54
55
    SdrGrafObjGeoData()
56
0
    :   bMirrored(false)
57
0
    {
58
0
    }
59
};
60
61
class GraphicObject;
62
class SdrGraphicLink;
63
64
/**
65
 * This class represents an embedded or linked bitmap graphic object.
66
 */
67
class SVXCORE_DLLPUBLIC SdrGrafObj final : public SdrRectObj
68
{
69
private:
70
    // to allow sdr::properties::GraphicProperties access to SetXPolyDirty()
71
    friend class sdr::properties::GraphicProperties;
72
73
    // to allow sdr::contact::ViewObjectContactOfGraphic access to ImpUpdateGraphicLink()
74
    friend class sdr::contact::ViewObjectContactOfGraphic;
75
    friend class SdrExchangeView; // Only for a ForceSwapIn() call.
76
    friend class SdrGraphicLink;
77
78
    SAL_DLLPRIVATE virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
79
    SAL_DLLPRIVATE virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() override;
80
81
    OUString m_aFileName; // If it's a Link, the filename can be found in here
82
    OUString m_aFilterName;
83
    std::unique_ptr<GraphicObject> mpGraphicObject; // In order to speed up output of bitmaps, especially rotated ones
84
    std::unique_ptr<GraphicObject> mpReplacementGraphicObject;
85
    SdrGraphicLink* m_pGraphicLink; // And here a pointer for linked graphics
86
    bool m_bMirrored:1; // True: the graphic is horizontal, which means it's mirrored along the y-axis
87
88
    // Flag for allowing text animation. Default is true.
89
    bool mbGrafAnimationAllowed:1;
90
91
    bool mbIsSignatureLine;
92
    OUString maSignatureLineId;
93
    OUString maSignatureLineSuggestedSignerName;
94
    OUString maSignatureLineSuggestedSignerTitle;
95
    OUString maSignatureLineSuggestedSignerEmail;
96
    OUString maSignatureLineSigningInstructions;
97
    bool mbIsSignatureLineShowSignDate;
98
    bool mbIsSignatureLineCanAddComment;
99
    bool mbSignatureLineIsSigned;
100
    css::uno::Reference<css::graphic::XGraphic> mpSignatureLineUnsignedGraphic;
101
102
    std::unique_ptr<css::drawing::BarCode> mpBarCode;
103
    SAL_DLLPRIVATE void                    ImpRegisterLink();
104
    SAL_DLLPRIVATE void                    ImpDeregisterLink();
105
    SAL_DLLPRIVATE void                    ImpSetLinkedGraphic( const Graphic& rGraphic );
106
    SAL_DLLPRIVATE void onGraphicChanged();
107
    SAL_DLLPRIVATE GDIMetaFile             GetMetaFile(GraphicType &rGraphicType) const;
108
109
    // protected destructor
110
    SAL_DLLPRIVATE virtual ~SdrGrafObj() override;
111
112
public:
113
    SdrGrafObj(SdrModel& rSdrModel);
114
    // Copy constructor
115
    SAL_DLLPRIVATE SdrGrafObj(SdrModel& rSdrModel, SdrGrafObj const & rSource);
116
    SdrGrafObj(
117
        SdrModel& rSdrModel,
118
        const Graphic& rGrf);
119
    SdrGrafObj(
120
        SdrModel& rSdrModel,
121
        const Graphic& rGrf,
122
        const tools::Rectangle& rRect);
123
124
    void                    SetGraphicObject( const GraphicObject& rGrfObj );
125
    const GraphicObject&    GetGraphicObject(bool bForceSwapIn = false) const;
126
    SAL_DLLPRIVATE const GraphicObject*    GetReplacementGraphicObject() const;
127
    // An exploded view of a pdf page as a draw document.
128
    SAL_DLLPRIVATE css::uno::Reference<css::lang::XComponent> GetReplacementGraphicModel() const;
129
130
    SAL_DLLPRIVATE void                    NbcSetGraphic(const Graphic& rGrf);
131
    void                    SetGraphic(const Graphic& rGrf);
132
    const Graphic&          GetGraphic() const;
133
134
    Graphic                 GetTransformedGraphic( SdrGrafObjTransformsAttrs nTransformFlags = SdrGrafObjTransformsAttrs::ALL ) const;
135
136
    GraphicType             GetGraphicType() const;
137
138
    GraphicAttr             GetGraphicAttr( SdrGrafObjTransformsAttrs nTransformFlags = SdrGrafObjTransformsAttrs::ALL  ) const;
139
140
    // Keep ATM for SD.
141
    bool IsAnimated() const;
142
    bool IsEPS() const;
143
144
    SAL_DLLPRIVATE MapMode          GetGrafPrefMapMode() const;
145
    SAL_DLLPRIVATE Size             GetGrafPrefSize() const;
146
147
    SAL_DLLPRIVATE void                    SetGrafStreamURL( const OUString& rGraphicStreamURL );
148
    SAL_DLLPRIVATE OUString const &        GetGrafStreamURL() const;
149
    Size                    getOriginalSize() const;
150
151
private:
152
    SAL_DLLPRIVATE void                    ForceSwapIn() const;
153
154
public:
155
    void                    SetGraphicLink(const OUString& rFileName);
156
    void                    ReleaseGraphicLink();
157
    bool IsLinkedGraphic() const;
158
159
122
    const OUString& GetFileName() const { return m_aFileName;}
160
161
    void                    StartAnimation();
162
163
    SAL_DLLPRIVATE virtual void            TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
164
    SAL_DLLPRIVATE virtual SdrObjKind      GetObjIdentifier() const override;
165
166
    SAL_DLLPRIVATE virtual OUString        TakeObjNameSingul() const override;
167
    SAL_DLLPRIVATE virtual OUString        TakeObjNamePlural() const override;
168
169
    virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
170
171
    SAL_DLLPRIVATE virtual sal_uInt32 GetHdlCount() const override;
172
    SAL_DLLPRIVATE virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
173
174
    virtual void            NbcResize(const Point& rRef, double xFact, double yFact) override;
175
    SAL_DLLPRIVATE virtual void            NbcMirror(const Point& rRef1, const Point& rRef2) override;
176
    SAL_DLLPRIVATE virtual std::unique_ptr<SdrObjGeoData>  NewGeoData() const override;
177
    SAL_DLLPRIVATE virtual void            SaveGeoData(SdrObjGeoData& rGeo) const override;
178
    SAL_DLLPRIVATE virtual void            RestoreGeoData(const SdrObjGeoData& rGeo) override;
179
180
    bool                    HasGDIMetaFile() const;
181
182
    // react on model/page change
183
    SAL_DLLPRIVATE virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;
184
185
    bool isEmbeddedVectorGraphicData() const;
186
    GDIMetaFile getMetafileFromEmbeddedVectorGraphicData() const;
187
188
    SAL_DLLPRIVATE virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
189
190
    virtual void            AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly = false ) override;
191
192
   SAL_DLLPRIVATE  virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
193
194
883
    bool IsMirrored() const { return m_bMirrored;}
195
    SAL_DLLPRIVATE void SetMirrored( bool _bMirrored );
196
197
0
    virtual bool shouldKeepAspectRatio() const override { return true; }
198
199
    // Access to GrafAnimationAllowed flag
200
    SAL_DLLPRIVATE void SetGrafAnimationAllowed(bool bNew);
201
202
    SAL_DLLPRIVATE css::uno::Reference< css::io::XInputStream > getInputStream() const;
203
204
    // #i103116# FullDrag support
205
    SAL_DLLPRIVATE virtual rtl::Reference<SdrObject> getFullDragClone() const override;
206
207
    // add handles for crop mode when selected
208
    SAL_DLLPRIVATE virtual void addCropHandles(SdrHdlList& rTarget) const override;
209
210
    // Signature Line
211
4
    void setIsSignatureLine(bool bIsSignatureLine) { mbIsSignatureLine = bIsSignatureLine; }
212
199
    bool isSignatureLine() const { return mbIsSignatureLine; }
213
214
    void setSignatureLineId(const OUString& rSignatureLineId)
215
4
    {
216
4
        maSignatureLineId = rSignatureLineId;
217
4
    }
218
219
0
    const OUString& getSignatureLineId() const { return maSignatureLineId; }
220
221
    void setSignatureLineSuggestedSignerName(const OUString& rSuggestedSignerName)
222
4
    {
223
4
        maSignatureLineSuggestedSignerName = rSuggestedSignerName;
224
4
    }
225
226
    const OUString& getSignatureLineSuggestedSignerName() const
227
0
    {
228
0
        return maSignatureLineSuggestedSignerName;
229
0
    }
230
231
    void setSignatureLineSuggestedSignerTitle(const OUString& rSuggestedSignerTitle)
232
4
    {
233
4
        maSignatureLineSuggestedSignerTitle = rSuggestedSignerTitle;
234
4
    }
235
236
    const OUString& getSignatureLineSuggestedSignerTitle() const
237
0
    {
238
0
        return maSignatureLineSuggestedSignerTitle;
239
0
    }
240
241
    void setSignatureLineSuggestedSignerEmail(const OUString& rSuggestedSignerEmail)
242
4
    {
243
4
        maSignatureLineSuggestedSignerEmail = rSuggestedSignerEmail;
244
4
    }
245
    const OUString& getSignatureLineSuggestedSignerEmail() const
246
0
    {
247
0
        return maSignatureLineSuggestedSignerEmail;
248
0
    }
249
250
    void setSignatureLineSigningInstructions(const OUString& rSigningInstructions)
251
4
    {
252
4
        maSignatureLineSigningInstructions = rSigningInstructions;
253
4
    }
254
255
    const OUString& getSignatureLineSigningInstructions() const
256
0
    {
257
0
        return maSignatureLineSigningInstructions;
258
0
    }
259
260
    void setSignatureLineShowSignDate(bool bIsSignatureLineShowSignDate)
261
4
    {
262
4
        mbIsSignatureLineShowSignDate = bIsSignatureLineShowSignDate;
263
4
    }
264
265
0
    bool isSignatureLineShowSignDate() const { return mbIsSignatureLineShowSignDate; }
266
267
    void setSignatureLineCanAddComment(bool bIsSignatureCanAddComment)
268
4
    {
269
4
        mbIsSignatureLineCanAddComment = bIsSignatureCanAddComment;
270
4
    }
271
272
0
    bool isSignatureLineCanAddComment() const { return mbIsSignatureLineCanAddComment; }
273
274
    css::uno::Reference<css::graphic::XGraphic> const & getSignatureLineUnsignedGraphic() const
275
0
    {
276
0
        return mpSignatureLineUnsignedGraphic;
277
0
    }
278
279
    void setSignatureLineUnsignedGraphic(const css::uno::Reference<css::graphic::XGraphic>& rGraphic)
280
1
    {
281
1
        mpSignatureLineUnsignedGraphic = rGraphic;
282
1
    }
283
284
0
    bool isSignatureLineSigned() const { return mbSignatureLineIsSigned; }
285
286
4
    void setSignatureLineIsSigned(bool bIsSigned) { mbSignatureLineIsSigned = bIsSigned; }
287
288
    // Qr Code
289
    void setQrCode(css::drawing::BarCode& rBarCode)
290
0
    {
291
0
        mpBarCode = std::make_unique<css::drawing::BarCode>(rBarCode);
292
0
    }
293
294
    css::drawing::BarCode* getQrCode() const
295
199
    {
296
199
        return mpBarCode.get();
297
199
    }
298
};
299
300
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */