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::sun::star::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  std::shared_ptr<ImpGraphic> mxImpGraphic;
87  SAL_DLLPRIVATE void ImplTestRefCount();
88 
89 public:
90  SAL_DLLPRIVATE ImpGraphic* ImplGetImpGraphic() const { return mxImpGraphic.get(); }
91 
92  Graphic();
93  Graphic( const GraphicExternalLink& rGraphicLink );
94  Graphic( const Graphic& rGraphic );
95  Graphic( Graphic&& rGraphic ) noexcept;
96  Graphic( const Bitmap& rBmp );
97  Graphic( const Image& rImage );
98  Graphic( const BitmapEx& rBmpEx );
99  Graphic( const std::shared_ptr<VectorGraphicData>& rVectorGraphicDataPtr );
100  Graphic( const Animation& rAnimation );
101  Graphic( const GDIMetaFile& rMtf );
102  Graphic( const css::uno::Reference< css::graphic::XGraphic >& rxGraphic );
103 
104  Graphic& operator=( const Graphic& rGraphic );
105  Graphic& operator=( Graphic&& rGraphic ) noexcept;
106  bool operator==( const Graphic& rGraphic ) const;
107  bool operator!=( const Graphic& rGraphic ) const;
108 
109  bool IsNone() const;
110 
111  void Clear();
112 
113  GraphicType GetType() const;
114  void SetDefaultType();
115  bool IsSupportedGraphic() const;
116 
117  bool IsTransparent() const;
118  bool IsAlpha() const;
119  bool IsAnimated() const;
120  bool IsEPS() const;
121 
122  bool isAvailable() const;
123  bool makeAvailable();
124 
125  // #i102089# Access of Bitmap potentially will have to rasterconvert the Graphic
126  // if it is a MetaFile. To be able to control this conversion it is necessary to
127  // allow giving parameters which control AntiAliasing and LineSnapping of the
128  // MetaFile when played. Defaults will use a no-AAed, not snapped conversion as
129  // before.
130  BitmapEx GetBitmapEx(const GraphicConversionParameters& rParameters = GraphicConversionParameters()) const;
132  const BitmapEx& GetBitmapExRef() const;
133 
134  Animation GetAnimation() const;
135  const GDIMetaFile& GetGDIMetaFile() const;
136 
137  css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const;
138 
139  Size GetPrefSize() const;
140  void SetPrefSize( const Size& rPrefSize );
141 
142  MapMode GetPrefMapMode() const;
143  void SetPrefMapMode( const MapMode& rPrefMapMode );
144 
145  basegfx::B2DSize GetPPI() const;
146 
147  Size GetSizePixel( const OutputDevice* pRefDevice = nullptr ) const;
148 
149  sal_uLong GetSizeBytes() const;
150 
151  void Draw( OutputDevice* pOutDev,
152  const Point& rDestPt ) const;
153  void Draw( OutputDevice* pOutDev,
154  const Point& rDestPt,
155  const Size& rDestSize ) const;
156  static void DrawEx( OutputDevice* pOutDev, const OUString& rText,
157  vcl::Font& rFont, const BitmapEx& rBitmap,
158  const Point& rDestPt, const Size& rDestSize );
159 
160  void StartAnimation( OutputDevice* pOutDev,
161  const Point& rDestPt,
162  const Size& rDestSize,
163  long nExtraData = 0,
164  OutputDevice* pFirstFrameOutDev = nullptr );
165  void StopAnimation( OutputDevice* pOutputDevice,
166  long nExtraData );
167 
168  void SetAnimationNotifyHdl( const Link<Animation*,void>& rLink );
169  Link<Animation*,void> GetAnimationNotifyHdl() const;
170 
171  sal_uInt32 GetAnimationLoopCount() const;
172 
173  BitmapChecksum GetChecksum() const;
174 
175  OUString getOriginURL() const;
176  void setOriginURL(OUString const & rOriginURL);
177 
178  OString getUniqueID() const;
179 
180  std::shared_ptr<GraphicReader>& GetReaderContext();
181  void SetReaderContext( const std::shared_ptr<GraphicReader> &pReader );
182  void SetDummyContext(bool value);
183  bool IsDummyContext() const;
184 
185  void SetGfxLink(const std::shared_ptr<GfxLink>& rGfxLink);
186  std::shared_ptr<GfxLink> GetSharedGfxLink() const;
187  GfxLink GetGfxLink() const;
188  bool IsGfxLink() const;
189 
190  bool ExportNative( SvStream& rOStream ) const;
191 
192  friend VCL_DLLPUBLIC void WriteGraphic(SvStream& rOStream, const Graphic& rGraphic);
193  friend VCL_DLLPUBLIC void ReadGraphic(SvStream& rIStream, Graphic& rGraphic);
194 
195  const std::shared_ptr<VectorGraphicData>& getVectorGraphicData() const;
196 
198  sal_Int32 getPageNumber() const;
199 
200  static css::uno::Sequence<sal_Int8> getUnoTunnelId();
201 };
202 
203 namespace std {
204 
205 template <>
206 struct hash<Graphic>
207 {
208  std::size_t operator()(Graphic const & rGraphic) const
209  {
210  return static_cast<std::size_t>(rGraphic.GetChecksum());
211  }
212 };
213 
214 } // end namespace std
215 
216 #endif // INCLUDED_VCL_GRAPH_HXX
217 
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
void ReadGraphic(SvStream &rIStream, Graphic &rGraphic)
Definition: graph.cxx:528
std::shared_ptr< ImpGraphic > mxImpGraphic
Definition: graph.hxx:86
signed char sal_Int8
BitmapChecksum GetChecksum() const
Definition: graph.cxx:518
#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:208
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:90
bool getSnapHorVerLines() const
Definition: graph.hxx:79
void WriteGraphic(SvStream &rOStream, const Graphic &rGraphic)
Definition: graph.cxx:534
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:302
#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