1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVX_SVDOGRAF_HXX
21 #define INCLUDED_SVX_SVDOGRAF_HXX
23 #include <com/sun/star/io/XInputStream.hpp>
24 #include <com/sun/star/graphic/XGraphic.hpp>
25 #include <com/sun/star/drawing/QRCode.hpp>
26 #include <com/sun/star/uno/Sequence.hxx>
27 #include <vcl/graph.hxx>
28 #include <svx/svdorect.hxx>
29 #include <vcl/GraphicObject.hxx>
30 #include <svx/svxdllapi.h>
31 #include <o3tl/typed_flags_set.hxx>
39 class GraphicProperties
;
40 } // end of namespace properties
43 class ViewObjectContactOfGraphic
;
44 } // end of namespace contact
45 } // end of namespace sdr
48 * Options for GetTransformedGraphic()
50 enum class SdrGrafObjTransformsAttrs
59 template<> struct typed_flags
<SdrGrafObjTransformsAttrs
> : is_typed_flags
<SdrGrafObjTransformsAttrs
, 0x03> {};
62 class SdrGrafObjGeoData final
: public SdrTextObjGeoData
77 * This class represents an embedded or linked bitmap graphic object.
79 class SVXCORE_DLLPUBLIC SdrGrafObj
: public SdrRectObj
82 // to allow sdr::properties::GraphicProperties access to SetXPolyDirty()
83 friend class sdr::properties::GraphicProperties
;
85 // to allow sdr::contact::ViewObjectContactOfGraphic access to ImpUpdateGraphicLink()
86 friend class sdr::contact::ViewObjectContactOfGraphic
;
87 friend class SdrExchangeView
; // Only for a ForceSwapIn() call.
88 friend class SdrGraphicLink
;
90 virtual std::unique_ptr
<sdr::contact::ViewContact
> CreateObjectSpecificViewContact() override
;
91 virtual std::unique_ptr
<sdr::properties::BaseProperties
> CreateObjectSpecificProperties() override
;
93 void ImpSetAttrToGrafInfo(); // Copy values from the pool
94 GraphicAttr aGrafInfo
;
96 OUString aFileName
; // If it's a Link, the filename can be found in here
99 std::unique_ptr
<GraphicObject
> mpGraphicObject
; // In order to speed up output of bitmaps, especially rotated ones
100 std::unique_ptr
<GraphicObject
> mpReplacementGraphicObject
;
101 SdrGraphicLink
* pGraphicLink
; // And here a pointer for linked graphics
102 bool bMirrored
:1; // True: the graphic is horizontal, which means it's mirrored along the y-axis
104 // Flag for allowing text animation. Default is true.
105 bool mbGrafAnimationAllowed
:1;
107 bool mbIsSignatureLine
;
108 OUString maSignatureLineId
;
109 OUString maSignatureLineSuggestedSignerName
;
110 OUString maSignatureLineSuggestedSignerTitle
;
111 OUString maSignatureLineSuggestedSignerEmail
;
112 OUString maSignatureLineSigningInstructions
;
113 bool mbIsSignatureLineShowSignDate
;
114 bool mbIsSignatureLineCanAddComment
;
115 bool mbSignatureLineIsSigned
;
116 css::uno::Reference
<css::graphic::XGraphic
> mpSignatureLineUnsignedGraphic
;
118 std::unique_ptr
<css::drawing::QRCode
> mpQrCode
;
119 void ImpRegisterLink();
120 void ImpDeregisterLink();
121 void ImpSetLinkedGraphic( const Graphic
& rGraphic
);
122 void onGraphicChanged();
123 GDIMetaFile
GetMetaFile(GraphicType
&rGraphicType
) const;
126 // protected destructor
127 virtual ~SdrGrafObj() override
;
130 SdrGrafObj(SdrModel
& rSdrModel
);
133 const Graphic
& rGrf
);
137 const tools::Rectangle
& rRect
);
139 void SetGraphicObject( const GraphicObject
& rGrfObj
);
140 const GraphicObject
& GetGraphicObject(bool bForceSwapIn
= false) const;
141 const GraphicObject
* GetReplacementGraphicObject() const;
143 void NbcSetGraphic(const Graphic
& rGrf
);
144 void SetGraphic(const Graphic
& rGrf
);
145 const Graphic
& GetGraphic() const;
147 Graphic
GetTransformedGraphic( SdrGrafObjTransformsAttrs nTransformFlags
= SdrGrafObjTransformsAttrs::ALL
) const;
149 GraphicType
GetGraphicType() const;
151 GraphicAttr
GetGraphicAttr( SdrGrafObjTransformsAttrs nTransformFlags
= SdrGrafObjTransformsAttrs::ALL
) const;
154 bool IsAnimated() const;
157 MapMode
GetGrafPrefMapMode() const;
158 Size
GetGrafPrefSize() const;
160 void SetGrafStreamURL( const OUString
& rGraphicStreamURL
);
161 OUString
const & GetGrafStreamURL() const;
162 Size
getOriginalSize() const;
165 void ForceSwapIn() const;
168 void SetGraphicLink(const OUString
& rFileName
, const OUString
& rReferer
, const OUString
& rFilterName
);
169 void ReleaseGraphicLink();
170 bool IsLinkedGraphic() const;
172 const OUString
& GetFileName() const { return aFileName
;}
174 void StartAnimation();
176 virtual void TakeObjInfo(SdrObjTransformInfoRec
& rInfo
) const override
;
177 virtual sal_uInt16
GetObjIdentifier() const override
;
179 virtual OUString
TakeObjNameSingul() const override
;
180 virtual OUString
TakeObjNamePlural() const override
;
182 virtual SdrGrafObj
* CloneSdrObject(SdrModel
& rTargetModel
) const override
;
183 SdrGrafObj
& operator=(const SdrGrafObj
& rObj
);
185 virtual sal_uInt32
GetHdlCount() const override
;
186 virtual void AddToHdlList(SdrHdlList
& rHdlList
) const override
;
188 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) override
;
189 virtual void NbcMirror(const Point
& rRef1
, const Point
& rRef2
) override
;
190 virtual SdrObjGeoData
* NewGeoData() const override
;
191 virtual void SaveGeoData(SdrObjGeoData
& rGeo
) const override
;
192 virtual void RestGeoData(const SdrObjGeoData
& rGeo
) override
;
194 bool HasGDIMetaFile() const;
196 // react on model/page change
197 virtual void handlePageChange(SdrPage
* pOldPage
, SdrPage
* pNewPage
) override
;
199 bool isEmbeddedVectorGraphicData() const;
200 GDIMetaFile
getMetafileFromEmbeddedVectorGraphicData() const;
202 bool isEmbeddedPdfData() const;
203 const std::shared_ptr
<std::vector
<sal_Int8
>> & getEmbeddedPdfData() const;
204 /// Returns the page number of the embedded data (typically to re-render or import it).
205 sal_Int32
getEmbeddedPageNumber() const;
207 virtual SdrObjectUniquePtr
DoConvertToPolyObj(bool bBezier
, bool bAddText
) const override
;
209 virtual void AdjustToMaxRect( const tools::Rectangle
& rMaxRect
, bool bShrinkOnly
= false ) override
;
211 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
213 bool IsMirrored() const { return bMirrored
;}
214 void SetMirrored( bool _bMirrored
);
216 virtual bool shouldKeepAspectRatio() const override
{ return true; }
218 // Access to GrafAnimationAllowed flag
219 void SetGrafAnimationAllowed(bool bNew
);
221 css::uno::Reference
< css::io::XInputStream
> getInputStream() const;
223 // #i103116# FullDrag support
224 virtual SdrObjectUniquePtr
getFullDragClone() const override
;
226 // add handles for crop mode when selected
227 virtual void addCropHandles(SdrHdlList
& rTarget
) const override
;
230 void setIsSignatureLine(bool bIsSignatureLine
) { mbIsSignatureLine
= bIsSignatureLine
; };
231 bool isSignatureLine() const { return mbIsSignatureLine
; };
232 void setSignatureLineId(const OUString
& rSignatureLineId
)
234 maSignatureLineId
= rSignatureLineId
;
236 const OUString
& getSignatureLineId() const { return maSignatureLineId
; };
237 void setSignatureLineSuggestedSignerName(const OUString
& rSuggestedSignerName
)
239 maSignatureLineSuggestedSignerName
= rSuggestedSignerName
;
241 const OUString
& getSignatureLineSuggestedSignerName() const
243 return maSignatureLineSuggestedSignerName
;
245 void setSignatureLineSuggestedSignerTitle(const OUString
& rSuggestedSignerTitle
)
247 maSignatureLineSuggestedSignerTitle
= rSuggestedSignerTitle
;
249 const OUString
& getSignatureLineSuggestedSignerTitle() const
251 return maSignatureLineSuggestedSignerTitle
;
253 void setSignatureLineSuggestedSignerEmail(const OUString
& rSuggestedSignerEmail
)
255 maSignatureLineSuggestedSignerEmail
= rSuggestedSignerEmail
;
257 const OUString
& getSignatureLineSuggestedSignerEmail() const
259 return maSignatureLineSuggestedSignerEmail
;
261 void setSignatureLineSigningInstructions(const OUString
& rSigningInstructions
)
263 maSignatureLineSigningInstructions
= rSigningInstructions
;
265 const OUString
& getSignatureLineSigningInstructions() const
267 return maSignatureLineSigningInstructions
;
269 void setSignatureLineShowSignDate(bool bIsSignatureLineShowSignDate
)
271 mbIsSignatureLineShowSignDate
= bIsSignatureLineShowSignDate
;
273 bool isSignatureLineShowSignDate() const { return mbIsSignatureLineShowSignDate
; };
274 void setSignatureLineCanAddComment(bool bIsSignatureCanAddComment
)
276 mbIsSignatureLineCanAddComment
= bIsSignatureCanAddComment
;
278 bool isSignatureLineCanAddComment() const { return mbIsSignatureLineCanAddComment
; };
279 css::uno::Reference
<css::graphic::XGraphic
> const & getSignatureLineUnsignedGraphic() const
281 return mpSignatureLineUnsignedGraphic
;
283 void setSignatureLineUnsignedGraphic(css::uno::Reference
<css::graphic::XGraphic
> rGraphic
)
285 mpSignatureLineUnsignedGraphic
= rGraphic
;
287 bool isSignatureLineSigned() const { return mbSignatureLineIsSigned
; };
288 void setSignatureLineIsSigned(bool bIsSigned
) { mbSignatureLineIsSigned
= bIsSigned
; }
291 void setQrCode(css::drawing::QRCode
& rQrCode
)
293 mpQrCode
= std::make_unique
<css::drawing::QRCode
>(rQrCode
);
296 css::drawing::QRCode
* getQrCode() const
298 return mpQrCode
.get();
302 #endif // INCLUDED_SVX_SVDOGRAF_HXX
304 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */