1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include "dxfgrprd.hxx"
24 #include <tools/long.hxx>
50 // base class of an entity
52 class DXFBasicEntity
{
56 DXFBasicEntity
* pSucc
;
57 // pointer to next entity (in the list of DXFEntities.pFirst)
60 // entity kind (line or circle or what)
62 // properties that all entities have, each
63 // commented with group codes:
64 OString m_sLayer
; // 8
65 OString m_sLineType
; // 6
66 double fThickness
; // 39
67 tools::Long nColor
; // 62
68 tools::Long nSpace
; // 67
69 DXFVector aExtrusion
; // 210,220,230
73 DXFBasicEntity(DXFEntityType eThisType
);
74 // always initialize the constructors of entities with default values
78 virtual ~DXFBasicEntity();
79 void Read(DXFGroupReader
& rDGR
);
80 // Reads a parameter till the next 0-group
84 virtual void EvaluateGroup(DXFGroupReader
& rDGR
);
85 // This method will be called by Read() for every parameter (respectively
87 // As far as the group code of the entity is known, the corresponding
88 // parameter is fetched.
93 // the different kinds of entities
95 class DXFLineEntity
: public DXFBasicEntity
{
99 DXFVector aP0
; // 10,20,30
100 DXFVector aP1
; // 11,21,31
106 virtual void EvaluateGroup(DXFGroupReader
& rDGR
) override
;
109 class DXFPointEntity
: public DXFBasicEntity
{
113 DXFVector aP0
; // 10,20,30
119 virtual void EvaluateGroup(DXFGroupReader
& rDGR
) override
;
122 class DXFCircleEntity
: public DXFBasicEntity
{
126 DXFVector aP0
; // 10,20,30
127 double fRadius
; // 40
133 virtual void EvaluateGroup(DXFGroupReader
& rDGR
) override
;
136 class DXFArcEntity
: public DXFBasicEntity
{
140 DXFVector aP0
; // 10,20,30
141 double fRadius
; // 40
149 virtual void EvaluateGroup(DXFGroupReader
& rDGR
) override
;
152 class DXFTraceEntity
: public DXFBasicEntity
{
156 DXFVector aP0
; // 10,20,30
157 DXFVector aP1
; // 11,21,31
158 DXFVector aP2
; // 12,22,32
159 DXFVector aP3
; // 13,23,33
165 virtual void EvaluateGroup(DXFGroupReader
& rDGR
) override
;
168 class DXFSolidEntity
: public DXFBasicEntity
{
172 DXFVector aP0
; // 10,20,30
173 DXFVector aP1
; // 11,21,31
174 DXFVector aP2
; // 12,22,32
175 DXFVector aP3
; // 13,23,33
181 virtual void EvaluateGroup(DXFGroupReader
& rDGR
) override
;
184 class DXFTextEntity
: public DXFBasicEntity
{
188 DXFVector aP0
; // 10,20,30
189 double fHeight
; // 40
190 OString m_sText
; // 1
191 double fRotAngle
; // 50
192 double fXScale
; // 41
193 double fOblAngle
; // 42
194 OString m_sStyle
; // 7
195 tools::Long nGenFlags
; // 71
196 tools::Long nHorzJust
; // 72
197 tools::Long nVertJust
; // 73
198 DXFVector aAlign
; // 11,21,31
204 virtual void EvaluateGroup(DXFGroupReader
& rDGR
) override
;
207 class DXFShapeEntity
: public DXFBasicEntity
{
209 DXFVector aP0
; // 10,20,30
211 OString m_sName
; // 2
212 double fRotAngle
; // 50
213 double fXScale
; // 41
214 double fOblAngle
; // 51
222 virtual void EvaluateGroup(DXFGroupReader
& rDGR
) override
;
225 class DXFInsertEntity
: public DXFBasicEntity
{
229 tools::Long nAttrFlag
; // 66
230 OString m_sName
; // 2
231 DXFVector aP0
; // 10,20,30
232 double fXScale
; // 41
233 double fYScale
; // 42
234 double fZScale
; // 43
235 double fRotAngle
; // 50
236 tools::Long nColCount
; // 70
237 tools::Long nRowCount
; // 71
238 double fColSpace
; // 44
239 double fRowSpace
; // 45
245 virtual void EvaluateGroup(DXFGroupReader
& rDGR
) override
;
248 class DXFAttDefEntity
: public DXFBasicEntity
{
250 DXFVector aP0
; // 10,20,30
251 double fHeight
; // 40
252 OString m_sDefVal
; // 1
253 OString m_sPrompt
; // 3
254 OString m_sTagStr
; // 2
255 tools::Long nAttrFlags
; // 70
256 tools::Long nFieldLen
; // 73
257 double fRotAngle
; // 50
258 double fXScale
; // 41
259 double fOblAngle
; // 51
260 OString m_sStyle
; // 7
261 tools::Long nGenFlags
; // 71
262 tools::Long nHorzJust
; // 72
263 tools::Long nVertJust
; // 74
264 DXFVector aAlign
; // 11,21,31
272 virtual void EvaluateGroup(DXFGroupReader
& rDGR
) override
;
275 class DXFAttribEntity
: public DXFBasicEntity
{
279 DXFVector aP0
; // 10,20,30
280 double fHeight
; // 40
281 OString m_sText
; // 1
282 OString m_sTagStr
; // 2
283 tools::Long nAttrFlags
; // 70
284 tools::Long nFieldLen
; // 73
285 double fRotAngle
; // 50
286 double fXScale
; // 41
287 double fOblAngle
; // 51
288 OString m_sStyle
; // 7
289 tools::Long nGenFlags
; // 71
290 tools::Long nHorzJust
; // 72
291 tools::Long nVertJust
; // 74
292 DXFVector aAlign
; // 11,21,31
298 virtual void EvaluateGroup(DXFGroupReader
& rDGR
) override
;
301 class DXFPolyLineEntity
: public DXFBasicEntity
{
305 tools::Long nFlags
; // 70
306 double fSWidth
; // 40
307 double fEWidth
; // 41
308 tools::Long nMeshMCount
; // 71
309 tools::Long nMeshNCount
; // 72
310 tools::Long nMDensity
; // 73
311 tools::Long nNDensity
; // 74
312 tools::Long nCSSType
; // 75
318 virtual void EvaluateGroup(DXFGroupReader
& rDGR
) override
;
321 class DXFLWPolyLineEntity
: public DXFBasicEntity
324 sal_Int32 nCount
; // 90
328 sal_Int32 nFlags
; // 70 1 = closed, 128 = plinegen
329 double fConstantWidth
; // 43 (optional - default: 0, not used if fStartWidth and/or fEndWidth is used)
330 double fStartWidth
; // 40
331 double fEndWidth
; // 41
333 std::vector
<DXFVector
> aP
;
335 DXFLWPolyLineEntity();
339 virtual void EvaluateGroup( DXFGroupReader
& rDGR
) override
;
347 virtual ~DXFEdgeType(){};
348 virtual bool EvaluateGroup( DXFGroupReader
& /*rDGR*/ ){ return true; };
352 DXFEdgeType( sal_Int32 EdgeType
):nEdgeType(EdgeType
){};
355 struct DXFEdgeTypeLine
: public DXFEdgeType
357 DXFVector aStartPoint
; // 10,20
358 DXFVector aEndPoint
; // 11,21
360 virtual bool EvaluateGroup( DXFGroupReader
& rDGR
) override
;
363 struct DXFEdgeTypeCircularArc
: public DXFEdgeType
365 DXFVector aCenter
; // 10,20
366 double fRadius
; // 40
367 double fStartAngle
; // 50
368 double fEndAngle
; // 51
369 sal_Int32 nIsCounterClockwiseFlag
; // 73
370 DXFEdgeTypeCircularArc();
371 virtual bool EvaluateGroup( DXFGroupReader
& rDGR
) override
;
374 struct DXFEdgeTypeEllipticalArc
: public DXFEdgeType
376 DXFVector aCenter
; // 10,20
377 DXFVector aEndPoint
; // 11,21
378 double fLength
; // 40
379 double fStartAngle
; // 50
380 double fEndAngle
; // 51
381 sal_Int32 nIsCounterClockwiseFlag
; // 73
383 DXFEdgeTypeEllipticalArc();
384 virtual bool EvaluateGroup( DXFGroupReader
& rDGR
) override
;
387 struct DXFEdgeTypeSpline
: public DXFEdgeType
389 sal_Int32 nDegree
; // 94
390 sal_Int32 nRational
; // 73
391 sal_Int32 nPeriodic
; // 74
392 sal_Int32 nKnotCount
; // 75
393 sal_Int32 nControlCount
; // 76
396 virtual bool EvaluateGroup( DXFGroupReader
& rDGR
) override
;
399 struct DXFBoundaryPathData
402 sal_Int32 nPointCount
; // 93
404 sal_Int32 nFlags
; // 92
405 sal_Int32 nHasBulgeFlag
; // 72
406 sal_Int32 nIsClosedFlag
; // 73
408 sal_Int32 nSourceBoundaryObjects
; // 97
409 sal_Int32 nEdgeCount
; // 93
412 sal_Int32 nPointIndex
;
414 std::vector
<DXFVector
> aP
;
415 std::vector
<std::unique_ptr
<DXFEdgeType
>> aEdges
;
417 DXFBoundaryPathData();
419 bool EvaluateGroup( DXFGroupReader
& rDGR
);
422 class DXFHatchEntity
: public DXFBasicEntity
424 bool bIsInBoundaryPathContext
;
425 sal_Int32 nCurrentBoundaryPathIndex
;
429 sal_Int32 nFlags
; // 70 (solid fill = 1, pattern fill = 0)
430 sal_Int32 nAssociativityFlag
; // 71 (associative = 1, non-associative = 0)
431 sal_Int32 nMaxBoundaryPathCount
; // 91
432 sal_Int32 nHatchStyle
; // 75 (odd parity = 0, outmost area = 1, entire area = 2 )
433 sal_Int32 nHatchPatternType
; // 76 (user defined = 0, predefined = 1, custom = 2)
434 double fHatchPatternAngle
; // 52 (pattern fill only)
435 double fHatchPatternScale
; // 41 (pattern fill only:scale or spacing)
436 sal_Int32 nHatchDoubleFlag
; // 77 (pattern fill only:double = 1, not double = 0)
437 sal_Int32 nHatchPatternDefinitionLines
; // 78
438 double fPixelSize
; // 47
439 sal_Int32 nNumberOfSeedPoints
; // 98
441 std::vector
<DXFBoundaryPathData
> aBoundaryPathData
;
447 virtual void EvaluateGroup( DXFGroupReader
& rDGR
) override
;
450 class DXFVertexEntity
: public DXFBasicEntity
{
454 DXFVector aP0
; // 10,20,30
455 double fSWidth
; // 40 (if <0.0, then one has DXFPolyLine::fSWidth)
456 double fEWidth
; // 41 (if <0.0, then one has DXFPolyLine::fEWidth)
458 tools::Long nFlags
; // 70
459 double fCFTDir
; // 50
465 virtual void EvaluateGroup(DXFGroupReader
& rDGR
) override
;
468 class DXFSeqEndEntity
: public DXFBasicEntity
{
475 class DXF3DFaceEntity
: public DXFBasicEntity
{
479 DXFVector aP0
; // 10,20,30
480 DXFVector aP1
; // 11,21,31
481 DXFVector aP2
; // 12,22,32
482 DXFVector aP3
; // 13,23,33
483 tools::Long nIEFlags
; // 70
489 virtual void EvaluateGroup(DXFGroupReader
& rDGR
) override
;
492 class DXFDimensionEntity
: public DXFBasicEntity
{
496 OString m_sPseudoBlock
; // 2
498 DXFDimensionEntity();
502 virtual void EvaluateGroup(DXFGroupReader
& rDGR
) override
;
506 // read and represent the set of entities
513 , mbBeingDrawn(false)
522 DXFBasicEntity
* pFirst
; // list of entities, READ ONLY!
523 mutable bool mbBeingDrawn
; // guard for loop in entity parsing
525 void Read(DXFGroupReader
& rDGR
);
526 // read entities by rGDR of a DXF file until a
527 // ENDBLK, ENDSEC or EOF (of group 0).
528 // (all unknown thing will be skipped)
531 // deletes all entities
534 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */