LibreOffice Module vcl (master) 1
gdimtf.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_GDIMTF_HXX
21#define INCLUDED_VCL_GDIMTF_HXX
22
23#include <vcl/dllapi.h>
24#include <tools/gen.hxx>
25#include <tools/solar.h>
26#include <vcl/mapmod.hxx>
27#include <vcl/bitmap.hxx>
28#include <vcl/vclptr.hxx>
29#include <vector>
30
31class OutputDevice;
32class MetaAction;
33class SvStream;
34class Color;
35class BitmapEx;
36namespace tools {
37 class Polygon;
38 class PolyPolygon;
39}
40class Gradient;
41struct ImplMetaReadData;
42
43#define GDI_METAFILE_END (size_t(0xFFFFFFFF))
44
45enum class MtfConversion
46{
49};
50
51
52typedef Color (*ColorExchangeFnc)( const Color& rColor, const void* pColParam );
53typedef BitmapEx (*BmpExchangeFnc)( const BitmapEx& rBmpEx, const void* pBmpParam );
54
56{
57private:
58 ::std::vector< rtl::Reference<MetaAction> > m_aList;
60
69
70 // tdf#155479 need to know if it's SVG export
71 bool m_bSVG;
72
73
74 SAL_DLLPRIVATE static Color ImplColAdjustFnc( const Color& rColor, const void* pColParam );
75 SAL_DLLPRIVATE static BitmapEx ImplBmpAdjustFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
76
77 SAL_DLLPRIVATE static Color ImplColConvertFnc( const Color& rColor, const void* pColParam );
78 SAL_DLLPRIVATE static BitmapEx ImplBmpConvertFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
79
80 SAL_DLLPRIVATE static Color ImplColMonoFnc( const Color& rColor, const void* pColParam );
81 SAL_DLLPRIVATE static BitmapEx ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
82
83 SAL_DLLPRIVATE static Color ImplColReplaceFnc( const Color& rColor, const void* pColParam );
84 SAL_DLLPRIVATE static BitmapEx ImplBmpReplaceFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
85
86 SAL_DLLPRIVATE void ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pColParam,
87 BmpExchangeFnc pFncBmp, const void* pBmpParam );
88
89 SAL_DLLPRIVATE static Point ImplGetRotatedPoint( const Point& rPt, const Point& rRotatePt,
90 const Size& rOffset, double fSin, double fCos );
91 SAL_DLLPRIVATE static tools::Polygon ImplGetRotatedPolygon( const tools::Polygon& rPoly, const Point& rRotatePt,
92 const Size& rOffset, double fSin, double fCos );
93 SAL_DLLPRIVATE static tools::PolyPolygon ImplGetRotatedPolyPolygon( const tools::PolyPolygon& rPoly, const Point& rRotatePt,
94 const Size& rOffset, double fSin, double fCos );
95 SAL_DLLPRIVATE static void ImplAddGradientEx( GDIMetaFile& rMtf,
96 const OutputDevice& rMapDev,
97 const tools::PolyPolygon& rPolyPoly,
98 const Gradient& rGrad );
99
100 SAL_DLLPRIVATE bool ImplPlayWithRenderer(OutputDevice& rOut, const Point& rPos, Size rLogicDestSize);
101
102 void Linker( OutputDevice* pOut, bool bLink );
103
104public:
105 GDIMetaFile();
106 GDIMetaFile( const GDIMetaFile& rMtf );
107 ~GDIMetaFile();
108
109 GDIMetaFile& operator=( const GDIMetaFile& rMtf );
110 bool operator==( const GDIMetaFile& rMtf ) const;
111 bool operator!=( const GDIMetaFile& rMtf ) const { return !( *this == rMtf ); }
112
113 void Clear();
114 void Mirror( BmpMirrorFlags nMirrorFlags );
115 void Move( tools::Long nX, tools::Long nY );
116 // additional Move method getting specifics how to handle MapMode( MapUnit::MapPixel )
117 void Move( tools::Long nX, tools::Long nY, tools::Long nDPIX, tools::Long nDPIY );
118 void ScaleActions(double fScaleX, double fScaleY);
119 void Scale( double fScaleX, double fScaleY );
120 void Scale( const Fraction& rScaleX, const Fraction& rScaleY );
121 void Rotate( Degree10 nAngle10 );
122 void Clip( const tools::Rectangle& );
123 bool HasTransparentActions() const;
124
125 /* get the bound rect of the contained actions
126 * caveats:
127 * - clip actions will limit the contained actions,
128 * but the current clipregion of the passed OutputDevice will not
129 * - coordinates of actions will be transformed to preferred mapmode
130 * - the returned rectangle is relative to the preferred mapmode of the metafile
131 */
132 tools::Rectangle GetBoundRect( OutputDevice& i_rReference ) const;
133
134 void Adjust( short nLuminancePercent, short nContrastPercent,
135 short nChannelRPercent = 0, short nChannelGPercent = 0,
136 short nChannelBPercent = 0, double fGamma = 1.0,
137 bool bInvert = false, bool msoBrightness = false );
138
139 void Convert( MtfConversion eConversion );
140 void ReplaceColors( const Color* pSearchColors, const Color* rReplaceColors,
141 sal_uLong nColorCount );
142
143 GDIMetaFile GetMonochromeMtf( const Color& rCol ) const;
144
145 void Record( OutputDevice* pOutDev );
146 bool IsRecord() const { return m_bRecord; }
147
148 void Play(GDIMetaFile& rMtf);
149 void Play(OutputDevice& rOutDev, size_t nPos = GDI_METAFILE_END);
150 void Play(OutputDevice& rOutDev, const Point& rPos, const Size& rSize);
151
152 void Pause( bool bPause );
153 bool IsPause() const { return m_bPause; }
154
155 void Stop();
156
157 void WindStart();
158 void WindPrev();
159
160 size_t GetActionSize() const;
161
162 void AddAction(const rtl::Reference<MetaAction>& pAction);
163 void AddAction(const rtl::Reference<MetaAction>& pAction, size_t nPos);
164 void push_back(const rtl::Reference<MetaAction>& pAction);
169 void ReplaceAction( rtl::Reference<MetaAction> pAction, size_t nAction );
170
171 MetaAction* FirstAction();
172 MetaAction* NextAction();
173 MetaAction* GetAction( size_t nAction ) const;
174 MetaAction* GetCurAction() const { return GetAction( m_nCurrentActionElement ); }
175
176 const Size& GetPrefSize() const { return m_aPrefSize; }
177 void SetPrefSize( const Size& rSize ) { m_aPrefSize = rSize; }
178
179 const MapMode& GetPrefMapMode() const { return m_aPrefMapMode; }
180 void SetPrefMapMode( const MapMode& rMapMode ) { m_aPrefMapMode = rMapMode; }
181
182
183 sal_uLong GetSizeBytes() const;
184
186 bool CreateThumbnail(BitmapEx& rBitmapEx,
187 BmpConversion nColorConversion = BmpConversion::N24Bit,
188 BmpScaleFlag nScaleFlag = BmpScaleFlag::BestQuality) const;
189
190 void UseCanvas( bool _bUseCanvas );
191 bool GetUseCanvas() const { return m_bUseCanvas; }
192
193 // tdf#155479
194 bool getSVG() const { return m_bSVG; }
195 void setSVG(bool bNew) { m_bSVG = bNew; }
196
198 void dumpAsXml(const char* pFileName = nullptr) const;
199};
200
201#endif // INCLUDED_VCL_GDIMTF_HXX
202
203/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool m_bPause
Definition: gdimtf.hxx:66
bool m_bUseCanvas
Definition: gdimtf.hxx:68
size_t m_nCurrentActionElement
Definition: gdimtf.hxx:59
bool IsPause() const
Definition: gdimtf.hxx:153
const Size & GetPrefSize() const
Definition: gdimtf.hxx:176
bool IsRecord() const
Definition: gdimtf.hxx:146
MetaAction * GetCurAction() const
Definition: gdimtf.hxx:174
GDIMetaFile * m_pNext
Definition: gdimtf.hxx:64
GDIMetaFile * m_pPrev
Definition: gdimtf.hxx:63
::std::vector< rtl::Reference< MetaAction > > m_aList
Definition: gdimtf.hxx:58
void setSVG(bool bNew)
Definition: gdimtf.hxx:195
VclPtr< OutputDevice > m_pOutDev
Definition: gdimtf.hxx:65
bool operator!=(const GDIMetaFile &rMtf) const
Definition: gdimtf.hxx:111
bool m_bSVG
Definition: gdimtf.hxx:71
bool getSVG() const
Definition: gdimtf.hxx:194
void SetPrefMapMode(const MapMode &rMapMode)
Definition: gdimtf.hxx:180
bool GetUseCanvas() const
Definition: gdimtf.hxx:191
MapMode m_aPrefMapMode
Definition: gdimtf.hxx:61
Size m_aPrefSize
Definition: gdimtf.hxx:62
bool m_bRecord
Definition: gdimtf.hxx:67
const MapMode & GetPrefMapMode() const
Definition: gdimtf.hxx:179
void SetPrefSize(const Size &rSize)
Definition: gdimtf.hxx:177
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
aCursorMoveIdle Stop()
Color(* ColorExchangeFnc)(const Color &rColor, const void *pColParam)
Definition: gdimtf.hxx:52
BitmapEx(* BmpExchangeFnc)(const BitmapEx &rBmpEx, const void *pBmpParam)
Definition: gdimtf.hxx:53
#define GDI_METAFILE_END
Definition: gdimtf.hxx:43
MtfConversion
Definition: gdimtf.hxx:46
BmpMirrorFlags
void Clear(EHistoryType eHistory)
Clip
long Long
sal_uIntPtr sal_uLong
bool operator==(const ItalicMatrix &a, const ItalicMatrix &b)
Definition: vclenum.hxx:175