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 <vcl/mapmod.hxx>
26 #include <vcl/bitmap.hxx>
27 #include <vcl/vclptr.hxx>
28 #include <vector>
29 
30 class OutputDevice;
31 class MetaAction;
32 class SvStream;
33 class Color;
34 class BitmapEx;
35 namespace tools {
36  class Polygon;
37  class PolyPolygon;
38 }
39 class Gradient;
40 struct ImplMetaReadData;
41 
42 #define GDI_METAFILE_END (size_t(0xFFFFFFFF))
43 
44 enum class MtfConversion
45 {
48 };
49 
50 
51 typedef Color (*ColorExchangeFnc)( const Color& rColor, const void* pColParam );
52 typedef BitmapEx (*BmpExchangeFnc)( const BitmapEx& rBmpEx, const void* pBmpParam );
53 
54 VCL_DLLPUBLIC SvStream& ReadGDIMetaFile(SvStream& rIStm, GDIMetaFile& rGDIMetaFile, ImplMetaReadData* pReadData = nullptr);
55 VCL_DLLPUBLIC SvStream& WriteGDIMetaFile( SvStream& rOStm, const GDIMetaFile& rGDIMetaFile );
56 
58 {
59 private:
60  ::std::vector< rtl::Reference<MetaAction> > m_aList;
62 
68  bool m_bPause;
69  bool m_bRecord;
71 
72 
73  SAL_DLLPRIVATE static Color ImplColAdjustFnc( const Color& rColor, const void* pColParam );
74  SAL_DLLPRIVATE static BitmapEx ImplBmpAdjustFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
75 
76  SAL_DLLPRIVATE static Color ImplColConvertFnc( const Color& rColor, const void* pColParam );
77  SAL_DLLPRIVATE static BitmapEx ImplBmpConvertFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
78 
79  SAL_DLLPRIVATE static Color ImplColMonoFnc( const Color& rColor, const void* pColParam );
80  SAL_DLLPRIVATE static BitmapEx ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
81 
82  SAL_DLLPRIVATE static Color ImplColReplaceFnc( const Color& rColor, const void* pColParam );
83  SAL_DLLPRIVATE static BitmapEx ImplBmpReplaceFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
84 
85  SAL_DLLPRIVATE void ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pColParam,
86  BmpExchangeFnc pFncBmp, const void* pBmpParam );
87 
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 );
98 
99  SAL_DLLPRIVATE bool ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, Size rLogicDestSize );
100 
101  void Linker( OutputDevice* pOut, bool bLink );
102 
103 public:
104  GDIMetaFile();
105  GDIMetaFile( const GDIMetaFile& rMtf );
106  ~GDIMetaFile();
107 
108  GDIMetaFile& operator=( const GDIMetaFile& rMtf );
109  bool operator==( const GDIMetaFile& rMtf ) const;
110  bool operator!=( const GDIMetaFile& rMtf ) const { return !( *this == rMtf ); }
111 
112  void Clear();
113  void Mirror( BmpMirrorFlags nMirrorFlags );
114  void Move( tools::Long nX, tools::Long nY );
115  // additional Move method getting specifics how to handle MapMode( MapUnit::MapPixel )
116  void Move( tools::Long nX, tools::Long nY, tools::Long nDPIX, tools::Long nDPIY );
117  void Scale( double fScaleX, double fScaleY );
118  void Scale( const Fraction& rScaleX, const Fraction& rScaleY );
119  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, tools::Rectangle* pHairline = nullptr ) 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_uLong nColorCount );
140 
141  GDIMetaFile GetMonochromeMtf( const Color& rCol ) const;
142 
143  void Record( OutputDevice* pOutDev );
144  bool IsRecord() const { return m_bRecord; }
145 
146  void Play( GDIMetaFile& rMtf );
147  void Play( OutputDevice* pOutDev, size_t nPos = GDI_METAFILE_END );
148  void Play( OutputDevice* pOutDev, const Point& rPos,
149  const Size& rSize );
150 
151  void Pause( bool bPause );
152  bool IsPause() const { return m_bPause; }
153 
154  void Stop();
155 
156  void WindStart();
157  void WindPrev();
158 
159  size_t GetActionSize() const;
160 
161  void AddAction(const rtl::Reference<MetaAction>& pAction);
162  void AddAction(const rtl::Reference<MetaAction>& pAction, size_t nPos);
163  void push_back(const rtl::Reference<MetaAction>& pAction);
168  void ReplaceAction( rtl::Reference<MetaAction> pAction, size_t nAction );
169 
170  MetaAction* FirstAction();
171  MetaAction* NextAction();
172  MetaAction* GetAction( size_t nAction ) const;
173  MetaAction* GetCurAction() const { return GetAction( m_nCurrentActionElement ); }
174 
175  const Size& GetPrefSize() const { return m_aPrefSize; }
176  void SetPrefSize( const Size& rSize ) { m_aPrefSize = rSize; }
177 
178  const MapMode& GetPrefMapMode() const { return m_aPrefMapMode; }
179  void SetPrefMapMode( const MapMode& rMapMode ) { m_aPrefMapMode = rMapMode; }
180 
181 
182  BitmapChecksum GetChecksum() const;
183  sal_uLong GetSizeBytes() const;
184 
185  // Methods for reading and writing the new formats;
186  // the Read method also reads the old format
187  SvStream& Read( SvStream& rIStm );
188  SvStream& Write( SvStream& rOStm );
189 
190  // Stream-operators write (still) the old format
191  // and read both the old and the new format
192  friend VCL_DLLPUBLIC SvStream& ReadGDIMetaFile(SvStream& rIStm, GDIMetaFile& rGDIMetaFile, ImplMetaReadData* pReadData);
193  friend VCL_DLLPUBLIC SvStream& WriteGDIMetaFile(SvStream& rOStm, const GDIMetaFile& rGDIMetaFile);
194 
196  bool CreateThumbnail(BitmapEx& rBitmapEx,
197  BmpConversion nColorConversion = BmpConversion::N24Bit,
198  BmpScaleFlag nScaleFlag = BmpScaleFlag::BestQuality) const;
199 
200  void UseCanvas( bool _bUseCanvas );
201  bool GetUseCanvas() const { return m_bUseCanvas; }
202 
204  void dumpAsXml(const char* pFileName = nullptr) const;
205 };
206 
207 #endif // INCLUDED_VCL_GDIMTF_HXX
208 
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
GDIMetaFile * m_pPrev
Definition: gdimtf.hxx:65
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
VclPtr< OutputDevice > m_pOutDev
Definition: gdimtf.hxx:67
MetaAction * GetCurAction() const
Definition: gdimtf.hxx:173
const MapMode & GetPrefMapMode() const
Definition: gdimtf.hxx:178
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
VCL_DLLPUBLIC SvStream & ReadGDIMetaFile(SvStream &rIStm, GDIMetaFile &rGDIMetaFile, ImplMetaReadData *pReadData=nullptr)
Definition: gdimtf.cxx:2645
sal_uIntPtr sal_uLong
MtfConversion
Definition: gdimtf.hxx:44
long Long
void SetPrefSize(const Size &rSize)
Definition: gdimtf.hxx:176
bool IsRecord() const
Definition: gdimtf.hxx:144
VCL_DLLPUBLIC SvStream & WriteGDIMetaFile(SvStream &rOStm, const GDIMetaFile &rGDIMetaFile)
Definition: gdimtf.cxx:2729
BitmapEx(* BmpExchangeFnc)(const BitmapEx &rBmpEx, const void *pBmpParam)
Definition: gdimtf.hxx:52
Size m_aPrefSize
Definition: gdimtf.hxx:64
Point Rotate(const Point &rPoint, Degree10 nOrientation, const Point &rOrigin)
bool operator==(const ItalicMatrix &a, const ItalicMatrix &b)
Definition: vclenum.hxx:206
bool m_bPause
Definition: gdimtf.hxx:68
bool GetUseCanvas() const
Definition: gdimtf.hxx:201
const Size & GetPrefSize() const
Definition: gdimtf.hxx:175
GDIMetaFile * m_pNext
Definition: gdimtf.hxx:66
::std::vector< rtl::Reference< MetaAction > > m_aList
Definition: gdimtf.hxx:60
Color(* ColorExchangeFnc)(const Color &rColor, const void *pColParam)
Definition: gdimtf.hxx:51
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:302
BmpMirrorFlags
Definition: bitmap.hxx:37
BmpScaleFlag
Definition: bitmap.hxx:49
Clip
bool m_bRecord
Definition: gdimtf.hxx:69
BmpConversion
Definition: bitmap.hxx:66
#define GDI_METAFILE_END
Definition: gdimtf.hxx:42
bool IsPause() const
Definition: gdimtf.hxx:152
MapMode m_aPrefMapMode
Definition: gdimtf.hxx:63
bool operator!=(const GDIMetaFile &rMtf) const
Definition: gdimtf.hxx:110
bool m_bUseCanvas
Definition: gdimtf.hxx:70
aCursorMoveIdle Stop()
size_t m_nCurrentActionElement
Definition: gdimtf.hxx:61
void SetPrefMapMode(const MapMode &rMapMode)
Definition: gdimtf.hxx:179