tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / include / vcl / gdimtf.hxx
blob2b24745ede9aa84d0e8e04b0461ffd6b6fb0c020
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_GDIMTF_HXX
21 #define INCLUDED_VCL_GDIMTF_HXX
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>
31 class OutputDevice;
32 class MetaAction;
33 class SvStream;
34 class Color;
35 class BitmapEx;
36 namespace tools {
37 class Polygon;
38 class PolyPolygon;
40 class Gradient;
41 struct ImplMetaReadData;
43 #define GDI_METAFILE_END (size_t(0xFFFFFFFF))
45 enum class MtfConversion
47 N1BitThreshold,
48 N8BitGreys
52 typedef Color (*ColorExchangeFnc)( const Color& rColor, const void* pColParam );
53 typedef BitmapEx (*BmpExchangeFnc)( const BitmapEx& rBmpEx, const void* pBmpParam );
55 class VCL_DLLPUBLIC GDIMetaFile final
57 private:
58 ::std::vector< rtl::Reference<MetaAction> > m_aList;
59 size_t m_nCurrentActionElement;
61 MapMode m_aPrefMapMode;
62 Size m_aPrefSize;
63 GDIMetaFile* m_pPrev;
64 GDIMetaFile* m_pNext;
65 VclPtr<OutputDevice> m_pOutDev;
66 bool m_bPause;
67 bool m_bRecord;
68 bool m_bUseCanvas;
70 // tdf#155479 need to know if it's SVG export
71 bool m_bSVG;
74 SAL_DLLPRIVATE static Color ImplColAdjustFnc( const Color& rColor, const void* pColParam );
75 SAL_DLLPRIVATE static BitmapEx ImplBmpAdjustFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
77 SAL_DLLPRIVATE static Color ImplColConvertFnc( const Color& rColor, const void* pColParam );
78 SAL_DLLPRIVATE static BitmapEx ImplBmpConvertFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
80 SAL_DLLPRIVATE static Color ImplColMonoFnc( const Color& rColor, const void* pColParam );
81 SAL_DLLPRIVATE static BitmapEx ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
83 SAL_DLLPRIVATE static Color ImplColReplaceFnc( const Color& rColor, const void* pColParam );
84 SAL_DLLPRIVATE static BitmapEx ImplBmpReplaceFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
86 SAL_DLLPRIVATE void ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pColParam,
87 BmpExchangeFnc pFncBmp, const void* pBmpParam );
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 );
100 SAL_DLLPRIVATE bool ImplPlayWithRenderer(OutputDevice& rOut, const Point& rPos, Size rLogicDestSize);
102 SAL_DLLPRIVATE void Linker( OutputDevice* pOut, bool bLink );
104 public:
105 GDIMetaFile();
106 GDIMetaFile( const GDIMetaFile& rMtf );
107 ~GDIMetaFile();
109 GDIMetaFile& operator=( const GDIMetaFile& rMtf );
110 bool operator==( const GDIMetaFile& rMtf ) const;
111 bool operator!=( const GDIMetaFile& rMtf ) const { return !( *this == rMtf ); }
113 void Clear();
114 SAL_DLLPRIVATE 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 SAL_DLLPRIVATE void Rotate( Degree10 nAngle10 );
122 void Clip( const tools::Rectangle& );
123 bool HasTransparentActions() const;
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
132 tools::Rectangle GetBoundRect( OutputDevice& i_rReference ) const;
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 );
139 void Convert( MtfConversion eConversion );
140 void ReplaceColors( const Color* pSearchColors, const Color* rReplaceColors,
141 sal_uLong nColorCount );
143 GDIMetaFile GetMonochromeMtf( const Color& rCol ) const;
145 void Record( OutputDevice* pOutDev );
146 bool IsRecord() const { return m_bRecord; }
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);
152 void Pause( bool bPause );
153 bool IsPause() const { return m_bPause; }
155 void Stop();
157 void WindStart();
158 void WindPrev();
160 size_t GetActionSize() const;
162 void AddAction(const rtl::Reference<MetaAction>& pAction);
163 void AddAction(const rtl::Reference<MetaAction>& pAction, size_t nPos);
164 SAL_DLLPRIVATE void push_back(const rtl::Reference<MetaAction>& pAction);
166 * @param nAction the action to replace
168 SAL_DLLPRIVATE void ReplaceAction( rtl::Reference<MetaAction> pAction, size_t nAction );
170 MetaAction* FirstAction();
171 MetaAction* NextAction();
172 MetaAction* GetAction( size_t nAction ) const;
173 MetaAction* GetCurAction() const { return GetAction( m_nCurrentActionElement ); }
175 const Size& GetPrefSize() const { return m_aPrefSize; }
176 void SetPrefSize( const Size& rSize ) { m_aPrefSize = rSize; }
178 const MapMode& GetPrefMapMode() const { return m_aPrefMapMode; }
179 void SetPrefMapMode( const MapMode& rMapMode ) { m_aPrefMapMode = rMapMode; }
182 SAL_DLLPRIVATE sal_uLong GetSizeBytes() const;
184 /// Creates an antialiased thumbnail
185 bool CreateThumbnail(BitmapEx& rBitmapEx,
186 BmpConversion nColorConversion = BmpConversion::N24Bit,
187 BmpScaleFlag nScaleFlag = BmpScaleFlag::BestQuality) const;
189 void UseCanvas( bool _bUseCanvas );
190 bool GetUseCanvas() const { return m_bUseCanvas; }
192 // tdf#155479
193 bool getSVG() const { return m_bSVG; }
194 void setSVG(bool bNew) { m_bSVG = bNew; }
196 /// Dumps the meta actions as XML in metafile.xml.
197 void dumpAsXml(const char* pFileName = nullptr) const;
200 #endif // INCLUDED_VCL_GDIMTF_HXX
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */