tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / include / svx / svdograf.hxx
blobfae28c0a72dcd200007f6a8bde67070e5d7ef6d3
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 #pragma once
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>
32 namespace sdr::properties { class GraphicProperties; }
33 namespace sdr::contact { class ViewObjectContactOfGraphic; }
35 /**
36 * Options for GetTransformedGraphic()
38 enum class SdrGrafObjTransformsAttrs
40 NONE = 0x00,
41 MIRROR = 0x01,
42 ROTATE = 0x02,
43 ALL = 0x03,
45 namespace o3tl
47 template<> struct typed_flags<SdrGrafObjTransformsAttrs> : is_typed_flags<SdrGrafObjTransformsAttrs, 0x03> {};
50 class SdrGrafObjGeoData final : public SdrTextObjGeoData
52 public:
53 bool bMirrored;
55 SdrGrafObjGeoData()
56 : bMirrored(false)
61 class GraphicObject;
62 class SdrGraphicLink;
64 /**
65 * This class represents an embedded or linked bitmap graphic object.
67 class SVXCORE_DLLPUBLIC SdrGrafObj final : public SdrRectObj
69 private:
70 // to allow sdr::properties::GraphicProperties access to SetXPolyDirty()
71 friend class sdr::properties::GraphicProperties;
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;
78 SAL_DLLPRIVATE virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
79 SAL_DLLPRIVATE virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() override;
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
88 // Flag for allowing text animation. Default is true.
89 bool mbGrafAnimationAllowed:1;
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;
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;
109 // protected destructor
110 SAL_DLLPRIVATE virtual ~SdrGrafObj() override;
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);
124 void SetGraphicObject( const GraphicObject& rGrfObj );
125 const GraphicObject& GetGraphicObject(bool bForceSwapIn = false) const;
126 SAL_DLLPRIVATE const GraphicObject* GetReplacementGraphicObject() const;
128 SAL_DLLPRIVATE void NbcSetGraphic(const Graphic& rGrf);
129 void SetGraphic(const Graphic& rGrf);
130 const Graphic& GetGraphic() const;
132 Graphic GetTransformedGraphic( SdrGrafObjTransformsAttrs nTransformFlags = SdrGrafObjTransformsAttrs::ALL ) const;
134 GraphicType GetGraphicType() const;
136 GraphicAttr GetGraphicAttr( SdrGrafObjTransformsAttrs nTransformFlags = SdrGrafObjTransformsAttrs::ALL ) const;
138 // Keep ATM for SD.
139 bool IsAnimated() const;
140 bool IsEPS() const;
142 SAL_DLLPRIVATE MapMode GetGrafPrefMapMode() const;
143 SAL_DLLPRIVATE Size GetGrafPrefSize() const;
145 SAL_DLLPRIVATE void SetGrafStreamURL( const OUString& rGraphicStreamURL );
146 SAL_DLLPRIVATE OUString const & GetGrafStreamURL() const;
147 Size getOriginalSize() const;
149 private:
150 SAL_DLLPRIVATE void ForceSwapIn() const;
152 public:
153 void SetGraphicLink(const OUString& rFileName);
154 void ReleaseGraphicLink();
155 bool IsLinkedGraphic() const;
157 const OUString& GetFileName() const { return m_aFileName;}
159 void StartAnimation();
161 SAL_DLLPRIVATE virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
162 SAL_DLLPRIVATE virtual SdrObjKind GetObjIdentifier() const override;
164 SAL_DLLPRIVATE virtual OUString TakeObjNameSingul() const override;
165 SAL_DLLPRIVATE virtual OUString TakeObjNamePlural() const override;
167 virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
169 SAL_DLLPRIVATE virtual sal_uInt32 GetHdlCount() const override;
170 SAL_DLLPRIVATE virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
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;
178 bool HasGDIMetaFile() const;
180 // react on model/page change
181 SAL_DLLPRIVATE virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;
183 bool isEmbeddedVectorGraphicData() const;
184 GDIMetaFile getMetafileFromEmbeddedVectorGraphicData() const;
186 SAL_DLLPRIVATE virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
188 virtual void AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly = false ) override;
190 SAL_DLLPRIVATE virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
192 bool IsMirrored() const { return m_bMirrored;}
193 SAL_DLLPRIVATE void SetMirrored( bool _bMirrored );
195 virtual bool shouldKeepAspectRatio() const override { return true; }
197 // Access to GrafAnimationAllowed flag
198 SAL_DLLPRIVATE void SetGrafAnimationAllowed(bool bNew);
200 SAL_DLLPRIVATE css::uno::Reference< css::io::XInputStream > getInputStream() const;
202 // #i103116# FullDrag support
203 SAL_DLLPRIVATE virtual rtl::Reference<SdrObject> getFullDragClone() const override;
205 // add handles for crop mode when selected
206 SAL_DLLPRIVATE virtual void addCropHandles(SdrHdlList& rTarget) const override;
208 // Signature Line
209 void setIsSignatureLine(bool bIsSignatureLine) { mbIsSignatureLine = bIsSignatureLine; }
210 bool isSignatureLine() const { return mbIsSignatureLine; }
212 void setSignatureLineId(const OUString& rSignatureLineId)
214 maSignatureLineId = rSignatureLineId;
217 const OUString& getSignatureLineId() const { return maSignatureLineId; }
219 void setSignatureLineSuggestedSignerName(const OUString& rSuggestedSignerName)
221 maSignatureLineSuggestedSignerName = rSuggestedSignerName;
224 const OUString& getSignatureLineSuggestedSignerName() const
226 return maSignatureLineSuggestedSignerName;
229 void setSignatureLineSuggestedSignerTitle(const OUString& rSuggestedSignerTitle)
231 maSignatureLineSuggestedSignerTitle = rSuggestedSignerTitle;
234 const OUString& getSignatureLineSuggestedSignerTitle() const
236 return maSignatureLineSuggestedSignerTitle;
239 void setSignatureLineSuggestedSignerEmail(const OUString& rSuggestedSignerEmail)
241 maSignatureLineSuggestedSignerEmail = rSuggestedSignerEmail;
243 const OUString& getSignatureLineSuggestedSignerEmail() const
245 return maSignatureLineSuggestedSignerEmail;
248 void setSignatureLineSigningInstructions(const OUString& rSigningInstructions)
250 maSignatureLineSigningInstructions = rSigningInstructions;
253 const OUString& getSignatureLineSigningInstructions() const
255 return maSignatureLineSigningInstructions;
258 void setSignatureLineShowSignDate(bool bIsSignatureLineShowSignDate)
260 mbIsSignatureLineShowSignDate = bIsSignatureLineShowSignDate;
263 bool isSignatureLineShowSignDate() const { return mbIsSignatureLineShowSignDate; }
265 void setSignatureLineCanAddComment(bool bIsSignatureCanAddComment)
267 mbIsSignatureLineCanAddComment = bIsSignatureCanAddComment;
270 bool isSignatureLineCanAddComment() const { return mbIsSignatureLineCanAddComment; }
272 css::uno::Reference<css::graphic::XGraphic> const & getSignatureLineUnsignedGraphic() const
274 return mpSignatureLineUnsignedGraphic;
277 void setSignatureLineUnsignedGraphic(const css::uno::Reference<css::graphic::XGraphic>& rGraphic)
279 mpSignatureLineUnsignedGraphic = rGraphic;
282 bool isSignatureLineSigned() const { return mbSignatureLineIsSigned; }
284 void setSignatureLineIsSigned(bool bIsSigned) { mbSignatureLineIsSigned = bIsSigned; }
286 // Qr Code
287 void setQrCode(css::drawing::BarCode& rBarCode)
289 mpBarCode = std::make_unique<css::drawing::BarCode>(rBarCode);
292 css::drawing::BarCode* getQrCode() const
294 return mpBarCode.get();
298 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */