• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DomCR / ACadSharp / 18713416846

22 Oct 2025 10:35AM UTC coverage: 78.048% (+0.1%) from 77.923%
18713416846

Pull #831

github

web-flow
Merge 7f185e92a into f84cb1d2a
Pull Request #831: Table entity refactor

7226 of 10046 branches covered (71.93%)

Branch coverage included in aggregate %.

547 of 637 new or added lines in 13 files covered. (85.87%)

10 existing lines in 4 files now uncovered.

27143 of 33990 relevant lines covered (79.86%)

107697.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.96
/src/ACadSharp/IO/DXF/DxfStreamReader/DxfObjectsSectionReader.cs
1
using ACadSharp.Classes;
2
using ACadSharp.Entities;
3
using ACadSharp.IO.Templates;
4
using ACadSharp.Objects;
5
using ACadSharp.Objects.Evaluations;
6
using CSMath;
7
using System;
8
using System.Diagnostics;
9
using System.IO;
10
using System.Linq;
11
using static ACadSharp.IO.Templates.CadEvaluationGraphTemplate;
12
using static ACadSharp.IO.Templates.CadTableEntityTemplate;
13

14
namespace ACadSharp.IO.DXF
15
{
16
        internal class DxfObjectsSectionReader : DxfSectionReaderBase
17
        {
18
                public delegate bool ReadObjectDelegate<T>(CadTemplate template, DxfMap map) where T : CadObject;
19

20
                public DxfObjectsSectionReader(IDxfStreamReader reader, DxfDocumentBuilder builder)
21
                        : base(reader, builder)
242✔
22
                {
242✔
23
                }
242✔
24

25
                public override void Read()
26
                {
242✔
27
                        //Advance to the first value in the section
28
                        this._reader.ReadNext();
242✔
29

30
                        //Loop until the section ends
31
                        while (this._reader.ValueAsString != DxfFileToken.EndSection)
72,228✔
32
                        {
71,986✔
33
                                CadTemplate template = null;
71,986✔
34

35
                                try
36
                                {
71,986✔
37
                                        template = this.readObject();
71,986✔
38
                                }
71,986✔
39
                                catch (Exception ex)
×
40
                                {
×
41
                                        if (!this._builder.Configuration.Failsafe)
×
42
                                                throw;
×
43

44
                                        this._builder.Notify($"Error while reading an object at line {this._reader.Position}", NotificationType.Error, ex);
×
45

46
                                        while (this._reader.DxfCode != DxfCode.Start)
×
47
                                                this._reader.ReadNext();
×
48
                                }
×
49

50
                                if (template == null)
71,986✔
51
                                        continue;
242✔
52

53
                                //Add the object and the template to the builder
54
                                this._builder.AddTemplate(template);
71,744✔
55
                        }
71,744✔
56
                }
242✔
57

58
                private CadTemplate readObject()
59
                {
71,986✔
60
                        switch (this._reader.ValueAsString)
71,986!
61
                        {
62
                                case DxfFileToken.ObjectPlaceholder:
63
                                        return this.readObjectCodes<AcdbPlaceHolder>(new CadNonGraphicalObjectTemplate(new AcdbPlaceHolder()), this.readObjectSubclassMap);
230✔
64
                                case DxfFileToken.ObjectDBColor:
65
                                        return this.readObjectCodes<BookColor>(new CadNonGraphicalObjectTemplate(new BookColor()), this.readBookColor);
228✔
66
                                case DxfFileToken.ObjectDictionary:
67
                                        return this.readObjectCodes<CadDictionary>(new CadDictionaryTemplate(), this.readDictionary);
23,376✔
68
                                case DxfFileToken.ObjectDictionaryWithDefault:
69
                                        return this.readObjectCodes<CadDictionaryWithDefault>(new CadDictionaryWithDefaultTemplate(), this.readDictionaryWithDefault);
230✔
70
                                case DxfFileToken.ObjectLayout:
71
                                        return this.readObjectCodes<Layout>(new CadLayoutTemplate(), this.readLayout);
942✔
72
                                case DxfFileToken.ObjectPlotSettings:
73
                                        return this.readObjectCodes<PlotSettings>(new CadNonGraphicalObjectTemplate(new PlotSettings()), this.readPlotSettings);
×
74
                                case DxfFileToken.ObjectEvalGraph:
75
                                        return this.readObjectCodes<EvaluationGraph>(new CadEvaluationGraphTemplate(), this.readEvaluationGraph);
532✔
76
                                case DxfFileToken.ObjectImageDefinition:
77
                                        return this.readObjectCodes<ImageDefinition>(new CadNonGraphicalObjectTemplate(new ImageDefinition()), this.readObjectSubclassMap);
228✔
78
                                case DxfFileToken.ObjectDictionaryVar:
79
                                        return this.readObjectCodes<DictionaryVariable>(new CadTemplate<DictionaryVariable>(new DictionaryVariable()), this.readObjectSubclassMap);
3,282✔
80
                                case DxfFileToken.ObjectPdfDefinition:
81
                                        return this.readObjectCodes<PdfUnderlayDefinition>(new CadNonGraphicalObjectTemplate(new PdfUnderlayDefinition()), this.readObjectSubclassMap);
228✔
82
                                case DxfFileToken.ObjectSortEntsTable:
83
                                        return this.readSortentsTable();
684✔
84
                                case DxfFileToken.ObjectImageDefinitionReactor:
85
                                        return this.readObjectCodes<ImageDefinitionReactor>(new CadNonGraphicalObjectTemplate(new ImageDefinitionReactor()), this.readObjectSubclassMap);
228✔
86
                                case DxfFileToken.ObjectProxyObject:
87
                                        return this.readObjectCodes<ProxyObject>(new CadNonGraphicalObjectTemplate(new ProxyObject()), this.readProxyObject);
×
88
                                case DxfFileToken.ObjectRasterVariables:
89
                                        return this.readObjectCodes<RasterVariables>(new CadNonGraphicalObjectTemplate(new RasterVariables()), this.readObjectSubclassMap);
228✔
90
                                case DxfFileToken.ObjectGroup:
91
                                        return this.readObjectCodes<Group>(new CadGroupTemplate(), this.readGroup);
456✔
92
                                case DxfFileToken.ObjectGeoData:
93
                                        return this.readObjectCodes<GeoData>(new CadGeoDataTemplate(), this.readGeoData);
2✔
94
                                case DxfFileToken.ObjectScale:
95
                                        return this.readObjectCodes<Scale>(new CadTemplate<Scale>(new Scale()), this.readScale);
7,794✔
96
                                case DxfFileToken.ObjectTableContent:
97
                                        return this.readObjectCodes<TableContent>(new CadTableContentTemplate(), this.readTableContent);
380✔
98
                                case DxfFileToken.ObjectVisualStyle:
99
                                        return this.readObjectCodes<VisualStyle>(new CadTemplate<VisualStyle>(new VisualStyle()), this.readVisualStyle);
5,520✔
100
                                case DxfFileToken.ObjectSpatialFilter:
101
                                        return this.readObjectCodes<SpatialFilter>(new CadSpatialFilterTemplate(), this.readSpatialFilter);
228✔
102
                                case DxfFileToken.ObjectMLeaderStyle:
103
                                        return this.readObjectCodes<MultiLeaderStyle>(new CadMLeaderStyleTemplate(), this.readMLeaderStyle);
472✔
104
                                case DxfFileToken.ObjectXRecord:
105
                                        return this.readObjectCodes<XRecord>(new CadXRecordTemplate(), this.readXRecord);
18,632✔
106
                                default:
107
                                        DxfMap map = DxfMap.Create<CadObject>();
8,086✔
108
                                        CadUnknownNonGraphicalObjectTemplate unknownEntityTemplate = null;
8,086✔
109
                                        if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
8,086✔
110
                                        {
7,844✔
111
                                                //this._builder.Notify($"NonGraphicalObject not supported read as an UnknownNonGraphicalObject: {this._reader.ValueAsString}", NotificationType.NotImplemented);
112
                                                unknownEntityTemplate = new CadUnknownNonGraphicalObjectTemplate(new UnknownNonGraphicalObject(dxfClass));
7,844✔
113
                                        }
7,844✔
114
                                        else
115
                                        {
242✔
116
                                                //this._builder.Notify($"UnknownNonGraphicalObject not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
117
                                        }
242✔
118

119
                                        this._reader.ReadNext();
8,086✔
120

121
                                        do
122
                                        {
384,542✔
123
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
384,542✔
124
                                                {
38,532✔
125
                                                        this.readCommonCodes(unknownEntityTemplate, out bool isExtendedData, map);
38,532✔
126
                                                        if (isExtendedData)
38,532✔
127
                                                                continue;
48✔
128
                                                }
38,484✔
129

130
                                                this._reader.ReadNext();
384,494✔
131
                                        }
384,494✔
132
                                        while (this._reader.DxfCode != DxfCode.Start);
384,542✔
133

134
                                        return unknownEntityTemplate;
8,086✔
135
                        }
136
                }
71,986✔
137

138
                protected CadTemplate readObjectCodes<T>(CadTemplate template, ReadObjectDelegate<T> readObject)
139
                        where T : CadObject
140
                {
63,216✔
141
                        this._reader.ReadNext();
63,216✔
142

143
                        DxfMap map = DxfMap.Create<T>();
63,216✔
144

145
                        while (this._reader.DxfCode != DxfCode.Start)
967,481✔
146
                        {
904,265✔
147
                                if (!readObject(template, map))
904,265✔
148
                                {
305,881✔
149
                                        this.readCommonCodes(template, out bool isExtendedData, map);
305,881✔
150
                                        if (isExtendedData)
305,881✔
151
                                                continue;
6,069✔
152
                                }
299,812✔
153

154
                                if (this._reader.DxfCode != DxfCode.Start)
898,196✔
155
                                        this._reader.ReadNext();
878,652✔
156
                        }
898,196✔
157

158
                        return template;
63,216✔
159
                }
63,216✔
160

161
                private bool readProxyObject(CadTemplate template, DxfMap map)
162
                {
×
163
                        ProxyObject proxy = template.CadObject as ProxyObject;
×
164

165
                        switch (this._reader.Code)
×
166
                        {
167
                                case 90:
168
                                case 94:
169
                                //Undocumented
170
                                case 97:
171
                                case 71:
172
                                        return true;
×
173
                                case 95:
174
                                        int format = this._reader.ValueAsInt;
×
175
                                        proxy.Version = (ACadVersion)(format & 0xFFFF);
×
176
                                        proxy.MaintenanceVersion = (short)(format >> 16);
×
177
                                        return true;
×
178
                                case 91:
179
                                        var classId = this._reader.ValueAsShort;
×
180
                                        if (this._builder.DocumentToBuild.Classes.TryGetByClassNumber(classId, out DxfClass dxfClass))
×
181
                                        {
×
182
                                                proxy.DxfClass = dxfClass;
×
183
                                        }
×
184
                                        return true;
×
185
                                case 161:
186
                                        return true;
×
187
                                case 162:
188
                                        return true;
×
189
                                case 310:
190
                                        if (proxy.BinaryData == null)
×
191
                                        {
×
192
                                                proxy.BinaryData = new MemoryStream();
×
193
                                        }
×
194
                                        proxy.BinaryData.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
195
                                        return true;
×
196
                                case 311:
197
                                        if (proxy.Data == null)
×
198
                                        {
×
199
                                                proxy.Data = new MemoryStream();
×
200
                                        }
×
201
                                        proxy.Data.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
202
                                        return true;
×
203
                                default:
204
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.ProxyObject]);
×
205
                        }
206
                }
×
207

208
                private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
209
                {
27,438✔
210
                        switch (this._reader.Code)
27,438✔
211
                        {
212
                                default:
213
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
27,438✔
214
                        }
215
                }
27,438✔
216

217
                private bool readPlotSettings(CadTemplate template, DxfMap map)
218
                {
29,830✔
219
                        switch (this._reader.Code)
29,830✔
220
                        {
221
                                default:
222
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
29,830✔
223
                        }
224
                }
29,830✔
225

226
                private bool readEvaluationGraph(CadTemplate template, DxfMap map)
227
                {
3,648✔
228
                        CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
3,648✔
229
                        EvaluationGraph evGraph = tmp.CadObject;
3,648✔
230

231
                        switch (this._reader.Code)
3,648✔
232
                        {
233
                                case 91:
234
                                        while (this._reader.Code == 91)
3,572✔
235
                                        {
3,040✔
236
                                                GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
3,040✔
237
                                                EvaluationGraph.Node node = nodeTemplate.Node;
3,040✔
238

239
                                                node.Index = this._reader.ValueAsInt;
3,040✔
240

241
                                                this._reader.ExpectedCode(93);
3,040✔
242
                                                node.Flags = this._reader.ValueAsInt;
3,040✔
243

244
                                                this._reader.ExpectedCode(95);
3,040✔
245
                                                node.NextNodeIndex = this._reader.ValueAsInt;
3,040✔
246

247
                                                this._reader.ExpectedCode(360);
3,040✔
248
                                                nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
3,040✔
249

250
                                                this._reader.ExpectedCode(92);
3,040✔
251
                                                node.Data1 = this._reader.ValueAsInt;
3,040✔
252
                                                this._reader.ExpectedCode(92);
3,040✔
253
                                                node.Data2 = this._reader.ValueAsInt;
3,040✔
254
                                                this._reader.ExpectedCode(92);
3,040✔
255
                                                node.Data3 = this._reader.ValueAsInt;
3,040✔
256
                                                this._reader.ExpectedCode(92);
3,040✔
257
                                                node.Data4 = this._reader.ValueAsInt;
3,040✔
258

259
                                                this._reader.ReadNext();
3,040✔
260

261
                                                tmp.NodeTemplates.Add(nodeTemplate);
3,040✔
262
                                        }
3,040✔
263

264
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
532✔
265
                                case 92:
266
                                        //Edges
267
                                        while (this._reader.Code == 92)
2,508✔
268
                                        {
2,280✔
269
                                                this._reader.ExpectedCode(93);
2,280✔
270
                                                this._reader.ExpectedCode(94);
2,280✔
271
                                                this._reader.ExpectedCode(91);
2,280✔
272
                                                this._reader.ExpectedCode(91);
2,280✔
273
                                                this._reader.ExpectedCode(92);
2,280✔
274
                                                this._reader.ExpectedCode(92);
2,280✔
275
                                                this._reader.ExpectedCode(92);
2,280✔
276
                                                this._reader.ExpectedCode(92);
2,280✔
277
                                                this._reader.ExpectedCode(92);
2,280✔
278

279
                                                this._reader.ReadNext();
2,280✔
280
                                        }
2,280✔
281

282
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
228✔
283
                                default:
284
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
2,888✔
285
                        }
286
                }
3,648✔
287

288
                private bool readLayout(CadTemplate template, DxfMap map)
289
                {
60,712✔
290
                        CadLayoutTemplate tmp = template as CadLayoutTemplate;
60,712✔
291

292
                        switch (this._reader.Code)
60,712✔
293
                        {
294
                                case 330:
295
                                        tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
1,884✔
296
                                        return true;
1,884✔
297
                                case 331:
298
                                        tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
914✔
299
                                        return true;
914✔
300
                                default:
301
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
57,914✔
302
                                        {
29,830✔
303
                                                return this.readPlotSettings(template, map);
29,830✔
304
                                        }
305
                                        return true;
28,084✔
306
                        }
307
                }
60,712✔
308

309
                private bool readGroup(CadTemplate template, DxfMap map)
310
                {
5,928✔
311
                        CadGroupTemplate tmp = template as CadGroupTemplate;
5,928✔
312

313
                        switch (this._reader.Code)
5,928✔
314
                        {
315
                                case 70:
316
                                        return true;
456✔
317
                                case 340:
318
                                        tmp.Handles.Add(this._reader.ValueAsHandle);
2,736✔
319
                                        return true;
2,736✔
320
                                default:
321
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,736✔
322
                        }
323
                }
5,928✔
324

325
                private bool readGeoData(CadTemplate template, DxfMap map)
326
                {
102✔
327
                        CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
328

329
                        switch (this._reader.Code)
102✔
330
                        {
331
                                case 40 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
332
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
333
                                                tmp.CadObject.ReferencePoint.X,
1✔
334
                                                this._reader.ValueAsDouble,
1✔
335
                                                tmp.CadObject.ReferencePoint.Z
1✔
336
                                                );
1✔
337
                                        return true;
1✔
338
                                case 41 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
339
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
340
                                                this._reader.ValueAsDouble,
1✔
341
                                                tmp.CadObject.ReferencePoint.Y,
1✔
342
                                                tmp.CadObject.ReferencePoint.Z
1✔
343
                                                );
1✔
344
                                        return true;
1✔
345
                                case 42 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
346
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
347
                                                tmp.CadObject.ReferencePoint.X,
1✔
348
                                                tmp.CadObject.ReferencePoint.Y,
1✔
349
                                                this._reader.ValueAsDouble
1✔
350
                                                );
1✔
351
                                        return true;
1✔
352
                                case 46 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
353
                                        tmp.CadObject.HorizontalUnitScale = this._reader.ValueAsDouble;
1✔
354
                                        return true;
1✔
355
                                case 52 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
356
                                        double angle = System.Math.PI / 2.0 - this._reader.ValueAsAngle;
1✔
357
                                        tmp.CadObject.NorthDirection = new CSMath.XY(Math.Cos(angle), Math.Sin(angle));
1✔
358
                                        return true;
1✔
359
                                // Number of Geo-Mesh points
360
                                case 93:
361
                                        var npts = this._reader.ValueAsInt;
3✔
362
                                        for (int i = 0; i < npts; i++)
54✔
363
                                        {
24✔
364
                                                this._reader.ReadNext();
24✔
365
                                                double sourceX = this._reader.ValueAsDouble;
24✔
366
                                                this._reader.ReadNext();
24✔
367
                                                double sourceY = this._reader.ValueAsDouble;
24✔
368

369
                                                this._reader.ReadNext();
24✔
370
                                                double destX = this._reader.ValueAsDouble;
24✔
371
                                                this._reader.ReadNext();
24✔
372
                                                double destY = this._reader.ValueAsDouble;
24✔
373

374
                                                tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
24✔
375
                                                {
24✔
376
                                                        Source = new CSMath.XY(sourceX, sourceY),
24✔
377
                                                        Destination = new CSMath.XY(destX, destY)
24✔
378
                                                });
24✔
379
                                        }
24✔
380
                                        return true;
3✔
381
                                // Number of Geo-Mesh points
382
                                case 96:
383
                                        var nfaces = this._reader.ValueAsInt;
2✔
384
                                        for (int i = 0; i < nfaces; i++)
4!
385
                                        {
×
386
                                                this._reader.ReadNext();
×
387
                                                Debug.Assert(this._reader.Code == 97);
×
388
                                                int index1 = this._reader.ValueAsInt;
×
389
                                                this._reader.ReadNext();
×
390
                                                Debug.Assert(this._reader.Code == 98);
×
391
                                                int index2 = this._reader.ValueAsInt;
×
392
                                                this._reader.ReadNext();
×
393
                                                Debug.Assert(this._reader.Code == 99);
×
394
                                                int index3 = this._reader.ValueAsInt;
×
395

396
                                                tmp.CadObject.Faces.Add(new GeoData.GeoMeshFace
×
397
                                                {
×
398
                                                        Index1 = index1,
×
399
                                                        Index2 = index2,
×
400
                                                        Index3 = index3
×
401
                                                });
×
402
                                        }
×
403
                                        return true;
2✔
404
                                case 303:
405
                                        tmp.CadObject.CoordinateSystemDefinition += this._reader.ValueAsString;
13✔
406
                                        return true;
13✔
407
                                //Obsolete codes for version GeoDataVersion.R2009
408
                                case 3:
409
                                case 4:
410
                                case 14:
411
                                case 24:
412
                                case 15:
413
                                case 25:
414
                                case 43:
415
                                case 44:
416
                                case 45:
417
                                case 94:
418
                                case 293:
419
                                case 16:
420
                                case 26:
421
                                case 17:
422
                                case 27:
423
                                case 54:
424
                                case 140:
425
                                case 304:
426
                                case 292:
427
                                        return true;
19✔
428
                                default:
429
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
60✔
430
                        }
431
                }
102✔
432

433
                private bool readScale(CadTemplate template, DxfMap map)
434
                {
69,942✔
435
                        switch (this._reader.Code)
69,942✔
436
                        {
437
                                // Undocumented codes
438
                                case 70:
439
                                        //Always 0
440
                                        return true;
7,794✔
441
                                default:
442
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
62,148✔
443
                        }
444
                }
69,942✔
445

446
                private bool readLinkedData(CadTemplate template, DxfMap map)
447
                {
2,280✔
448
                        switch (this._reader.Code)
2,280✔
449
                        {
450
                                default:
451
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.LinkedData]);
2,280✔
452
                        }
453
                }
2,280✔
454

455
                private bool readTableContent(CadTemplate template, DxfMap map)
456
                {
4,864✔
457
                        switch (this._reader.Code)
4,864✔
458
                        {
459
                                case 90:
460
                                        //Column count
461
                                        return true;
380✔
462
                                case 91:
463
                                        //Row count
464
                                        return true;
380✔
465
                                case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumn, StringComparison.InvariantCultureIgnoreCase):
1,824✔
466
                                        //Read Column
467
                                        this.readTableColumn();
1,444✔
468
                                        return true;
1,444✔
469
                                case 301 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRow, StringComparison.InvariantCultureIgnoreCase):
380✔
470
                                        //Read Row
471
                                        this.readTableRow();
380✔
472
                                        return true;
380✔
473
                                default:
474
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.TableLinkedTableData]))
2,280!
475
                                        {
2,280✔
476
                                                return this.readLinkedData(template, map);
2,280✔
477
                                        }
NEW
478
                                        return true;
×
479
                        }
480
                }
4,864✔
481

482
                private TableEntity.Column readTableColumn()
483
                {
1,444✔
484
                        this._reader.ReadNext();
1,444✔
485

486
                        TableEntity.Column column = new TableEntity.Column();
1,444✔
487

488
                        bool end = false;
1,444✔
489
                        while (this._reader.DxfCode != DxfCode.Start)
4,332!
490
                        {
4,332✔
491
                                switch (this._reader.Code)
4,332!
492
                                {
493
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
4,332✔
494
                                                this.readLinkedTableColumn(column);
1,444✔
495
                                                break;
1,444✔
496
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
2,888✔
497
                                                this.readFormattedTableColumn(column);
1,444✔
498
                                                break;
1,444✔
499
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumnBegin, StringComparison.InvariantCultureIgnoreCase):
1,444!
500
                                                this.readTableColumn(column);
1,444✔
501
                                                end = true;
1,444✔
502
                                                break;
1,444✔
503
                                        default:
NEW
504
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
NEW
505
                                                break;
×
506
                                }
507

508
                                if (end)
4,332✔
509
                                {
1,444✔
510
                                        return column;
1,444✔
511
                                }
512

513
                                this._reader.ReadNext();
2,888✔
514
                        }
2,888✔
515

NEW
516
                        return column;
×
517
                }
1,444✔
518

519
                private TableEntity.Row readTableRow()
520
                {
380✔
521
                        this._reader.ReadNext();
380✔
522

523
                        TableEntity.Row row = new TableEntity.Row();
380✔
524

525
                        bool end = false;
380✔
526
                        while (this._reader.DxfCode != DxfCode.Start)
61,408✔
527
                        {
61,028✔
528
                                switch (this._reader.Code)
61,028✔
529
                                {
530
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
10,488✔
531
                                                this.readLinkedTableRow(row);
1,824✔
532
                                                break;
1,824✔
533
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
8,664✔
534
                                        //break;
535
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRowBegin, StringComparison.InvariantCultureIgnoreCase):
6,992✔
536
                                        //end = true;
537
                                        //break;
538
                                        default:
539
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
59,204✔
540
                                                break;
59,204✔
541
                                }
542

543
                                if (end)
61,028!
NEW
544
                                {
×
NEW
545
                                        return row;
×
546
                                }
547

548
                                this._reader.ReadNext();
61,028✔
549
                        }
61,028✔
550

551
                        return row;
380✔
552
                }
380✔
553

554
                private void readTableColumn(TableEntity.Column column)
555
                {
1,444✔
556
                        this._reader.ReadNext();
1,444✔
557

558
                        bool end = false;
1,444✔
559
                        while (this._reader.DxfCode != DxfCode.Start)
4,332✔
560
                        {
4,332✔
561
                                switch (this._reader.Code)
4,332!
562
                                {
NEW
563
                                        case 1 when this._reader.ValueAsString.Equals("TABLECOLUMN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
NEW
564
                                                break;
×
565
                                        case 1:
NEW
566
                                                end = true;
×
NEW
567
                                                break;
×
568
                                        case 40:
569
                                                column.Width = this._reader.ValueAsDouble;
1,444✔
570
                                                break;
1,444✔
571
                                        case 90:
572
                                                //StyleId
573
                                                break;
1,444✔
574
                                        case 309:
575
                                                end = this._reader.ValueAsString.Equals("TABLECOLUMN_END", StringComparison.InvariantCultureIgnoreCase);
1,444✔
576
                                                break;
1,444✔
577
                                        default:
NEW
578
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
NEW
579
                                                break;
×
580
                                }
581

582
                                if (end)
4,332✔
583
                                {
1,444✔
584
                                        break;
1,444✔
585
                                }
586

587
                                this._reader.ReadNext();
2,888✔
588
                        }
2,888✔
589
                }
1,444✔
590

591
                private void readLinkedTableColumn(TableEntity.Column column)
592
                {
1,444✔
593
                        this._reader.ReadNext();
1,444✔
594

595
                        bool end = false;
1,444✔
596
                        while (this._reader.DxfCode != DxfCode.Start)
5,776✔
597
                        {
5,776✔
598
                                switch (this._reader.Code)
5,776!
599
                                {
NEW
600
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
NEW
601
                                                break;
×
602
                                        case 1:
NEW
603
                                                end = true;
×
NEW
604
                                                break;
×
605
                                        case 91:
606
                                                column.CustomData = this._reader.ValueAsInt;
1,444✔
607
                                                break;
1,444✔
608
                                        case 300:
609
                                                column.Name = this._reader.ValueAsString;
1,444✔
610
                                                break;
1,444✔
611
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,444!
612
                                                this.readCustomData();
1,444✔
613
                                                break;
1,444✔
614
                                        case 309:
615
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,444✔
616
                                                break;
1,444✔
617
                                        default:
NEW
618
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableColumn)} method.", NotificationType.None);
×
NEW
619
                                                break;
×
620
                                }
621

622
                                if (end)
5,776✔
623
                                {
1,444✔
624
                                        break;
1,444✔
625
                                }
626

627
                                this._reader.ReadNext();
4,332✔
628
                        }
4,332✔
629
                }
1,444✔
630

631
                private void readLinkedTableRow(TableEntity.Row column)
632
                {
1,824✔
633
                        this._reader.ReadNext();
1,824✔
634

635
                        bool end = false;
1,824✔
636
                        while (this._reader.DxfCode != DxfCode.Start)
14,972✔
637
                        {
14,820✔
638
                                switch (this._reader.Code)
14,820!
639
                                {
NEW
640
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
✔
NEW
641
                                                break;
×
642
                                        case 90:
643
                                                column.CustomData = this._reader.ValueAsInt;
1,824✔
644
                                                break;
1,824✔
645
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectCell, StringComparison.InvariantCultureIgnoreCase):
6,384✔
646
                                                this.readCell();
6,384✔
647
                                                break;
6,384✔
648
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,672✔
649
                                                this.readCustomData();
1,672✔
650
                                                break;
1,672✔
651
                                        case 309:
652
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_END, StringComparison.InvariantCultureIgnoreCase);
1,672✔
653
                                                break;
1,672✔
654
                                        default:
655
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableRow)} method.", NotificationType.None);
3,268✔
656
                                                break;
3,268✔
657
                                }
658

659
                                if (end)
14,820✔
660
                                {
1,672✔
661
                                        break;
1,672✔
662
                                }
663

664
                                this._reader.ReadNext();
13,148✔
665
                        }
13,148✔
666
                }
1,824✔
667

668
                private TableEntity.Cell readCell()
669
                {
6,384✔
670
                        this._reader.ReadNext();
6,384✔
671

672
                        TableEntity.Cell cell = new TableEntity.Cell();
6,384✔
673

674
                        bool end = false;
6,384✔
675
                        while (this._reader.DxfCode != DxfCode.Start)
20,140✔
676
                        {
19,988✔
677
                                switch (this._reader.Code)
19,988✔
678
                                {
679
                                        case 1 when this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
18,848✔
680
                                                this.readLinkedTableCell(cell);
6,384✔
681
                                                break;
6,384✔
682
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
12,464✔
683
                                                this.readFormattedTableCell(cell);
6,232✔
684
                                                break;
6,232✔
685
                                        case 1 when this._reader.ValueAsString.Equals("TABLECELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
6,232✔
686
                                                this.readTableCell(cell);
6,232✔
687
                                                end = true;
6,232✔
688
                                                break;
6,232✔
689
                                        default:
690
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCell)} method.", NotificationType.None);
1,140✔
691
                                                break;
1,140✔
692
                                }
693

694
                                if (end)
19,988✔
695
                                {
6,232✔
696
                                        return cell;
6,232✔
697
                                }
698

699
                                this._reader.ReadNext();
13,756✔
700
                        }
13,756✔
701

702
                        return cell;
152✔
703
                }
6,384✔
704

705
                private void readTableCell(TableEntity.Cell cell)
706
                {
6,232✔
707
                        var map = DxfClassMap.Create(cell.GetType(), "TABLECELL_BEGIN");
6,232✔
708

709
                        this._reader.ReadNext();
6,232✔
710

711
                        bool end = false;
6,232✔
712
                        while (this._reader.DxfCode != DxfCode.Start)
19,456✔
713
                        {
19,456✔
714
                                switch (this._reader.Code)
19,456✔
715
                                {
716
                                        case 309:
717
                                                end = this._reader.ValueAsString.Equals("TABLECELL_END", StringComparison.InvariantCultureIgnoreCase);
6,232✔
718
                                                break;
6,232✔
719
                                        default:
720
                                                if (!this.tryAssignCurrentValue(cell, map))
13,224✔
721
                                                {
456✔
722
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableCell)} {this._reader.Position}.", NotificationType.None);
456✔
723
                                                }
456✔
724
                                                break;
13,224✔
725
                                }
726

727
                                if (end)
19,456✔
728
                                {
6,232✔
729
                                        break;
6,232✔
730
                                }
731

732
                                this._reader.ReadNext();
13,224✔
733
                        }
13,224✔
734
                }
6,232✔
735

736

737
                private void readFormattedTableCell(TableEntity.Cell cell)
738
                {
6,232✔
739
                        var map = DxfClassMap.Create(cell.GetType(), "FORMATTEDTABLEDATACELL_BEGIN");
6,232✔
740

741
                        this._reader.ReadNext();
6,232✔
742

743
                        bool end = false;
6,232✔
744
                        while (this._reader.DxfCode != DxfCode.Start)
12,464✔
745
                        {
12,464✔
746
                                switch (this._reader.Code)
12,464!
747
                                {
748
                                        case 300 when this._reader.ValueAsString.Equals("CELLTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
6,232!
749
                                                this.readCellTableFormat(cell);
6,232✔
750
                                                continue;
6,232✔
751
                                        case 309:
752
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
6,232✔
753
                                                break;
6,232✔
754
                                        default:
NEW
755
                                                if (!this.tryAssignCurrentValue(cell, map))
×
NEW
756
                                                {
×
NEW
757
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableCell)} {this._reader.Position}.", NotificationType.None);
×
NEW
758
                                                }
×
NEW
759
                                                break;
×
760
                                }
761

762
                                if (end)
6,232!
763
                                {
6,232✔
764
                                        break;
6,232✔
765
                                }
766

NEW
767
                                this._reader.ReadNext();
×
NEW
768
                        }
×
769
                }
6,232✔
770

771
                private void readCellTableFormat(TableEntity.Cell cell)
772
                {
6,232✔
773
                        var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
6,232✔
774

775
                        this._reader.ReadNext();
6,232✔
776

777
                        bool end = false;
6,232✔
778
                        while (this._reader.Code == 1)
12,464✔
779
                        {
6,232✔
780
                                switch (this._reader.Code)
6,232!
781
                                {
782
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
6,232!
783
                                                this.readStyleOverride(cell.StyleOverride);
6,232✔
784
                                                break;
6,232✔
NEW
785
                                        case 1 when this._reader.ValueAsString.Equals("CELLSTYLE_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
NEW
786
                                                this.readCellStyle(new CadCellStyleTemplate());
×
NEW
787
                                                break;
×
788
                                        default:
NEW
789
                                                if (!this.tryAssignCurrentValue(cell, map))
×
NEW
790
                                                {
×
NEW
791
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellTableFormat)} {this._reader.Position}.", NotificationType.None);
×
NEW
792
                                                }
×
NEW
793
                                                break;
×
794
                                }
795

796
                                if (end)
6,232!
NEW
797
                                {
×
NEW
798
                                        break;
×
799
                                }
800

801
                                this._reader.ReadNext();
6,232✔
802
                        }
6,232✔
803
                }
6,232✔
804

805
                private void readCellStyle(CadCellStyleTemplate template)
NEW
806
                {
×
807
                        //var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
808

NEW
809
                        this._reader.ReadNext();
×
810

NEW
811
                        bool end = false;
×
NEW
812
                        while (this._reader.Code != 1)
×
NEW
813
                        {
×
NEW
814
                                switch (this._reader.Code)
×
815
                                {
816
                                        case 309:
NEW
817
                                                end = this._reader.ValueAsString.Equals("CELLSTYLE_END", StringComparison.InvariantCultureIgnoreCase);
×
NEW
818
                                                break;
×
819
                                        default:
820
                                                //if (!this.tryAssignCurrentValue(cell, map))
NEW
821
                                                {
×
NEW
822
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellStyle)} {this._reader.Position}.", NotificationType.None);
×
NEW
823
                                                }
×
NEW
824
                                                break;
×
825
                                }
826

NEW
827
                                if (end)
×
NEW
828
                                {
×
NEW
829
                                        break;
×
830
                                }
831

NEW
832
                                this._reader.ReadNext();
×
NEW
833
                        }
×
NEW
834
                }
×
835

836
                private void readLinkedTableCell(TableEntity.Cell cell)
837
                {
6,384✔
838
                        var map = DxfClassMap.Create(cell.GetType(), "LINKEDTABLEDATACELL_BEGIN");
6,384✔
839

840
                        this._reader.ReadNext();
6,384✔
841

842
                        bool end = false;
6,384✔
843
                        while (this._reader.DxfCode != DxfCode.Start)
63,992✔
844
                        {
63,840✔
845
                                switch (this._reader.Code)
63,840✔
846
                                {
847
                                        case 95:
848
                                                //BL 95 Number of cell contents
849
                                                break;
6,232✔
850
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
6,384✔
851
                                                this.readCustomData();
6,384✔
852
                                                break;
6,384✔
853
                                        case 302 when this._reader.ValueAsString.Equals("CONTENT", StringComparison.InvariantCultureIgnoreCase):
4,864✔
854
                                                this.readLinkedTableCellContent();
4,864✔
855
                                                break;
4,864✔
856
                                        case 309:
857
                                                end = this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
6,232✔
858
                                                break;
6,232✔
859
                                        default:
860
                                                if (!this.tryAssignCurrentValue(cell, map))
40,128✔
861
                                                {
13,832✔
862
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCell)} {this._reader.Position}.", NotificationType.None);
13,832✔
863
                                                }
13,832✔
864
                                                break;
40,128✔
865
                                }
866

867
                                if (end)
63,840✔
868
                                {
6,232✔
869
                                        break;
6,232✔
870
                                }
871

872
                                this._reader.ReadNext();
57,608✔
873
                        }
57,608✔
874
                }
6,384✔
875

876
                private void readLinkedTableCellContent()
877
                {
4,864✔
878
                        TableEntity.CellContent content = new TableEntity.CellContent();
4,864✔
879
                        var map = DxfClassMap.Create(content.GetType(), "CONTENT");
4,864✔
880

881
                        this._reader.ReadNext();
4,864✔
882

883
                        bool end = false;
4,864✔
884
                        while (this._reader.DxfCode != DxfCode.Start)
9,728✔
885
                        {
9,728✔
886
                                switch (this._reader.Code)
9,728!
887
                                {
888
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
9,728✔
889
                                                readFormattedCellContent();
4,864✔
890
                                                end = true;
4,864✔
891
                                                break;
4,864✔
892
                                        case 1 when this._reader.ValueAsString.Equals("CELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
4,864!
893
                                                readCellContent();
4,864✔
894
                                                break;
4,864✔
895
                                        default:
NEW
896
                                                if (!this.tryAssignCurrentValue(content, map))
×
NEW
897
                                                {
×
NEW
898
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCellContent)} {this._reader.Position}.", NotificationType.None);
×
NEW
899
                                                }
×
NEW
900
                                                break;
×
901
                                }
902

903
                                if (end)
9,728✔
904
                                {
4,864✔
905
                                        break;
4,864✔
906
                                }
907

908
                                this._reader.ReadNext();
4,864✔
909
                        }
4,864✔
910
                }
4,864✔
911

912
                private void readCellContent()
913
                {
4,864✔
914
                        TableEntity.CellContent content = new TableEntity.CellContent();
4,864✔
915
                        var map = DxfClassMap.Create(content.GetType(), "CELLCONTENT_BEGIN");
4,864✔
916

917
                        this._reader.ReadNext();
4,864✔
918

919
                        bool end = false;
4,864✔
920
                        while (this._reader.DxfCode != DxfCode.Start)
19,456✔
921
                        {
19,456✔
922
                                switch (this._reader.Code)
19,456✔
923
                                {
924
                                        case 91:
925
                                                break;
4,864✔
926
                                        case 300 when this._reader.ValueAsString.Equals("VALUE", StringComparison.InvariantCultureIgnoreCase):
4,408✔
927
                                                this.readDataMapValue();
4,408✔
928
                                                break;
4,408✔
929
                                        case 309:
930
                                                end = this._reader.ValueAsString.Equals("CELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,864✔
931
                                                break;
4,864✔
932
                                        default:
933
                                                if (!this.tryAssignCurrentValue(content, map))
5,320✔
934
                                                {
456✔
935
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellContent)} {this._reader.Position}.", NotificationType.None);
456✔
936
                                                }
456✔
937
                                                break;
5,320✔
938
                                }
939

940
                                if (end)
19,456✔
941
                                {
4,864✔
942
                                        break;
4,864✔
943
                                }
944

945
                                this._reader.ReadNext();
14,592✔
946
                        }
14,592✔
947
                }
4,864✔
948

949
                private void readFormattedCellContent()
950
                {
4,864✔
951
                        TableEntity.ContentFormat format = new();
4,864✔
952
                        CadTableCellContentFormatTemplate template = new CadTableCellContentFormatTemplate(format);
4,864✔
953
                        var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
4,864✔
954

955
                        this._reader.ReadNext();
4,864✔
956

957
                        bool end = false;
4,864✔
958
                        while (this._reader.DxfCode != DxfCode.Start)
14,592✔
959
                        {
14,592✔
960
                                switch (this._reader.Code)
14,592✔
961
                                {
962
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
4,864✔
963
                                                readContentFormat(template);
4,864✔
964
                                                break;
4,864✔
965
                                        case 309:
966
                                                end = this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,864✔
967
                                                break;
4,864✔
968
                                        default:
969
                                                if (!this.tryAssignCurrentValue(format, map))
4,864!
NEW
970
                                                {
×
NEW
971
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedCellContent)} method.", NotificationType.None);
×
NEW
972
                                                }
×
973
                                                break;
4,864✔
974
                                }
975

976
                                if (end)
14,592✔
977
                                {
4,864✔
978
                                        break;
4,864✔
979
                                }
980

981
                                this._reader.ReadNext();
9,728✔
982
                        }
9,728✔
983
                }
4,864✔
984

985
                private void readContentFormat(CadTableCellContentFormatTemplate template)
986
                {
10,184✔
987
                        var format = template.Format;
10,184✔
988
                        var map = DxfClassMap.Create(format.GetType(), "CONTENTFORMAT_BEGIN");
10,184✔
989

990
                        this._reader.ReadNext();
10,184✔
991

992
                        bool end = false;
10,184✔
993
                        while (this._reader.DxfCode != DxfCode.Start)
132,392✔
994
                        {
132,392✔
995
                                switch (this._reader.Code)
132,392✔
996
                                {
997
                                        case 1 when this._reader.ValueAsString.Equals("CONTENTFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
10,184✔
998
                                                break;
10,184✔
999
                                        case 309:
1000
                                                end = this._reader.ValueAsString.Equals("CONTENTFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
10,184✔
1001
                                                break;
10,184✔
1002
                                        case 340:
1003
                                                template.TextStyleHandle = this._reader.ValueAsHandle;
10,184✔
1004
                                                break;
10,184✔
1005
                                        default:
1006
                                                if (!this.tryAssignCurrentValue(format, map))
101,840!
NEW
1007
                                                {
×
NEW
1008
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readContentFormat)} method.", NotificationType.None);
×
NEW
1009
                                                }
×
1010
                                                break;
101,840✔
1011
                                }
1012

1013
                                if (end)
132,392✔
1014
                                {
10,184✔
1015
                                        break;
10,184✔
1016
                                }
1017

1018
                                this._reader.ReadNext();
122,208✔
1019
                        }
122,208✔
1020
                }
10,184✔
1021

1022
                private void readFormattedTableColumn(TableEntity.Column column)
1023
                {
1,444✔
1024
                        this._reader.ReadNext();
1,444✔
1025

1026
                        bool end = false;
1,444✔
1027
                        while (this._reader.DxfCode != DxfCode.Start)
4,332✔
1028
                        {
4,332✔
1029
                                switch (this._reader.Code)
4,332!
1030
                                {
1031
                                        case 300 when this._reader.ValueAsString.Equals("COLUMNTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,444!
1032
                                                break;
1,444✔
1033
                                        case 300:
NEW
1034
                                                end = true;
×
NEW
1035
                                                break;
×
1036
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,444!
1037
                                                this.readStyleOverride(column.StyleOverride);
1,444✔
1038
                                                break;
1,444✔
1039
                                        case 309:
1040
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,444✔
1041
                                                break;
1,444✔
1042
                                        default:
NEW
1043
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableColumn)} method.", NotificationType.None);
×
NEW
1044
                                                break;
×
1045
                                }
1046

1047
                                if (end)
4,332✔
1048
                                {
1,444✔
1049
                                        break;
1,444✔
1050
                                }
1051

1052
                                this._reader.ReadNext();
2,888✔
1053
                        }
2,888✔
1054
                }
1,444✔
1055

1056
                private void readStyleOverride(TableEntity.CellStyle style)
