LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / include / vcl / gdimtf.hxx
blobf8637675482dcab8c28be21ffbdcff7d85a8abce
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;
71 SAL_DLLPRIVATE static Color ImplColAdjustFnc( const Color& rColor, const void* pColParam );
72 SAL_DLLPRIVATE static BitmapEx ImplBmpAdjustFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
74 SAL_DLLPRIVATE static Color ImplColConvertFnc( const Color& rColor, const void* pColParam );
75 SAL_DLLPRIVATE static BitmapEx ImplBmpConvertFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
77 SAL_DLLPRIVATE static Color ImplColMonoFnc( const Color& rColor, const void* pColParam );
78 SAL_DLLPRIVATE static BitmapEx ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
80 SAL_DLLPRIVATE static Color ImplColReplaceFnc( const Color& rColor, const void* pColParam );
81 SAL_DLLPRIVATE static BitmapEx ImplBmpReplaceFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
83 SAL_DLLPRIVATE void ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pColParam,
84 BmpExchangeFnc pFncBmp, const void* pBmpParam );
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 );
97 SAL_DLLPRIVATE bool ImplPlayWithRenderer(OutputDevice& rOut, const Point& rPos, Size rLogicDestSize);
99 void Linker( OutputDevice* pOut, bool bLink );
101 public:
102 GDIMetaFile();
103 GDIMetaFile( const GDIMetaFile& rMtf );
104 ~GDIMetaFile();
106 GDIMetaFile& operator=( const GDIMetaFile& rMtf );
107 bool operator==( const GDIMetaFile& rMtf ) const;
108 bool operator!=( const GDIMetaFile& rMtf ) const { return !( *this == rMtf ); }
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;
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
128 tools::Rectangle GetBoundRect( OutputDevice& i_rReference ) const;
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 );
135 void Convert( MtfConversion eConversion );
136 void ReplaceColors( const Color* pSearchColors, const Color* rReplaceColors,
137 sal_uLong nColorCount );
139 GDIMetaFile GetMonochromeMtf( const Color& rCol ) const;
141 void Record( OutputDevice* pOutDev );
142 bool IsRecord() const { return m_bRecord; }
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);
148 void Pause( bool bPause );
149 bool IsPause() const { return m_bPause; }
151 void Stop();
153 void WindStart();
154 void WindPrev();
156 size_t GetActionSize() const;
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);
162 * @param pAction takes ownership
163 * @param nAction the action to replace
165 void ReplaceAction( rtl::Reference<MetaAction> pAction, size_t nAction );
167 MetaAction* FirstAction();
168 MetaAction* NextAction();
169 MetaAction* GetAction( size_t nAction ) const;
170 MetaAction* GetCurAction() const { return GetAction( m_nCurrentActionElement ); }
172 const Size& GetPrefSize() const { return m_aPrefSize; }
173 void SetPrefSize( const Size& rSize ) { m_aPrefSize = rSize; }
175 const MapMode& GetPrefMapMode() const { return m_aPrefMapMode; }
176 void SetPrefMapMode( const MapMode& rMapMode ) { m_aPrefMapMode = rMapMode; }
179 sal_uLong GetSizeBytes() const;
181 /// Creates an antialiased thumbnail
182 bool CreateThumbnail(BitmapEx& rBitmapEx,
183 BmpConversion nColorConversion = BmpConversion::N24Bit,
184 BmpScaleFlag nScaleFlag = BmpScaleFlag::BestQuality) const;
186 void UseCanvas( bool _bUseCanvas );
187 bool GetUseCanvas() const { return m_bUseCanvas; }
189 /// Dumps the meta actions as XML in metafile.xml.
190 void dumpAsXml(const char* pFileName = nullptr) const;
193 #endif // INCLUDED_VCL_GDIMTF_HXX
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */