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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_filter.hxx"
26
27 #include <string.h>
28 #include <dxfentrd.hxx>
29
30 //--------------------------DXFBasicEntity--------------------------------------
31
DXFBasicEntity(DXFEntityType eThisType)32 DXFBasicEntity::DXFBasicEntity(DXFEntityType eThisType)
33 {
34 eType=eThisType;
35 pSucc=NULL;
36 strncpy(sLayer,"0", 2 );
37 strncpy(sLineType,"BYLAYER", 8 );
38 fElevation=0;
39 fThickness=0;
40 nColor=256;
41 nSpace=0;
42 aExtrusion.fx=0.0;
43 aExtrusion.fy=0.0;
44 aExtrusion.fz=1.0;
45 }
46
Read(DXFGroupReader & rDGR)47 void DXFBasicEntity::Read(DXFGroupReader & rDGR)
48 {
49 while (rDGR.Read()!=0) EvaluateGroup(rDGR);
50 }
51
EvaluateGroup(DXFGroupReader & rDGR)52 void DXFBasicEntity::EvaluateGroup(DXFGroupReader & rDGR)
53 {
54 switch (rDGR.GetG())
55 {
56 case 8: strncpy( sLayer, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
57 case 6: strncpy( sLineType, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
58 case 38: fElevation=rDGR.GetF(); break;
59 case 39: fThickness=rDGR.GetF(); break;
60 case 62: nColor=rDGR.GetI(); break;
61 case 67: nSpace=rDGR.GetI(); break;
62 case 210: aExtrusion.fx=rDGR.GetF(); break;
63 case 220: aExtrusion.fy=rDGR.GetF(); break;
64 case 230: aExtrusion.fz=rDGR.GetF(); break;
65 }
66 }
67
~DXFBasicEntity()68 DXFBasicEntity::~DXFBasicEntity()
69 {
70 }
71
72 //--------------------------DXFLineEntity---------------------------------------
73
DXFLineEntity()74 DXFLineEntity::DXFLineEntity() : DXFBasicEntity(DXF_LINE)
75 {
76 }
77
EvaluateGroup(DXFGroupReader & rDGR)78 void DXFLineEntity::EvaluateGroup(DXFGroupReader & rDGR)
79 {
80 switch (rDGR.GetG()) {
81 case 10: aP0.fx=rDGR.GetF(); break;
82 case 20: aP0.fy=rDGR.GetF(); break;
83 case 30: aP0.fz=rDGR.GetF(); break;
84 case 11: aP1.fx=rDGR.GetF(); break;
85 case 21: aP1.fy=rDGR.GetF(); break;
86 case 31: aP1.fz=rDGR.GetF(); break;
87 default: DXFBasicEntity::EvaluateGroup(rDGR);
88 }
89 }
90
91 //--------------------------DXFPointEntity--------------------------------------
92
DXFPointEntity()93 DXFPointEntity::DXFPointEntity() : DXFBasicEntity(DXF_POINT)
94 {
95 }
96
EvaluateGroup(DXFGroupReader & rDGR)97 void DXFPointEntity::EvaluateGroup(DXFGroupReader & rDGR)
98 {
99 switch (rDGR.GetG()) {
100 case 10: aP0.fx=rDGR.GetF(); break;
101 case 20: aP0.fy=rDGR.GetF(); break;
102 case 30: aP0.fz=rDGR.GetF(); break;
103 default: DXFBasicEntity::EvaluateGroup(rDGR);
104 }
105 }
106
107 //--------------------------DXFCircleEntity-------------------------------------
108
DXFCircleEntity()109 DXFCircleEntity::DXFCircleEntity() : DXFBasicEntity(DXF_CIRCLE)
110 {
111 fRadius=1.0;
112 }
113
EvaluateGroup(DXFGroupReader & rDGR)114 void DXFCircleEntity::EvaluateGroup(DXFGroupReader & rDGR)
115 {
116 switch (rDGR.GetG()) {
117 case 10: aP0.fx=rDGR.GetF(); break;
118 case 20: aP0.fy=rDGR.GetF(); break;
119 case 30: aP0.fz=rDGR.GetF(); break;
120 case 40: fRadius=rDGR.GetF(); break;
121 default: DXFBasicEntity::EvaluateGroup(rDGR);
122 }
123 }
124
125 //--------------------------DXFArcEntity----------------------------------------
126
DXFArcEntity()127 DXFArcEntity::DXFArcEntity() : DXFBasicEntity(DXF_ARC)
128 {
129 fRadius=1.0;
130 fStart=0;
131 fEnd=360.0;
132 }
133
EvaluateGroup(DXFGroupReader & rDGR)134 void DXFArcEntity::EvaluateGroup(DXFGroupReader & rDGR)
135 {
136 switch (rDGR.GetG()) {
137 case 10: aP0.fx=rDGR.GetF(); break;
138 case 20: aP0.fy=rDGR.GetF(); break;
139 case 30: aP0.fz=rDGR.GetF(); break;
140 case 40: fRadius=rDGR.GetF(); break;
141 case 50: fStart=rDGR.GetF(); break;
142 case 51: fEnd=rDGR.GetF(); break;
143 default: DXFBasicEntity::EvaluateGroup(rDGR);
144 }
145 }
146
147 //--------------------------DXFTraceEntity--------------------------------------
148
DXFTraceEntity()149 DXFTraceEntity::DXFTraceEntity() : DXFBasicEntity(DXF_TRACE)
150 {
151 }
152
EvaluateGroup(DXFGroupReader & rDGR)153 void DXFTraceEntity::EvaluateGroup(DXFGroupReader & rDGR)
154 {
155 switch (rDGR.GetG()) {
156 case 10: aP0.fx=rDGR.GetF(); break;
157 case 20: aP0.fy=rDGR.GetF(); break;
158 case 30: aP0.fz=rDGR.GetF(); break;
159 case 11: aP1.fx=rDGR.GetF(); break;
160 case 21: aP1.fy=rDGR.GetF(); break;
161 case 31: aP1.fz=rDGR.GetF(); break;
162 case 12: aP2.fx=rDGR.GetF(); break;
163 case 22: aP2.fy=rDGR.GetF(); break;
164 case 32: aP2.fz=rDGR.GetF(); break;
165 case 13: aP3.fx=rDGR.GetF(); break;
166 case 23: aP3.fy=rDGR.GetF(); break;
167 case 33: aP3.fz=rDGR.GetF(); break;
168 default: DXFBasicEntity::EvaluateGroup(rDGR);
169 }
170 }
171
172 //--------------------------DXFSolidEntity--------------------------------------
173
DXFSolidEntity()174 DXFSolidEntity::DXFSolidEntity() : DXFBasicEntity(DXF_SOLID)
175 {
176 }
177
EvaluateGroup(DXFGroupReader & rDGR)178 void DXFSolidEntity::EvaluateGroup(DXFGroupReader & rDGR)
179 {
180 switch (rDGR.GetG()) {
181 case 10: aP0.fx=rDGR.GetF(); break;
182 case 20: aP0.fy=rDGR.GetF(); break;
183 case 30: aP0.fz=rDGR.GetF(); break;
184 case 11: aP1.fx=rDGR.GetF(); break;
185 case 21: aP1.fy=rDGR.GetF(); break;
186 case 31: aP1.fz=rDGR.GetF(); break;
187 case 12: aP2.fx=rDGR.GetF(); break;
188 case 22: aP2.fy=rDGR.GetF(); break;
189 case 32: aP2.fz=rDGR.GetF(); break;
190 case 13: aP3.fx=rDGR.GetF(); break;
191 case 23: aP3.fy=rDGR.GetF(); break;
192 case 33: aP3.fz=rDGR.GetF(); break;
193 default: DXFBasicEntity::EvaluateGroup(rDGR);
194 }
195 }
196
197 //--------------------------DXFTextEntity---------------------------------------
198
DXFTextEntity()199 DXFTextEntity::DXFTextEntity() : DXFBasicEntity(DXF_TEXT)
200 {
201 fHeight=1.0;
202 sText[0]=0;
203 fRotAngle=0.0;
204 fXScale=1.0;
205 fOblAngle=0.0;
206 strncpy( sStyle, "STANDARD", 9 );
207 nGenFlags=0;
208 nHorzJust=0;
209 nVertJust=0;
210 }
211
EvaluateGroup(DXFGroupReader & rDGR)212 void DXFTextEntity::EvaluateGroup(DXFGroupReader & rDGR)
213 {
214 switch (rDGR.GetG()) {
215 case 10: aP0.fx=rDGR.GetF(); break;
216 case 20: aP0.fy=rDGR.GetF(); break;
217 case 30: aP0.fz=rDGR.GetF(); break;
218 case 40: fHeight=rDGR.GetF(); break;
219 case 1: strncpy( sText, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
220 case 50: fRotAngle=rDGR.GetF(); break;
221 case 41: fXScale=rDGR.GetF(); break;
222 case 42: fOblAngle=rDGR.GetF(); break;
223 case 7: strncpy( sStyle, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
224 case 71: nGenFlags=rDGR.GetI(); break;
225 case 72: nHorzJust=rDGR.GetI(); break;
226 case 73: nVertJust=rDGR.GetI(); break;
227 case 11: aAlign.fx=rDGR.GetF(); break;
228 case 21: aAlign.fy=rDGR.GetF(); break;
229 case 31: aAlign.fz=rDGR.GetF(); break;
230 default: DXFBasicEntity::EvaluateGroup(rDGR);
231 }
232 }
233
234 //--------------------------DXFShapeEntity--------------------------------------
235
DXFShapeEntity()236 DXFShapeEntity::DXFShapeEntity() : DXFBasicEntity(DXF_SHAPE)
237 {
238 fSize=1.0;
239 sName[0]=0;
240 fRotAngle=0;
241 fXScale=1.0;
242 fOblAngle=0;
243 }
244
EvaluateGroup(DXFGroupReader & rDGR)245 void DXFShapeEntity::EvaluateGroup(DXFGroupReader & rDGR)
246 {
247 switch (rDGR.GetG()) {
248 case 10: aP0.fx=rDGR.GetF(); break;
249 case 20: aP0.fy=rDGR.GetF(); break;
250 case 30: aP0.fz=rDGR.GetF(); break;
251 case 40: fSize=rDGR.GetF(); break;
252 case 2: strncpy( sName, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
253 case 50: fRotAngle=rDGR.GetF(); break;
254 case 41: fXScale=rDGR.GetF(); break;
255 case 51: fOblAngle=rDGR.GetF(); break;
256 default: DXFBasicEntity::EvaluateGroup(rDGR);
257 }
258 }
259
260 //--------------------------DXFInsertEntity-------------------------------------
261
DXFInsertEntity()262 DXFInsertEntity::DXFInsertEntity() : DXFBasicEntity(DXF_INSERT)
263 {
264 nAttrFlag=0;
265 sName[0]=0;
266 fXScale=1.0;
267 fYScale=1.0;
268 fZScale=1.0;
269 fRotAngle=0.0;
270 nColCount=1;
271 nRowCount=1;
272 fColSpace=0.0;
273 fRowSpace=0.0;
274 }
275
EvaluateGroup(DXFGroupReader & rDGR)276 void DXFInsertEntity::EvaluateGroup(DXFGroupReader & rDGR)
277 {
278 switch (rDGR.GetG()) {
279 case 66: nAttrFlag=rDGR.GetI(); break;
280 case 2: strncpy( sName, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
281 case 10: aP0.fx=rDGR.GetF(); break;
282 case 20: aP0.fy=rDGR.GetF(); break;
283 case 30: aP0.fz=rDGR.GetF(); break;
284 case 41: fXScale=rDGR.GetF(); break;
285 case 42: fYScale=rDGR.GetF(); break;
286 case 43: fZScale=rDGR.GetF(); break;
287 case 50: fRotAngle=rDGR.GetF(); break;
288 case 70: nColCount=rDGR.GetI(); break;
289 case 71: nRowCount=rDGR.GetI(); break;
290 case 44: fColSpace=rDGR.GetF(); break;
291 case 45: fRowSpace=rDGR.GetF(); break;
292 default: DXFBasicEntity::EvaluateGroup(rDGR);
293 }
294 }
295
296 //--------------------------DXFAttDefEntity-------------------------------------
297
DXFAttDefEntity()298 DXFAttDefEntity::DXFAttDefEntity() : DXFBasicEntity(DXF_ATTDEF)
299 {
300 fHeight=1.0;
301 sDefVal[0]=0;
302 sPrompt[0]=0;
303 sTagStr[0]=0;
304 nAttrFlags=0;
305 nFieldLen=0;
306 fRotAngle=0.0;
307 fXScale=1.0;
308 fOblAngle=0.0;
309 strncpy( sStyle, "STANDARD", 9 );
310 nGenFlags=0;
311 nHorzJust=0;
312 nVertJust=0;
313 }
314
EvaluateGroup(DXFGroupReader & rDGR)315 void DXFAttDefEntity::EvaluateGroup(DXFGroupReader & rDGR)
316 {
317 switch (rDGR.GetG()) {
318 case 10: aP0.fx=rDGR.GetF(); break;
319 case 20: aP0.fy=rDGR.GetF(); break;
320 case 30: aP0.fz=rDGR.GetF(); break;
321 case 40: fHeight=rDGR.GetF(); break;
322 case 1: strncpy( sDefVal, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
323 case 3: strncpy( sPrompt, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
324 case 2: strncpy( sTagStr, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
325 case 70: nAttrFlags=rDGR.GetI(); break;
326 case 73: nFieldLen=rDGR.GetI(); break;
327 case 50: fRotAngle=rDGR.GetF(); break;
328 case 41: fXScale=rDGR.GetF(); break;
329 case 51: fOblAngle=rDGR.GetF(); break;
330 case 7: strncpy( sStyle, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
331 case 71: nGenFlags=rDGR.GetI(); break;
332 case 72: nHorzJust=rDGR.GetI(); break;
333 case 74: nVertJust=rDGR.GetI(); break;
334 case 11: aAlign.fx=rDGR.GetF(); break;
335 case 21: aAlign.fy=rDGR.GetF(); break;
336 case 31: aAlign.fz=rDGR.GetF(); break;
337 default: DXFBasicEntity::EvaluateGroup(rDGR);
338 }
339 }
340
341 //--------------------------DXFAttribEntity-------------------------------------
342
DXFAttribEntity()343 DXFAttribEntity::DXFAttribEntity() : DXFBasicEntity(DXF_ATTRIB)
344 {
345 fHeight=1.0;
346 sText[0]=0;
347 sTagStr[0]=0;
348 nAttrFlags=0;
349 nFieldLen=0;
350 fRotAngle=0.0;
351 fXScale=1.0;
352 fOblAngle=0.0;
353 strncpy( sStyle, "STANDARD", 9 );
354 nGenFlags=0;
355 nHorzJust=0;
356 nVertJust=0;
357 }
358
EvaluateGroup(DXFGroupReader & rDGR)359 void DXFAttribEntity::EvaluateGroup(DXFGroupReader & rDGR)
360 {
361 switch (rDGR.GetG()) {
362 case 10: aP0.fx=rDGR.GetF(); break;
363 case 20: aP0.fy=rDGR.GetF(); break;
364 case 30: aP0.fz=rDGR.GetF(); break;
365 case 40: fHeight=rDGR.GetF(); break;
366 case 1: strncpy( sText, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
367 case 2: strncpy( sTagStr, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
368 case 70: nAttrFlags=rDGR.GetI(); break;
369 case 73: nFieldLen=rDGR.GetI(); break;
370 case 50: fRotAngle=rDGR.GetF(); break;
371 case 41: fXScale=rDGR.GetF(); break;
372 case 51: fOblAngle=rDGR.GetF(); break;
373 case 7: strncpy( sStyle, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
374 case 71: nGenFlags=rDGR.GetI(); break;
375 case 72: nHorzJust=rDGR.GetI(); break;
376 case 74: nVertJust=rDGR.GetI(); break;
377 case 11: aAlign.fx=rDGR.GetF(); break;
378 case 21: aAlign.fy=rDGR.GetF(); break;
379 case 31: aAlign.fz=rDGR.GetF(); break;
380 default: DXFBasicEntity::EvaluateGroup(rDGR);
381 }
382 }
383
384 //--------------------------DXFPolyLine-----------------------------------------
385
DXFPolyLineEntity()386 DXFPolyLineEntity::DXFPolyLineEntity() : DXFBasicEntity(DXF_POLYLINE)
387 {
388 fElevation=0.0;
389 nFlags=0;
390 fSWidth=0.0;
391 fEWidth=0.0;
392 nMeshMCount=0;
393 nMeshNCount=0;
394 nMDensity=0;
395 nNDensity=0;
396 nCSSType=0;
397 }
398
EvaluateGroup(DXFGroupReader & rDGR)399 void DXFPolyLineEntity::EvaluateGroup(DXFGroupReader & rDGR)
400 {
401 switch (rDGR.GetG()) {
402 case 30: fElevation=rDGR.GetF(); break;
403 case 70: nFlags=rDGR.GetI(); break;
404 case 40: fSWidth=rDGR.GetF(); break;
405 case 41: fEWidth=rDGR.GetF(); break;
406 case 71: nMeshMCount=rDGR.GetI(); break;
407 case 72: nMeshNCount=rDGR.GetI(); break;
408 case 73: nMDensity=rDGR.GetI(); break;
409 case 74: nNDensity=rDGR.GetI(); break;
410 case 75: nCSSType=rDGR.GetI(); break;
411 default: DXFBasicEntity::EvaluateGroup(rDGR);
412 }
413 }
414
415 //--------------------------DXFLWPolyLine---------------------------------------
416
DXFLWPolyLineEntity()417 DXFLWPolyLineEntity::DXFLWPolyLineEntity() :
418 DXFBasicEntity( DXF_LWPOLYLINE ),
419 nIndex( 0 ),
420 nCount( 0 ),
421 nFlags( 0 ),
422 fConstantWidth( 0.0 ),
423 fStartWidth( 0.0 ),
424 fEndWidth( 0.0 ),
425 pP( NULL )
426 {
427 }
428
EvaluateGroup(DXFGroupReader & rDGR)429 void DXFLWPolyLineEntity::EvaluateGroup( DXFGroupReader & rDGR )
430 {
431 switch ( rDGR.GetG() )
432 {
433 case 90 :
434 {
435 nCount = rDGR.GetI();
436 if ( nCount )
437 pP = new DXFVector[ nCount ];
438 }
439 break;
440 case 70: nFlags = rDGR.GetI(); break;
441 case 43: fConstantWidth = rDGR.GetF(); break;
442 case 40: fStartWidth = rDGR.GetF(); break;
443 case 41: fEndWidth = rDGR.GetF(); break;
444 case 10:
445 {
446 if ( pP && ( nIndex < nCount ) )
447 pP[ nIndex ].fx = rDGR.GetF();
448 }
449 break;
450 case 20:
451 {
452 if ( pP && ( nIndex < nCount ) )
453 pP[ nIndex++ ].fy = rDGR.GetF();
454 }
455 break;
456 default: DXFBasicEntity::EvaluateGroup(rDGR);
457 }
458 }
459
~DXFLWPolyLineEntity()460 DXFLWPolyLineEntity::~DXFLWPolyLineEntity()
461 {
462 delete[] pP;
463 }
464
465 //--------------------------DXFHatchEntity-------------------------------------
466
DXFEdgeTypeLine()467 DXFEdgeTypeLine::DXFEdgeTypeLine() :
468 DXFEdgeType( 1 )
469 {
470
471 }
~DXFEdgeTypeLine()472 DXFEdgeTypeLine::~DXFEdgeTypeLine()
473 {
474
475 }
EvaluateGroup(DXFGroupReader & rDGR)476 sal_Bool DXFEdgeTypeLine::EvaluateGroup( DXFGroupReader & rDGR )
477 {
478 sal_Bool bExecutingGroupCode = sal_True;
479 switch ( rDGR.GetG() )
480 {
481 case 10 : aStartPoint.fx = rDGR.GetF(); break;
482 case 20 : aStartPoint.fy = rDGR.GetF(); break;
483 case 11 : aEndPoint.fx = rDGR.GetF(); break;
484 case 21 : aEndPoint.fy = rDGR.GetF(); break;
485 default : bExecutingGroupCode = sal_False; break;
486 }
487 return bExecutingGroupCode;
488 }
489
DXFEdgeTypeCircularArc()490 DXFEdgeTypeCircularArc::DXFEdgeTypeCircularArc() :
491 DXFEdgeType( 2 ),
492 fRadius( 0.0 ),
493 fStartAngle( 0.0 ),
494 fEndAngle( 0.0 ),
495 nIsCounterClockwiseFlag( 0 )
496 {
497 }
~DXFEdgeTypeCircularArc()498 DXFEdgeTypeCircularArc::~DXFEdgeTypeCircularArc()
499 {
500 }
EvaluateGroup(DXFGroupReader & rDGR)501 sal_Bool DXFEdgeTypeCircularArc::EvaluateGroup( DXFGroupReader & rDGR )
502 {
503 sal_Bool bExecutingGroupCode = sal_True;
504 switch ( rDGR.GetG() )
505 {
506 case 10 : aCenter.fx = rDGR.GetF(); break;
507 case 20 : aCenter.fy = rDGR.GetF(); break;
508 case 40 : fRadius = rDGR.GetF(); break;
509 case 50 : fStartAngle = rDGR.GetF(); break;
510 case 51 : fEndAngle = rDGR.GetF(); break;
511 case 73 : nIsCounterClockwiseFlag = rDGR.GetI(); break;
512 default : bExecutingGroupCode = sal_False; break;
513 }
514 return bExecutingGroupCode;
515 }
516
DXFEdgeTypeEllipticalArc()517 DXFEdgeTypeEllipticalArc::DXFEdgeTypeEllipticalArc() :
518 DXFEdgeType( 3 ),
519 fLength( 0.0 ),
520 fStartAngle( 0.0 ),
521 fEndAngle( 0.0 ),
522 nIsCounterClockwiseFlag( 0 )
523 {
524 }
~DXFEdgeTypeEllipticalArc()525 DXFEdgeTypeEllipticalArc::~DXFEdgeTypeEllipticalArc()
526 {
527
528 }
EvaluateGroup(DXFGroupReader & rDGR)529 sal_Bool DXFEdgeTypeEllipticalArc::EvaluateGroup( DXFGroupReader & rDGR )
530 {
531 sal_Bool bExecutingGroupCode = sal_True;
532 switch( rDGR.GetG() )
533 {
534 case 10 : aCenter.fx = rDGR.GetF(); break;
535 case 20 : aCenter.fy = rDGR.GetF(); break;
536 case 11 : aEndPoint.fx = rDGR.GetF(); break;
537 case 21 : aEndPoint.fy = rDGR.GetF(); break;
538 case 40 : fLength = rDGR.GetF(); break;
539 case 50 : fStartAngle = rDGR.GetF(); break;
540 case 51 : fEndAngle = rDGR.GetF(); break;
541 case 73 : nIsCounterClockwiseFlag = rDGR.GetI(); break;
542 default : bExecutingGroupCode = sal_False; break;
543 }
544 return bExecutingGroupCode;
545 }
546
DXFEdgeTypeSpline()547 DXFEdgeTypeSpline::DXFEdgeTypeSpline() :
548 DXFEdgeType( 4 ),
549 nDegree( 0 ),
550 nRational( 0 ),
551 nPeriodic( 0 ),
552 nKnotCount( 0 ),
553 nControlCount( 0 )
554 {
555 }
~DXFEdgeTypeSpline()556 DXFEdgeTypeSpline::~DXFEdgeTypeSpline()
557 {
558
559 }
EvaluateGroup(DXFGroupReader & rDGR)560 sal_Bool DXFEdgeTypeSpline::EvaluateGroup( DXFGroupReader & rDGR )
561 {
562 sal_Bool bExecutingGroupCode = sal_True;
563 switch ( rDGR.GetG() )
564 {
565 case 94 : nDegree = rDGR.GetI(); break;
566 case 73 : nRational = rDGR.GetI(); break;
567 case 74 : nPeriodic = rDGR.GetI(); break;
568 case 95 : nKnotCount = rDGR.GetI(); break;
569 case 96 : nControlCount = rDGR.GetI(); break;
570 default : bExecutingGroupCode = sal_False; break;
571 }
572 return bExecutingGroupCode;
573 }
574
DXFBoundaryPathData()575 DXFBoundaryPathData::DXFBoundaryPathData() :
576 nFlags( 0 ),
577 nHasBulgeFlag( 0 ),
578 nIsClosedFlag( 0 ),
579 nPointCount( 0 ),
580 fBulge( 0.0 ),
581 nSourceBoundaryObjects( 0 ),
582 nEdgeCount( 0 ),
583 bIsPolyLine( sal_True ),
584 nPointIndex( 0 ),
585 pP( NULL )
586 {
587 }
588
~DXFBoundaryPathData()589 DXFBoundaryPathData::~DXFBoundaryPathData()
590 {
591 sal_uInt32 i = 0;
592 for ( i = 0; i < aEdges.size(); i++ )
593 delete aEdges[ i ];
594 delete[] pP;
595 }
596
EvaluateGroup(DXFGroupReader & rDGR)597 sal_Bool DXFBoundaryPathData::EvaluateGroup( DXFGroupReader & rDGR )
598 {
599 sal_Bool bExecutingGroupCode = sal_True;
600 if ( bIsPolyLine )
601 {
602 switch( rDGR.GetG() )
603 {
604 case 92 :
605 {
606 nFlags = rDGR.GetI();
607 if ( ( nFlags & 2 ) == 0 )
608 bIsPolyLine = sal_False;
609 }
610 break;
611 case 93 :
612 {
613 nPointCount = rDGR.GetI();
614 if ( nPointCount )
615 pP = new DXFVector[ nPointCount ];
616 }
617 break;
618 case 72 : nHasBulgeFlag = rDGR.GetI(); break;
619 case 73 : nIsClosedFlag = rDGR.GetI(); break;
620 case 97 : nSourceBoundaryObjects = rDGR.GetI(); break;
621 case 42 : fBulge = rDGR.GetF(); break;
622 case 10:
623 {
624 if ( pP && ( nPointIndex < nPointCount ) )
625 pP[ nPointIndex ].fx = rDGR.GetF();
626 }
627 break;
628 case 20:
629 {
630 if ( pP && ( nPointIndex < nPointCount ) )
631 pP[ nPointIndex++ ].fy = rDGR.GetF();
632 }
633 break;
634
635 default : bExecutingGroupCode = sal_False; break;
636 }
637 }
638 else
639 {
640 if ( rDGR.GetG() == 93 )
641 nEdgeCount = rDGR.GetI();
642 else if ( rDGR.GetG() == 72 )
643 {
644 sal_Int32 nEdgeType = rDGR.GetI();
645 switch( nEdgeType )
646 {
647 case 1 : aEdges.push_back( new DXFEdgeTypeLine() ); break;
648 case 2 : aEdges.push_back( new DXFEdgeTypeCircularArc() ); break;
649 case 3 : aEdges.push_back( new DXFEdgeTypeEllipticalArc() ); break;
650 case 4 : aEdges.push_back( new DXFEdgeTypeSpline() ); break;
651 }
652 }
653 else if ( aEdges.size() )
654 aEdges[ aEdges.size() - 1 ]->EvaluateGroup( rDGR );
655 else
656 bExecutingGroupCode = sal_False;
657 }
658 return bExecutingGroupCode;
659 }
660
DXFHatchEntity()661 DXFHatchEntity::DXFHatchEntity() :
662 DXFBasicEntity( DXF_HATCH ),
663 bIsInBoundaryPathContext( sal_False ),
664 nCurrentBoundaryPathIndex( -1 ),
665 nFlags( 0 ),
666 nAssociativityFlag( 0 ),
667 nBoundaryPathCount( 0 ),
668 nHatchStyle( 0 ),
669 nHatchPatternType( 0 ),
670 fHatchPatternAngle( 0.0 ),
671 fHatchPatternScale( 1.0 ),
672 nHatchDoubleFlag( 0 ),
673 nHatchPatternDefinitionLines( 0 ),
674 fPixelSize( 1.0 ),
675 nNumberOfSeedPoints( 0 ),
676 pBoundaryPathData( NULL )
677 {
678 }
679
EvaluateGroup(DXFGroupReader & rDGR)680 void DXFHatchEntity::EvaluateGroup( DXFGroupReader & rDGR )
681 {
682 switch ( rDGR.GetG() )
683 {
684 // case 10 : aElevationPoint.fx = rDGR.GetF(); break;
685 // case 20 : aElevationPoint.fy = rDGR.GetF(); break;
686 // case 30 : aElevationPoint.fz = rDGR.GetF(); break;
687 case 70 : nFlags = rDGR.GetI(); break;
688 case 71 : nAssociativityFlag = rDGR.GetI(); break;
689 case 91 :
690 {
691 bIsInBoundaryPathContext = sal_True;
692 nBoundaryPathCount = rDGR.GetI();
693 if ( nBoundaryPathCount )
694 pBoundaryPathData = new DXFBoundaryPathData[ nBoundaryPathCount ];
695 }
696 break;
697 case 75 :
698 {
699 nHatchStyle = rDGR.GetI();
700 bIsInBoundaryPathContext = sal_False;
701 }
702 break;
703 case 76 : nHatchPatternType = rDGR.GetI(); break;
704 case 52 : fHatchPatternAngle = rDGR.GetF(); break;
705 case 41 : fHatchPatternScale = rDGR.GetF(); break;
706 case 77 : nHatchDoubleFlag = rDGR.GetI(); break;
707 case 78 : nHatchPatternDefinitionLines = rDGR.GetI(); break;
708 case 47 : fPixelSize = rDGR.GetF(); break;
709 case 98 : nNumberOfSeedPoints = rDGR.GetI(); break;
710
711 //!! passthrough !!
712 case 92 : nCurrentBoundaryPathIndex++;
713 default:
714 {
715 sal_Bool bExecutingGroupCode = sal_False;
716 if ( bIsInBoundaryPathContext )
717 {
718 if ( ( nCurrentBoundaryPathIndex >= 0 ) &&
719 ( nCurrentBoundaryPathIndex < nBoundaryPathCount ) )
720 bExecutingGroupCode = pBoundaryPathData[ nCurrentBoundaryPathIndex ].EvaluateGroup( rDGR );
721 }
722 if ( bExecutingGroupCode == sal_False )
723 DXFBasicEntity::EvaluateGroup(rDGR);
724 }
725 break;
726 }
727 }
728
~DXFHatchEntity()729 DXFHatchEntity::~DXFHatchEntity()
730 {
731 delete[] pBoundaryPathData;
732 }
733
734 //--------------------------DXFVertexEntity-------------------------------------
735
DXFVertexEntity()736 DXFVertexEntity::DXFVertexEntity() : DXFBasicEntity(DXF_VERTEX)
737 {
738 fSWidth=-1.0;
739 fEWidth=-1.0;
740 fBulge=0.0;
741 nFlags=0;
742 fCFTDir=0.0;
743
744 }
745
EvaluateGroup(DXFGroupReader & rDGR)746 void DXFVertexEntity::EvaluateGroup(DXFGroupReader & rDGR)
747 {
748 switch (rDGR.GetG()) {
749 case 10: aP0.fx=rDGR.GetF(); break;
750 case 20: aP0.fy=rDGR.GetF(); break;
751 case 30: aP0.fz=rDGR.GetF(); break;
752 case 40: fSWidth=rDGR.GetF(); break;
753 case 41: fEWidth=rDGR.GetF(); break;
754 case 42: fBulge=rDGR.GetF(); break;
755 case 70: nFlags=rDGR.GetI(); break;
756 case 50: fCFTDir=rDGR.GetF(); break;
757 default: DXFBasicEntity::EvaluateGroup(rDGR);
758 }
759 }
760
761 //--------------------------DXFSeqEndEntity-------------------------------------
762
DXFSeqEndEntity()763 DXFSeqEndEntity::DXFSeqEndEntity() : DXFBasicEntity(DXF_SEQEND)
764 {
765 }
766
767 //--------------------------DXF3DFace-------------------------------------------
768
DXF3DFaceEntity()769 DXF3DFaceEntity::DXF3DFaceEntity() : DXFBasicEntity(DXF_3DFACE)
770 {
771 nIEFlags=0;
772 }
773
EvaluateGroup(DXFGroupReader & rDGR)774 void DXF3DFaceEntity::EvaluateGroup(DXFGroupReader & rDGR)
775 {
776 switch (rDGR.GetG()) {
777 case 10: aP0.fx=rDGR.GetF(); break;
778 case 20: aP0.fy=rDGR.GetF(); break;
779 case 30: aP0.fz=rDGR.GetF(); break;
780 case 11: aP1.fx=rDGR.GetF(); break;
781 case 21: aP1.fy=rDGR.GetF(); break;
782 case 31: aP1.fz=rDGR.GetF(); break;
783 case 12: aP2.fx=rDGR.GetF(); break;
784 case 22: aP2.fy=rDGR.GetF(); break;
785 case 32: aP2.fz=rDGR.GetF(); break;
786 case 13: aP3.fx=rDGR.GetF(); break;
787 case 23: aP3.fy=rDGR.GetF(); break;
788 case 33: aP3.fz=rDGR.GetF(); break;
789 case 70: nIEFlags=rDGR.GetI(); break;
790 default: DXFBasicEntity::EvaluateGroup(rDGR);
791 }
792 }
793
794
795 //--------------------------DXFDimensionEntity----------------------------------
796
DXFDimensionEntity()797 DXFDimensionEntity::DXFDimensionEntity() : DXFBasicEntity(DXF_DIMENSION)
798 {
799 sPseudoBlock[0]=0;
800 }
801
EvaluateGroup(DXFGroupReader & rDGR)802 void DXFDimensionEntity::EvaluateGroup(DXFGroupReader & rDGR)
803 {
804 switch (rDGR.GetG()) {
805 case 2: strncpy( sPseudoBlock, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
806 default: DXFBasicEntity::EvaluateGroup(rDGR);
807 }
808 }
809
810 //---------------------------- DXFEntites --------------------------------------
811
Read(DXFGroupReader & rDGR)812 void DXFEntities::Read(DXFGroupReader & rDGR)
813 {
814 DXFBasicEntity * pE, * * ppSucc;
815
816 ppSucc=&pFirst;
817 while (*ppSucc!=NULL) ppSucc=&((*ppSucc)->pSucc);
818
819 while (rDGR.GetG()!=0) rDGR.Read();
820
821 while (strcmp(rDGR.GetS(),"ENDBLK")!=0 &&
822 strcmp(rDGR.GetS(),"ENDSEC")!=0 &&
823 strcmp(rDGR.GetS(),"EOF")!=0 )
824 {
825
826 if (strcmp(rDGR.GetS(),"LINE" )==0) pE=new DXFLineEntity;
827 else if (strcmp(rDGR.GetS(),"POINT" )==0) pE=new DXFPointEntity;
828 else if (strcmp(rDGR.GetS(),"CIRCLE" )==0) pE=new DXFCircleEntity;
829 else if (strcmp(rDGR.GetS(),"ARC" )==0) pE=new DXFArcEntity;
830 else if (strcmp(rDGR.GetS(),"TRACE" )==0) pE=new DXFTraceEntity;
831 else if (strcmp(rDGR.GetS(),"SOLID" )==0) pE=new DXFSolidEntity;
832 else if (strcmp(rDGR.GetS(),"TEXT" )==0) pE=new DXFTextEntity;
833 else if (strcmp(rDGR.GetS(),"SHAPE" )==0) pE=new DXFShapeEntity;
834 else if (strcmp(rDGR.GetS(),"INSERT" )==0) pE=new DXFInsertEntity;
835 else if (strcmp(rDGR.GetS(),"ATTDEF" )==0) pE=new DXFAttDefEntity;
836 else if (strcmp(rDGR.GetS(),"ATTRIB" )==0) pE=new DXFAttribEntity;
837 else if (strcmp(rDGR.GetS(),"POLYLINE" )==0) pE=new DXFPolyLineEntity;
838 else if (strcmp(rDGR.GetS(),"LWPOLYLINE")==0) pE=new DXFLWPolyLineEntity;
839 else if (strcmp(rDGR.GetS(),"VERTEX" )==0) pE=new DXFVertexEntity;
840 else if (strcmp(rDGR.GetS(),"SEQEND" )==0) pE=new DXFSeqEndEntity;
841 else if (strcmp(rDGR.GetS(),"3DFACE" )==0) pE=new DXF3DFaceEntity;
842 else if (strcmp(rDGR.GetS(),"DIMENSION" )==0) pE=new DXFDimensionEntity;
843 else if (strcmp(rDGR.GetS(),"HATCH" )==0) pE=new DXFHatchEntity;
844 else
845 {
846 do {
847 rDGR.Read();
848 } while (rDGR.GetG()!=0);
849 continue;
850 }
851 *ppSucc=pE;
852 ppSucc=&(pE->pSucc);
853 pE->Read(rDGR);
854 }
855 }
856
Clear()857 void DXFEntities::Clear()
858 {
859 DXFBasicEntity * ptmp;
860
861 while (pFirst!=NULL) {
862 ptmp=pFirst;
863 pFirst=ptmp->pSucc;
864 delete ptmp;
865 }
866 }
867
868