Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/include/svx/svdograf.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 <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
128
    SAL_DLLPRIVATE void                    NbcSetGraphic(const Graphic& rGrf);
129
    void                    SetGraphic(const Graphic& rGrf);
130
    const Graphic&          GetGraphic() const;
131
132
    Graphic                 GetTransformedGraphic( SdrGrafObjTransformsAttrs nTransformFlags = SdrGrafObjTransformsAttrs::ALL ) const;
133
134
    GraphicType             GetGraphicType() const;
135
136
    GraphicAttr             GetGraphicAttr( SdrGrafObjTransformsAttrs nTransformFlags = SdrGrafObjTransformsAttrs::ALL  ) const;
137
138
    // Keep ATM for SD.
139
    bool IsAnimated() const;
140
    bool IsEPS() const;
141
142
    SAL_DLLPRIVATE MapMode          GetGrafPrefMapMode() const;
143
    SAL_DLLPRIVATE Size             GetGrafPrefSize() const;
144
145
    SAL_DLLPRIVATE void                    SetGrafStreamURL( const OUString& rGraphicStreamURL );
146
    SAL_DLLPRIVATE OUString const &        GetGrafStreamURL() const;
147
    Size                    getOriginalSize() const;
148
149
private:
150
    SAL_DLLPRIVATE void                    ForceSwapIn() const;
151
152
public:
153
    void                    SetGraphicLink(const OUString& rFileName);
154
    void                    ReleaseGraphicLink();
155
    bool IsLinkedGraphic() const;
156
157
133
    const OUString& GetFileName() const { return m_aFileName;}
158
159
    void                    StartAnimation();
160
161
    SAL_DLLPRIVATE virtual void            TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
162
    SAL_DLLPRIVATE virtual SdrObjKind      GetObjIdentifier() const override;
163
164
    SAL_DLLPRIVATE virtual OUString        TakeObjNameSingul() const override;
165
    SAL_DLLPRIVATE virtual OUString        TakeObjNamePlural() const override;
166
167
    virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
168
169
    SAL_DLLPRIVATE virtual sal_uInt32 GetHdlCount() const override;
170
    SAL_DLLPRIVATE virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
171
172
    virtual void            NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
173
    SAL_DLLPRIVATE virtual void            NbcMirror(const Point& rRef1, const Point& rRef2) override;
174
    SAL_DLLPRIVATE virtual std::unique_ptr<SdrObjGeoData>  NewGeoData() const override;
175
    SAL_DLLPRIVATE virtual void            SaveGeoData(SdrObjGeoData& rGeo) const override;
176
    SAL_DLLPRIVATE virtual void            RestoreGeoData(const SdrObjGeoData& rGeo) override;
177
178
    bool                    HasGDIMetaFile() const;
179
180
    // react on model/page change
181
    SAL_DLLPRIVATE virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;
182
183
    bool isEmbeddedVectorGraphicData() const;
184
    GDIMetaFile getMetafileFromEmbeddedVectorGraphicData() const;
185
186
    SAL_DLLPRIVATE virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
187
188
    virtual void            AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly = false ) override;
189
190
   SAL_DLLPRIVATE  virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
191
192
697
    bool IsMirrored() const { return m_bMirrored;}
193
    SAL_DLLPRIVATE void SetMirrored( bool _bMirrored );
194
195
0
    virtual bool shouldKeepAspectRatio() const override { return true; }
196
197
    // Access to GrafAnimationAllowed flag
198
    SAL_DLLPRIVATE void SetGrafAnimationAllowed(bool bNew);
199
200
    SAL_DLLPRIVATE css::uno::Reference< css::io::XInputStream > getInputStream() const;
201
202
    // #i103116# FullDrag support
203
    SAL_DLLPRIVATE virtual rtl::Reference<SdrObject> getFullDragClone() const override;
204
205
    // add handles for crop mode when selected
