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 aReferer;
96  OUString aFilterName;
97  std::unique_ptr<GraphicObject> mpGraphicObject; // In order to speed up output of bitmaps, especially rotated ones
98  std::unique_ptr<GraphicObject> mpReplacementGraphicObject;
99  SdrGraphicLink* pGraphicLink; // And here a pointer for linked graphics
100  bool bMirrored:1; // True: the graphic is horizontal, which means it's mirrored along the y-axis
101 
102  // Flag for allowing text animation. Default is true.
103  bool mbGrafAnimationAllowed:1;
104 
114  css::uno::Reference<css::graphic::XGraphic> mpSignatureLineUnsignedGraphic;
115 
116  std::unique_ptr<css::drawing::QRCode> mpQrCode;
117  void ImpRegisterLink();
118  void ImpDeregisterLink();
119  void ImpSetLinkedGraphic( const Graphic& rGraphic );
120  void onGraphicChanged();
121  GDIMetaFile GetMetaFile(GraphicType &rGraphicType) const;
122 
123 protected:
124  // protected destructor
125  virtual ~SdrGrafObj() override;
126 
127 public:
128  SdrGrafObj(SdrModel& rSdrModel);
129  SdrGrafObj(
130  SdrModel& rSdrModel,
131  const Graphic& rGrf);
132  SdrGrafObj(
133  SdrModel& rSdrModel,
134  const Graphic& rGrf,
135  const tools::Rectangle& rRect);
136 
137  void SetGraphicObject( const GraphicObject& rGrfObj );
138  const GraphicObject& GetGraphicObject(bool bForceSwapIn = false) const;
139  const GraphicObject* GetReplacementGraphicObject() const;
140 
141  void NbcSetGraphic(const Graphic& rGrf);
142  void SetGraphic(const Graphic& rGrf);
143  const Graphic& GetGraphic() const;
144 
145  Graphic GetTransformedGraphic( SdrGrafObjTransformsAttrs nTransformFlags = SdrGrafObjTransformsAttrs::ALL ) const;
146 
147  GraphicType GetGraphicType() const;
148 
149  GraphicAttr GetGraphicAttr( SdrGrafObjTransformsAttrs nTransformFlags = SdrGrafObjTransformsAttrs::ALL ) const;
150 
151  // Keep ATM for SD.
152  bool IsAnimated() const;
153  bool IsEPS() const;
154 
155  MapMode GetGrafPrefMapMode() const;
156  Size GetGrafPrefSize() const;
157 
158  void SetGrafStreamURL( const OUString& rGraphicStreamURL );
159  OUString const & GetGrafStreamURL() const;
160  Size getOriginalSize() const;
161 
162 private:
163  void ForceSwapIn() const;
164 
165 public:
166  void SetGraphicLink(const OUString& rFileName, const OUString& rReferer, const OUString& rFilterName);
167  void ReleaseGraphicLink();
168  bool IsLinkedGraphic() const;
169 
170  const OUString& GetFileName() const { return aFileName;}
171 
172  void StartAnimation();
173 
174  virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
175  virtual sal_uInt16 GetObjIdentifier() const override;
176 
177  virtual OUString TakeObjNameSingul() const override;
178  virtual OUString TakeObjNamePlural() const override;
179 
180  virtual SdrGrafObj* CloneSdrObject(SdrModel& rTargetModel) const override;
181  SdrGrafObj& operator=(const SdrGrafObj& rObj);
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 SdrObjGeoData* NewGeoData() const override;
189  virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
190  virtual void RestGeoData(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  void setSignatureLineId(const OUString& rSignatureLineId)
226  {
227  maSignatureLineId = rSignatureLineId;
228  };
229  const OUString& getSignatureLineId() const { return maSignatureLineId; };
230  void setSignatureLineSuggestedSignerName(const OUString& rSuggestedSignerName)
231  {
232  maSignatureLineSuggestedSignerName = rSuggestedSignerName;
233  };
234  const OUString& getSignatureLineSuggestedSignerName() const
235  {
236  return maSignatureLineSuggestedSignerName;
237  };
238  void setSignatureLineSuggestedSignerTitle(const OUString& rSuggestedSignerTitle)
239  {
240  maSignatureLineSuggestedSignerTitle = rSuggestedSignerTitle;
241  };
242  const OUString& getSignatureLineSuggestedSignerTitle() const
243  {
244  return maSignatureLineSuggestedSignerTitle;
245  };
246  void setSignatureLineSuggestedSignerEmail(const OUString& rSuggestedSignerEmail)
247  {
248  maSignatureLineSuggestedSignerEmail = rSuggestedSignerEmail;
249  };
250  const OUString& getSignatureLineSuggestedSignerEmail() const
251  {
252  return maSignatureLineSuggestedSignerEmail;
253  };
254  void setSignatureLineSigningInstructions(const OUString& rSigningInstructions)
255  {
256  maSignatureLineSigningInstructions = rSigningInstructions;
257  };
258  const OUString& getSignatureLineSigningInstructions() const
259  {
260  return maSignatureLineSigningInstructions;
261  };
262  void setSignatureLineShowSignDate(bool bIsSignatureLineShowSignDate)
263  {
264  mbIsSignatureLineShowSignDate = bIsSignatureLineShowSignDate;
265  };
266  bool isSignatureLineShowSignDate() const { return mbIsSignatureLineShowSignDate; };
267  void setSignatureLineCanAddComment(bool bIsSignatureCanAddComment)
268  {
269  mbIsSignatureLineCanAddComment = bIsSignatureCanAddComment;
270  };
271  bool isSignatureLineCanAddComment() const { return mbIsSignatureLineCanAddComment; };
272  css::uno::Reference<css::graphic::XGraphic> const & getSignatureLineUnsignedGraphic() const
273  {
274  return mpSignatureLineUnsignedGraphic;
275  };
276  void setSignatureLineUnsignedGraphic(css::uno::Reference<css::graphic::XGraphic> rGraphic)
277  {
278  mpSignatureLineUnsignedGraphic = rGraphic;
279  };
280  bool isSignatureLineSigned() const { return mbSignatureLineIsSigned; };
281  void setSignatureLineIsSigned(bool bIsSigned) { mbSignatureLineIsSigned = bIsSigned; }
282 
283  // Qr Code
284  void setQrCode(css::drawing::QRCode& rQrCode)
285  {
286  mpQrCode = std::make_unique<css::drawing::QRCode>(rQrCode);
287  };
288 
289  css::drawing::QRCode* getQrCode() const
290  {
291  return mpQrCode.get();
292  };
293 };
294 
295 #endif // INCLUDED_SVX_SVDOGRAF_HXX
296 
297 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString aFilterName
Definition: svdograf.hxx:96
bool mbIsSignatureLineCanAddComment
Definition: svdograf.hxx:112
OUString maSignatureLineId
Definition: svdograf.hxx:106
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: svdorect.cxx:39
const OUString & GetFileName() const
Definition: svdograf.hxx:170
virtual void NbcMirror(const Point &rRef1, const Point &rRef2) override
Definition: svdorect.cxx:485
void setSignatureLineSuggestedSignerName(const OUString &rSuggestedSignerName)
Definition: svdograf.hxx:230
void setIsSignatureLine(bool bIsSignatureLine)
Definition: svdograf.hxx:223
virtual OUString TakeObjNameSingul() const override
Definition: svdorect.cxx:192
GraphicType
void setSignatureLineSuggestedSignerEmail(const OUString &rSuggestedSignerEmail)
Definition: svdograf.hxx:246
virtual void addCropHandles(SdrHdlList &rTarget) const
Definition: svdobj.cxx:1193
SVX_DLLPRIVATE void ImpDeregisterLink()
Definition: svdotxln.cxx:266
OUString aFileName
Definition: svdograf.hxx:94
void setSignatureLineCanAddComment(bool bIsSignatureCanAddComment)
Definition: svdograf.hxx:267
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:97
OUString maSignatureLineSuggestedSignerEmail
Definition: svdograf.hxx:109
virtual SdrObjectUniquePtr getFullDragClone() const override
Definition: svdotext.cxx:2033
All geometrical data of an arbitrary object for use in undo/redo.
Definition: svdobj.hxx:226
const OUString & getSignatureLineSigningInstructions() const
Definition: svdograf.hxx:258
bool isSignatureLineCanAddComment() const
Definition: svdograf.hxx:271
virtual 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:1435
Rectangle objects (rectangle, circle, ...)
Definition: svdorect.hxx:39
Provides information about various ZObject properties.
Definition: svdobj.hxx:248
virtual void SaveGeoData(SdrObjGeoData &rGeo) const override
Definition: svdotext.cxx:1440
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override
Definition: svdorect.cxx:543
bool isSignatureLine() const
Definition: svdograf.hxx:224
bool mbSignatureLineIsSigned
Definition: svdograf.hxx:113
void setSignatureLineShowSignDate(bool bIsSignatureLineShowSignDate)
Definition: svdograf.hxx:262
OUString maSignatureLineSigningInstructions
Definition: svdograf.hxx:110
virtual void handlePageChange(SdrPage *pOldPage, SdrPage *pNewPage) override
Definition: svdotext.cxx:442
OUString maSignatureLineSuggestedSignerName
Definition: svdograf.hxx:107
css::uno::Reference< css::graphic::XGraphic > mpSignatureLineUnsignedGraphic
Definition: svdograf.hxx:114
virtual sal_uInt32 GetHdlCount() const override
Via GetHdlCount the number of Handles can be retrieved.
Definition: svdorect.cxx:295
virtual void AdjustToMaxRect(const tools::Rectangle &rMaxRect, bool bShrinkOnly=false)
Definition: svdobj.cxx:1618
bool mbIsSignatureLine
Definition: svdograf.hxx:105
SdrGraphicLink * pGraphicLink
Definition: svdograf.hxx:99
void setSignatureLineSigningInstructions(const OUString &rSigningInstructions)
Definition: svdograf.hxx:254
void setSignatureLineSuggestedSignerTitle(const OUString &rSuggestedSignerTitle)
Definition: svdograf.hxx:238
void setSignatureLineUnsignedGraphic(css::uno::Reference< css::graphic::XGraphic > rGraphic)
Definition: svdograf.hxx:276
void setQrCode(css::drawing::QRCode &rQrCode)
Definition: svdograf.hxx:284
This class represents an embedded or linked bitmap graphic object.
Definition: svdograf.hxx:77
void setSignatureLineIsSigned(bool bIsSigned)
Definition: svdograf.hxx:281
SdrGrafObjTransformsAttrs
Options for GetTransformedGraphic()
Definition: svdograf.hxx:48
SVX_DLLPRIVATE void ImpRegisterLink()
Definition: svdotxln.cxx:254
const OUString & getSignatureLineSuggestedSignerName() const
Definition: svdograf.hxx:234
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const override
Definition: svdorect.cxx:138
const OUString & getSignatureLineSuggestedSignerTitle() const
Definition: svdograf.hxx:242
std::unique_ptr< css::drawing::QRCode > mpQrCode
Definition: svdograf.hxx:116
virtual SdrRectObj * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: svdorect.cxx:246
SdrRectObj & operator=(const SdrRectObj &rCopy)
Definition: svdorect.cxx:251
virtual sal_uInt16 GetObjIdentifier() const override
Definition: svdorect.cxx:164
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: svdorect.cxx:47
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
Definition: svdorect.cxx:467
css::drawing::QRCode * getQrCode() const
Definition: svdograf.hxx:289
std::unique_ptr< GraphicObject > mpReplacementGraphicObject
Definition: svdograf.hxx:98
css::uno::Reference< css::graphic::XGraphic > const & getSignatureLineUnsignedGraphic() const
Definition: svdograf.hxx:272
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
OUString aReferer
Definition: svdograf.hxx:95
void setSignatureLineId(const OUString &rSignatureLineId)
Definition: svdograf.hxx:225
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:114
bool isSignatureLineShowSignDate() const
Definition: svdograf.hxx:266
GraphicAttr aGrafInfo
Definition: svdograf.hxx:92
virtual void RestGeoData(const SdrObjGeoData &rGeo) override
Definition: svdorect.cxx:577
virtual void AddToHdlList(SdrHdlList &rHdlList) const override
Definition: svdorect.cxx:300
bool IsMirrored() const
Definition: svdograf.hxx:206
void SetMirrored(long &nPageLeftMargin, long &nPageRightMargin, long &nPageTopMargin, long &nPageBottomMargin, bool &bMirrored)
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:229
bool isSignatureLineSigned() const
Definition: svdograf.hxx:280
OUString maSignatureLineSuggestedSignerTitle
Definition: svdograf.hxx:108
const OUString & getSignatureLineSuggestedSignerEmail() const
Definition: svdograf.hxx:250
bool mbIsSignatureLineShowSignDate
Definition: svdograf.hxx:111
virtual OUString TakeObjNamePlural() const override
Definition: svdorect.cxx:225
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Detects when a stylesheet is changed.
Definition: svdorect.cxx:571