1057
                {
7,676✔
1058
                        this._reader.ReadNext();
7,676✔
1059

1060
                        bool end = false;
7,676✔
1061
                        while (this._reader.DxfCode != DxfCode.Start)
91,428✔
1062
                        {
91,428✔
1063
                                switch (this._reader.Code)
91,428!
1064
                                {
NEW
1065
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
NEW
1066
                                                break;
×
1067
                                        case 1:
NEW
1068
                                                end = true;
×
NEW
1069
                                                break;
×
1070
                                        case 90:
1071
                                                style.Type = (TableEntity.CellStyleTypeType)this._reader.ValueAsInt;
7,676✔
1072
                                                break;
7,676✔
1073
                                        case 170:
1074
                                                //Has data
1075
                                                break;
7,676✔
1076
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,320✔
1077
                                                readContentFormat(new CadTableCellContentFormatTemplate(new TableEntity.ContentFormat()));
5,320✔
1078
                                                break;
5,320✔
1079
                                        case 301 when this._reader.ValueAsString.Equals("MARGIN", StringComparison.InvariantCultureIgnoreCase):
3,192✔
1080
                                                this.readCellMargin();
3,192✔
1081
                                                break;
3,192✔
1082
                                        case 302 when this._reader.ValueAsString.Equals("GRIDFORMAT", StringComparison.InvariantCultureIgnoreCase):
13,984✔
1083
                                                this.readGridFormat();
13,984✔
1084
                                                break;
13,984✔
1085
                                        case 309:
1086
                                                end = this._reader.ValueAsString.Equals("TABLEFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
7,676✔
1087
                                                break;
7,676✔
1088
                                        default:
1089
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readStyleOverride)} method.", NotificationType.None);
45,904✔
1090
                                                break;
45,904✔
1091
                                }
1092

1093
                                if (end)
91,428✔
1094
                                {
7,676✔
1095
                                        break;
7,676✔
1096
                                }
1097

1098
                                this._reader.ReadNext();
83,752✔
1099
                        }
83,752✔
1100
                }
7,676✔
1101

1102
                private void readGridFormat()
1103
                {
13,984✔
1104
                        this._reader.ReadNext();
13,984✔
1105

1106
                        bool end = false;
13,984✔
1107
                        while (this._reader.DxfCode != DxfCode.Start)
125,856✔
1108
                        {
125,856✔
1109
                                switch (this._reader.Code)
125,856✔
1110
                                {
1111
                                        case 1 when this._reader.ValueAsString.Equals("GRIDFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
13,984✔
1112
                                                break;
13,984✔
1113
                                        case 309:
1114
                                                end = this._reader.ValueAsString.Equals("GRIDFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
13,984✔
1115
                                                break;
13,984✔
1116
                                        default:
1117
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readGridFormat)} method.", NotificationType.None);
97,888✔
1118
                                                break;
97,888✔
1119
                                }
1120

1121
                                if (end)
125,856✔
1122
                                {
13,984✔
1123
                                        break;
13,984✔
1124
                                }
1125

1126
                                this._reader.ReadNext();
111,872✔
1127
                        }
111,872✔
1128
                }
13,984✔
1129

1130
                private void readCellMargin()
1131
                {
3,192✔
1132
                        this._reader.ReadNext();
3,192✔
1133

1134
                        bool end = false;
3,192✔
1135
                        while (this._reader.DxfCode != DxfCode.Start)
25,536✔
1136
                        {
25,536✔
1137
                                switch (this._reader.Code)
25,536✔
1138
                                {
1139
                                        case 1 when this._reader.ValueAsString.Equals("CELLMARGIN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
3,192✔
1140
                                                break;
3,192✔
1141
                                        case 309:
1142
                                                end = this._reader.ValueAsString.Equals("CELLMARGIN_END", StringComparison.InvariantCultureIgnoreCase);
3,192✔
1143
                                                break;
3,192✔
1144
                                        default:
1145
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellMargin)} method.", NotificationType.None);
19,152✔
1146
                                                break;
19,152✔
1147
                                }
1148

1149
                                if (end)
25,536✔
1150
                                {
3,192✔
1151
                                        break;
3,192✔
1152
                                }
1153

1154
                                this._reader.ReadNext();
22,344✔
1155
                        }
22,344✔
1156
                }
3,192✔
1157

1158
                private void readCustomData()
1159
                {
9,500✔
1160
                        this._reader.ReadNext();
9,500✔
1161

1162
                        int ndata = 0;
9,500✔
1163
                        bool end = false;
9,500✔
1164
                        while (this._reader.DxfCode != DxfCode.Start)
88,388✔
1165
                        {
88,236✔
1166
                                switch (this._reader.Code)
88,236✔
1167
                                {
1168
                                        case 1 when this._reader.ValueAsString.Equals("DATAMAP_BEGIN", StringComparison.InvariantCultureIgnoreCase):
9,500!
1169
                                                break;
9,500✔
1170
                                        case 1:
NEW
1171
                                                end = true;
×
NEW
1172
                                                break;
×
1173
                                        case 90:
1174
                                                ndata = this._reader.ValueAsInt;
9,652✔
1175
                                                break;
9,652✔
1176
                                        case 300:
1177
                                                //Name
1178
                                                break;
6,232✔
1179
                                        case 301 when this._reader.ValueAsString.Equals("DATAMAP_VALUE", StringComparison.InvariantCultureIgnoreCase):
6,232✔
1180
                                                this.readDataMapValue();
6,232✔
1181
                                                break;
6,232✔
1182
                                        case 309:
1183
                                                end = this._reader.ValueAsString.Equals("DATAMAP_END", StringComparison.InvariantCultureIgnoreCase);
9,348✔
1184
                                                break;
9,348✔
1185
                                        default:
1186
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCustomData)} method.", NotificationType.None);
47,272✔
1187
                                                break;
47,272✔
1188
                                }
1189

1190
                                if (end)
88,236✔
1191
                                {
9,348✔
1192
                                        break;
9,348✔
1193
                                }
1194

1195
                                this._reader.ReadNext();
78,888✔
1196
                        }
78,888✔
1197
                }
9,500✔
1198

1199
                private void readDataMapValue()
1200
                {
10,640✔
1201
                        TableEntity.CellValue value = new TableEntity.CellValue();
10,640✔
1202
                        var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
10,640✔
1203

1204
                        this._reader.ReadNext();
10,640✔
1205

1206
                        bool end = false;
10,640✔
1207
                        while (this._reader.DxfCode != DxfCode.Start)
392,160✔
1208
                        {
392,008✔
1209
                                switch (this._reader.Code)
392,008✔
1210
                                {
1211
                                        case 140:
1212
                                                break;
15,732✔
1213
                                        case 304:
1214
                                                end = this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.InvariantCultureIgnoreCase);
10,488✔
1215
                                                break;
10,488✔
1216
                                        default:
1217
                                                if (!this.tryAssignCurrentValue(value, map))
365,788✔
1218
                                                {
174,344✔
1219
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readDataMapValue)} method.", NotificationType.None);
174,344✔
1220
                                                }
174,344✔
1221
                                                break;
365,788✔
1222
                                }
1223

1224
                                if (end)
392,008✔
1225
                                {
10,488✔
1226
                                        break;
10,488✔
1227
                                }
1228

1229
                                this._reader.ReadNext();
381,520✔
1230
                        }
381,520✔
1231
                }
10,640✔
1232

1233
                private bool readVisualStyle(CadTemplate template, DxfMap map)
1234
                {
411,192✔
1235
                        switch (this._reader.Code)
411,192✔
1236
                        {
1237
                                // Undocumented codes
1238
                                case 176:
1239
                                case 177:
1240
                                case 420:
1241
                                        return true;
141,178✔
1242
                                default:
1243
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
270,014✔
1244
                        }
1245
                }
411,192✔
1246