206
    SAL_DLLPRIVATE virtual void addCropHandles(SdrHdlList& rTarget) const override;
207
208
    // Signature Line
209
3
    void setIsSignatureLine(bool bIsSignatureLine) { mbIsSignatureLine = bIsSignatureLine; }
210
0
    bool isSignatureLine() const { return mbIsSignatureLine; }
211
212
    void setSignatureLineId(const OUString& rSignatureLineId)
213
3
    {
214
3
        maSignatureLineId = rSignatureLineId;
215
3
    }
216
217
0
    const OUString& getSignatureLineId() const { return maSignatureLineId; }
218
219
    void setSignatureLineSuggestedSignerName(const OUString& rSuggestedSignerName)
220
3
    {
221
3
        maSignatureLineSuggestedSignerName = rSuggestedSignerName;
222
3
    }
223
224
    const OUString& getSignatureLineSuggestedSignerName() const
225
0
    {
226
0
        return maSignatureLineSuggestedSignerName;
227
0
    }
228
229
    void setSignatureLineSuggestedSignerTitle(const OUString& rSuggestedSignerTitle)
230
3
    {
231
3
        maSignatureLineSuggestedSignerTitle = rSuggestedSignerTitle;
232
3
    }
233
234
    const OUString& getSignatureLineSuggestedSignerTitle() const
235
0
    {
236
0
        return maSignatureLineSuggestedSignerTitle;
237
0
    }
238
239
    void setSignatureLineSuggestedSignerEmail(const OUString& rSuggestedSignerEmail)
240
3
    {
241
3
        maSignatureLineSuggestedSignerEmail = rSuggestedSignerEmail;
242
3
    }
243
    const OUString& getSignatureLineSuggestedSignerEmail() const
244
0
    {
245
0
        return maSignatureLineSuggestedSignerEmail;
246
0
    }
247
248
    void setSignatureLineSigningInstructions(const OUString& rSigningInstructions)
249
3
    {
250
3
        maSignatureLineSigningInstructions = rSigningInstructions;
251
3
    }
252
253
    const OUString& getSignatureLineSigningInstructions() const
254
0
    {
255
0
        return maSignatureLineSigningInstructions;
256
0
    }
257
258
    void setSignatureLineShowSignDate(bool bIsSignatureLineShowSignDate)
259
3
    {
260
3
        mbIsSignatureLineShowSignDate = bIsSignatureLineShowSignDate;
261
3
    }
262
263
0
    bool isSignatureLineShowSignDate() const { return mbIsSignatureLineShowSignDate; }
264
265
    void setSignatureLineCanAddComment(bool bIsSignatureCanAddComment)
266
3
    {
267
3
        mbIsSignatureLineCanAddComment = bIsSignatureCanAddComment;
268
3
    }
269
270
0
    bool isSignatureLineCanAddComment() const { return mbIsSignatureLineCanAddComment; }
271
272
    css::uno::Reference<css::graphic::XGraphic> const & getSignatureLineUnsignedGraphic() const
273
0
    {
274
0
        return mpSignatureLineUnsignedGraphic;
275
0
    }
276
277
    void setSignatureLineUnsignedGraphic(const css::uno::Reference<css::graphic::XGraphic>& rGraphic)
278
2
    {
279
2
        mpSignatureLineUnsignedGraphic = rGraphic;
280
2
    }
281
282
0
    bool isSignatureLineSigned() const { return mbSignatureLineIsSigned; }
283
284
3
    void setSignatureLineIsSigned(bool bIsSigned) { mbSignatureLineIsSigned = bIsSigned; }
285
286
    // Qr Code
287
    void setQrCode(css::drawing::BarCode& rBarCode)
288
0
    {
289
0
        mpBarCode = std::make_unique<css::drawing::BarCode>(rBarCode);
290
0
    }
291
292
    css::drawing::BarCode* getQrCode() const
293
0
    {
294
0
        return mpBarCode.get();
295
0
    }
296
};
297
298
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */