Line data Source code
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/metaact.hxx>
24 : #include <vcl/graph.hxx>
25 : #include <vcl/gdimtf.hxx>
26 : #include <vcl/virdev.hxx>
27 : #include <vcl/fltcall.hxx>
28 :
29 : class LineInfo;
30 : namespace basegfx { class B2DPolygon; }
31 :
32 79 : class EMFWriter
33 : {
34 : private:
35 :
36 : ScopedVclPtr<VirtualDevice> maVDev;
37 : MapMode maDestMapMode;
38 : SvStream& m_rStm;
39 : bool* mpHandlesUsed;
40 : sal_uLong mnHandleCount;
41 : sal_uLong mnRecordCount;
42 : sal_uLong mnRecordPos;
43 : sal_uLong mnRecordPlusPos;
44 : bool mbRecordOpen;
45 : bool mbRecordPlusOpen;
46 : bool mbLineChanged;
47 : sal_uInt32 mnLineHandle;
48 : bool mbFillChanged;
49 : sal_uInt32 mnFillHandle;
50 : bool mbTextChanged;
51 : sal_uInt32 mnTextHandle;
52 : sal_uInt32 mnHorTextAlign;
53 :
54 : void ImplBeginRecord( sal_uInt32 nType );
55 : void ImplEndRecord();
56 : void ImplBeginPlusRecord( sal_uInt16 nType, sal_uInt16 nFlags );
57 : void ImplEndPlusRecord();
58 : void ImplPlusRecord( sal_uInt16 nType, sal_uInt16 nFlags );
59 : void ImplBeginCommentRecord( sal_Int32 nCommentType );
60 : void ImplEndCommentRecord();
61 :
62 : sal_uLong ImplAcquireHandle();
63 : void ImplReleaseHandle( sal_uLong nHandle );
64 :
65 : bool ImplPrepareHandleSelect( sal_uInt32& rHandle, sal_uLong nSelectType );
66 : void ImplCheckLineAttr();
67 : void ImplCheckFillAttr();
68 : void ImplCheckTextAttr();
69 :
70 : void ImplWriteColor( const Color& rColor );
71 : void ImplWriteRasterOp( RasterOp eRop );
72 : void ImplWriteExtent( long nExtent );
73 : void ImplWritePoint( const Point& rPoint );
74 : void ImplWriteSize( const Size& rSize);
75 : void ImplWriteRect( const Rectangle& rRect );
76 : void ImplWritePath( const tools::PolyPolygon& rPolyPoly, bool bClose );
77 : void ImplWritePolygonRecord( const Polygon& rPoly, bool bClose );
78 : void ImplWritePolyPolygonRecord( const tools::PolyPolygon& rPolyPoly );
79 : void ImplWriteBmpRecord( const Bitmap& rBmp, const Point& rPt, const Size& rSz, sal_uInt32 nROP );
80 : void ImplWriteTextRecord( const Point& rPos, const OUString& rText, const long* pDXArray, sal_uInt32 nWidth );
81 :
82 : void Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon);
83 : void ImplWrite( const GDIMetaFile& rMtf );
84 : void WriteEMFPlusHeader( const Size &rMtfSizePix, const Size &rMtfSizeLog );
85 : void ImplWritePlusEOF();
86 : void ImplWritePlusFillPolygonRecord( const Polygon& rPoly, const sal_uInt32& nTrans );
87 : void ImplWritePlusColor( const Color& rColor, const sal_uInt32& nTrans );
88 : void ImplWritePlusPoint( const Point& rPoint );
89 :
90 : public:
91 :
92 79 : explicit EMFWriter(SvStream &rStream)
93 : : maVDev( VclPtr<VirtualDevice>::Create() )
94 : , m_rStm(rStream)
95 : , mpHandlesUsed(NULL)
96 : , mnHandleCount(0)
97 : , mnRecordCount(0)
98 : , mnRecordPos(0)
99 : , mnRecordPlusPos(0)
100 : , mbRecordOpen(false)
101 : , mbRecordPlusOpen(false)
102 : , mbLineChanged(false)
103 : , mnLineHandle(0)
104 : , mbFillChanged(false)
105 : , mnFillHandle(0)
106 : , mbTextChanged(false)
107 : , mnTextHandle(0)
108 79 : , mnHorTextAlign(0)
109 : {
110 79 : }
111 :
112 : bool WriteEMF(const GDIMetaFile& rMtf);
113 : };
114 :
115 : #endif // INCLUDED_VCL_SOURCE_FILTER_WMF_EMFWR_HXX
116 :
117 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|