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 ( rDGR.GetStatus() && nCount >= 0 )
437 {
438 try
439 {
440 pP = new DXFVector[ nCount ];
441 }
442 catch (::std::bad_alloc)
443 {
444 rDGR.SetError();
445 }
446 }
447 else
448 rDGR.SetError();
449 }
450 break;
451 case 70: nFlags = rDGR.GetI(); break;
452 case 43: fConstantWidth = rDGR.GetF(); break;
453 case 40: fStartWidth = rDGR.GetF(); break;
454 case 41: fEndWidth = rDGR.GetF(); break;
455 case 10:
456 {
457 if ( pP && ( nIndex < nCount ) )
458 pP[ nIndex ].fx = rDGR.GetF();
459 }
460 break;
461 case 20:
462 {
463 if ( pP && ( nIndex < nCount ) )
464 pP[ nIndex++ ].fy = rDGR.GetF();
465 }
466 break;
467 default: DXFBasicEntity::EvaluateGroup(rDGR);
468 }
469 }
470
~DXFLWPolyLineEntity()471 DXFLWPolyLineEntity::~DXFLWPolyLineEntity()
472 {
473 delete[] pP;
474 }
475
476 //--------------------------DXFHatchEntity-------------------------------------
477
DXFEdgeTypeLine()478 DXFEdgeTypeLine::DXFEdgeTypeLine() :
479 DXFEdgeType( 1 )
480 {
481
482 }
~DXFEdgeTypeLine()483 DXFEdgeTypeLine::~DXFEdgeTypeLine()
484 {
485
486 }
EvaluateGroup(DXFGroupReader & rDGR)487 sal_Bool DXFEdgeTypeLine::EvaluateGroup( DXFGroupReader & rDGR )
488 {
489 sal_Bool bExecutingGroupCode = sal_True;
490 switch ( rDGR.GetG() )
491 {
492 case 10 : aStartPoint.fx = rDGR.GetF(); break;
493 case 20 : aStartPoint.fy = rDGR.GetF(); break;
494 case 11 : aEndPoint.fx = rDGR.GetF(); break;
495 case 21 : aEndPoint.fy = rDGR.GetF(); break;
496 default : bExecutingGroupCode = sal_False; break;
497 }
498 return bExecutingGroupCode;
499 }
500
DXFEdgeTypeCircularArc()501 DXFEdgeTypeCircularArc::DXFEdgeTypeCircularArc() :
502 DXFEdgeType( 2 ),
503 fRadius( 0.0 ),
504 fStartAngle( 0.0 ),
505 fEndAngle( 0.0 ),
506 nIsCounterClockwiseFlag( 0 )
507 {
508 }
~DXFEdgeTypeCircularArc()509 DXFEdgeTypeCircularArc::~DXFEdgeTypeCircularArc()
510 {
511 }
EvaluateGroup(DXFGroupReader & rDGR)512 sal_Bool DXFEdgeTypeCircularArc::EvaluateGroup( DXFGroupReader & rDGR )
513 {
514 sal_Bool bExecutingGroupCode = sal_True;
515 switch ( rDGR.GetG() )
516 {
517 case 10 : aCenter.fx = rDGR.GetF(); break;
518 case 20 : aCenter.fy = rDGR.GetF(); break;
519 case 40 : fRadius = rDGR.GetF(); break;
520 case 50 : fStartAngle = rDGR.GetF(); break;
521 case 51 : fEndAngle = rDGR.GetF(); break;
522 case 73 : nIsCounterClockwiseFlag = rDGR.GetI(); break;
523 default : bExecutingGroupCode = sal_False; break;
524 }
525 return bExecutingGroupCode;
526 }
527
DXFEdgeTypeEllipticalArc()528 DXFEdgeTypeEllipticalArc::DXFEdgeTypeEllipticalArc() :
529 DXFEdgeType( 3 ),
530 fLength( 0.0 ),
531 fStartAngle( 0.0 ),
532 fEndAngle( 0.0 ),
533 nIsCounterClockwiseFlag( 0 )
534 {
535 }
~DXFEdgeTypeEllipticalArc()536 DXFEdgeTypeEllipticalArc::~DXFEdgeTypeEllipticalArc()
537 {
538
539 }
EvaluateGroup(DXFGroupReader & rDGR)540 sal_Bool DXFEdgeTypeEllipticalArc::EvaluateGroup( DXFGroupReader & rDGR )
541 {
542 sal_Bool bExecutingGroupCode = sal_True;
543 switch( rDGR.GetG() )
544 {
545 case 10 : aCenter.fx = rDGR.GetF(); break;
546 case 20 : aCenter.fy = rDGR.GetF(); break;
547 case 11 : aEndPoint.fx = rDGR.GetF(); break;
548 case 21 : aEndPoint.fy = rDGR.GetF(); break;
549 case 40 : fLength = rDGR.GetF(); break;
550 case 50 : fStartAngle = rDGR.GetF(); break;
551 case 51 : fEndAngle = rDGR.GetF(); break;
552 case 73 : nIsCounterClockwiseFlag = rDGR.GetI(); break;
553 default : bExecutingGroupCode = sal_False; break;
554 }
555 return bExecutingGroupCode;
556 }
557
DXFEdgeTypeSpline()558 DXFEdgeTypeSpline::DXFEdgeTypeSpline() :
559 DXFEdgeType( 4 ),
560 nDegree( 0 ),
561 nRational( 0 ),
562 nPeriodic( 0 ),
563 nKnotCount( 0 ),
564 nControlCount( 0 )
565 {
566 }
~DXFEdgeTypeSpline()567 DXFEdgeTypeSpline::~DXFEdgeTypeSpline()
568 {
569
570 }
EvaluateGroup(DXFGroupReader & rDGR)571 sal_Bool DXFEdgeTypeSpline::EvaluateGroup( DXFGroupReader & rDGR )
572 {
573 sal_Bool bExecutingGroupCode = sal_True;
574 switch ( rDGR.GetG() )
575 {
576 case 94 : nDegree = rDGR.GetI(); break;
577 case 73 : nRational = rDGR.GetI(); break;
578 case 74 : nPeriodic = rDGR.GetI(); break;
579 case 95 : nKnotCount = rDGR.GetI(); break;
580 case 96 : nControlCount = rDGR.GetI(); break;
581 default : bExecutingGroupCode = sal_False; break;
582 }
583 return bExecutingGroupCode;
584 }
585
DXFBoundaryPathData()586 DXFBoundaryPathData::DXFBoundaryPathData() :
587 nFlags( 0 ),
588 nHasBulgeFlag( 0 ),
589 nIsClosedFlag( 0 ),
590 nPointCount( 0 ),
591 fBulge( 0.0 ),
592 nSourceBoundaryObjects( 0 ),
593 nEdgeCount( 0 ),
594 bIsPolyLine( sal_True ),
595 nPointIndex( 0 ),
596 pP( NULL )
597 {
598 }
599
~DXFBoundaryPathData()600 DXFBoundaryPathData::~DXFBoundaryPathData()
601 {
602 sal_uInt32 i = 0;
603 for ( i = 0; i < aEdges.size(); i++ )
604 delete aEdges[ i ];
605 delete[] pP;
606 }
607
EvaluateGroup(DXFGroupReader & rDGR)608 sal_Bool DXFBoundaryPathData::EvaluateGroup( DXFGroupReader & rDGR )
609 {
610 sal_Bool bExecutingGroupCode = sal_True;
611 if ( bIsPolyLine )
612 {
613 switch( rDGR.GetG() )
614 {
615 case 92 :
616 {
617 nFlags = rDGR.GetI();
618 if ( ( nFlags & 2 ) == 0 )
619 bIsPolyLine = sal_False;
620 }
621 break;
622 case 93 :
623 {
624 nPointCount = rDGR.GetI();
625 if ( rDGR.GetStatus() && nPointCount >= 0 )
626 {
627 try
628 {
629 pP = new DXFVector[ nPointCount ];
630 }
631 catch (::std::bad_alloc)
632 {
633 rDGR.SetError();
634 }
635 }
636 else
637 rDGR.SetError();
638 }
639 break;
640 case 72 : nHasBulgeFlag = rDGR.GetI(); break;
641 case 73 : nIsClosedFlag = rDGR.GetI(); break;
642 case 97 : nSourceBoundaryObjects = rDGR.GetI(); break;
643 case 42 : fBulge = rDGR.GetF(); break;
644 case 10:
645 {
646 if ( pP && ( nPointIndex < nPointCount ) )
647 pP[ nPointIndex ].fx = rDGR.GetF();
648 }
649 break;
650 case 20:
651 {
652 if ( pP && ( nPointIndex < nPointCount ) )
653 pP[ nPointIndex++ ].fy = rDGR.GetF();
654 }
655 break;
656
657 default : bExecutingGroupCode = sal_False; break;
658 }
659 }
660 else
661 {
662 if ( rDGR.GetG() == 93 )
663 nEdgeCount = rDGR.GetI();
664 else if ( rDGR.GetG() == 72 )
665 {
666 sal_Int32 nEdgeType = rDGR.GetI();
667 switch( nEdgeType )
668 {
669 case 1 : aEdges.push_back( new DXFEdgeTypeLine() ); break;
670 case 2 : aEdges.push_back( new DXFEdgeTypeCircularArc() ); break;
671 case 3 : aEdges.push_back( new DXFEdgeTypeEllipticalArc() ); break;
672 case 4 : aEdges.push_back( new DXFEdgeTypeSpline() ); break;
673 }
674 }
675 else if ( aEdges.size() )
676 aEdges[ aEdges.size() - 1 ]->EvaluateGroup( rDGR );
677 else
678 bExecutingGroupCode = sal_False;
679 }
680 return bExecutingGroupCode;
681 }
682
DXFHatchEntity()683 DXFHatchEntity::DXFHatchEntity() :
684 DXFBasicEntity( DXF_HATCH ),
685 bIsInBoundaryPathContext( sal_False ),
686 nCurrentBoundaryPathIndex( -1 ),
687 nFlags( 0 ),
688 nAssociativityFlag( 0 ),
689 nBoundaryPathCount( 0 ),
690 nHatchStyle( 0 ),
691 nHatchPatternType( 0 ),
692 fHatchPatternAngle( 0.0 ),
693 fHatchPatternScale( 1.0 ),
694 nHatchDoubleFlag( 0 ),
695 nHatchPatternDefinitionLines( 0 ),
696 fPixelSize( 1.0 ),
697 nNumberOfSeedPoints( 0 ),
698 pBoundaryPathData( NULL )
699 {
700 }
701
EvaluateGroup(DXFGroupReader & rDGR)702 void DXFHatchEntity::EvaluateGroup( DXFGroupReader & rDGR )
703 {
704 switch ( rDGR.GetG() )
705 {
706 // case 10 : aElevationPoint.fx = rDGR.GetF(); break;
707 // case 20 : aElevationPoint.fy = rDGR.GetF(); break;
708 // case 30 : aElevationPoint.fz = rDGR.GetF(); break;
709 case 70 : nFlags = rDGR.GetI(); break;
710 case 71 : nAssociativityFlag = rDGR.GetI(); break;
711 case 91 :
712 {
713 bIsInBoundaryPathContext = sal_True;
714 nBoundaryPathCount = rDGR.GetI();
715 if ( rDGR.GetStatus() && nBoundaryPathCount >= 0 )
716 {
717 try
718 {
719 pBoundaryPathData = new DXFBoundaryPathData[ nBoundaryPathCount ];
720 }
721 catch (::std::bad_alloc)
722 {
723 rDGR.SetError();
724 }
725 }
726 else
727 rDGR.SetError();
728 }
729 break;
730 case 75 :
731 {
732 nHatchStyle = rDGR.GetI();
733 bIsInBoundaryPathContext = sal_False;
734 }
735 break;
736 case 76 : nHatchPatternType = rDGR.GetI(); break;
737 case 52 : fHatchPatternAngle = rDGR.GetF(); break;
738 case 41 : fHatchPatternScale = rDGR.GetF(); break;
739 case 77 : nHatchDoubleFlag = rDGR.GetI(); break;
740 case 78 : nHatchPatternDefinitionLines = rDGR.GetI(); break;
741 case 47 : fPixelSize = rDGR.GetF(); break;
742 case 98 : nNumberOfSeedPoints = rDGR.GetI(); break;
743
744 //!! passthrough !!
745 case 92 : nCurrentBoundaryPathIndex++;
746 default:
747 {
748 sal_Bool bExecutingGroupCode = sal_False;
749 if ( bIsInBoundaryPathContext )
750 {
751 if ( ( nCurrentBoundaryPathIndex >= 0 ) &&
752 ( nCurrentBoundaryPathIndex < nBoundaryPathCount ) )
753 bExecutingGroupCode = pBoundaryPathData[ nCurrentBoundaryPathIndex ].EvaluateGroup( rDGR );
754 }
755 if ( bExecutingGroupCode == sal_False )
756 DXFBasicEntity::EvaluateGroup(rDGR);
757 }
758 break;
759 }
760 }
761
~DXFHatchEntity()762 DXFHatchEntity::~DXFHatchEntity()
763 {
764 delete[] pBoundaryPathData;
765 }
766
767 //--------------------------DXFVertexEntity-------------------------------------
768
DXFVertexEntity()769 DXFVertexEntity::DXFVertexEntity() : DXFBasicEntity(DXF_VERTEX)
770 {
771 fSWidth=-1.0;
772 fEWidth=-1.0;
773 fBulge=0.0;
774 nFlags=0;
775 fCFTDir=0.0;
776
777 }
778
EvaluateGroup(DXFGroupReader & rDGR)779 void DXFVertexEntity::EvaluateGroup(DXFGroupReader & rDGR)
780 {
781 switch (rDGR.GetG()) {
782 case 10: aP0.fx=rDGR.GetF(); break;
783 case 20: aP0.fy=rDGR.GetF(); break;
784 case 30: aP0.fz=rDGR.GetF(); break;
785 case 40: fSWidth=rDGR.GetF(); break;
786 case 41: fEWidth=rDGR.GetF(); break;
787 case 42: fBulge=rDGR.GetF(); break;
788 case 70: nFlags=rDGR.GetI(); break;
789 case 50: fCFTDir=rDGR.GetF(); break;
790 default: DXFBasicEntity::EvaluateGroup(rDGR);
791 }
792 }
793
794 //--------------------------DXFSeqEndEntity-------------------------------------
795
DXFSeqEndEntity()796 DXFSeqEndEntity::DXFSeqEndEntity() : DXFBasicEntity(DXF_SEQEND)
797 {
798 }
799
800 //--------------------------DXF3DFace-------------------------------------------
801
DXF3DFaceEntity()802 DXF3DFaceEntity::DXF3DFaceEntity() : DXFBasicEntity(DXF_3DFACE)
803 {
804 nIEFlags=0;
805 }
806
EvaluateGroup(DXFGroupReader & rDGR)807 void DXF3DFaceEntity::EvaluateGroup(DXFGroupReader & rDGR)
808 {
809 switch (rDGR.GetG()) {
810 case 10: aP0.fx=rDGR.GetF(); break;
811 case 20: aP0.fy=rDGR.GetF(); break;
812 case 30: aP0.fz=rDGR.GetF(); break;
813 case 11: aP1.fx=rDGR.GetF(); break;
814 case 21: aP1.fy=rDGR.GetF(); break;
815 case 31: aP1.fz=rDGR.GetF(); break;
816 case 12: aP2.fx=rDGR.GetF(); break;
817 case 22: aP2.fy=rDGR.GetF(); break;
818 case 32: aP2.fz=rDGR.GetF(); break;
819 case 13: aP3.fx=rDGR.GetF(); break;
820 case 23: aP3.fy=rDGR.GetF(); break;
821 case 33: aP3.fz=rDGR.GetF(); break;
822 case 70: nIEFlags=rDGR.GetI(); break;
823 default: DXFBasicEntity::EvaluateGroup(rDGR);
824 }
825 }
826
827
828 //--------------------------DXFDimensionEntity----------------------------------
829
DXFDimensionEntity()830 DXFDimensionEntity::DXFDimensionEntity() : DXFBasicEntity(DXF_DIMENSION)
831 {
832 sPseudoBlock[0]=0;
833 }
834
EvaluateGroup(DXFGroupReader & rDGR)835 void DXFDimensionEntity::EvaluateGroup(DXFGroupReader & rDGR)
836 {
837 switch (rDGR.GetG()) {
838 case 2: strncpy( sPseudoBlock, rDGR.GetS(), DXF_MAX_STRING_LEN + 1 ); break;
839 default: DXFBasicEntity::EvaluateGroup(rDGR);
840 }
841 }
842
843 //---------------------------- DXFEntites --------------------------------------
844
Read(DXFGroupReader & rDGR)845 void DXFEntities::Read(DXFGroupReader & rDGR)
846 {
847 DXFBasicEntity * pE, * * ppSucc;
848
849 ppSucc=&pFirst;
850 while (*ppSucc!=NULL) ppSucc=&((*ppSucc)->pSucc);
851
852 while (rDGR.GetG()!=0) rDGR.Read();
853
854 while (strcmp(rDGR.GetS(),"ENDBLK")!=0 &&
855 strcmp(rDGR.GetS(),"ENDSEC")!=0 &&
856 strcmp(rDGR.GetS(),"EOF")!=0 )
857 {
858
859 if (strcmp(rDGR.GetS(),"LINE" )==0) pE=new DXFLineEntity;
860 else if (strcmp(rDGR.GetS(),"POINT" )==0) pE=new DXFPointEntity;
861 else if (strcmp(rDGR.GetS(),"CIRCLE" )==0) pE=new DXFCircleEntity;
862 else if (strcmp(rDGR.GetS(),"ARC" )==0) pE=new DXFArcEntity;
863 else if (strcmp(rDGR.GetS(),"TRACE" )==0) pE=new DXFTraceEntity;
864 else if (strcmp(rDGR.GetS(),"SOLID" )==0) pE=new DXFSolidEntity;
865 else if (strcmp(rDGR.GetS(),"TEXT" )==0) pE=new DXFTextEntity;
866 else if (strcmp(rDGR.GetS(),"SHAPE" )==0) pE=new DXFShapeEntity;
867 else if (strcmp(rDGR.GetS(),"INSERT" )==0) pE=new DXFInsertEntity;
868 else if (strcmp(rDGR.GetS(),"ATTDEF" )==0) pE=new DXFAttDefEntity;
869 else if (strcmp(rDGR.GetS(),"ATTRIB" )==0) pE=new DXFAttribEntity;
870 else if (strcmp(rDGR.GetS(),"POLYLINE" )==0) pE=new DXFPolyLineEntity;
871 else if (strcmp(rDGR.GetS(),"LWPOLYLINE")==0) pE=new DXFLWPolyLineEntity;
872 else if (strcmp(rDGR.GetS(),"VERTEX" )==0) pE=new DXFVertexEntity;
873 else if (strcmp(rDGR.GetS(),"SEQEND" )==0) pE=new DXFSeqEndEntity;
874 else if (strcmp(rDGR.GetS(),"3DFACE" )==0) pE=new DXF3DFaceEntity;
875 else if (strcmp(rDGR.GetS(),"DIMENSION" )==0) pE=new DXFDimensionEntity;
876 else if (strcmp(rDGR.GetS(),"HATCH" )==0) pE=new DXFHatchEntity;
877 else
878 {
879 do {
880 rDGR.Read();
881 } while (rDGR.GetG()!=0);
882 continue;
883 }
884 *ppSucc=pE;
885 ppSucc=&(pE->pSucc);
886 pE->Read(rDGR);
887 }
888 }
889
Clear()890 void DXFEntities::Clear()
891 {
892 DXFBasicEntity * ptmp;
893
894 while (pFirst!=NULL) {
895 ptmp=pFirst;
896 pFirst=ptmp->pSucc;
897 delete ptmp;
898 }
899 }
900
901