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