lok: calc - send other views our selection in their co-ordinates.
[LibreOffice.git] / include / vcl / gdimtf.hxx
blob661caf863a22e936714319ef7db13562c9bb9ad3
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 <vcl/mapmod.hxx>
26 #include <vcl/bitmap.hxx>
27 #include <vcl/vclptr.hxx>
28 #include <vector>
30 class OutputDevice;
31 class MetaAction;
32 class SvStream;
33 class Color;
34 class BitmapEx;
35 namespace tools {
36 class Polygon;
37 class PolyPolygon;
39 class Gradient;
40 struct ImplMetaReadData;
42 #define GDI_METAFILE_END (size_t(0xFFFFFFFF))
44 enum class MtfConversion
46 N1BitThreshold,
47 N8BitGreys
51 typedef Color (*ColorExchangeFnc)( const Color& rColor, const void* pColParam );
52 typedef BitmapEx (*BmpExchangeFnc)( const BitmapEx& rBmpEx, const void* pBmpParam );
54 VCL_DLLPUBLIC SvStream& ReadGDIMetaFile(SvStream& rIStm, GDIMetaFile& rGDIMetaFile, ImplMetaReadData* pReadData = nullptr);
55 VCL_DLLPUBLIC SvStream& WriteGDIMetaFile( SvStream& rOStm, const GDIMetaFile& rGDIMetaFile );
57 class VCL_DLLPUBLIC GDIMetaFile final
59 private:
60 ::std::vector< rtl::Reference<MetaAction> > m_aList;
61 size_t m_nCurrentActionElement;
63 MapMode m_aPrefMapMode;
64 Size m_aPrefSize;
65 GDIMetaFile* m_pPrev;
66 GDIMetaFile* m_pNext;
67 VclPtr<OutputDevice> m_pOutDev;
68 bool m_bPause;
69 bool m_bRecord;
70 bool m_bUseCanvas;
73 SAL_DLLPRIVATE static Color ImplColAdjustFnc( const Color& rColor, const void* pColParam );
74 SAL_DLLPRIVATE static BitmapEx ImplBmpAdjustFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
76 SAL_DLLPRIVATE static Color ImplColConvertFnc( const Color& rColor, const void* pColParam );
77 SAL_DLLPRIVATE static BitmapEx ImplBmpConvertFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
79 SAL_DLLPRIVATE static Color ImplColMonoFnc( const Color& rColor, const void* pColParam );
80 SAL_DLLPRIVATE static BitmapEx ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
82 SAL_DLLPRIVATE static Color ImplColReplaceFnc( const Color& rColor, const void* pColParam );
83 SAL_DLLPRIVATE static BitmapEx ImplBmpReplaceFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
85 SAL_DLLPRIVATE void ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pColParam,
86 BmpExchangeFnc pFncBmp, const void* pBmpParam );
88 SAL_DLLPRIVATE static Point ImplGetRotatedPoint( const Point& rPt, const Point& rRotatePt,
89 const Size& rOffset, double fSin, double fCos );
90 SAL_DLLPRIVATE static tools::Polygon ImplGetRotatedPolygon( const tools::Polygon& rPoly, const Point& rRotatePt,
91 const Size& rOffset, double fSin, double fCos );
92 SAL_DLLPRIVATE static tools::PolyPolygon ImplGetRotatedPolyPolygon( const tools::PolyPolygon& rPoly, const Point& rRotatePt,
93 const Size& rOffset, double fSin, double fCos );
94 SAL_DLLPRIVATE static void ImplAddGradientEx( GDIMetaFile& rMtf,
95 const OutputDevice& rMapDev,
96 const tools::PolyPolygon& rPolyPoly,
97 const Gradient& rGrad );
99 SAL_DLLPRIVATE bool ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, Size rLogicDestSize );
101 void Linker( OutputDevice* pOut, bool bLink );
103 public:
104 GDIMetaFile();
105 GDIMetaFile( const GDIMetaFile& rMtf );
106 ~GDIMetaFile();
108 GDIMetaFile& operator=( const GDIMetaFile& rMtf );
109 bool operator==( const GDIMetaFile& rMtf ) const;
110 bool operator!=( const GDIMetaFile& rMtf ) const { return !( *this == rMtf ); }
112 void Clear();
113 void Mirror( BmpMirrorFlags nMirrorFlags );
114 void Move( long nX, long nY );
115 // additional Move method getting specifics how to handle MapMode( MapUnit::MapPixel )
116 void Move( long nX, long nY, long nDPIX, long nDPIY );
117 void Scale( double fScaleX, double fScaleY );
118 void Scale( const Fraction& rScaleX, const Fraction& rScaleY );
119 void Rotate( long nAngle10 );
120 void Clip( const tools::Rectangle& );
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, tools::Rectangle* pHairline = nullptr ) 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* pOutDev, size_t nPos = GDI_METAFILE_END );
146 void Play( OutputDevice* pOutDev, const Point& rPos,
147 const Size& rSize );
149 void Pause( bool bPause );
150 bool IsPause() const { return m_bPause; }
152 void Stop();
154 void WindStart();
155 void WindPrev();
157 size_t GetActionSize() const;
159 void AddAction(const rtl::Reference<MetaAction>& pAction);
160 void AddAction(const rtl::Reference<MetaAction>& pAction, size_t nPos);
161 void push_back(const rtl::Reference<MetaAction>& pAction);
163 * @param pAction takes ownership
164 * @param nAction the action to replace
166 void ReplaceAction( rtl::Reference<MetaAction> pAction, size_t nAction );
168 MetaAction* FirstAction();
169 MetaAction* NextAction();
170 MetaAction* GetAction( size_t nAction ) const;
171 MetaAction* GetCurAction() const { return GetAction( m_nCurrentActionElement ); }
173 const Size& GetPrefSize() const { return m_aPrefSize; }
174 void SetPrefSize( const Size& rSize ) { m_aPrefSize = rSize; }
176 const MapMode& GetPrefMapMode() const { return m_aPrefMapMode; }
177 void SetPrefMapMode( const MapMode& rMapMode ) { m_aPrefMapMode = rMapMode; }
180 BitmapChecksum GetChecksum() const;
181 sal_uLong GetSizeBytes() const;
183 // Methods for reading and writing the new formats;
184 // the Read method also reads the old format
185 SvStream& Read( SvStream& rIStm );
186 SvStream& Write( SvStream& rOStm );
188 // Stream-operators write (still) the old format
189 // and read both the old and the new format
190 friend VCL_DLLPUBLIC SvStream& ReadGDIMetaFile(SvStream& rIStm, GDIMetaFile& rGDIMetaFile, ImplMetaReadData* pReadData);
191 friend VCL_DLLPUBLIC SvStream& WriteGDIMetaFile(SvStream& rOStm, const GDIMetaFile& rGDIMetaFile);
193 /// Creates an antialiased thumbnail
194 bool CreateThumbnail(BitmapEx& rBitmapEx,
195 BmpConversion nColorConversion = BmpConversion::N24Bit,
196 BmpScaleFlag nScaleFlag = BmpScaleFlag::BestQuality) const;
198 void UseCanvas( bool _bUseCanvas );
199 bool GetUseCanvas() const { return m_bUseCanvas; }
201 /// Dumps the meta actions as XML in metafile.xml.
202 void dumpAsXml(const char* pFileName = nullptr) const;
205 #endif // INCLUDED_VCL_GDIMTF_HXX
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */