LibreOffice Module vcl (master)  1
emfwr.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_SOURCE_FILTER_WMF_EMFWR_HXX
21 #define INCLUDED_VCL_SOURCE_FILTER_WMF_EMFWR_HXX
22 
23 #include <vcl/gdimtf.hxx>
24 #include <vcl/virdev.hxx>
25 
26 class LineInfo;
27 namespace basegfx { class B2DPolygon; }
28 enum class EmfPlusRecordType;
29 
30 class EMFWriter
31 {
32 private:
33 
37  std::vector<bool> mHandlesUsed;
45  sal_uInt32 mnLineHandle;
47  sal_uInt32 mnFillHandle;
49  sal_uInt32 mnTextHandle;
50  sal_uInt32 mnHorTextAlign;
51 
52  void ImplBeginRecord( sal_uInt32 nType );
53  void ImplEndRecord();
54  void ImplBeginPlusRecord( EmfPlusRecordType nType, sal_uInt16 nFlags );
55  void ImplEndPlusRecord();
56  void ImplPlusRecord( EmfPlusRecordType nType, sal_uInt16 nFlags );
57  void ImplBeginCommentRecord( sal_Int32 nCommentType );
58  void ImplEndCommentRecord();
59 
61  void ImplReleaseHandle( sal_uLong nHandle );
62 
63  bool ImplPrepareHandleSelect( sal_uInt32& rHandle, sal_uLong nSelectType );
64  void ImplCheckLineAttr();
65  void ImplCheckFillAttr();
66  void ImplCheckTextAttr();
67 
68  void ImplWriteColor( const Color& rColor );
69  void ImplWriteRasterOp( RasterOp eRop );
70  void ImplWriteExtent( long nExtent );
71  void ImplWritePoint( const Point& rPoint );
72  void ImplWriteSize( const Size& rSize);
73  void ImplWriteRect( const tools::Rectangle& rRect );
74  void ImplWritePath( const tools::PolyPolygon& rPolyPoly, bool bClose );
75  void ImplWritePolygonRecord( const tools::Polygon& rPoly, bool bClose );
76  void ImplWritePolyPolygonRecord( const tools::PolyPolygon& rPolyPoly );
77  void ImplWriteBmpRecord( const Bitmap& rBmp, const Point& rPt, const Size& rSz, sal_uInt32 nROP );
78  void ImplWriteTextRecord( const Point& rPos, const OUString& rText, const long* pDXArray, sal_uInt32 nWidth );
79 
80  void Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon);
81  void ImplWrite( const GDIMetaFile& rMtf );
82  void WriteEMFPlusHeader( const Size &rMtfSizePix, const Size &rMtfSizeLog );
83  void ImplWritePlusEOF();
84  void ImplWritePlusFillPolygonRecord( const tools::Polygon& rPoly, sal_uInt32 nTrans );
85  void ImplWritePlusColor( const Color& rColor, sal_uInt32 nTrans );
86  void ImplWritePlusPoint( const Point& rPoint );
87 
88 public:
89 
90  explicit EMFWriter(SvStream &rStream)
91  : maVDev( VclPtr<VirtualDevice>::Create() )
92  , m_rStm(rStream)
93  , mnHandleCount(0)
94  , mnRecordCount(0)
95  , mnRecordPos(0)
96  , mnRecordPlusPos(0)
97  , mbRecordOpen(false)
98  , mbRecordPlusOpen(false)
99  , mbLineChanged(false)
100  , mnLineHandle(0)
101  , mbFillChanged(false)
102  , mnFillHandle(0)
103  , mbTextChanged(false)
104  , mnTextHandle(0)
105  , mnHorTextAlign(0)
106  {
107  }
108 
109  bool WriteEMF(const GDIMetaFile& rMtf);
110 };
111 
112 #endif // INCLUDED_VCL_SOURCE_FILTER_WMF_EMFWR_HXX
113 
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void ImplEndCommentRecord()
Definition: emfwr.cxx:117
void ImplWriteSize(const Size &rSize)
Definition: emfwr.cxx:601
sal_uInt32 mnLineHandle
Definition: emfwr.hxx:45
void ImplCheckTextAttr()
Definition: emfwr.cxx:451
void ImplWriteRect(const tools::Rectangle &rRect)
Definition: emfwr.cxx:607
void ImplWriteExtent(long nExtent)
Definition: emfwr.cxx:589
void ImplBeginPlusRecord(EmfPlusRecordType nType, sal_uInt16 nFlags)
Definition: emfwr.cxx:129
std::vector< bool > mHandlesUsed
Definition: emfwr.hxx:37
void ImplWritePlusFillPolygonRecord(const tools::Polygon &rPoly, sal_uInt32 nTrans)
Definition: emfwr.cxx:224
void ImplWrite(const GDIMetaFile &rMtf)
Definition: emfwr.cxx:948
A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for refer...
Definition: button.hxx:32
MapMode maDestMapMode
Definition: emfwr.hxx:35
void ImplWriteTextRecord(const Point &rPos, const OUString &rText, const long *pDXArray, sal_uInt32 nWidth)
Definition: emfwr.cxx:841
void ImplWritePlusColor(const Color &rColor, sal_uInt32 nTrans)
Definition: emfwr.cxx:206
bool mbLineChanged
Definition: emfwr.hxx:44
void ImplWritePolygonRecord(const tools::Polygon &rPoly, bool bClose)
Definition: emfwr.cxx:619
sal_uIntPtr sal_uLong
bool ImplPrepareHandleSelect(sal_uInt32 &rHandle, sal_uLong nSelectType)
Definition: emfwr.cxx:384
bool mbRecordOpen
Definition: emfwr.hxx:42
sal_uLong mnRecordPos
Definition: emfwr.hxx:40
bool mbTextChanged
Definition: emfwr.hxx:48
void ImplCheckFillAttr()
Definition: emfwr.cxx:433
sal_uInt32 mnTextHandle
Definition: emfwr.hxx:49
void ImplBeginRecord(sal_uInt32 nType)
Definition: emfwr.cxx:348
void ImplWriteRasterOp(RasterOp eRop)
Definition: emfwr.cxx:573
RasterOp
Definition: vclenum.hxx:191
void ImplReleaseHandle(sal_uLong nHandle)
Definition: emfwr.cxx:342
bool mbRecordPlusOpen
Definition: emfwr.hxx:43
void ImplWritePoint(const Point &rPoint)
Definition: emfwr.cxx:595
ScopedVclPtr< VirtualDevice > maVDev
Definition: emfwr.hxx:34
void ImplWriteColor(const Color &rColor)
Definition: emfwr.cxx:563
void ImplWritePlusPoint(const Point &rPoint)
Definition: emfwr.cxx:217
void ImplEndPlusRecord()
Definition: emfwr.cxx:143
EmfPlusRecordType
Definition: emfwr.cxx:98
void Impl_handleLineInfoPolyPolygons(const LineInfo &rInfo, const basegfx::B2DPolygon &rLinePolygon)
Definition: emfwr.cxx:912
sal_uLong mnRecordCount
Definition: emfwr.hxx:39
void ImplBeginCommentRecord(sal_Int32 nCommentType)
Definition: emfwr.cxx:110
sal_uInt32 mnHorTextAlign
Definition: emfwr.hxx:50
bool WriteEMF(const GDIMetaFile &rMtf)
Definition: emfwr.cxx:239
void ImplWritePlusEOF()
Definition: emfwr.cxx:199
sal_uInt32 mnFillHandle
Definition: emfwr.hxx:47
void ImplWritePolyPolygonRecord(const tools::PolyPolygon &rPolyPoly)
Definition: emfwr.cxx:644
void ImplWritePath(const tools::PolyPolygon &rPolyPoly, bool bClose)
Definition: emfwr.cxx:693
void ImplEndRecord()
Definition: emfwr.cxx:362
void ImplWriteBmpRecord(const Bitmap &rBmp, const Point &rPt, const Size &rSz, sal_uInt32 nROP)
Definition: emfwr.cxx:778
sal_uLong mnHandleCount
Definition: emfwr.hxx:38
EMFWriter(SvStream &rStream)
Definition: emfwr.hxx:90
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
SvStream & m_rStm
Definition: emfwr.hxx:36
void ImplPlusRecord(EmfPlusRecordType nType, sal_uInt16 nFlags)
Definition: emfwr.cxx:159
void WriteEMFPlusHeader(const Size &rMtfSizePix, const Size &rMtfSizeLog)
Definition: emfwr.cxx:165
sal_uLong mnRecordPlusPos
Definition: emfwr.hxx:41
sal_uLong ImplAcquireHandle()
Definition: emfwr.cxx:323
bool mbFillChanged
Definition: emfwr.hxx:46
void ImplCheckLineAttr()
Definition: emfwr.cxx:416