LibreOffice Module vcl (master)  1
graph.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_VCL_GRAPH_HXX
21 #define INCLUDED_VCL_GRAPH_HXX
22 
23 #include <memory>
24 #include <vcl/dllapi.h>
25 #include <tools/solar.h>
26 #include <rtl/ustring.hxx>
27 #include <vcl/bitmapex.hxx>
29 #include <vcl/gfxlink.hxx>
30 #include <com/sun/star/uno/Reference.hxx>
34 
35 enum class GraphicType
36 {
37  NONE,
38  Bitmap,
40  Default
41 };
42 
43 namespace com { namespace sun { namespace star { namespace graphic { class XGraphic;} } } }
44 namespace vcl { class Font; }
45 
46 class Bitmap;
47 class GDIMetaFile;
48 class SvStream;
49 class ImpGraphic;
50 class OutputDevice;
51 class GraphicReader;
52 
54 {
55 private:
56  Size maSizePixel; // default is (0,0)
57 
58  bool mbUnlimitedSize : 1; // default is false
59  bool mbAntiAliase : 1; // default is false
60  bool mbSnapHorVerLines : 1; // default is false
61 
62 public:
64  const Size& rSizePixel = Size(),
65  bool bUnlimitedSize = false,
66  bool bAntiAliase = false,
67  bool bSnapHorVerLines = false)
68  : maSizePixel(rSizePixel),
69  mbUnlimitedSize(bUnlimitedSize),
70  mbAntiAliase(bAntiAliase),
71  mbSnapHorVerLines(bSnapHorVerLines)
72  {
73  }
74 
75  // data read access
76  const Size& getSizePixel() const { return maSizePixel; }
77  bool getUnlimitedSize() const { return mbUnlimitedSize; }
78  bool getAntiAliase() const { return mbAntiAliase; }
79  bool getSnapHorVerLines() const { return mbSnapHorVerLines; }
80 };
81 
82 class Image;
84 {
85 private:
86 
87  std::shared_ptr<ImpGraphic> mxImpGraphic;
88 
89 public:
90 
91  SAL_DLLPRIVATE void ImplTestRefCount();
92  SAL_DLLPRIVATE ImpGraphic* ImplGetImpGraphic() const { return mxImpGraphic.get(); }
93 
94 public:
95  Graphic();
96  Graphic( const GraphicExternalLink& rGraphicLink );
97  Graphic( const Graphic& rGraphic );
98  Graphic( Graphic&& rGraphic ) noexcept;
99  Graphic( const Bitmap& rBmp );
100  Graphic( const Image& rImage );
101  Graphic( const BitmapEx& rBmpEx );
102  Graphic( const VectorGraphicDataPtr& rVectorGraphicDataPtr );
103  Graphic( const Animation& rAnimation );
104  Graphic( const GDIMetaFile& rMtf );
105  Graphic( const css::uno::Reference< css::graphic::XGraphic >& rxGraphic );
106 
107  Graphic& operator=( const Graphic& rGraphic );
108  Graphic& operator=( Graphic&& rGraphic ) noexcept;
109  bool operator==( const Graphic& rGraphic ) const;
110  bool operator!=( const Graphic& rGraphic ) const;
111 
112  bool IsNone() const;
113 
114  void Clear();
115 
116  GraphicType GetType() const;
117  void SetDefaultType();
118  bool IsSupportedGraphic() const;
119 
120  bool IsTransparent() const;
121  bool IsAlpha() const;
122  bool IsAnimated() const;
123  bool IsEPS() const;
124 
125  bool isAvailable() const;
126  bool makeAvailable();
127 
128  // #i102089# Access of Bitmap potentially will have to rasterconvert the Graphic
129  // if it is a MetaFile. To be able to control this conversion it is necessary to
130  // allow giving parameters which control AntiAliasing and LineSnapping of the
131  // MetaFile when played. Defaults will use a no-AAed, not snapped conversion as
132  // before.
133  BitmapEx GetBitmapEx(const GraphicConversionParameters& rParameters = GraphicConversionParameters()) const;
135  const BitmapEx& GetBitmapExRef() const;
136 
137  Animation GetAnimation() const;
138  const GDIMetaFile& GetGDIMetaFile() const;
139 
140  css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const;
141 
142  Size GetPrefSize() const;
143  void SetPrefSize( const Size& rPrefSize );
144 
145  MapMode GetPrefMapMode() const;
146  void SetPrefMapMode( const MapMode& rPrefMapMode );
147 
148  basegfx::B2DSize GetPPI() const;
149 
150  Size GetSizePixel( const OutputDevice* pRefDevice = nullptr ) const;
151 
152  sal_uLong GetSizeBytes() const;
153 
154  void Draw( OutputDevice* pOutDev,
155  const Point& rDestPt ) const;
156  void Draw( OutputDevice* pOutDev,
157  const Point& rDestPt,
158  const Size& rDestSize ) const;
159  static void DrawEx( OutputDevice* pOutDev, const OUString& rText,
160  vcl::Font& rFont, const BitmapEx& rBitmap,
161  const Point& rDestPt, const Size& rDestSize );
162 
163  void StartAnimation( OutputDevice* pOutDev,
164  const Point& rDestPt,
165  const Size& rDestSize,
166  long nExtraData = 0,
167  OutputDevice* pFirstFrameOutDev = nullptr );
168  void StopAnimation( OutputDevice* pOutputDevice,
169  long nExtraData );
170 
171  void SetAnimationNotifyHdl( const Link<Animation*,void>& rLink );
172  Link<Animation*,void> GetAnimationNotifyHdl() const;
173 
174  sal_uInt32 GetAnimationLoopCount() const;
175 
176  BitmapChecksum GetChecksum() const;
177 
178  OUString getOriginURL() const;
179  void setOriginURL(OUString const & rOriginURL);
180 
181  OString getUniqueID() const;
182 
183 public:
184 
185  std::shared_ptr<GraphicReader>& GetReaderContext();
186  void SetReaderContext( const std::shared_ptr<GraphicReader> &pReader );
187  void SetDummyContext(bool value);
188  bool IsDummyContext() const;
189 private:
190  friend class GraphicObject;
191 
192 public:
193  void SetGfxLink(const std::shared_ptr<GfxLink>& rGfxLink);
194  std::shared_ptr<GfxLink> GetSharedGfxLink() const;
195  GfxLink GetGfxLink() const;
196  bool IsGfxLink() const;
197 
198  bool ExportNative( SvStream& rOStream ) const;
199 
200  friend VCL_DLLPUBLIC void WriteGraphic(SvStream& rOStream, const Graphic& rGraphic);
201  friend VCL_DLLPUBLIC void ReadGraphic(SvStream& rIStream, Graphic& rGraphic);
202 
203 public:
204 
205  const VectorGraphicDataPtr& getVectorGraphicData() const;
206 
208  sal_Int32 getPageNumber() const;
209 
210  static css::uno::Sequence<sal_Int8> getUnoTunnelId();
211 };
212 
213 namespace std {
214 
215 template <>
216 struct hash<Graphic>
217 {
218  std::size_t operator()(Graphic const & rGraphic) const
219  {
220  return static_cast<std::size_t>(rGraphic.GetChecksum());
221  }
222 };
223 
224 } // end namespace std
225 
226 #endif // INCLUDED_VCL_GRAPH_HXX
227 
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
void ReadGraphic(SvStream &rIStream, Graphic &rGraphic)
Definition: graph.cxx:547
std::shared_ptr< ImpGraphic > mxImpGraphic
Definition: graph.hxx:87
signed char sal_Int8
BitmapChecksum GetChecksum() const
Definition: graph.cxx:537
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
sal_uIntPtr sal_uLong
GraphicType
Definition: graph.hxx:35
std::size_t operator()(Graphic const &rGraphic) const
Definition: graph.hxx:218
bool getUnlimitedSize() const
Definition: graph.hxx:77
B2DVector B2DSize
const Size & getSizePixel() const
Definition: graph.hxx:76
SAL_DLLPRIVATE ImpGraphic * ImplGetImpGraphic() const
Definition: graph.hxx:92
bool getSnapHorVerLines() const
Definition: graph.hxx:79
void WriteGraphic(SvStream &rOStream, const Graphic &rGraphic)
Definition: graph.cxx:553
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
std::shared_ptr< VectorGraphicData > VectorGraphicDataPtr
#define SAL_WARN_UNUSED
Definition: image.hxx:40
GraphicConversionParameters(const Size &rSizePixel=Size(), bool bUnlimitedSize=false, bool bAntiAliase=false, bool bSnapHorVerLines=false)
Definition: graph.hxx:63
bool getAntiAliase() const
Definition: graph.hxx:78