tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / vcl / source / filter / idxf / dxfentrd.cxx
blob9f9e075514dbbe9432894df95b5d8a2c2034e93c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include <o3tl/safeint.hxx>
24 #include "dxfentrd.hxx"
26 //--------------------------DXFBasicEntity--------------------------------------
28 DXFBasicEntity::DXFBasicEntity(DXFEntityType eThisType)
29 : m_sLayer("0"_ostr)
30 , m_sLineType("BYLAYER"_ostr)
32 eType=eThisType;
33 pSucc=nullptr;
34 fThickness=0;
35 nColor=256;
36 nSpace=0;
37 aExtrusion.fx=0.0;
38 aExtrusion.fy=0.0;
39 aExtrusion.fz=1.0;
42 void DXFBasicEntity::Read(DXFGroupReader & rDGR)
44 while (rDGR.Read()!=0) EvaluateGroup(rDGR);
47 void DXFBasicEntity::EvaluateGroup(DXFGroupReader & rDGR)
49 switch (rDGR.GetG())
51 case 8: m_sLayer = rDGR.GetS(); break;
52 case 6: m_sLineType = rDGR.GetS(); break;
53 case 39: fThickness=rDGR.GetF(); break;
54 case 62: nColor=rDGR.GetI(); break;
55 case 67: nSpace=rDGR.GetI(); break;
56 case 210: aExtrusion.fx=rDGR.GetF(); break;
57 case 220: aExtrusion.fy=rDGR.GetF(); break;
58 case 230: aExtrusion.fz=rDGR.GetF(); break;
62 DXFBasicEntity::~DXFBasicEntity()
66 //--------------------------DXFLineEntity---------------------------------------
68 DXFLineEntity::DXFLineEntity() : DXFBasicEntity(DXF_LINE)
72 void DXFLineEntity::EvaluateGroup(DXFGroupReader & rDGR)
74 switch (rDGR.GetG()) {
75 case 10: aP0.fx=rDGR.GetF(); break;
76 case 20: aP0.fy=rDGR.GetF(); break;
77 case 30: aP0.fz=rDGR.GetF(); break;
78 case 11: aP1.fx=rDGR.GetF(); break;
79 case 21: aP1.fy=rDGR.GetF(); break;
80 case 31: aP1.fz=rDGR.GetF(); break;
81 default: DXFBasicEntity::EvaluateGroup(rDGR);
85 //--------------------------DXFPointEntity--------------------------------------
87 DXFPointEntity::DXFPointEntity() : DXFBasicEntity(DXF_POINT)
91 void DXFPointEntity::EvaluateGroup(DXFGroupReader & rDGR)
93 switch (rDGR.GetG()) {
94 case 10: aP0.fx=rDGR.GetF(); break;
95 case 20: aP0.fy=rDGR.GetF(); break;
96 case 30: aP0.fz=rDGR.GetF(); break;
97 default: DXFBasicEntity::EvaluateGroup(rDGR);
101 //--------------------------DXFCircleEntity-------------------------------------
103 DXFCircleEntity::DXFCircleEntity() : DXFBasicEntity(DXF_CIRCLE)
105 fRadius=1.0;
108 void DXFCircleEntity::EvaluateGroup(DXFGroupReader & rDGR)
110 switch (rDGR.GetG()) {
111 case 10: aP0.fx=rDGR.GetF(); break;
112 case 20: aP0.fy=rDGR.GetF(); break;
113 case 30: aP0.fz=rDGR.GetF(); break;
114 case 40: fRadius=rDGR.GetF(); break;
115 default: DXFBasicEntity::EvaluateGroup(rDGR);
119 //--------------------------DXFArcEntity----------------------------------------
121 DXFArcEntity::DXFArcEntity() : DXFBasicEntity(DXF_ARC)
123 fRadius=1.0;
124 fStart=0;
125 fEnd=360.0;
128 void DXFArcEntity::EvaluateGroup(DXFGroupReader & rDGR)
130 switch (rDGR.GetG()) {
131 case 10: aP0.fx=rDGR.GetF(); break;
132 case 20: aP0.fy=rDGR.GetF(); break;
133 case 30: aP0.fz=rDGR.GetF(); break;
134 case 40: fRadius=rDGR.GetF(); break;
135 case 50: fStart=rDGR.GetF(); break;
136 case 51: fEnd=rDGR.GetF(); break;
137 default: DXFBasicEntity::EvaluateGroup(rDGR);
141 //--------------------------DXFTraceEntity--------------------------------------
143 DXFTraceEntity::DXFTraceEntity() : DXFBasicEntity(DXF_TRACE)
147 void DXFTraceEntity::EvaluateGroup(DXFGroupReader & rDGR)
149 switch (rDGR.GetG()) {
150 case 10: aP0.fx=rDGR.GetF(); break;
151 case 20: aP0.fy=rDGR.GetF(); break;
152 case 30: aP0.fz=rDGR.GetF(); break;
153 case 11: aP1.fx=rDGR.GetF(); break;
154 case 21: aP1.fy=rDGR.GetF(); break;
155 case 31: aP1.fz=rDGR.GetF(); break;
156 case 12: aP2.fx=rDGR.GetF(); break;
157 case 22: aP2.fy=rDGR.GetF(); break;
158 case 32: aP2.fz=rDGR.GetF(); break;
159 case 13: aP3.fx=rDGR.GetF(); break;
160 case 23: aP3.fy=rDGR.GetF(); break;
161 case 33: aP3.fz=rDGR.GetF(); break;
162 default: DXFBasicEntity::EvaluateGroup(rDGR);
166 //--------------------------DXFSolidEntity--------------------------------------
168 DXFSolidEntity::DXFSolidEntity() : DXFBasicEntity(DXF_SOLID)
172 void DXFSolidEntity::EvaluateGroup(DXFGroupReader & rDGR)
174 switch (rDGR.GetG()) {
175 case 10: aP0.fx=rDGR.GetF(); break;
176 case 20: aP0.fy=rDGR.GetF(); break;
177 case 30: aP0.fz=rDGR.GetF(); break;
178 case 11: aP1.fx=rDGR.GetF(); break;
179 case 21: aP1.fy=rDGR.GetF(); break;
180 case 31: aP1.fz=rDGR.GetF(); break;
181 case 12: aP2.fx=rDGR.GetF(); break;
182 case 22: aP2.fy=rDGR.GetF(); break;
183 case 32: aP2.fz=rDGR.GetF(); break;
184 case 13: aP3.fx=rDGR.GetF(); break;
185 case 23: aP3.fy=rDGR.GetF(); break;
186 case 33: aP3.fz=rDGR.GetF(); break;
187 default: DXFBasicEntity::EvaluateGroup(rDGR);
191 //--------------------------DXFTextEntity---------------------------------------
193 DXFTextEntity::DXFTextEntity()
194 : DXFBasicEntity(DXF_TEXT)
195 , m_sStyle("STANDARD"_ostr)
197 fHeight=1.0;
198 fRotAngle=0.0;
199 fXScale=1.0;
200 fOblAngle=0.0;
201 nGenFlags=0;
202 nHorzJust=0;
203 nVertJust=0;
206 void DXFTextEntity::EvaluateGroup(DXFGroupReader & rDGR)
208 switch (rDGR.GetG()) {
209 case 10: aP0.fx=rDGR.GetF(); break;
210 case 20: aP0.fy=rDGR.GetF(); break;
211 case 30: aP0.fz=rDGR.GetF(); break;
212 case 40: fHeight=rDGR.GetF(); break;
213 case 1: m_sText = rDGR.GetS(); break;
214 case 50: fRotAngle=rDGR.GetF(); break;
215 case 41: fXScale=rDGR.GetF(); break;
216 case 42: fOblAngle=rDGR.GetF(); break;
217 case 7: m_sStyle = rDGR.GetS(); break;
218 case 71: nGenFlags=rDGR.GetI(); break;
219 case 72: nHorzJust=rDGR.GetI(); break;
220 case 73: nVertJust=rDGR.GetI(); break;
221 case 11: aAlign.fx=rDGR.GetF(); break;
222 case 21: aAlign.fy=rDGR.GetF(); break;
223 case 31: aAlign.fz=rDGR.GetF(); break;
224 default: DXFBasicEntity::EvaluateGroup(rDGR);
228 //--------------------------DXFShapeEntity--------------------------------------
230 DXFShapeEntity::DXFShapeEntity() : DXFBasicEntity(DXF_SHAPE)
232 fSize=1.0;
233 fRotAngle=0;
234 fXScale=1.0;
235 fOblAngle=0;
238 void DXFShapeEntity::EvaluateGroup(DXFGroupReader & rDGR)
240 switch (rDGR.GetG()) {
241 case 10: aP0.fx=rDGR.GetF(); break;
242 case 20: aP0.fy=rDGR.GetF(); break;
243 case 30: aP0.fz=rDGR.GetF(); break;
244 case 40: fSize=rDGR.GetF(); break;
245 case 2: m_sName = rDGR.GetS(); break;
246 case 50: fRotAngle=rDGR.GetF(); break;
247 case 41: fXScale=rDGR.GetF(); break;
248 case 51: fOblAngle=rDGR.GetF(); break;
249 default: DXFBasicEntity::EvaluateGroup(rDGR);
253 //--------------------------DXFInsertEntity-------------------------------------
255 DXFInsertEntity::DXFInsertEntity() : DXFBasicEntity(DXF_INSERT)
257 nAttrFlag=0;
258 fXScale=1.0;
259 fYScale=1.0;
260 fZScale=1.0;
261 fRotAngle=0.0;
262 nColCount=1;
263 nRowCount=1;
264 fColSpace=0.0;
265 fRowSpace=0.0;
268 void DXFInsertEntity::EvaluateGroup(DXFGroupReader & rDGR)
270 switch (rDGR.GetG()) {
271 case 66: nAttrFlag=rDGR.GetI(); break;
272 case 2: m_sName = rDGR.GetS(); break;
273 case 10: aP0.fx=rDGR.GetF(); break;
274 case 20: aP0.fy=rDGR.GetF(); break;
275 case 30: aP0.fz=rDGR.GetF(); break;
276 case 41: fXScale=rDGR.GetF(); break;
277 case 42: fYScale=rDGR.GetF(); break;
278 case 43: fZScale=rDGR.GetF(); break;
279 case 50: fRotAngle=rDGR.GetF(); break;
280 case 70: nColCount=rDGR.GetI(); break;
281 case 71: nRowCount=rDGR.GetI(); break;
282 case 44: fColSpace=rDGR.GetF(); break;
283 case 45: fRowSpace=rDGR.GetF(); break;
284 default: DXFBasicEntity::EvaluateGroup(rDGR);
288 //--------------------------DXFAttDefEntity-------------------------------------
290 DXFAttDefEntity::DXFAttDefEntity()
291 : DXFBasicEntity(DXF_ATTDEF)
292 , m_sStyle("STANDARD"_ostr)
294 fHeight=1.0;
295 nAttrFlags=0;
296 nFieldLen=0;
297 fRotAngle=0.0;
298 fXScale=1.0;
299 fOblAngle=0.0;
300 nGenFlags=0;
301 nHorzJust=0;
302 nVertJust=0;
305 void DXFAttDefEntity::EvaluateGroup(DXFGroupReader & rDGR)
307 switch (rDGR.GetG()) {
308 case 10: aP0.fx=rDGR.GetF(); break;
309 case 20: aP0.fy=rDGR.GetF(); break;
310 case 30: aP0.fz=rDGR.GetF(); break;
311 case 40: fHeight=rDGR.GetF(); break;
312 case 1: m_sDefVal = rDGR.GetS(); break;
313 case 3: m_sPrompt = rDGR.GetS(); break;
314 case 2: m_sTagStr = rDGR.GetS(); break;
315 case 70: nAttrFlags=rDGR.GetI(); break;
316 case 73: nFieldLen=rDGR.GetI(); break;
317 case 50: fRotAngle=rDGR.GetF(); break;
318 case 41: fXScale=rDGR.GetF(); break;
319 case 51: fOblAngle=rDGR.GetF(); break;
320 case 7: m_sStyle = rDGR.GetS(); break;
321 case 71: nGenFlags=rDGR.GetI(); break;
322 case 72: nHorzJust=rDGR.GetI(); break;
323 case 74: nVertJust=rDGR.GetI(); break;
324 case 11: aAlign.fx=rDGR.GetF(); break;
325 case 21: aAlign.fy=rDGR.GetF(); break;
326 case 31: aAlign.fz=rDGR.GetF(); break;
327 default: DXFBasicEntity::EvaluateGroup(rDGR);
331 //--------------------------DXFAttribEntity-------------------------------------
333 DXFAttribEntity::DXFAttribEntity()
334 : DXFBasicEntity(DXF_ATTRIB)
335 , m_sStyle("STANDARD"_ostr)
337 fHeight=1.0;
338 nAttrFlags=0;
339 nFieldLen=0;
340 fRotAngle=0.0;
341 fXScale=1.0;
342 fOblAngle=0.0;
343 nGenFlags=0;
344 nHorzJust=0;
345 nVertJust=0;
348 void DXFAttribEntity::EvaluateGroup(DXFGroupReader & rDGR)
350 switch (rDGR.GetG()) {
351 case 10: aP0.fx=rDGR.GetF(); break;
352 case 20: aP0.fy=rDGR.GetF(); break;
353 case 30: aP0.fz=rDGR.GetF(); break;
354 case 40: fHeight=rDGR.GetF(); break;
355 case 1: m_sText = rDGR.GetS(); break;
356 case 2: m_sTagStr = rDGR.GetS(); break;
357 case 70: nAttrFlags=rDGR.GetI(); break;
358 case 73: nFieldLen=rDGR.GetI(); break;
359 case 50: fRotAngle=rDGR.GetF(); break;
360 case 41: fXScale=rDGR.GetF(); break;
361 case 51: fOblAngle=rDGR.GetF(); break;
362 case 7: m_sStyle = rDGR.GetS(); break;
363 case 71: nGenFlags=rDGR.GetI(); break;
364 case 72: nHorzJust=rDGR.GetI(); break;
365 case 74: nVertJust=rDGR.GetI(); break;
366 case 11: aAlign.fx=rDGR.GetF(); break;
367 case 21: aAlign.fy=rDGR.GetF(); break;
368 case 31: aAlign.fz=rDGR.GetF(); break;
369 default: DXFBasicEntity::EvaluateGroup(rDGR);
373 //--------------------------DXFPolyLine-----------------------------------------
375 DXFPolyLineEntity::DXFPolyLineEntity() : DXFBasicEntity(DXF_POLYLINE)
377 nFlags=0;
378 fSWidth=0.0;
379 fEWidth=0.0;
380 nMeshMCount=0;
381 nMeshNCount=0;
382 nMDensity=0;
383 nNDensity=0;
384 nCSSType=0;
387 void DXFPolyLineEntity::EvaluateGroup(DXFGroupReader & rDGR)
389 switch (rDGR.GetG()) {
390 case 70: nFlags=rDGR.GetI(); break;
391 case 40: fSWidth=rDGR.GetF(); break;
392 case 41: fEWidth=rDGR.GetF(); break;
393 case 71: nMeshMCount=rDGR.GetI(); break;
394 case 72: nMeshNCount=rDGR.GetI(); break;
395 case 73: nMDensity=rDGR.GetI(); break;
396 case 74: nNDensity=rDGR.GetI(); break;
397 case 75: nCSSType=rDGR.GetI(); break;
398 default: DXFBasicEntity::EvaluateGroup(rDGR);
402 //--------------------------DXFLWPolyLine---------------------------------------
404 DXFLWPolyLineEntity::DXFLWPolyLineEntity() :
405 DXFBasicEntity( DXF_LWPOLYLINE ),
406 nIndex( 0 ),
407 nCount( 0 ),
408 nFlags( 0 ),
409 fConstantWidth( 0.0 ),
410 fStartWidth( 0.0 ),
411 fEndWidth( 0.0 )
415 void DXFLWPolyLineEntity::EvaluateGroup( DXFGroupReader & rDGR )
417 switch ( rDGR.GetG() )
419 case 90 :
421 nCount = rDGR.GetI();
422 // limit alloc to max reasonable size based on remaining data in stream
423 if (nCount > 0 && o3tl::make_unsigned(nCount) <= rDGR.remainingSize())
424 aP.reserve(nCount);
425 else
426 nCount = 0;
428 break;
429 case 70: nFlags = rDGR.GetI(); break;
430 case 43: fConstantWidth = rDGR.GetF(); break;
431 case 40: fStartWidth = rDGR.GetF(); break;
432 case 41: fEndWidth = rDGR.GetF(); break;
433 case 10:
435 if (nIndex < nCount)
437 aP.resize(nIndex+1);
438 aP[nIndex].fx = rDGR.GetF();
441 break;
442 case 20:
444 if (nIndex < nCount)
446 aP.resize(nIndex+1);
447 aP[nIndex].fy = rDGR.GetF();
448 ++nIndex;
451 break;
452 default: DXFBasicEntity::EvaluateGroup(rDGR);
456 //--------------------------DXFHatchEntity-------------------------------------
458 DXFEdgeTypeLine::DXFEdgeTypeLine() :
459 DXFEdgeType( 1 )
464 bool DXFEdgeTypeLine::EvaluateGroup( DXFGroupReader & rDGR )
466 bool bExecutingGroupCode = true;
467 switch ( rDGR.GetG() )
469 case 10 : aStartPoint.fx = rDGR.GetF(); break;
470 case 20 : aStartPoint.fy = rDGR.GetF(); break;
471 case 11 : aEndPoint.fx = rDGR.GetF(); break;
472 case 21 : aEndPoint.fy = rDGR.GetF(); break;
473 default : bExecutingGroupCode = false; break;
475 return bExecutingGroupCode;
478 DXFEdgeTypeCircularArc::DXFEdgeTypeCircularArc() :
479 DXFEdgeType( 2 ),
480 fRadius( 0.0 ),
481 fStartAngle( 0.0 ),
482 fEndAngle( 0.0 ),
483 nIsCounterClockwiseFlag( 0 )
487 bool DXFEdgeTypeCircularArc::EvaluateGroup( DXFGroupReader & rDGR )
489 bool bExecutingGroupCode = true;
490 switch ( rDGR.GetG() )
492 case 10 : aCenter.fx = rDGR.GetF(); break;
493 case 20 : aCenter.fy = rDGR.GetF(); break;
494 case 40 : fRadius = rDGR.GetF(); break;
495 case 50 : fStartAngle = rDGR.GetF(); break;
496 case 51 : fEndAngle = rDGR.GetF(); break;
497 case 73 : nIsCounterClockwiseFlag = rDGR.GetI(); break;
498 default : bExecutingGroupCode = false; break;
500 return bExecutingGroupCode;
503 DXFEdgeTypeEllipticalArc::DXFEdgeTypeEllipticalArc() :
504 DXFEdgeType( 3 ),
505 fLength( 0.0 ),
506 fStartAngle( 0.0 ),
507 fEndAngle( 0.0 ),
508 nIsCounterClockwiseFlag( 0 )
512 bool DXFEdgeTypeEllipticalArc::EvaluateGroup( DXFGroupReader & rDGR )
514 bool bExecutingGroupCode = true;
515 switch( rDGR.GetG() )
517 case 10 : aCenter.fx = rDGR.GetF(); break;
518 case 20 : aCenter.fy = rDGR.GetF(); break;
519 case 11 : aEndPoint.fx = rDGR.GetF(); break;
520 case 21 : aEndPoint.fy = rDGR.GetF(); break;
521 case 40 : fLength = rDGR.GetF(); break;
522 case 50 : fStartAngle = rDGR.GetF(); break;
523 case 51 : fEndAngle = rDGR.GetF(); break;
524 case 73 : nIsCounterClockwiseFlag = rDGR.GetI(); break;
525 default : bExecutingGroupCode = false; break;
527 return bExecutingGroupCode;
530 DXFEdgeTypeSpline::DXFEdgeTypeSpline() :
531 DXFEdgeType( 4 ),
532 nDegree( 0 ),
533 nRational( 0 ),
534 nPeriodic( 0 ),
535 nKnotCount( 0 ),
536 nControlCount( 0 )
540 bool DXFEdgeTypeSpline::EvaluateGroup( DXFGroupReader & rDGR )
542 bool bExecutingGroupCode = true;
543 switch ( rDGR.GetG() )
545 case 94 : nDegree = rDGR.GetI(); break;
546 case 73 : nRational = rDGR.GetI(); break;
547 case 74 : nPeriodic = rDGR.GetI(); break;
548 case 95 : nKnotCount = rDGR.GetI(); break;
549 case 96 : nControlCount = rDGR.GetI(); break;
550 default : bExecutingGroupCode = false; break;
552 return bExecutingGroupCode;
555 DXFBoundaryPathData::DXFBoundaryPathData() :
556 nPointCount( 0 ),
557 nFlags( 0 ),
558 nHasBulgeFlag( 0 ),
559 nIsClosedFlag( 0 ),
560 fBulge( 0.0 ),
561 nSourceBoundaryObjects( 0 ),
562 nEdgeCount( 0 ),
563 bIsPolyLine( true ),
564 nPointIndex( 0 )
568 bool DXFBoundaryPathData::EvaluateGroup( DXFGroupReader & rDGR )
570 bool bExecutingGroupCode = true;
571 if ( bIsPolyLine )
573 switch( rDGR.GetG() )
575 case 92 :
577 nFlags = rDGR.GetI();
578 if ( ( nFlags & 2 ) == 0 )
579 bIsPolyLine = false;
581 break;
582 case 93 :
584 nPointCount = rDGR.GetI();
585 // limit alloc to max reasonable size based on remaining data in stream
586 if (nPointCount > 0 && o3tl::make_unsigned(nPointCount) <= rDGR.remainingSize())
587 aP.reserve(nPointCount);
588 else
589 nPointCount = 0;
591 break;
592 case 72 : nHasBulgeFlag = rDGR.GetI(); break;
593 case 73 : nIsClosedFlag = rDGR.GetI(); break;
594 case 97 : nSourceBoundaryObjects = rDGR.GetI(); break;
595 case 42 : fBulge = rDGR.GetF(); break;
596 case 10:
598 if (nPointIndex < nPointCount)
600 aP.resize(nPointIndex+1);
601 aP[nPointIndex].fx = rDGR.GetF();
604 break;
605 case 20:
607 if (nPointIndex < nPointCount)
609 aP.resize(nPointIndex+1);
610 aP[nPointIndex].fy = rDGR.GetF();
611 ++nPointIndex;
614 break;
616 default : bExecutingGroupCode = false; break;
619 else
621 if ( rDGR.GetG() == 93 )
622 nEdgeCount = rDGR.GetI();
623 else if ( rDGR.GetG() == 72 )
625 sal_Int32 nEdgeType = rDGR.GetI();
626 switch( nEdgeType )
628 case 1 : aEdges.emplace_back( new DXFEdgeTypeLine() ); break;
629 case 2 : aEdges.emplace_back( new DXFEdgeTypeCircularArc() ); break;
630 case 3 : aEdges.emplace_back( new DXFEdgeTypeEllipticalArc() ); break;
631 case 4 : aEdges.emplace_back( new DXFEdgeTypeSpline() ); break;
634 else if ( !aEdges.empty() )
635 aEdges.back()->EvaluateGroup( rDGR );
636 else
637 bExecutingGroupCode = false;
639 return bExecutingGroupCode;
642 DXFHatchEntity::DXFHatchEntity() :
643 DXFBasicEntity( DXF_HATCH ),
644 bIsInBoundaryPathContext( false ),
645 nCurrentBoundaryPathIndex( -1 ),
646 nFlags( 0 ),
647 nAssociativityFlag( 0 ),
648 nMaxBoundaryPathCount( 0 ),
649 nHatchStyle( 0 ),
650 nHatchPatternType( 0 ),
651 fHatchPatternAngle( 0.0 ),
652 fHatchPatternScale( 1.0 ),
653 nHatchDoubleFlag( 0 ),
654 nHatchPatternDefinitionLines( 0 ),
655 fPixelSize( 1.0 ),
656 nNumberOfSeedPoints( 0 )
660 void DXFHatchEntity::EvaluateGroup( DXFGroupReader & rDGR )
662 switch ( rDGR.GetG() )
664 // case 10 : aElevationPoint.fx = rDGR.GetF(); break;
665 // case 20 : aElevationPoint.fy = rDGR.GetF(); break;
666 // case 30 : aElevationPoint.fz = rDGR.GetF(); break;
667 case 70 : nFlags = rDGR.GetI(); break;
668 case 71 : nAssociativityFlag = rDGR.GetI(); break;
669 case 91 :
671 bIsInBoundaryPathContext = true;
672 nMaxBoundaryPathCount = rDGR.GetI();
673 // limit alloc to max reasonable size based on remaining data in stream
674 if (nMaxBoundaryPathCount > 0 && o3tl::make_unsigned(nMaxBoundaryPathCount) <= rDGR.remainingSize())
675 aBoundaryPathData.reserve(nMaxBoundaryPathCount);
676 else
677 nMaxBoundaryPathCount = 0;
679 break;
680 case 75 :
682 nHatchStyle = rDGR.GetI();
683 bIsInBoundaryPathContext = false;
685 break;
686 case 76 : nHatchPatternType = rDGR.GetI(); break;
687 case 52 : fHatchPatternAngle = rDGR.GetF(); break;
688 case 41 : fHatchPatternScale = rDGR.GetF(); break;
689 case 77 : nHatchDoubleFlag = rDGR.GetI(); break;
690 case 78 : nHatchPatternDefinitionLines = rDGR.GetI(); break;
691 case 47 : fPixelSize = rDGR.GetF(); break;
692 case 98 : nNumberOfSeedPoints = rDGR.GetI(); break;
694 case 92:
695 nCurrentBoundaryPathIndex++;
696 [[fallthrough]];
697 default:
699 bool bExecutingGroupCode = false;
700 if ( bIsInBoundaryPathContext )
702 if (nCurrentBoundaryPathIndex >= 0 && nCurrentBoundaryPathIndex < nMaxBoundaryPathCount)
704 aBoundaryPathData.resize(nCurrentBoundaryPathIndex + 1);
705 bExecutingGroupCode = aBoundaryPathData.back().EvaluateGroup(rDGR);
708 if ( !bExecutingGroupCode )
709 DXFBasicEntity::EvaluateGroup(rDGR);
711 break;
715 //--------------------------DXFVertexEntity-------------------------------------
717 DXFVertexEntity::DXFVertexEntity() : DXFBasicEntity(DXF_VERTEX)
719 fSWidth=-1.0;
720 fEWidth=-1.0;
721 fBulge=0.0;
722 nFlags=0;
723 fCFTDir=0.0;
727 void DXFVertexEntity::EvaluateGroup(DXFGroupReader & rDGR)
729 switch (rDGR.GetG()) {
730 case 10: aP0.fx=rDGR.GetF(); break;
731 case 20: aP0.fy=rDGR.GetF(); break;
732 case 30: aP0.fz=rDGR.GetF(); break;
733 case 40: fSWidth=rDGR.GetF(); break;
734 case 41: fEWidth=rDGR.GetF(); break;
735 case 42: fBulge=rDGR.GetF(); break;
736 case 70: nFlags=rDGR.GetI(); break;
737 case 50: fCFTDir=rDGR.GetF(); break;
738 default: DXFBasicEntity::EvaluateGroup(rDGR);
742 //--------------------------DXFSeqEndEntity-------------------------------------
744 DXFSeqEndEntity::DXFSeqEndEntity() : DXFBasicEntity(DXF_SEQEND)
748 //--------------------------DXF3DFace-------------------------------------------
750 DXF3DFaceEntity::DXF3DFaceEntity() : DXFBasicEntity(DXF_3DFACE)
752 nIEFlags=0;
755 void DXF3DFaceEntity::EvaluateGroup(DXFGroupReader & rDGR)
757 switch (rDGR.GetG()) {
758 case 10: aP0.fx=rDGR.GetF(); break;
759 case 20: aP0.fy=rDGR.GetF(); break;
760 case 30: aP0.fz=rDGR.GetF(); break;
761 case 11: aP1.fx=rDGR.GetF(); break;
762 case 21: aP1.fy=rDGR.GetF(); break;
763 case 31: aP1.fz=rDGR.GetF(); break;
764 case 12: aP2.fx=rDGR.GetF(); break;
765 case 22: aP2.fy=rDGR.GetF(); break;
766 case 32: aP2.fz=rDGR.GetF(); break;
767 case 13: aP3.fx=rDGR.GetF(); break;
768 case 23: aP3.fy=rDGR.GetF(); break;
769 case 33: aP3.fz=rDGR.GetF(); break;
770 case 70: nIEFlags=rDGR.GetI(); break;
771 default: DXFBasicEntity::EvaluateGroup(rDGR);
776 //--------------------------DXFDimensionEntity----------------------------------
778 DXFDimensionEntity::DXFDimensionEntity() : DXFBasicEntity(DXF_DIMENSION)
782 void DXFDimensionEntity::EvaluateGroup(DXFGroupReader & rDGR)
784 switch (rDGR.GetG()) {
785 case 2: m_sPseudoBlock = rDGR.GetS(); break;
786 default: DXFBasicEntity::EvaluateGroup(rDGR);
790 //---------------------------- DXFEntities --------------------------------------
792 void DXFEntities::Read(DXFGroupReader & rDGR)
794 DXFBasicEntity * pE, * * ppSucc;
796 ppSucc=&pFirst;
797 while (*ppSucc!=nullptr) ppSucc=&((*ppSucc)->pSucc);
799 while (rDGR.GetG()!=0) rDGR.Read();
801 while (rDGR.GetS()!="ENDBLK" &&
802 rDGR.GetS()!="ENDSEC" &&
803 rDGR.GetS()!="EOF" )
806 if (rDGR.GetS() == "LINE" ) pE=new DXFLineEntity;
807 else if (rDGR.GetS() == "POINT" ) pE=new DXFPointEntity;
808 else if (rDGR.GetS() == "CIRCLE" ) pE=new DXFCircleEntity;
809 else if (rDGR.GetS() == "ARC" ) pE=new DXFArcEntity;
810 else if (rDGR.GetS() == "TRACE" ) pE=new DXFTraceEntity;
811 else if (rDGR.GetS() == "SOLID" ) pE=new DXFSolidEntity;
812 else if (rDGR.GetS() == "TEXT" ) pE=new DXFTextEntity;
813 else if (rDGR.GetS() == "SHAPE" ) pE=new DXFShapeEntity;
814 else if (rDGR.GetS() == "INSERT" ) pE=new DXFInsertEntity;
815 else if (rDGR.GetS() == "ATTDEF" ) pE=new DXFAttDefEntity;
816 else if (rDGR.GetS() == "ATTRIB" ) pE=new DXFAttribEntity;
817 else if (rDGR.GetS() == "POLYLINE" ) pE=new DXFPolyLineEntity;
818 else if (rDGR.GetS() == "LWPOLYLINE") pE=new DXFLWPolyLineEntity;
819 else if (rDGR.GetS() == "VERTEX" ) pE=new DXFVertexEntity;
820 else if (rDGR.GetS() == "SEQEND" ) pE=new DXFSeqEndEntity;
821 else if (rDGR.GetS() == "3DFACE" ) pE=new DXF3DFaceEntity;
822 else if (rDGR.GetS() == "DIMENSION" ) pE=new DXFDimensionEntity;
823 else if (rDGR.GetS() == "HATCH" ) pE=new DXFHatchEntity;
824 else
826 do {
827 rDGR.Read();
828 } while (rDGR.GetG()!=0);
829 continue;
831 *ppSucc=pE;
832 ppSucc=&(pE->pSucc);
833 pE->Read(rDGR);
837 void DXFEntities::Clear()
839 DXFBasicEntity * ptmp;
841 while (pFirst!=nullptr) {
842 ptmp=pFirst;
843 pFirst=ptmp->pSucc;
844 delete ptmp;
848 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */