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  virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
203 
204  virtual void AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly = false ) override;
205 
206  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
207 
208  bool IsMirrored() const { return bMirrored;}
209  void SetMirrored( bool _bMirrored );
210 
211  virtual bool shouldKeepAspectRatio() const override { return true; }
212 
213  // Access to GrafAnimationAllowed flag
214  void SetGrafAnimationAllowed(bool bNew);
215 
216  css::uno::Reference< css::io::XInputStream > getInputStream() const;
217 
218  // #i103116# FullDrag support
219  virtual SdrObjectUniquePtr getFullDragClone() const override;
220 
221  // add handles for crop mode when selected
222  virtual void addCropHandles(SdrHdlList& rTarget) const override;
223 
224  // Signature Line
225  void setIsSignatureLine(bool bIsSignatureLine) { mbIsSignatureLine = bIsSignatureLine; };
226  bool isSignatureLine() const { return mbIsSignatureLine; };
227  void setSignatureLineId(const OUString& rSignatureLineId)
228  {
229  maSignatureLineId = rSignatureLineId;
230  };
231  const OUString& getSignatureLineId() const { return maSignatureLineId; };
232  void setSignatureLineSuggestedSignerName(const OUString& rSuggestedSignerName)
233  {
234  maSignatureLineSuggestedSignerName = rSuggestedSignerName;
235  };
236  const OUString& getSignatureLineSuggestedSignerName() const
237  {
238  return maSignatureLineSuggestedSignerName;
239  };
240  void setSignatureLineSuggestedSignerTitle(const OUString& rSuggestedSignerTitle)
241  {
242  maSignatureLineSuggestedSignerTitle = rSuggestedSignerTitle;
243  };
244  const OUString& getSignatureLineSuggestedSignerTitle() const
245  {
246  return maSignatureLineSuggestedSignerTitle;
247  };
248  void setSignatureLineSuggestedSignerEmail(const OUString& rSuggestedSignerEmail)
249  {
250  maSignatureLineSuggestedSignerEmail = rSuggestedSignerEmail;
251  };
252  const OUString& getSignatureLineSuggestedSignerEmail() const
253  {
254  return maSignatureLineSuggestedSignerEmail;
255  };
256  void setSignatureLineSigningInstructions(const OUString& rSigningInstructions)
257  {
258  maSignatureLineSigningInstructions = rSigningInstructions;
259  };
260  const OUString& getSignatureLineSigningInstructions() const
261  {
262  return maSignatureLineSigningInstructions;
263  };
264  void setSignatureLineShowSignDate(bool bIsSignatureLineShowSignDate)
265  {
266  mbIsSignatureLineShowSignDate = bIsSignatureLineShowSignDate;
267  };
268  bool isSignatureLineShowSignDate() const { return mbIsSignatureLineShowSignDate; };
269  void setSignatureLineCanAddComment(bool bIsSignatureCanAddComment)
270  {
271  mbIsSignatureLineCanAddComment = bIsSignatureCanAddComment;
272  };
273  bool isSignatureLineCanAddComment() const { return mbIsSignatureLineCanAddComment; };
274  css::uno::Reference<css::graphic::XGraphic> const & getSignatureLineUnsignedGraphic() const
275  {
276  return mpSignatureLineUnsignedGraphic;
277  };
278  void setSignatureLineUnsignedGraphic(css::uno::Reference<css::graphic::XGraphic> rGraphic)
279  {
280  mpSignatureLineUnsignedGraphic = rGraphic;
281  };
282  bool isSignatureLineSigned() const { return mbSignatureLineIsSigned; };
283  void setSignatureLineIsSigned(bool bIsSigned) { mbSignatureLineIsSigned = bIsSigned; }
284 
285  // Qr Code
286  void setQrCode(css::drawing::QRCode& rQrCode)
287  {
288  mpQrCode = std::make_unique<css::drawing::QRCode>(rQrCode);
289  };
290 
291  css::drawing::QRCode* getQrCode() const
292  {
293  return mpQrCode.get();
294  };
295 };
296 
297 #endif // INCLUDED_SVX_SVDOGRAF_HXX
298 
299 /* 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:39
const OUString & GetFileName() const
Definition: svdograf.hxx:172
virtual void NbcMirror(const Point &rRef1, const Point &rRef2) override
Definition: svdorect.cxx:485
void setSignatureLineSuggestedSignerName(const OUString &rSuggestedSignerName)
Definition: svdograf.hxx:232
void setIsSignatureLine(bool bIsSignatureLine)
Definition: svdograf.hxx:225
virtual OUString TakeObjNameSingul() const override
Definition: svdorect.cxx:192
GraphicType
void setSignatureLineSuggestedSignerEmail(const OUString &rSuggestedSignerEmail)
Definition: svdograf.hxx:248
virtual void addCropHandles(SdrHdlList &rTarget) const
Definition: svdobj.cxx:1193
SVX_DLLPRIVATE void ImpDeregisterLink()
Definition: svdotxln.cxx:266
OUString aFileName
Definition: svdograf.hxx:96
void setSignatureLineCanAddComment(bool bIsSignatureCanAddComment)
Definition: svdograf.hxx:269
virtual bool shouldKeepAspectRatio() const override
Whether the aspect ratio should be kept by default when resizing.
Definition: svdograf.hxx:211
std::unique_ptr< GraphicObject > mpGraphicObject
Definition: svdograf.hxx:99
OUString maSignatureLineSuggestedSignerEmail
Definition: svdograf.hxx:111
virtual SdrObjectUniquePtr getFullDragClone() const override
Definition: svdotext.cxx:2025
All geometrical data of an arbitrary object for use in undo/redo.
Definition: svdobj.hxx:226
const OUString & getSignatureLineSigningInstructions() const
Definition: svdograf.hxx:260
bool isSignatureLineCanAddComment() const
Definition: svdograf.hxx:273
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:1427
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:1432
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override
Definition: svdorect.cxx:543
bool isSignatureLine() const
Definition: svdograf.hxx:226
bool mbSignatureLineIsSigned
Definition: svdograf.hxx:115
void setSignatureLineShowSignDate(bool bIsSignatureLineShowSignDate)
Definition: svdograf.hxx:264
OUString maSignatureLineSigningInstructions
Definition: svdograf.hxx:112
virtual void handlePageChange(SdrPage *pOldPage, SdrPage *pNewPage) override
Definition: svdotext.cxx:442
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:295
virtual void AdjustToMaxRect(const tools::Rectangle &rMaxRect, bool bShrinkOnly=false)
Definition: svdobj.cxx:1617
bool mbIsSignatureLine
Definition: svdograf.hxx:107
SdrGraphicLink * pGraphicLink
Definition: svdograf.hxx:101
void setSignatureLineSigningInstructions(const OUString &rSigningInstructions)
Definition: svdograf.hxx:256
void setSignatureLineSuggestedSignerTitle(const OUString &rSuggestedSignerTitle)
Definition: svdograf.hxx:240
void setSignatureLineUnsignedGraphic(css::uno::Reference< css::graphic::XGraphic > rGraphic)
Definition: svdograf.hxx:278
void setQrCode(css::drawing::QRCode &rQrCode)
Definition: svdograf.hxx:286
This class represents an embedded or linked bitmap graphic object.
Definition: svdograf.hxx:79
void setSignatureLineIsSigned(bool bIsSigned)
Definition: svdograf.hxx:283
SdrGrafObjTransformsAttrs
Options for GetTransformedGraphic()
Definition: svdograf.hxx:50
SVX_DLLPRIVATE void ImpRegisterLink()
Definition: svdotxln.cxx:254
const OUString & getSignatureLineSuggestedSignerName() const
Definition: svdograf.hxx:236
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const override
Definition: svdorect.cxx:138
const OUString & getSignatureLineSuggestedSignerTitle() const
Definition: svdograf.hxx:244
std::unique_ptr< css::drawing::QRCode > mpQrCode
Definition: svdograf.hxx:118
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:291
std::unique_ptr< GraphicObject > mpReplacementGraphicObject
Definition: svdograf.hxx:100
css::uno::Reference< css::graphic::XGraphic > const & getSignatureLineUnsignedGraphic() const
Definition: svdograf.hxx:274
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
OUString aReferer
Definition: svdograf.hxx:97
void setSignatureLineId(const OUString &rSignatureLineId)
Definition: svdograf.hxx:227
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:114
bool isSignatureLineShowSignDate() const
Definition: svdograf.hxx:268
GraphicAttr aGrafInfo
Definition: svdograf.hxx:94
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:208
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:231
bool isSignatureLineSigned() const
Definition: svdograf.hxx:282
OUString maSignatureLineSuggestedSignerTitle
Definition: svdograf.hxx:110
const OUString & getSignatureLineSuggestedSignerEmail() const
Definition: svdograf.hxx:252
bool mbIsSignatureLineShowSignDate
Definition: svdograf.hxx:113
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