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