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( 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
127  */
128  tools::Rectangle GetBoundRect( OutputDevice& i_rReference, tools::Rectangle* pHairline = nullptr ) const;
129 
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 );
134 
135  void Convert( MtfConversion eConversion );
136  void ReplaceColors( const Color* pSearchColors, const Color* rReplaceColors,
137  sal_uLong nColorCount );
138 
139  GDIMetaFile GetMonochromeMtf( const Color& rCol ) const;
140 
141  void Record( OutputDevice* pOutDev );
142  bool IsRecord() const { return m_bRecord; }
143 
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 );
148 
149  void Pause( bool bPause );
150  bool IsPause() const { return m_bPause; }
151 
152  void Stop();
153 
154  void WindStart();
155  void WindPrev();
156 
157  size_t GetActionSize() const;
158 
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);
166  void ReplaceAction( rtl::Reference<MetaAction> pAction, size_t nAction );
167 
168  MetaAction* FirstAction();
169  MetaAction* NextAction();
170  MetaAction* GetAction( size_t nAction ) const;
171  MetaAction* GetCurAction() const { return GetAction( m_nCurrentActionElement ); }
172 
173  const Size& GetPrefSize() const { return m_aPrefSize; }
174  void SetPrefSize( const Size& rSize ) { m_aPrefSize = rSize; }
175 
176  const MapMode& GetPrefMapMode() const { return m_aPrefMapMode; }
177  void SetPrefMapMode( const MapMode& rMapMode ) { m_aPrefMapMode = rMapMode; }
178 
179 
180  BitmapChecksum GetChecksum() const;
181  sal_uLong GetSizeBytes() const;
182 
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 );
187 
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);
192 
194  bool CreateThumbnail(BitmapEx& rBitmapEx,
195  BmpConversion nColorConversion = BmpConversion::N24Bit,
196  BmpScaleFlag nScaleFlag = BmpScaleFlag::BestQuality) const;
197 
198  void UseCanvas( bool _bUseCanvas );
199  bool GetUseCanvas() const { return m_bUseCanvas; }
200 
202  void dumpAsXml(const char* pFileName = nullptr) const;
203 };
204 
205 #endif // INCLUDED_VCL_GDIMTF_HXX
206 
207 /* 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:171
const MapMode & GetPrefMapMode() const
Definition: gdimtf.hxx:176
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
VCL_DLLPUBLIC SvStream & ReadGDIMetaFile(SvStream &rIStm, GDIMetaFile &rGDIMetaFile, ImplMetaReadData *pReadData=nullptr)
Definition: gdimtf.cxx:2621
sal_uIntPtr sal_uLong
MtfConversion
Definition: gdimtf.hxx:44
void SetPrefSize(const Size &rSize)
Definition: gdimtf.hxx:174
bool IsRecord() const
Definition: gdimtf.hxx:142
VCL_DLLPUBLIC SvStream & WriteGDIMetaFile(SvStream &rOStm, const GDIMetaFile &rGDIMetaFile)
Definition: gdimtf.cxx:2705
BitmapEx(* BmpExchangeFnc)(const BitmapEx &rBmpEx, const void *pBmpParam)
Definition: gdimtf.hxx:52
Size m_aPrefSize
Definition: gdimtf.hxx:64
bool operator==(const ItalicMatrix &a, const ItalicMatrix &b)
Definition: vclenum.hxx:203
bool m_bPause
Definition: gdimtf.hxx:68
bool GetUseCanvas() const
Definition: gdimtf.hxx:199
const Size & GetPrefSize() const
Definition: gdimtf.hxx:173
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:304
BmpMirrorFlags
Definition: bitmap.hxx:36
BmpScaleFlag
Definition: bitmap.hxx:48
Clip
bool m_bRecord
Definition: gdimtf.hxx:69
BmpConversion
Definition: bitmap.hxx:65
#define GDI_METAFILE_END
Definition: gdimtf.hxx:42
bool IsPause() const
Definition: gdimtf.hxx:150
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
Point Rotate(const Point &rPoint, short nOrientation, const Point &rOrigin)
void SetPrefMapMode(const MapMode &rMapMode)
Definition: gdimtf.hxx:177