LibreOffice Module svx (master)  1
svdograf.hxx
Go to the documentation of this file.
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/QRCode.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 
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 
51 {
52 public:
53  bool bMirrored;
54 
56  : bMirrored(false)
57  {
58  }
59 };
60 
61 class GraphicObject;
62 class SdrGraphicLink;
63 
68 {
69 private:
70  // to allow sdr::properties::GraphicProperties access to SetXPolyDirty()
72 
73  // to allow sdr::contact::ViewObjectContactOfGraphic access to ImpUpdateGraphicLink()
75  friend class SdrExchangeView; // Only for a ForceSwapIn() call.
76  friend class SdrGraphicLink;
77 
78  virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
79  virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() override;
80 
81  void ImpSetAttrToGrafInfo(); // Copy values from the pool
83 
84  OUString aFileName; // If it's a Link, the filename can be found in here
85  OUString aFilterName;
86  std::unique_ptr<GraphicObject> mpGraphicObject; // In order to speed up output of bitmaps, especially rotated ones
87  std::unique_ptr<GraphicObject> mpReplacementGraphicObject;
88  SdrGraphicLink* pGraphicLink; // And here a pointer for linked graphics
89  bool bMirrored:1; // True: the graphic is horizontal, which means it's mirrored along the y-axis
90 
91  // Flag for allowing text animation. Default is true.
92  bool mbGrafAnimationAllowed:1;
93 
103  css::uno::Reference<css::graphic::XGraphic> mpSignatureLineUnsignedGraphic;
104 
105  std::unique_ptr<css::drawing::QRCode> mpQrCode;
106  void ImpRegisterLink();
107  void ImpDeregisterLink();
108  void ImpSetLinkedGraphic( const Graphic& rGraphic );
109  void onGraphicChanged();
110  GDIMetaFile GetMetaFile(GraphicType &rGraphicType) const;
111 
112  // protected destructor
113  virtual ~SdrGrafObj() override;
114 
115 public:
116  SdrGrafObj(SdrModel& rSdrModel);
117  // Copy constructor
118  SdrGrafObj(SdrModel& rSdrModel, SdrGrafObj const & rSource);
119  SdrGrafObj(
120  SdrModel& rSdrModel,
121  const Graphic& rGrf);
122  SdrGrafObj(
123  SdrModel& rSdrModel,
124  const Graphic& rGrf,
125  const tools::Rectangle& rRect);
126 
127  void SetGraphicObject( const GraphicObject& rGrfObj );
128  const GraphicObject& GetGraphicObject(bool bForceSwapIn = false) const;
129  const GraphicObject* GetReplacementGraphicObject() const;
130 
131  void NbcSetGraphic(const Graphic& rGrf);
132  void SetGraphic(const Graphic& rGrf);
133  const Graphic& GetGraphic() const;
134 
135  Graphic GetTransformedGraphic( SdrGrafObjTransformsAttrs nTransformFlags = SdrGrafObjTransformsAttrs::ALL ) const;
136 
137  GraphicType GetGraphicType() const;
138 
139  GraphicAttr GetGraphicAttr( SdrGrafObjTransformsAttrs nTransformFlags = SdrGrafObjTransformsAttrs::ALL ) const;
140 
141  // Keep ATM for SD.
142  bool IsAnimated() const;
143  bool IsEPS() const;
144 
145  MapMode GetGrafPrefMapMode() const;
146  Size GetGrafPrefSize() const;
147 
148  void SetGrafStreamURL( const OUString& rGraphicStreamURL );
149  OUString const & GetGrafStreamURL() const;
150  Size getOriginalSize() const;
151 
152 private:
153  void ForceSwapIn() const;
154 
155 public:
156  void SetGraphicLink(const OUString& rFileName);
157  void ReleaseGraphicLink();
158  bool IsLinkedGraphic() const;
159 
160  const OUString& GetFileName() const { return aFileName;}
161 
162  void StartAnimation();
163 
164  virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
165  virtual SdrObjKind GetObjIdentifier() const override;
166 
167  virtual OUString TakeObjNameSingul() const override;
168  virtual OUString TakeObjNamePlural() const override;
169 
170  virtual SdrGrafObj* CloneSdrObject(SdrModel& rTargetModel) const override;
171 
172  virtual sal_uInt32 GetHdlCount() const override;
173  virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
174 
175  virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
176  virtual void NbcMirror(const Point& rRef1, const Point& rRef2) override;
177  virtual std::unique_ptr<SdrObjGeoData> NewGeoData() const override;
178  virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
179  virtual void RestoreGeoData(const SdrObjGeoData& rGeo) override;
180 
181  bool HasGDIMetaFile() const;
182 
183  // react on model/page change
184  virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;
185 
186  bool isEmbeddedVectorGraphicData() const;
187  GDIMetaFile getMetafileFromEmbeddedVectorGraphicData() const;
188 
189  virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
190 
191  virtual void AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly = false ) override;
192 
193  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
194 
195  bool IsMirrored() const { return bMirrored;}
196  void SetMirrored( bool _bMirrored );
197 
198  virtual bool shouldKeepAspectRatio() const override { return true; }
199 
200  // Access to GrafAnimationAllowed flag
201  void SetGrafAnimationAllowed(bool bNew);
202 
203  css::uno::Reference< css::io::XInputStream > getInputStream() const;
204 
205  // #i103116# FullDrag support
206  virtual SdrObjectUniquePtr getFullDragClone() const override;
207 
208  // add handles for crop mode when selected
209  virtual void addCropHandles(SdrHdlList& rTarget) const override;
210 
211  // Signature Line
212  void setIsSignatureLine(bool bIsSignatureLine) { mbIsSignatureLine = bIsSignatureLine; }
213  bool isSignatureLine() const { return mbIsSignatureLine; }
214 
215  void setSignatureLineId(const OUString& rSignatureLineId)
216  {
217  maSignatureLineId = rSignatureLineId;
218  }
219 
220  const OUString& getSignatureLineId() const { return maSignatureLineId; }
221 
222  void setSignatureLineSuggestedSignerName(const OUString& rSuggestedSignerName)
223  {
224  maSignatureLineSuggestedSignerName = rSuggestedSignerName;
225  }
226 
227  const OUString& getSignatureLineSuggestedSignerName() const
228  {
229  return maSignatureLineSuggestedSignerName;
230  }
231 
232  void setSignatureLineSuggestedSignerTitle(const OUString& rSuggestedSignerTitle)
233  {
234  maSignatureLineSuggestedSignerTitle = rSuggestedSignerTitle;
235  }
236 
237  const OUString& getSignatureLineSuggestedSignerTitle() const
238  {
239  return maSignatureLineSuggestedSignerTitle;
240  }
241 
242  void setSignatureLineSuggestedSignerEmail(const OUString& rSuggestedSignerEmail)
243  {
244  maSignatureLineSuggestedSignerEmail = rSuggestedSignerEmail;
245  }
246  const OUString& getSignatureLineSuggestedSignerEmail() const
247  {
248  return maSignatureLineSuggestedSignerEmail;
249  }
250 
251  void setSignatureLineSigningInstructions(const OUString& rSigningInstructions)
252  {
253  maSignatureLineSigningInstructions = rSigningInstructions;
254  }
255 
256  const OUString& getSignatureLineSigningInstructions() const
257  {
258  return maSignatureLineSigningInstructions;
259  }
260 
261  void setSignatureLineShowSignDate(bool bIsSignatureLineShowSignDate)
262  {
263  mbIsSignatureLineShowSignDate = bIsSignatureLineShowSignDate;
264  }
265 
266  bool isSignatureLineShowSignDate() const { return mbIsSignatureLineShowSignDate; }
267 
268  void setSignatureLineCanAddComment(bool bIsSignatureCanAddComment)
269  {
270  mbIsSignatureLineCanAddComment = bIsSignatureCanAddComment;
271  }
272 
273  bool isSignatureLineCanAddComment() const { return mbIsSignatureLineCanAddComment; }
274 
275  css::uno::Reference<css::graphic::XGraphic> const & getSignatureLineUnsignedGraphic() const
276  {
277  return mpSignatureLineUnsignedGraphic;
278  }
279 
280  void setSignatureLineUnsignedGraphic(css::uno::Reference<css::graphic::XGraphic> rGraphic)
281  {
282  mpSignatureLineUnsignedGraphic = rGraphic;
283  }
284 
285  bool isSignatureLineSigned() const { return mbSignatureLineIsSigned; }
286 
287  void setSignatureLineIsSigned(bool bIsSigned) { mbSignatureLineIsSigned = bIsSigned; }
288 
289  // Qr Code
290  void setQrCode(css::drawing::QRCode& rQrCode)
291  {
292  mpQrCode = std::make_unique<css::drawing::QRCode>(rQrCode);
293  }
294 
295  css::drawing::QRCode* getQrCode() const
296  {
297  return mpQrCode.get();
298  }
299 };
300 
301 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString aFilterName
Definition: svdograf.hxx:85
void SetMirrored(tools::Long &nPageLeftMargin, tools::Long &nPageRightMargin, tools::Long &nPageTopMargin, tools::Long &nPageBottomMargin, bool &bMirrored)
bool mbIsSignatureLineCanAddComment
Definition: svdograf.hxx:101
OUString maSignatureLineId
Definition: svdograf.hxx:95
virtual void RestoreGeoData(const SdrObjGeoData &rGeo) override
Definition: svdorect.cxx:562
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: svdorect.cxx:40
const OUString & GetFileName() const
Definition: svdograf.hxx:160
virtual void NbcMirror(const Point &rRef1, const Point &rRef2) override
Definition: svdorect.cxx:470
void setSignatureLineSuggestedSignerName(const OUString &rSuggestedSignerName)
Definition: svdograf.hxx:222
void setIsSignatureLine(bool bIsSignatureLine)
Definition: svdograf.hxx:212
virtual OUString TakeObjNameSingul() const override
Definition: svdorect.cxx:201
GraphicType
void setSignatureLineSuggestedSignerEmail(const OUString &rSuggestedSignerEmail)
Definition: svdograf.hxx:242
virtual void addCropHandles(SdrHdlList &rTarget) const
Definition: svdobj.cxx:1252
SVX_DLLPRIVATE void ImpDeregisterLink()
Definition: svdotxln.cxx:266
OUString aFileName
Definition: svdograf.hxx:84
void setSignatureLineCanAddComment(bool bIsSignatureCanAddComment)
Definition: svdograf.hxx:268
virtual bool shouldKeepAspectRatio() const override
Whether the aspect ratio should be kept by default when resizing.
Definition: svdograf.hxx:198
std::unique_ptr< GraphicObject > mpGraphicObject
Definition: svdograf.hxx:86
OUString maSignatureLineSuggestedSignerEmail
Definition: svdograf.hxx:98
virtual SdrObjectUniquePtr getFullDragClone() const override
Definition: svdotext.cxx:2042
All geometrical data of an arbitrary object for use in undo/redo.
Definition: svdobj.hxx:173
const OUString & getSignatureLineSigningInstructions() const
Definition: svdograf.hxx:256
SdrObjKind
Definition: svdobjkind.hxx:24
bool isSignatureLineCanAddComment() const
Definition: svdograf.hxx:273
Rectangle objects (rectangle, circle, ...)
Definition: svdorect.hxx:38
Provides information about various ZObject properties.
Definition: svdobj.hxx:195
virtual void SaveGeoData(SdrObjGeoData &rGeo) const override
Definition: svdotext.cxx:1408
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override
Definition: svdorect.cxx:528
bool isSignatureLine() const
Definition: svdograf.hxx:213
bool mbSignatureLineIsSigned
Definition: svdograf.hxx:102
void setSignatureLineShowSignDate(bool bIsSignatureLineShowSignDate)
Definition: svdograf.hxx:261
OUString maSignatureLineSigningInstructions
Definition: svdograf.hxx:99
virtual void handlePageChange(SdrPage *pOldPage, SdrPage *pNewPage) override
Definition: svdotext.cxx:489
OUString maSignatureLineSuggestedSignerName
Definition: svdograf.hxx:96
css::uno::Reference< css::graphic::XGraphic > mpSignatureLineUnsignedGraphic
Definition: svdograf.hxx:103
virtual sal_uInt32 GetHdlCount() const override
Via GetHdlCount the number of Handles can be retrieved.
Definition: svdorect.cxx:282
virtual void AdjustToMaxRect(const tools::Rectangle &rMaxRect, bool bShrinkOnly=false)
Definition: svdobj.cxx:1686
bool mbIsSignatureLine
Definition: svdograf.hxx:94
SdrGraphicLink * pGraphicLink
Definition: svdograf.hxx:88
void setSignatureLineSigningInstructions(const OUString &rSigningInstructions)
Definition: svdograf.hxx:251
void setSignatureLineSuggestedSignerTitle(const OUString &rSuggestedSignerTitle)
Definition: svdograf.hxx:232
void setSignatureLineUnsignedGraphic(css::uno::Reference< css::graphic::XGraphic > rGraphic)
Definition: svdograf.hxx:280
void setQrCode(css::drawing::QRCode &rQrCode)
Definition: svdograf.hxx:290
This class represents an embedded or linked bitmap graphic object.
Definition: svdograf.hxx:67
void setSignatureLineIsSigned(bool bIsSigned)
Definition: svdograf.hxx:287
SdrGrafObjTransformsAttrs
Options for GetTransformedGraphic()
Definition: svdograf.hxx:38
SVX_DLLPRIVATE void ImpRegisterLink()
Definition: svdotxln.cxx:254
const OUString & getSignatureLineSuggestedSignerName() const
Definition: svdograf.hxx:227
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const override
Definition: svdorect.cxx:146
const OUString & getSignatureLineSuggestedSignerTitle() const
Definition: svdograf.hxx:237
std::unique_ptr< css::drawing::QRCode > mpQrCode
Definition: svdograf.hxx:105
virtual SdrRectObj * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: svdorect.cxx:248
virtual SdrObjKind GetObjIdentifier() const override
Definition: svdorect.cxx:172
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: svdorect.cxx:48
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
Definition: svdorect.cxx:452
css::drawing::QRCode * getQrCode() const
Definition: svdograf.hxx:295
std::unique_ptr< GraphicObject > mpReplacementGraphicObject
Definition: svdograf.hxx:87
css::uno::Reference< css::graphic::XGraphic > const & getSignatureLineUnsignedGraphic() const
Definition: svdograf.hxx:275
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
void setSignatureLineId(const OUString &rSignatureLineId)
Definition: svdograf.hxx:215
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:97
bool isSignatureLineShowSignDate() const
Definition: svdograf.hxx:266
GraphicAttr aGrafInfo
Definition: svdograf.hxx:82
virtual void AddToHdlList(SdrHdlList &rHdlList) const override
Definition: svdorect.cxx:287
bool IsMirrored() const
Definition: svdograf.hxx:195
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365
const OUString & getSignatureLineId() const
Definition: svdograf.hxx:220
bool isSignatureLineSigned() const
Definition: svdograf.hxx:285
OUString maSignatureLineSuggestedSignerTitle
Definition: svdograf.hxx:97
const OUString & getSignatureLineSuggestedSignerEmail() const
Definition: svdograf.hxx:246
bool mbIsSignatureLineShowSignDate
Definition: svdograf.hxx:100
virtual std::unique_ptr< SdrObjGeoData > NewGeoData() const override
A derived class must override these 3 methods if it has own geometric data that must be saved for Und...
Definition: svdotext.cxx:1403
virtual OUString TakeObjNamePlural() const override
Definition: svdorect.cxx:227
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Detects when a stylesheet is changed.
Definition: svdorect.cxx:556