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
71 SAL_DLLPRIVATE static Color ImplColAdjustFnc( const Color& rColor, const void* pColParam );
72 SAL_DLLPRIVATE static BitmapEx ImplBmpAdjustFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
73
74 SAL_DLLPRIVATE static Color ImplColConvertFnc( const Color& rColor, const void* pColParam );
75 SAL_DLLPRIVATE static BitmapEx ImplBmpConvertFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
76
77 SAL_DLLPRIVATE static Color ImplColMonoFnc( const Color& rColor, const void* pColParam );
78 SAL_DLLPRIVATE static BitmapEx ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
79
80 SAL_DLLPRIVATE static Color ImplColReplaceFnc( const Color& rColor, const void* pColParam );
81 SAL_DLLPRIVATE static BitmapEx ImplBmpReplaceFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
82
83 SAL_DLLPRIVATE void ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pColParam,
84 BmpExchangeFnc pFncBmp, const void* pBmpParam );
85
86 SAL_DLLPRIVATE static Point ImplGetRotatedPoint( const Point& rPt, const Point& rRotatePt,
87 const Size& rOffset, double fSin, double fCos );
88 SAL_DLLPRIVATE static tools::Polygon ImplGetRotatedPolygon( const tools::Polygon& rPoly, const Point& rRotatePt,
89 const Size& rOffset, double fSin, double fCos );
90 SAL_DLLPRIVATE static tools::PolyPolygon ImplGetRotatedPolyPolygon( const tools::PolyPolygon& rPoly, const Point& rRotatePt,
91 const Size& rOffset, double fSin, double fCos );
92 SAL_DLLPRIVATE static void ImplAddGradientEx( GDIMetaFile& rMtf,
93 const OutputDevice& rMapDev,
94 const tools::PolyPolygon& rPolyPoly,
95 const Gradient& rGrad );
96
97 SAL_DLLPRIVATE bool ImplPlayWithRenderer(OutputDevice& rOut, const Point& rPos, Size rLogicDestSize);
98
99 void Linker( OutputDevice* pOut, bool bLink );
100
101public:
102 GDIMetaFile();
103 GDIMetaFile( const GDIMetaFile& rMtf );
104 ~GDIMetaFile();
105
106 GDIMetaFile& operator=( const GDIMetaFile& rMtf );
107 bool operator==( const GDIMetaFile& rMtf ) const;
108 bool operator!=( const GDIMetaFile& rMtf ) const { return !( *this == rMtf ); }
109
110 void Clear();
111 void Mirror( BmpMirrorFlags nMirrorFlags );
112 void Move( tools::Long nX, tools::Long nY );
113 // additional Move method getting specifics how to handle MapMode( MapUnit::MapPixel )
114 void Move( tools::Long nX, tools::Long nY, tools::Long nDPIX, tools::Long nDPIY );
115 void Scale( double fScaleX, double fScaleY );
116 void Scale( const Fraction& rScaleX, const Fraction& rScaleY );
117 void Rotate( Degree10 nAngle10 );
118 void Clip( const tools::Rectangle& );
119 bool HasTransparentActions() const;
120
121 /* get the bound rect of the contained actions
122 * caveats:
123 * - clip actions will limit the contained actions,
124 * but the current clipregion of the passed OutputDevice will not
125 * - coordinates of actions will be transformed to preferred mapmode
126 * - the returned rectangle is relative to the preferred mapmode of the metafile
127 */
128 tools::Rectangle GetBoundRect( OutputDevice& i_rReference ) const;
129
130 void Adjust( short nLuminancePercent, short nContrastPercent,
131 short nChannelRPercent = 0, short nChannelGPercent = 0,
132 short nChannelBPercent = 0, double fGamma = 1.0,
133 bool bInvert = false, bool msoBrightness = false );
134
135 void Convert( MtfConversion eConversion );
136 void ReplaceColors( const Color* pSearchColors, const Color* rReplaceColors,
137 sal_uLong nColorCount );
138
139 GDIMetaFile GetMonochromeMtf( const Color& rCol ) const;
140
141 void Record( OutputDevice* pOutDev );
142 bool IsRecord() const { return m_bRecord; }
143
144 void Play(GDIMetaFile& rMtf);
145 void Play(OutputDevice& rOutDev, size_t nPos = GDI_METAFILE_END);
146 void Play(OutputDevice& rOutDev, const Point& rPos, const Size& rSize);
147
148 void Pause( bool bPause );
149 bool IsPause() const { return m_bPause; }
150
151 void Stop();
152
153 void WindStart();
154 void WindPrev();
155
156 size_t GetActionSize() const;
157
158 void AddAction(const rtl::Reference<MetaAction>& pAction);
159 void AddAction(const rtl::Reference<MetaAction>& pAction, size_t nPos);
160 void push_back(const rtl::Reference<MetaAction>& pAction);
165 void ReplaceAction( rtl::Reference<MetaAction> pAction, size_t nAction );
166
167 MetaAction* FirstAction();
168 MetaAction* NextAction();
169 MetaAction* GetAction( size_t nAction ) const;
170 MetaAction* GetCurAction() const { return GetAction( m_nCurrentActionElement ); }
171
172 const Size& GetPrefSize() const { return m_aPrefSize; }
173 void SetPrefSize( const Size& rSize ) { m_aPrefSize = rSize; }
174
175 const MapMode& GetPrefMapMode() const { return m_aPrefMapMode; }
176 void SetPrefMapMode( const MapMode& rMapMode ) { m_aPrefMapMode = rMapMode; }
177
178
179 sal_uLong GetSizeBytes() const;
180
182 bool CreateThumbnail(BitmapEx& rBitmapEx,
183 BmpConversion nColorConversion = BmpConversion::N24Bit,
184 BmpScaleFlag nScaleFlag = BmpScaleFlag::BestQuality) const;
185
186 void UseCanvas( bool _bUseCanvas );
187 bool GetUseCanvas() const { return m_bUseCanvas; }
188
190 void dumpAsXml(const char* pFileName = nullptr) const;
191};
192
193#endif // INCLUDED_VCL_GDIMTF_HXX
194
195/* 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:149
const Size & GetPrefSize() const
Definition: gdimtf.hxx:172
bool IsRecord() const
Definition: gdimtf.hxx:142
MetaAction * GetCurAction() const
Definition: gdimtf.hxx:170
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
VclPtr< OutputDevice > m_pOutDev
Definition: gdimtf.hxx:65
bool operator!=(const GDIMetaFile &rMtf) const
Definition: gdimtf.hxx:108
void SetPrefMapMode(const MapMode &rMapMode)
Definition: gdimtf.hxx:176
bool GetUseCanvas() const
Definition: gdimtf.hxx:187
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:175
void SetPrefSize(const Size &rSize)
Definition: gdimtf.hxx:173
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
Point Rotate(const Point &rPoint, Degree10 nOrientation, const Point &rOrigin)
BmpMirrorFlags
void Clear(EHistoryType eHistory)
Clip
long Long
sal_uIntPtr sal_uLong
bool operator==(const ItalicMatrix &a, const ItalicMatrix &b)
Definition: vclenum.hxx:182