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
34enum class GraphicType
35{
36 NONE,
37 Bitmap,
40};
41
42namespace com::sun::star::graphic { class XGraphic; }
43namespace vcl { class Font; }
44
45class Bitmap;
46class GDIMetaFile;
47class SvStream;
48class ImpGraphic;
49class OutputDevice;
50class GraphicReader;
51
53{
54private:
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
61public:
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
81class Image;
83{
84private:
85 std::shared_ptr<ImpGraphic> mxImpGraphic;
86 SAL_DLLPRIVATE void ImplTestRefCount();
87
88public:
89 SAL_DLLPRIVATE ImpGraphic* ImplGetImpGraphic() const { return mxImpGraphic.get(); }
90
91 Graphic();
92 Graphic(std::shared_ptr<GfxLink> const & rGfxLink, sal_Int32 nPageIndex = 0);
93 Graphic( const GraphicExternalLink& rGraphicLink );
94 Graphic( const Graphic& rGraphic );
95 Graphic( Graphic&& rGraphic ) noexcept;
96 Graphic( const Image& rImage );
97 Graphic( const BitmapEx& rBmpEx );
98 Graphic( const std::shared_ptr<VectorGraphicData>& rVectorGraphicDataPtr );
99 Graphic( const Animation& rAnimation );
100 Graphic( const GDIMetaFile& rMtf );
101 Graphic( const css::uno::Reference< css::graphic::XGraphic >& rxGraphic );
102
103 Graphic& operator=( const Graphic& rGraphic );
104 Graphic& operator=( Graphic&& rGraphic ) noexcept;
105 bool operator==( const Graphic& rGraphic ) const;
106 bool operator!=( const Graphic& rGraphic ) const;
107
108 bool IsNone() const;
109
110 void Clear();
111
112 GraphicType GetType() const;
113 void SetDefaultType();
114 bool IsSupportedGraphic() const;
115
116 bool IsTransparent() const;
117 bool IsAlpha() const;
118 bool IsAnimated() const;
119 bool IsEPS() const;
120
121 bool isAvailable() const;
122 bool makeAvailable();
123
124 // #i102089# Access of Bitmap potentially will have to rasterconvert the Graphic
125 // if it is a MetaFile. To be able to control this conversion it is necessary to
126 // allow giving parameters which control AntiAliasing and LineSnapping of the
127 // MetaFile when played. Defaults will use a no-AAed, not snapped conversion as
128 // before.
131 const BitmapEx& GetBitmapExRef() const;
132
133 Animation GetAnimation() const;
134 const GDIMetaFile& GetGDIMetaFile() const;
135
136 css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const;
137
138 Size GetPrefSize() const;
139 void SetPrefSize( const Size& rPrefSize );
140
141 MapMode GetPrefMapMode() const;
142 void SetPrefMapMode( const MapMode& rPrefMapMode );
143
144 basegfx::B2DSize GetPPI() const;
145
146 Size GetSizePixel( const OutputDevice* pRefDevice = nullptr ) const;
147
148 sal_uLong GetSizeBytes() const;
149
150 void Draw(OutputDevice& rOutDev, const Point& rDestPt) const;
151 void Draw(OutputDevice& rOutDev, const Point& rDestPt,
152 const Size& rDestSize) const;
153 static void DrawEx(OutputDevice& rOutDev, const OUString& rText,
154 vcl::Font& rFont, const BitmapEx& rBitmap,
155 const Point& rDestPt, const Size& rDestSize);
156
157 void StartAnimation(OutputDevice& rOutDev,
158 const Point& rDestPt,
159 const Size& rDestSize,
160 tools::Long nExtraData = 0,
161 OutputDevice* pFirstFrameOutDev = nullptr);
162 void StopAnimation( const OutputDevice* pOutputDevice,
163 tools::Long nExtraData );
164
165 void SetAnimationNotifyHdl( const Link<Animation*,void>& rLink );
166 Link<Animation*,void> GetAnimationNotifyHdl() const;
167
168 sal_uInt32 GetAnimationLoopCount() const;
169
170 BitmapChecksum GetChecksum() const;
171
172 OUString getOriginURL() const;
173 void setOriginURL(OUString const & rOriginURL);
174
175 OString getUniqueID() const;
176
177 std::shared_ptr<GraphicReader>& GetReaderContext();
178 void SetReaderContext( const std::shared_ptr<GraphicReader> &pReader );
179 void SetDummyContext(bool value);
180 bool IsDummyContext() const;
181
182 void SetGfxLink(const std::shared_ptr<GfxLink>& rGfxLink);
183 const std::shared_ptr<GfxLink> & GetSharedGfxLink() const;
184 GfxLink GetGfxLink() const;
185 bool IsGfxLink() const;
186
187 const std::shared_ptr<VectorGraphicData>& getVectorGraphicData() const;
188
190 sal_Int32 getPageNumber() const;
191};
192
193namespace std {
194
195template <>
196struct hash<Graphic>
197{
198 std::size_t operator()(Graphic const & rGraphic) const
199 {
200 return static_cast<std::size_t>(rGraphic.GetChecksum());
201 }
202};
203
204} // end namespace std
205
206/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
bool getAntiAliase() const
Definition: graph.hxx:77
bool getUnlimitedSize() const
Definition: graph.hxx:76
const Size & getSizePixel() const
Definition: graph.hxx:75
bool getSnapHorVerLines() const
Definition: graph.hxx:78
GraphicConversionParameters(const Size &rSizePixel=Size(), bool bUnlimitedSize=false, bool bAntiAliase=false, bool bSnapHorVerLines=false)
Definition: graph.hxx:62
std::shared_ptr< ImpGraphic > mxImpGraphic
Definition: graph.hxx:85
BitmapChecksum GetChecksum() const
Definition: graph.cxx:520
SAL_DLLPRIVATE ImpGraphic * ImplGetImpGraphic() const
Definition: graph.hxx:89
Definition: image.hxx:40
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
GraphicType
Definition: graph.hxx:35
void Clear(EHistoryType eHistory)
NONE
bool IsNone(const tools::Long nPageLeftMargin, const tools::Long nPageRightMargin, const tools::Long nPageTopMargin, const tools::Long nPageBottomMargin, bool bMirrored)
long Long
BitmapEx GetBitmapEx(BitmapEx const &rBitmapEx, DrawModeFlags nDrawMode)
Definition: drawmode.cxx:242
sal_uIntPtr sal_uLong
std::size_t operator()(Graphic const &rGraphic) const
Definition: graph.hxx:198
#define SAL_WARN_UNUSED
bool operator==(const ItalicMatrix &a, const ItalicMatrix &b)
Definition: vclenum.hxx:175
bool operator!=(const ItalicMatrix &a, const ItalicMatrix &b)
Definition: vclenum.hxx:180