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