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