1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _DXF2MTF_HXX
25 #define _DXF2MTF_HXX
26 
27 #include "dxfreprd.hxx"
28 #include <vcl/font.hxx>
29 #include <vcl/lineinfo.hxx>
30 
31 // MT: NOOLDSV, someone should change the code...
32 enum PenStyle { PEN_NULL, PEN_SOLID, PEN_DOT, PEN_DASH, PEN_DASHDOT };
33 enum BrushStyle { BRUSH_NULL, BRUSH_SOLID, BRUSH_HORZ, BRUSH_VERT,
34 				  BRUSH_CROSS, BRUSH_DIAGCROSS, BRUSH_UPDIAG, BRUSH_DOWNDIAG,
35 				  BRUSH_25, BRUSH_50, BRUSH_75,
36 				  BRUSH_BITMAP };
37 
38 
39 class DXF2GDIMetaFile {
40 private:
41 
42 	VirtualDevice * pVirDev;
43 	const DXFRepresentation * pDXF;
44 	sal_Bool bStatus;
45 
46 	sal_uInt16 OptPointsPerCircle;
47 
48 	sal_uLong nMinPercent;
49 	sal_uLong nMaxPercent;
50 	sal_uLong nLastPercent;
51 	sal_uLong nMainEntitiesCount;
52 
53 	long		nBlockColor;
54 	DXFLineInfo	aBlockDXFLineInfo;
55 	long		nParentLayerColor;
56 	DXFLineInfo	aParentLayerDXFLineInfo;
57 	Color		aActLineColor;
58 	Color		aActFillColor;
59 	Font		aActFont;
60 
61 	sal_uLong CountEntities(const DXFEntities & rEntities);
62 
63 	void MayCallback(sal_uLong nMainEntitiesProcessed);
64 
65 	Color ConvertColor(sal_uInt8 nColor);
66 
67 	long GetEntityColor(const DXFBasicEntity & rE);
68 
69 	DXFLineInfo LTypeToDXFLineInfo(const char * sLineType);
70 
71 	DXFLineInfo GetEntityDXFLineInfo(const DXFBasicEntity & rE);
72 
73 	sal_Bool SetLineAttribute(const DXFBasicEntity & rE, sal_uLong nWidth=0);
74 
75 	sal_Bool SetAreaAttribute(const DXFBasicEntity & rE);
76 
77 	sal_Bool SetFontAttribute(const DXFBasicEntity & rE, short nAngle,
78 						  sal_uInt16 nHeight, double fWidthScale);
79 
80 	void DrawLineEntity(const DXFLineEntity & rE, const DXFTransform & rTransform);
81 
82 	void DrawPointEntity(const DXFPointEntity & rE, const DXFTransform & rTransform);
83 
84 	void DrawCircleEntity(const DXFCircleEntity & rE, const DXFTransform & rTransform);
85 
86 	void DrawArcEntity(const DXFArcEntity & rE, const DXFTransform & rTransform);
87 
88 	void DrawTraceEntity(const DXFTraceEntity & rE, const DXFTransform & rTransform);
89 
90 	void DrawSolidEntity(const DXFSolidEntity & rE, const DXFTransform & rTransform);
91 
92 	void DrawTextEntity(const DXFTextEntity & rE, const DXFTransform & rTransform);
93 
94 	void DrawInsertEntity(const DXFInsertEntity & rE, const DXFTransform & rTransform);
95 
96 	void DrawAttribEntity(const DXFAttribEntity & rE, const DXFTransform & rTransform);
97 
98 	void DrawPolyLineEntity(const DXFPolyLineEntity & rE, const DXFTransform & rTransform);
99 
100 	void Draw3DFaceEntity(const DXF3DFaceEntity & rE, const DXFTransform & rTransform);
101 
102 	void DrawDimensionEntity(const DXFDimensionEntity & rE, const DXFTransform & rTransform);
103 
104 	void DrawLWPolyLineEntity( const DXFLWPolyLineEntity & rE, const DXFTransform & rTransform );
105 
106 	void DrawHatchEntity( const DXFHatchEntity & rE, const DXFTransform & rTransform );
107 
108 	void DrawEntities(const DXFEntities & rEntities,
109 					  const DXFTransform & rTransform,
110 					  sal_Bool bTopEntities);
111 
112 public:
113 
114 	DXF2GDIMetaFile();
115 	~DXF2GDIMetaFile();
116 
117 	sal_Bool Convert( const DXFRepresentation & rDXF, GDIMetaFile & rMTF, sal_uInt16 nMinPercent, sal_uInt16 nMaxPercent);
118 
119 };
120 
121 
122 #endif
123 
124 
125