Bump version to 6.4-15
[LibreOffice.git] / include / svx / svdograf.hxx
blob236267c42821a7d6fb220b2993b306dcab407724
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
32 #include <memory>
33 #include <cstddef>
35 namespace sdr
37 namespace properties
39 class GraphicProperties;
40 } // end of namespace properties
41 namespace contact
43 class ViewObjectContactOfGraphic;
44 } // end of namespace contact
45 } // end of namespace sdr
47 /**
48 * Options for GetTransformedGraphic()
50 enum class SdrGrafObjTransformsAttrs
52 NONE = 0x00,
53 MIRROR = 0x01,
54 ROTATE = 0x02,
55 ALL = 0x03,
57 namespace o3tl
59 template<> struct typed_flags<SdrGrafObjTransformsAttrs> : is_typed_flags<SdrGrafObjTransformsAttrs, 0x03> {};
62 class SdrGrafObjGeoData final : public SdrTextObjGeoData
64 public:
65 bool bMirrored;
67 SdrGrafObjGeoData()
68 : bMirrored(false)
73 class GraphicObject;
74 class SdrGraphicLink;
76 /**
77 * This class represents an embedded or linked bitmap graphic object.
79 class SVX_DLLPUBLIC SdrGrafObj : public SdrRectObj
81 private:
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
97 OUString aReferer;
98 OUString aFilterName;
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 DECL_LINK( ImpSwapHdl, const GraphicObject*, SvStream* );
123 DECL_LINK( ReplacementSwapHdl, const GraphicObject*, SvStream* );
124 void onGraphicChanged();
125 GDIMetaFile GetMetaFile(GraphicType &rGraphicType) const;
127 protected:
128 // protected destructor
129 virtual ~SdrGrafObj() override;
131 public:
132 SdrGrafObj(SdrModel& rSdrModel);
133 SdrGrafObj(
134 SdrModel& rSdrModel,
135 const Graphic& rGrf);
136 SdrGrafObj(
137 SdrModel& rSdrModel,
138 const Graphic& rGrf,
139 const tools::Rectangle& rRect);
141 void SetGraphicObject( const GraphicObject& rGrfObj );
142 const GraphicObject& GetGraphicObject(bool bForceSwapIn = false) const;
143 const GraphicObject* GetReplacementGraphicObject() const;
145 void NbcSetGraphic(const Graphic& rGrf);
146 void SetGraphic(const Graphic& rGrf);
147 const Graphic& GetGraphic() const;
149 Graphic GetTransformedGraphic( SdrGrafObjTransformsAttrs nTransformFlags = SdrGrafObjTransformsAttrs::ALL ) const;
151 GraphicType GetGraphicType() const;
153 GraphicAttr GetGraphicAttr( SdrGrafObjTransformsAttrs nTransformFlags = SdrGrafObjTransformsAttrs::ALL ) const;
155 // Keep ATM for SD.
156 bool IsAnimated() const;
157 bool IsEPS() const;
159 MapMode GetGrafPrefMapMode() const;
160 Size GetGrafPrefSize() const;
162 void SetGrafStreamURL( const OUString& rGraphicStreamURL );
163 OUString const & GetGrafStreamURL() const;
164 Size getOriginalSize() const;
166 private:
167 void ForceSwapIn() const;
169 public:
170 void SetGraphicLink(const OUString& rFileName, const OUString& rReferer, const OUString& rFilterName);
171 void ReleaseGraphicLink();
172 bool IsLinkedGraphic() const;
174 const OUString& GetFileName() const { return aFileName;}
176 void StartAnimation();
178 virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
179 virtual sal_uInt16 GetObjIdentifier() const override;
181 virtual OUString TakeObjNameSingul() const override;
182 virtual OUString TakeObjNamePlural() const override;
184 virtual SdrGrafObj* CloneSdrObject(SdrModel& rTargetModel) const override;
185 SdrGrafObj& operator=(const SdrGrafObj& rObj);
187 virtual sal_uInt32 GetHdlCount() const override;
188 virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
190 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
191 virtual void NbcMirror(const Point& rRef1, const Point& rRef2) override;
192 virtual SdrObjGeoData* NewGeoData() const override;
193 virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
194 virtual void RestGeoData(const SdrObjGeoData& rGeo) override;
196 bool HasGDIMetaFile() const;
198 // react on model/page change
199 virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;
201 bool isEmbeddedVectorGraphicData() const;
202 GDIMetaFile getMetafileFromEmbeddedVectorGraphicData() 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;
229 // Signature Line
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; }
290 // Qr Code
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: */