1247
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
1248
                {
4,788✔
1249
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,788✔
1250
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,788✔
1251

1252
                        switch (this._reader.Code)
4,788✔
1253
                        {
1254
                                case 10:
1255
                                        filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
456✔
1256
                                        return true;
456✔
1257
                                case 20:
1258
                                        var pt = filter.BoundaryPoints.LastOrDefault();
456✔
1259
                                        filter.BoundaryPoints.Add(new CSMath.XY(pt.X, this._reader.ValueAsDouble));
456✔
1260
                                        return true;
456✔
1261
                                case 40:
1262
                                        if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
456!
1263
                                        {
×
1264
                                                filter.FrontDistance = this._reader.ValueAsDouble;
×
1265
                                                tmp.HasFrontPlane = true;
×
1266
                                        }
×
1267

1268
                                        double[] array = new double[16]
456✔
1269
                                        {
456✔
1270
                                                0.0, 0.0, 0.0, 0.0,
456✔
1271
                                                0.0, 0.0, 0.0, 0.0,
456✔
1272
                                                0.0, 0.0, 0.0, 0.0,
456✔
1273
                                                0.0, 0.0, 0.0, 1.0
456✔
1274
                                        };
456✔
1275

1276
                                        for (int i = 0; i < 12; i++)
11,856✔
1277
                                        {
5,472✔
1278
                                                array[i] = this._reader.ValueAsDouble;
5,472✔
1279

1280
                                                if (i < 11)
5,472✔
1281
                                                {
5,016✔
1282
                                                        this._reader.ReadNext();
5,016✔
1283
                                                }
5,016✔
1284
                                        }
5,472✔
1285

1286
                                        if (tmp.InsertTransformRead)
456!
1287
                                        {
×
1288
                                                filter.InsertTransform = new Matrix4(array);
×
1289
                                                tmp.InsertTransformRead = true;
×
1290
                                        }
×
1291
                                        else
1292
                                        {
456✔
1293
                                                filter.InverseInsertTransform = new Matrix4(array);
456✔
1294
                                        }
456✔
1295

1296
                                        return true;
456✔
1297
                                case 73:
1298
                                default:
1299
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
3,420✔
1300
                        }
1301
                }
4,788✔
1302

1303
                private bool readMLeaderStyle(CadTemplate template, DxfMap map)
1304
                {
21,648✔
1305
                        var tmp = template as CadMLeaderStyleTemplate;
21,648✔
1306

1307
                        switch (this._reader.Code)
21,648✔
1308
                        {
1309
                                case 179:
1310
                                        return true;
242✔
1311
                                case 340:
1312
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
472✔
1313
                                        return true;
472✔
1314
                                case 342:
1315
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
472✔
1316
                                        return true;
472✔
1317
                                default:
1318
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
20,462✔
1319
                        }
1320
                }
21,648✔
1321

1322
                private bool readXRecord(CadTemplate template, DxfMap map)
1323
                {
71,640✔
1324
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
71,640✔
1325

1326
                        switch (this._reader.Code)
71,640✔
1327
                        {
1328
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
18,632✔
1329
                                        this.readXRecordEntries(tmp);
18,632✔
1330
                                        return true;
18,632✔
1331
                                default:
1332
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
53,008✔
1333
                        }
1334
                }
71,640✔
1335

1336
                private void readXRecordEntries(CadXRecordTemplate template)
1337
                {
18,632✔
1338
                        this._reader.ReadNext();
18,632✔
1339

1340
                        while (this._reader.DxfCode != DxfCode.Start)
993,532✔
1341
                        {
974,900✔
1342
                                switch (this._reader.GroupCodeValue)
974,900!
1343
                                {
1344
                                        case GroupCodeValueType.Handle:
1345
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
×
1346
                                                break;
×
1347
                                        default:
1348
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
974,900✔
1349
                                                break;
974,900✔
1350
                                }
1351

1352
                                this._reader.ReadNext();
974,900✔
1353
                        }
974,900✔
1354
                }
18,632✔
1355

1356
                private bool readBookColor(CadTemplate template, DxfMap map)
1357
                {
1,634✔
1358
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,634✔
1359
                        BookColor color = tmp.CadObject as BookColor;
1,634✔
1360

1361
                        switch (this._reader.Code)
1,634✔
1362
                        {
1363
                                case 430:
1364
                                        color.Name = this._reader.ValueAsString;
190✔
1365
                                        return true;
190✔
1366
                                default:
1367
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,444✔
1368
                        }
1369
                }
1,634✔
1370

1371
                private bool readDictionary(CadTemplate template, DxfMap map)
1372
                {
220,727✔
1373
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
220,727✔
1374
                        CadDictionary cadDictionary = tmp.CadObject;
220,727✔
1375

1376
                        switch (this._reader.Code)
220,727✔
1377
                        {
1378
                                case 280:
1379
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
16,007✔
1380
                                        return true;
16,007✔
1381
                                case 281:
1382
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
23,606✔
1383
                                        return true;
23,606✔
1384
                                case 3:
1385
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
50,227✔
1386
                                        return true;
50,227✔
1387
                                case 350: // Soft-owner ID/handle to entry object 
1388
                                case 360: // Hard-owner ID/handle to entry object
1389
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
50,227✔
1390
                                        return true;
50,227✔
1391
                                default:
1392
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
80,660✔
1393
                        }
1394
                }
220,727✔
1395

1396
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
1397
                {
2,070✔
1398
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
2,070✔
1399

1400
                        switch (this._reader.Code)
2,070✔
1401
                        {
1402
                                case 340:
1403
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
230✔
1404
                                        return true;
230✔
1405
                                default:
1406
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,840!
1407
                                        {
1,840✔
1408
                                                return this.readDictionary(template, map);
1,840✔
1409
                                        }
1410
                                        return true;
×
1411
                        }
1412
                }
2,070✔
1413

1414
                private CadTemplate readSortentsTable()
1415
                {
684✔
1416
                        SortEntitiesTable sortTable = new SortEntitiesTable();
684✔
1417
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
684✔
1418

1419
                        //Jump the 0 marker
1420
                        this._reader.ReadNext();
684✔
1421

1422
                        this.readCommonObjectData(template);
684✔
1423

1424
                        System.Diagnostics.Debug.Assert(DxfSubclassMarker.SortentsTable == this._reader.ValueAsString);
684✔
1425

1426
                        //Jump the 100 marker
1427
                        this._reader.ReadNext();
684✔
1428

1429
                        (ulong?, ulong?) pair = (null, null);
684✔
1430

1431
                        while (this._reader.DxfCode != DxfCode.Start)
5,016✔
1432
                        {
4,332✔
1433
                                switch (this._reader.Code)
4,332!
1434
                                {
1435
                                        case 5:
1436
                                                pair.Item1 = this._reader.ValueAsHandle;
1,824✔
1437
                                                break;
1,824✔
1438
                                        case 330:
1439
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
684✔
1440
                                                break;
684✔
1441
                                        case 331:
1442
                                                pair.Item2 = this._reader.ValueAsHandle;
1,824✔
1443
                                                break;
1,824✔
1444
                                        default:
1445
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
1446
                                                break;
×
1447
                                }
1448

1449
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
4,332✔
1450
                                {
1,824✔
1451
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,824✔
1452
                                        pair = (null, null);
1,824✔
1453
                                }
1,824✔
1454

1455
                                this._reader.ReadNext();
4,332✔
1456
                        }
4,332✔
1457

1458
                        return template;
684✔
1459
                }
684✔
1460
        }
1461
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc