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

DomCR / ACadSharp / 18801076916

25 Oct 2025 09:09AM UTC coverage: 78.088% (+0.2%) from 77.923%
18801076916

Pull #831

github

web-flow
Merge 05a04f21c into f84cb1d2a
Pull Request #831: Table entity refactor

7312 of 10151 branches covered (72.03%)

Branch coverage included in aggregate %.

713 of 839 new or added lines in 16 files covered. (84.98%)

4 existing lines in 3 files now uncovered.

27310 of 34186 relevant lines covered (79.89%)

107263.27 hits per line

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

84.68
/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,152✔
32
                        {
71,910✔
33
                                CadTemplate template = null;
71,910✔
34

35
                                try
36
                                {
71,910✔
37
                                        template = this.readObject();
71,910✔
38
                                }
71,910✔
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,910✔
51
                                        continue;
242✔
52

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

58
                private CadTemplate readObject()
59
                {
71,910✔
60
                        switch (this._reader.ValueAsString)
71,910!
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,300✔
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,910✔
137

138
                private bool _notMove = false;
242✔
139

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

145
                        DxfMap map = DxfMap.Create<T>();
63,140✔
146

147
                        while (this._reader.DxfCode != DxfCode.Start)
964,441✔
148
                        {
901,301✔
149
                                if (!readObject(template, map))
901,301✔
150
                                {
305,501✔
151
                                        this.readCommonCodes(template, out bool isExtendedData, map);
305,501✔
152
                                        if (isExtendedData)
305,501✔
153
                                                continue;
6,069✔
154
                                }
299,432✔
155

156
                                if (this._notMove)
895,232✔
157
                                {
1,368✔
158
                                        this._notMove = false;
1,368✔
159
                                        continue;
1,368✔
160
                                }
161

162
                                if (this._reader.DxfCode != DxfCode.Start)
893,864✔
163
                                {
874,700✔
164
                                        this._reader.ReadNext();
874,700✔
165
                                }
874,700✔
166
                        }
893,864✔
167

168
                        return template;
63,140✔
169
                }
63,140✔
170

171
                private bool readProxyObject(CadTemplate template, DxfMap map)
172
                {
×
173
                        ProxyObject proxy = template.CadObject as ProxyObject;
×
174

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

218
                private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
219
                {
27,438✔
220
                        switch (this._reader.Code)
27,438✔
221
                        {
222
                                default:
223
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
27,438✔
224
                        }
225
                }
27,438✔
226

227
                private bool readPlotSettings(CadTemplate template, DxfMap map)
228
                {
29,830✔
229
                        switch (this._reader.Code)
29,830✔
230
                        {
231
                                default:
232
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
29,830✔
233
                        }
234
                }
29,830✔
235

236
                private bool readEvaluationGraph(CadTemplate template, DxfMap map)
237
                {
3,648✔
238
                        CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
3,648✔
239
                        EvaluationGraph evGraph = tmp.CadObject;
3,648✔
240

241
                        switch (this._reader.Code)
3,648✔
242
                        {
243
                                case 91:
244
                                        while (this._reader.Code == 91)
3,572✔
245
                                        {
3,040✔
246
                                                GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
3,040✔
247
                                                EvaluationGraph.Node node = nodeTemplate.Node;
3,040✔
248

249
                                                node.Index = this._reader.ValueAsInt;
3,040✔
250

251
                                                this._reader.ExpectedCode(93);
3,040✔
252
                                                node.Flags = this._reader.ValueAsInt;
3,040✔
253

254
                                                this._reader.ExpectedCode(95);
3,040✔
255
                                                node.NextNodeIndex = this._reader.ValueAsInt;
3,040✔
256

257
                                                this._reader.ExpectedCode(360);
3,040✔
258
                                                nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
3,040✔
259

260
                                                this._reader.ExpectedCode(92);
3,040✔
261
                                                node.Data1 = this._reader.ValueAsInt;
3,040✔
262
                                                this._reader.ExpectedCode(92);
3,040✔
263
                                                node.Data2 = this._reader.ValueAsInt;
3,040✔
264
                                                this._reader.ExpectedCode(92);
3,040✔
265
                                                node.Data3 = this._reader.ValueAsInt;
3,040✔
266
                                                this._reader.ExpectedCode(92);
3,040✔
267
                                                node.Data4 = this._reader.ValueAsInt;
3,040✔
268

269
                                                this._reader.ReadNext();
3,040✔
270

271
                                                tmp.NodeTemplates.Add(nodeTemplate);
3,040✔
272
                                        }
3,040✔
273

274
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
532✔
275
                                case 92:
276
                                        //Edges
277
                                        while (this._reader.Code == 92)
2,508✔
278
                                        {
2,280✔
279
                                                this._reader.ExpectedCode(93);
2,280✔
280
                                                this._reader.ExpectedCode(94);
2,280✔
281
                                                this._reader.ExpectedCode(91);
2,280✔
282
                                                this._reader.ExpectedCode(91);
2,280✔
283
                                                this._reader.ExpectedCode(92);
2,280✔
284
                                                this._reader.ExpectedCode(92);
2,280✔
285
                                                this._reader.ExpectedCode(92);
2,280✔
286
                                                this._reader.ExpectedCode(92);
2,280✔
287
                                                this._reader.ExpectedCode(92);
2,280✔
288

289
                                                this._reader.ReadNext();
2,280✔
290
                                        }
2,280✔
291

292
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
228✔
293
                                default:
294
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
2,888✔
295
                        }
296
                }
3,648✔
297

298
                private bool readLayout(CadTemplate template, DxfMap map)
299
                {
60,712✔
300
                        CadLayoutTemplate tmp = template as CadLayoutTemplate;
60,712✔
301

302
                        switch (this._reader.Code)
60,712✔
303
                        {
304
                                case 330:
305
                                        tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
1,884✔
306
                                        return true;
1,884✔
307
                                case 331:
308
                                        tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
914✔
309
                                        return true;
914✔
310
                                default:
311
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
57,914✔
312
                                        {
29,830✔
313
                                                return this.readPlotSettings(template, map);
29,830✔
314
                                        }
315
                                        return true;
28,084✔
316
                        }
317
                }
60,712✔
318

319
                private bool readGroup(CadTemplate template, DxfMap map)
320
                {
5,928✔
321
                        CadGroupTemplate tmp = template as CadGroupTemplate;
5,928✔
322

323
                        switch (this._reader.Code)
5,928✔
324
                        {
325
                                case 70:
326
                                        return true;
456✔
327
                                case 340:
328
                                        tmp.Handles.Add(this._reader.ValueAsHandle);
2,736✔
329
                                        return true;
2,736✔
330
                                default:
331
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,736✔
332
                        }
333
                }
5,928✔
334

335
                private bool readGeoData(CadTemplate template, DxfMap map)
336
                {
102✔
337
                        CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
338

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

379
                                                this._reader.ReadNext();
24✔
380
                                                double destX = this._reader.ValueAsDouble;
24✔
381
                                                this._reader.ReadNext();
24✔
382
                                                double destY = this._reader.ValueAsDouble;
24✔
383

384
                                                tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
24✔
385
                                                {
24✔
386
                                                        Source = new CSMath.XY(sourceX, sourceY),
24✔
387
                                                        Destination = new CSMath.XY(destX, destY)
24✔
388
                                                });
24✔
389
                                        }
24✔
390
                                        return true;
3✔
391
                                // Number of Geo-Mesh points
392
                                case 96:
393
                                        var nfaces = this._reader.ValueAsInt;
2✔
394
                                        for (int i = 0; i < nfaces; i++)
4!
395
                                        {
×
396
                                                this._reader.ReadNext();
×
397
                                                Debug.Assert(this._reader.Code == 97);
×
398
                                                int index1 = this._reader.ValueAsInt;
×
399
                                                this._reader.ReadNext();
×
400
                                                Debug.Assert(this._reader.Code == 98);
×
401
                                                int index2 = this._reader.ValueAsInt;
×
402
                                                this._reader.ReadNext();
×
403
                                                Debug.Assert(this._reader.Code == 99);
×
404
                                                int index3 = this._reader.ValueAsInt;
×
405

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

443
                private bool readScale(CadTemplate template, DxfMap map)
444
                {
69,942✔
445
                        switch (this._reader.Code)
69,942✔
446
                        {
447
                                // Undocumented codes
448
                                case 70:
449
                                        //Always 0
450
                                        return true;
7,794✔
451
                                default:
452
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
62,148✔
453
                        }
454
                }
69,942✔
455

456
                private void readLinkedData(CadTemplate template, DxfMap map)
457
                {
380✔
458
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
380✔
459
                        LinkedData linkedData = tmp.CadObject;
380✔
460

461
                        this._reader.ReadNext();
380✔
462

463
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
1,140!
464
                        {
760✔
465
                                switch (this._reader.Code)
760✔
466
                                {
467
                                        default:
468
                                                if (!this.tryAssignCurrentValue(linkedData, map.SubClasses[DxfSubclassMarker.LinkedData]))
760!
NEW
469
                                                {
×
NEW
470
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedData)} {this._reader.Position}.", NotificationType.None);
×
NEW
471
                                                }
×
472
                                                break;
760✔
473
                                }
474

475
                                this._reader.ReadNext();
760✔
476
                        }
760✔
477
                }
380✔
478

479
                private bool readTableContent(CadTemplate template, DxfMap map)
480
                {
2,812✔
481
                        switch (this._reader.Code)
2,812✔
482
                        {
483
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.TableContent, StringComparison.InvariantCultureIgnoreCase):
1,444✔
484
                                        this.readTableContentSubclass(template, map);
304✔
485
                                        this._notMove = true;
304✔
486
                                        return true;
304✔
487
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.FormattedTableData, StringComparison.InvariantCultureIgnoreCase):
1,140✔
488
                                        this.readFormattedTableDataSubclass(template, map);
304✔
489
                                        this._notMove = true;
304✔
490
                                        return true;
304✔
491
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedTableData, StringComparison.InvariantCultureIgnoreCase):
836✔
492
                                        this.readLinkedTableDataSubclass(template, map);
380✔
493
                                        this._notMove = true;
380✔
494
                                        return true;
380✔
495
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedData, StringComparison.InvariantCultureIgnoreCase):
456✔
496
                                        this.readLinkedData(template, map);
380✔
497
                                        this._notMove = true;
380✔
498
                                        return true;
380✔
499
                                default:
500
                                        return false;
1,444✔
501
                        }
502
                }
2,812✔
503

504
                private void readTableContentSubclass(CadTemplate template, DxfMap map)
505
                {
304✔
506
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
304✔
507
                        TableContent tableContent = tmp.CadObject;
304✔
508

509
                        this._reader.ReadNext();
304✔
510

511
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
608✔
512
                        {
304✔
513
                                switch (this._reader.Code)
304!
514
                                {
515
                                        case 340:
516
                                                tmp.SytleHandle = this._reader.ValueAsHandle;
304✔
517
                                                break;
304✔
518
                                        default:
NEW
519
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.TableContent]))
×
NEW
520
                                                {
×
NEW
521
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableContentSubclass)} {this._reader.Position}.", NotificationType.None);
×
NEW
522
                                                }
×
NEW
523
                                                break;
×
524
                                }
525

526
                                this._reader.ReadNext();
304✔
527
                        }
304✔
528
                }
304✔
529

530
                private void readFormattedTableDataSubclass(CadTemplate template, DxfMap map)
531
                {
304✔
532
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
304✔
533
                        FormattedTableData formattedTable = tmp.CadObject;
304✔
534

535
                        this._reader.ReadNext();
304✔
536

537
                        TableEntity.CellRange cellRange = null;
304✔
538
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
2,736!
539
                        {
2,432✔
540
                                switch (this._reader.Code)
2,432!
541
                                {
542
                                        case 90:
543
                                                break;
304✔
544
                                        case 91:
545
                                                if (cellRange == null)
456✔
546
                                                {
456✔
547
                                                        cellRange = new();
456✔
548
                                                        formattedTable.MergedCellRanges.Add(cellRange);
456✔
549
                                                }
456✔
550
                                                cellRange.TopRowIndex = this._reader.ValueAsInt;
456✔
551
                                                break;
456✔
552
                                        case 92:
553
                                                if (cellRange == null)
456!
NEW
554
                                                {
×
NEW
555
                                                        cellRange = new();
×
NEW
556
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
NEW
557
                                                }
×
558
                                                cellRange.LeftColumnIndex = this._reader.ValueAsInt;
456✔
559
                                                break;
456✔
560
                                        case 93:
561
                                                if (cellRange == null)
456!
NEW
562
                                                {
×
NEW
563
                                                        cellRange = new();
×
NEW
564
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
NEW
565
                                                }
×
566
                                                cellRange.BottomRowIndex = this._reader.ValueAsInt;
456✔
567
                                                break;
456✔
568
                                        case 94:
569
                                                if (cellRange == null)
456!
NEW
570
                                                {
×
NEW
571
                                                        cellRange = new();
×
NEW
572
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
NEW
573
                                                }
×
574
                                                cellRange.RightColumnIndex = this._reader.ValueAsInt;
456✔
575
                                                cellRange = null;
456✔
576
                                                break;
456✔
577
                                        case 300 when this._reader.ValueAsString.Equals("TABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
304!
578
                                                this.readStyleOverride(new CadCellStyleTemplate(formattedTable.CellStyleOverride));
304✔
579
                                                break;
304✔
580
                                        default:
NEW
581
                                                if (!this.tryAssignCurrentValue(formattedTable, map.SubClasses[DxfSubclassMarker.FormattedTableData]))
×
NEW
582
                                                {
×
NEW
583
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
×
NEW
584
                                                }
×
NEW
585
                                                break;
×
586
                                }
587

588
                                this._reader.ReadNext();
2,432✔
589
                        }
2,432✔
590
                }
304✔
591

592
                private void readLinkedTableDataSubclass(CadTemplate template, DxfMap map)
593
                {
380✔
594
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
380✔
595
                        TableContent tableContent = tmp.CadObject;
380✔
596

597
                        this._reader.ReadNext();
380✔
598

599
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
5,016!
600
                        {
4,636✔
601
                                switch (this._reader.Code)
4,636✔
602
                                {
603
                                        case 90:
604
                                                //Column count
605
                                                break;
380✔
606
                                        case 91:
607
                                                //Row count
608
                                                break;
380✔
609
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumn, StringComparison.InvariantCultureIgnoreCase):
1,444✔
610
                                                //Read Column
611
                                                this.readTableColumn();
1,444✔
612
                                                break;
1,444✔
613
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRow, StringComparison.InvariantCultureIgnoreCase):
1,748✔
614
                                                //Read Row
615
                                                this.readTableRow();
1,748✔
616
                                                break;
1,748✔
617
                                        default:
618
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.LinkedTableData]))
684✔
619
                                                {
684✔
620
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
684✔
621
                                                }
684✔
622
                                                break;
684✔
623
                                }
624

625
                                this._reader.ReadNext();
4,636✔
626
                        }
4,636✔
627
                }
380✔
628

629

630
                private TableEntity.Column readTableColumn()
631
                {
1,444✔
632
                        this._reader.ReadNext();
1,444✔
633

634
                        TableEntity.Column column = new TableEntity.Column();
1,444✔
635

636
                        bool end = false;
1,444✔
637
                        while (this._reader.DxfCode != DxfCode.Start)
4,332!
638
                        {
4,332✔
639
                                switch (this._reader.Code)
4,332!
640
                                {
641
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
4,332✔
642
                                                this.readLinkedTableColumn(column);
1,444✔
643
                                                break;
1,444✔
644
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
2,888✔
645
                                                this.readFormattedTableColumn(column);
1,444✔
646
                                                break;
1,444✔
647
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumnBegin, StringComparison.InvariantCultureIgnoreCase):
1,444!
648
                                                this.readTableColumn(column);
1,444✔
649
                                                end = true;
1,444✔
650
                                                break;
1,444✔
651
                                        default:
NEW
652
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
NEW
653
                                                break;
×
654
                                }
655

656
                                if (end)
4,332✔
657
                                {
1,444✔
658
                                        return column;
1,444✔
659
                                }
660

661
                                this._reader.ReadNext();
2,888✔
662
                        }
2,888✔
663

NEW
664
                        return column;
×
665
                }
1,444✔
666

667
                private TableEntity.Row readTableRow()
668
                {
1,748✔
669
                        this._reader.ReadNext();
1,748✔
670

671
                        TableEntity.Row row = new TableEntity.Row();
1,748✔
672

673
                        bool end = false;
1,748✔
674
                        while (this._reader.DxfCode != DxfCode.Start)
14,136✔
675
                        {
14,060✔
676
                                switch (this._reader.Code)
14,060✔
677
                                {
678
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
7,144✔
679
                                                this.readLinkedTableRow(row);
1,824✔
680
                                                break;
1,824✔
681
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
5,320✔
682
                                                this.readFormattedTableRow(row);
1,672✔
683
                                                break;
1,672✔
684
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRowBegin, StringComparison.InvariantCultureIgnoreCase):
3,648✔
685
                                                this.readTableRow(row);
1,672✔
686
                                                end = true;
1,672✔
687
                                                break;
1,672✔
688
                                        default:
689
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
8,892✔
690
                                                break;
8,892✔
691
                                }
692

693
                                if (end)
14,060✔
694
                                {
1,672✔
695
                                        return row;
1,672✔
696
                                }
697

698
                                this._reader.ReadNext();
12,388✔
699
                        }
12,388✔
700

701
                        return row;
76✔
702
                }
1,748✔
703

704
                private void readTableRow(TableEntity.Row row)
705
                {
1,672✔
706
                        this._reader.ReadNext();
1,672✔
707

708
                        bool end = false;
1,672✔
709
                        while (this._reader.DxfCode != DxfCode.Start)
5,016✔
710
                        {
5,016✔
711
                                switch (this._reader.Code)
5,016!
712
                                {
713
                                        case 40:
714
                                                row.Height = this._reader.ValueAsDouble;
1,672✔
715
                                                break;
1,672✔
716
                                        case 90:
717
                                                //styleID
718
                                                break;
1,672✔
719
                                        case 309:
720
                                                end = this._reader.ValueAsString.Equals("TABLEROW_END", StringComparison.InvariantCultureIgnoreCase);
1,672✔
721
                                                break;
1,672✔
722
                                        default:
NEW
723
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
×
NEW
724
                                                break;
×
725
                                }
726

727
                                if (end)
5,016✔
728
                                {
1,672✔
729
                                        break;
1,672✔
730
                                }
731

732
                                this._reader.ReadNext();
3,344✔
733
                        }
3,344✔
734
                }
1,672✔
735

736
                private void readFormattedTableRow(TableEntity.Row row)
737
                {
1,672✔
738
                        this._reader.ReadNext();
1,672✔
739

740
                        bool end = false;
1,672✔
741
                        while (this._reader.DxfCode != DxfCode.Start)
5,016✔
742
                        {
5,016✔
743
                                switch (this._reader.Code)
5,016!
744
                                {
745
                                        case 300 when this._reader.ValueAsString.Equals("ROWTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,672!
746
                                                break;
1,672✔
747
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,672!
748
                                                this.readStyleOverride(new CadCellStyleTemplate(row.CellStyleOverride));
1,672✔
749
                                                break;
1,672✔
750
                                        case 309:
751
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATAROW_END", StringComparison.InvariantCultureIgnoreCase);
1,672✔
752
                                                break;
1,672✔
753
                                        default:
NEW
754
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableRow)} method.", NotificationType.None);
×
NEW
755
                                                break;
×
756
                                }
757

758
                                if (end)
5,016✔
759
                                {
1,672✔
760
                                        break;
1,672✔
761
                                }
762

763
                                this._reader.ReadNext();
3,344✔
764
                        }
3,344✔
765
                }
1,672✔
766

767
                private void readTableColumn(TableEntity.Column column)
768
                {
1,444✔
769
                        this._reader.ReadNext();
1,444✔
770

771
                        bool end = false;
1,444✔
772
                        while (this._reader.DxfCode != DxfCode.Start)
4,332✔
773
                        {
4,332✔
774
                                switch (this._reader.Code)
4,332!
775
                                {
NEW
776
                                        case 1 when this._reader.ValueAsString.Equals("TABLECOLUMN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
NEW
777
                                                break;
×
778
                                        case 1:
NEW
779
                                                end = true;
×
NEW
780
                                                break;
×
781
                                        case 40:
782
                                                column.Width = this._reader.ValueAsDouble;
1,444✔
783
                                                break;
1,444✔
784
                                        case 90:
785
                                                //StyleId
786
                                                break;
1,444✔
787
                                        case 309:
788
                                                end = this._reader.ValueAsString.Equals("TABLECOLUMN_END", StringComparison.InvariantCultureIgnoreCase);
1,444✔
789
                                                break;
1,444✔
790
                                        default:
NEW
791
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
NEW
792
                                                break;
×
793
                                }
794

795
                                if (end)
4,332✔
796
                                {
1,444✔
797
                                        break;
1,444✔
798
                                }
799

800
                                this._reader.ReadNext();
2,888✔
801
                        }
2,888✔
802
                }
1,444✔
803

804
                private void readLinkedTableColumn(TableEntity.Column column)
805
                {
1,444✔
806
                        this._reader.ReadNext();
1,444✔
807

808
                        bool end = false;
1,444✔
809
                        while (this._reader.DxfCode != DxfCode.Start)
5,776✔
810
                        {
5,776✔
811
                                switch (this._reader.Code)
5,776!
812
                                {
NEW
813
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
NEW
814
                                                break;
×
815
                                        case 1:
NEW
816
                                                end = true;
×
NEW
817
                                                break;
×
818
                                        case 91:
819
                                                column.CustomData = this._reader.ValueAsInt;
1,444✔
820
                                                break;
1,444✔
821
                                        case 300:
822
                                                column.Name = this._reader.ValueAsString;
1,444✔
823
                                                break;
1,444✔
824
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,444!
825
                                                this.readCustomData();
1,444✔
826
                                                break;
1,444✔
827
                                        case 309:
828
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,444✔
829
                                                break;
1,444✔
830
                                        default:
NEW
831
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableColumn)} method.", NotificationType.None);
×
NEW
832
                                                break;
×
833
                                }
834

835
                                if (end)
5,776✔
836
                                {
1,444✔
837
                                        break;
1,444✔
838
                                }
839

840
                                this._reader.ReadNext();
4,332✔
841
                        }
4,332✔
842
                }
1,444✔
843

844
                private void readLinkedTableRow(TableEntity.Row row)
845
                {
1,824✔
846
                        this._reader.ReadNext();
1,824✔
847

848
                        bool end = false;
1,824✔
849
                        while (this._reader.DxfCode != DxfCode.Start)
14,972✔
850
                        {
14,820✔
851
                                switch (this._reader.Code)
14,820!
852
                                {
NEW
853
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
✔
NEW
854
                                                break;
×
855
                                        case 90:
856
                                                break;
1,824✔
857
                                        case 91:
858
                                                row.CustomData = this._reader.ValueAsInt;
1,672✔
859
                                                break;
1,672✔
860
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectCell, StringComparison.InvariantCultureIgnoreCase):
6,384✔
861
                                                this.readCell();
6,384✔
862
                                                break;
6,384✔
863
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,672✔
864
                                                this.readCustomData();
1,672✔
865
                                                break;
1,672✔
866
                                        case 309:
867
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_END, StringComparison.InvariantCultureIgnoreCase);
1,672✔
868
                                                break;
1,672✔
869
                                        default:
870
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableRow)} method.", NotificationType.None);
1,596✔
871
                                                break;
1,596✔
872
                                }
873

874
                                if (end)
14,820✔
875
                                {
1,672✔
876
                                        break;
1,672✔
877
                                }
878

879
                                this._reader.ReadNext();
13,148✔
880
                        }
13,148✔
881
                }
1,824✔
882

883
                private TableEntity.Cell readCell()
884
                {
6,384✔
885
                        this._reader.ReadNext();
6,384✔
886

887
                        TableEntity.Cell cell = new TableEntity.Cell();
6,384✔
888
                        CadTableCellTemplate template = new CadTableCellTemplate(cell);
6,384✔
889

890
                        bool end = false;
6,384✔
891
                        while (this._reader.DxfCode != DxfCode.Start)
20,140✔
892
                        {
19,988✔
893
                                switch (this._reader.Code)
19,988✔
894
                                {
895
                                        case 1 when this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
18,848✔
896
                                                this.readLinkedTableCell(cell);
6,384✔
897
                                                break;
6,384✔
898
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
12,464✔
899
                                                this.readFormattedTableCell(cell);
6,232✔
900
                                                break;
6,232✔
901
                                        case 1 when this._reader.ValueAsString.Equals("TABLECELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
6,232✔
902
                                                this.readTableCell(cell);
6,232✔
903
                                                end = true;
6,232✔
904
                                                break;
6,232✔
905
                                        default:
906
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCell)} method.", NotificationType.None);
1,140✔
907
                                                break;
1,140✔
908
                                }
909

910
                                if (end)
19,988✔
911
                                {
6,232✔
912
                                        return cell;
6,232✔
913
                                }
914

915
                                this._reader.ReadNext();
13,756✔
916
                        }
13,756✔
917

918
                        return cell;
152✔
919
                }
6,384✔
920

921
                private void readTableCell(TableEntity.Cell cell)
922
                {
6,232✔
923
                        var map = DxfClassMap.Create(cell.GetType(), "TABLECELL_BEGIN");
6,232✔
924

925
                        this._reader.ReadNext();
6,232✔
926

927
                        bool end = false;
6,232✔
928
                        while (this._reader.DxfCode != DxfCode.Start)
19,456✔
929
                        {
19,456✔
930
                                switch (this._reader.Code)
19,456✔
931
                                {
932
                                        //Unknown
933
                                        case 40:
934
                                        case 41:
935
                                                break;
304✔
936
                                        case 309:
937
                                                end = this._reader.ValueAsString.Equals("TABLECELL_END", StringComparison.InvariantCultureIgnoreCase);
6,232✔
938
                                                break;
6,232✔
939
                                        case 330:
940
                                                //Unknown handle
941
                                                break;
152✔
942
                                        default:
943
                                                if (!this.tryAssignCurrentValue(cell, map))
12,768!
NEW
944
                                                {
×
NEW
945
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableCell)} {this._reader.Position}.", NotificationType.None);
×
NEW
946
                                                }
×
947
                                                break;
12,768✔
948
                                }
949

950
                                if (end)
19,456✔
951
                                {
6,232✔
952
                                        break;
6,232✔
953
                                }
954

955
                                this._reader.ReadNext();
13,224✔
956
                        }
13,224✔
957
                }
6,232✔
958

959

960
                private void readFormattedTableCell(TableEntity.Cell cell)
961
                {
6,232✔
962
                        var map = DxfClassMap.Create(cell.GetType(), "FORMATTEDTABLEDATACELL_BEGIN");
6,232✔
963

964
                        this._reader.ReadNext();
6,232✔
965

966
                        bool end = false;
6,232✔
967
                        while (this._reader.DxfCode != DxfCode.Start)
12,464✔
968
                        {
12,464✔
969
                                switch (this._reader.Code)
12,464!
970
                                {
971
                                        case 300 when this._reader.ValueAsString.Equals("CELLTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
6,232!
972
                                                this.readCellTableFormat(cell);
6,232✔
973
                                                continue;
6,232✔
974
                                        case 309:
975
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
6,232✔
976
                                                break;
6,232✔
977
                                        default:
NEW
978
                                                if (!this.tryAssignCurrentValue(cell, map))
×
NEW
979
                                                {
×
NEW
980
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableCell)} {this._reader.Position}.", NotificationType.None);
×
NEW
981
                                                }
×
NEW
982
                                                break;
×
983
                                }
984

985
                                if (end)
6,232!
986
                                {
6,232✔
987
                                        break;
6,232✔
988
                                }
989

NEW
990
                                this._reader.ReadNext();
×
NEW
991
                        }
×
992
                }
6,232✔
993

994
                private void readCellTableFormat(TableEntity.Cell cell)
995
                {
6,232✔
996
                        var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
6,232✔
997

998
                        this._reader.ReadNext();
6,232✔
999

1000
                        bool end = false;
6,232✔
1001
                        while (this._reader.Code == 1)
12,464✔
1002
                        {
6,232✔
1003
                                switch (this._reader.Code)
6,232!
1004
                                {
1005
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
6,232!
1006
                                                this.readStyleOverride(new CadCellStyleTemplate(cell.StyleOverride));
6,232✔
1007
                                                break;
6,232✔
NEW
1008
                                        case 1 when this._reader.ValueAsString.Equals("CELLSTYLE_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
NEW
1009
                                                this.readCellStyle(new CadCellStyleTemplate());
×
NEW
1010
                                                break;
×
1011
                                        default:
NEW
1012
                                                if (!this.tryAssignCurrentValue(cell, map))
×
NEW
1013
                                                {
×
NEW
1014
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellTableFormat)} {this._reader.Position}.", NotificationType.None);
×
NEW
1015
                                                }
×
NEW
1016
                                                break;
×
1017
                                }
1018

1019
                                if (end)
6,232!
NEW
1020
                                {
×
NEW
1021
                                        break;
×
1022
                                }
1023

1024
                                this._reader.ReadNext();
6,232✔
1025
                        }
6,232✔
1026
                }
6,232✔
1027

1028
                private void readCellStyle(CadCellStyleTemplate template)
NEW
1029
                {
×
1030
                        //var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
1031

NEW
1032
                        this._reader.ReadNext();
×
1033

NEW
1034
                        bool end = false;
×
NEW
1035
                        while (this._reader.Code != 1)
×
NEW
1036
                        {
×
NEW
1037
                                switch (this._reader.Code)
×
1038
                                {
1039
                                        case 309:
NEW
1040
                                                end = this._reader.ValueAsString.Equals("CELLSTYLE_END", StringComparison.InvariantCultureIgnoreCase);
×
NEW
1041
                                                break;
×
1042
                                        default:
1043
                                                //if (!this.tryAssignCurrentValue(cell, map))
NEW
1044
                                                {
×
NEW
1045
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellStyle)} {this._reader.Position}.", NotificationType.None);
×
NEW
1046
                                                }
×
NEW
1047
                                                break;
×
1048
                                }
1049

NEW
1050
                                if (end)
×
NEW
1051
                                {
×
NEW
1052
                                        break;
×
1053
                                }
1054

NEW
1055
                                this._reader.ReadNext();
×
NEW
1056
                        }
×
NEW
1057
                }
×
1058

1059
                private void readLinkedTableCell(TableEntity.Cell cell)
1060
                {
6,384✔
1061
                        var map = DxfClassMap.Create(cell.GetType(), "LINKEDTABLEDATACELL_BEGIN");
6,384✔
1062

1063
                        this._reader.ReadNext();
6,384✔
1064

1065
                        bool end = false;
6,384✔
1066
                        while (this._reader.DxfCode != DxfCode.Start)
63,992✔
1067
                        {
63,840✔
1068
                                switch (this._reader.Code)
63,840✔
1069
                                {
1070
                                        case 95:
1071
                                                //BL 95 Number of cell contents
1072
                                                break;
6,232✔
1073
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
6,384✔
1074
                                                this.readCustomData();
6,384✔
1075
                                                break;
6,384✔
1076
                                        case 302 when this._reader.ValueAsString.Equals("CONTENT", StringComparison.InvariantCultureIgnoreCase):
4,864✔
1077
                                                var c = this.readLinkedTableCellContent();
4,864✔
1078
                                                break;
4,864✔
1079
                                        case 309:
1080
                                                end = this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
6,232✔
1081
                                                break;
6,232✔
1082
                                        default:
1083
                                                if (!this.tryAssignCurrentValue(cell, map))
40,128✔
1084
                                                {
13,832✔
1085
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCell)} {this._reader.Position}.", NotificationType.None);
13,832✔
1086
                                                }
13,832✔
1087
                                                break;
40,128✔
1088
                                }
1089

1090
                                if (end)
63,840✔
1091
                                {
6,232✔
1092
                                        break;
6,232✔
1093
                                }
1094

1095
                                this._reader.ReadNext();
57,608✔
1096
                        }
57,608✔
1097
                }
6,384✔
1098

1099
                private CadTableCellContentTemplate readLinkedTableCellContent()
1100
                {
4,864✔
1101
                        TableEntity.CellContent content = new TableEntity.CellContent();
4,864✔
1102
                        CadTableCellContentTemplate template = new CadTableCellContentTemplate(content);
4,864✔
1103
                        var map = DxfClassMap.Create(content.GetType(), "CONTENT");
4,864✔
1104

1105
                        this._reader.ReadNext();
4,864✔
1106

1107
                        bool end = false;
4,864✔
1108
                        while (this._reader.DxfCode != DxfCode.Start)
9,728✔
1109
                        {
9,728✔
1110
                                switch (this._reader.Code)
9,728!
1111
                                {
1112
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
9,728✔
1113
                                                readFormattedCellContent();
4,864✔
1114
                                                end = true;
4,864✔
1115
                                                break;
4,864✔
1116
                                        case 1 when this._reader.ValueAsString.Equals("CELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
4,864!
1117
                                                readCellContent(template);
4,864✔
1118
                                                break;
4,864✔
1119
                                        default:
NEW
1120
                                                if (!this.tryAssignCurrentValue(content, map))
×
NEW
1121
                                                {
×
NEW
1122
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCellContent)} {this._reader.Position}.", NotificationType.None);
×
NEW
1123
                                                }
×
NEW
1124
                                                break;
×
1125
                                }
1126

1127
                                if (end)
9,728✔
1128
                                {
4,864✔
1129
                                        break;
4,864✔
1130
                                }
1131

1132
                                this._reader.ReadNext();
4,864✔
1133
                        }
4,864✔
1134

1135
                        return template;
4,864✔
1136
                }
4,864✔
1137

1138
                private void readCellContent(CadTableCellContentTemplate template)
1139
                {
4,864✔
1140
                        TableEntity.CellContent content = template.Content;
4,864✔
1141
                        var map = DxfClassMap.Create(content.GetType(), "CELLCONTENT_BEGIN");
4,864✔
1142

1143
                        this._reader.ReadNext();
4,864✔
1144

1145
                        bool end = false;
4,864✔
1146
                        while (this._reader.DxfCode != DxfCode.Start)
19,456✔
1147
                        {
19,456✔
1148
                                switch (this._reader.Code)
19,456✔
1149
                                {
1150
                                        case 91:
1151
                                                break;
4,864✔
1152
                                        case 300 when this._reader.ValueAsString.Equals("VALUE", StringComparison.InvariantCultureIgnoreCase):
4,408✔
1153
                                                this.readDataMapValue();
4,408✔
1154
                                                break;
4,408✔
1155
                                        case 309:
1156
                                                end = this._reader.ValueAsString.Equals("CELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,864✔
1157
                                                break;
4,864✔
1158
                                        case 340:
1159
                                                template.BlockRecordHandle = this._reader.ValueAsHandle;
456✔
1160
                                                break;
456✔
1161
                                        default:
1162
                                                if (!this.tryAssignCurrentValue(content, map))
4,864!
NEW
1163
                                                {
×
NEW
1164
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellContent)} {this._reader.Position}.", NotificationType.None);
×
NEW
1165
                                                }
×
1166
                                                break;
4,864✔
1167
                                }
1168

1169
                                if (end)
19,456✔
1170
                                {
4,864✔
1171
                                        break;
4,864✔
1172
                                }
1173

1174
                                this._reader.ReadNext();
14,592✔
1175
                        }
14,592✔
1176
                }
4,864✔
1177

1178
                private void readFormattedCellContent()
1179
                {
4,864✔
1180
                        TableEntity.ContentFormat format = new();
4,864✔
1181
                        CadTableCellContentFormatTemplate template = new CadTableCellContentFormatTemplate(format);
4,864✔
1182
                        var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
4,864✔
1183

1184
                        this._reader.ReadNext();
4,864✔
1185

1186
                        bool end = false;
4,864✔
1187
                        while (this._reader.DxfCode != DxfCode.Start)
14,592✔
1188
                        {
14,592✔
1189
                                switch (this._reader.Code)
14,592✔
1190
                                {
1191
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
4,864✔
1192
                                                readContentFormat(template);
4,864✔
1193
                                                break;
4,864✔
1194
                                        case 309:
1195
                                                end = this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,864✔
1196
                                                break;
4,864✔
1197
                                        default:
1198
                                                if (!this.tryAssignCurrentValue(format, map))
4,864!
NEW
1199
                                                {
×
NEW
1200
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedCellContent)} method.", NotificationType.None);
×
NEW
1201
                                                }
×
1202
                                                break;
4,864✔
1203
                                }
1204

1205
                                if (end)
14,592✔
1206
                                {
4,864✔
1207
                                        break;
4,864✔
1208
                                }
1209

1210
                                this._reader.ReadNext();
9,728✔
1211
                        }
9,728✔
1212
                }
4,864✔
1213

1214
                private void readContentFormat(CadTableCellContentFormatTemplate template)
1215
                {
11,400✔
1216
                        var format = template.Format;
11,400✔
1217
                        var map = DxfClassMap.Create(format.GetType(), "CONTENTFORMAT_BEGIN");
11,400✔
1218

1219
                        this._reader.ReadNext();
11,400✔
1220

1221
                        bool end = false;
11,400✔
1222
                        while (this._reader.DxfCode != DxfCode.Start)
148,200✔
1223
                        {
148,200✔
1224
                                switch (this._reader.Code)
148,200✔
1225
                                {
1226
                                        case 1 when this._reader.ValueAsString.Equals("CONTENTFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
11,400✔
1227
                                                break;
11,400✔
1228
                                        case 309:
1229
                                                end = this._reader.ValueAsString.Equals("CONTENTFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
11,400✔
1230
                                                break;
11,400✔
1231
                                        case 340:
1232
                                                template.TextStyleHandle = this._reader.ValueAsHandle;
11,400✔
1233
                                                break;
11,400✔
1234
                                        default:
1235
                                                if (!this.tryAssignCurrentValue(format, map))
114,000!
NEW
1236
                                                {
×
NEW
1237
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readContentFormat)} method.", NotificationType.None);
×
NEW
1238
                                                }
×
1239
                                                break;
114,000✔
1240
                                }
1241

1242
                                if (end)
148,200✔
1243
                                {
11,400✔
1244
                                        break;
11,400✔
1245
                                }
1246

1247
                                this._reader.ReadNext();
136,800✔
1248
                        }
136,800✔
1249
                }
11,400✔
1250

1251
                private void readFormattedTableColumn(TableEntity.Column column)
1252
                {
1,444✔
1253
                        this._reader.ReadNext();
1,444✔
1254

1255
                        bool end = false;
1,444✔
1256
                        while (this._reader.DxfCode != DxfCode.Start)
4,332✔
1257
                        {
4,332✔
1258
                                switch (this._reader.Code)
4,332!
1259
                                {
1260
                                        case 300 when this._reader.ValueAsString.Equals("COLUMNTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,444!
1261
                                                break;
1,444✔
1262
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,444!
1263
                                                this.readStyleOverride(new CadCellStyleTemplate(column.CellStyleOverride));
1,444✔
1264
                                                break;
1,444✔
1265
                                        case 309:
1266
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,444✔
1267
                                                break;
1,444✔
1268
                                        default:
NEW
1269
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableColumn)} method.", NotificationType.None);
×
NEW
1270
                                                break;
×
1271
                                }
1272

1273
                                if (end)
4,332✔
1274
                                {
1,444✔
1275
                                        break;
1,444✔
1276
                                }
1277

1278
                                this._reader.ReadNext();
2,888✔
1279
                        }
2,888✔
1280
                }
1,444✔
1281

1282
                private void readStyleOverride(CadCellStyleTemplate template)
1283
                {
9,652✔
1284
                        var style = template.Format as TableEntity.CellStyle;
9,652✔
1285
                        var mapstyle = DxfClassMap.Create(style.GetType(), "TABLEFORMAT_STYLE");
9,652✔
1286
                        var mapformat = DxfClassMap.Create(typeof(TableEntity.ContentFormat), "TABLEFORMAT_BEGIN");
9,652✔
1287

1288
                        this._reader.ReadNext();
9,652✔
1289

1290
                        bool end = false;
9,652✔
1291
                        TableEntity.CellEdgeFlags currBorder = TableEntity.CellEdgeFlags.Unknown;
9,652✔
1292
                        while (this._reader.DxfCode != DxfCode.Start)
106,324✔
1293
                        {
106,324✔
1294
                                switch (this._reader.Code)
106,324✔
1295
                                {
1296
                                        case 95:
1297
                                                currBorder = (TableEntity.CellEdgeFlags)this._reader.ValueAsInt;
13,984✔
1298
                                                break;
13,984✔
1299
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
304✔
1300
                                                break;
304✔
1301
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
6,536✔
1302
                                                readContentFormat(new CadTableCellContentFormatTemplate(new TableEntity.ContentFormat()));
6,536✔
1303
                                                break;
6,536✔
1304
                                        case 301 when this._reader.ValueAsString.Equals("MARGIN", StringComparison.InvariantCultureIgnoreCase):
3,344✔
1305
                                                this.readCellMargin(template);
3,344✔
1306
                                                break;
3,344✔
1307
                                        case 302 when this._reader.ValueAsString.Equals("GRIDFORMAT", StringComparison.InvariantCultureIgnoreCase):
13,984✔
1308
                                                TableEntity.CellBorder border = new TableEntity.CellBorder(currBorder);
13,984✔
1309
                                                this.readGridFormat(template, border);
13,984✔
1310
                                                break;
13,984✔
1311
                                        case 309:
1312
                                                end = this._reader.ValueAsString.Equals("TABLEFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
9,652✔
1313
                                                break;
9,652✔
1314
                                        default:
1315
                                                if (!this.tryAssignCurrentValue(style, mapstyle) && !this.tryAssignCurrentValue(style, mapformat))
58,520!
NEW
1316
                                                {
×
NEW
1317
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readStyleOverride)} method.", NotificationType.None);
×
NEW
1318
                                                }
×
1319
                                                break;
58,520✔
1320
                                }
1321

1322
                                if (end)
106,324✔
1323
                                {
9,652✔
1324
                                        break;
9,652✔
1325
                                }
1326

1327
                                this._reader.ReadNext();
96,672✔
1328
                        }
96,672✔
1329
                }
9,652✔
1330

1331
                private void readGridFormat(CadCellStyleTemplate template, TableEntity.CellBorder border)
1332
                {
13,984✔
1333
                        var map = DxfClassMap.Create(border.GetType(), nameof(TableEntity.CellBorder));
13,984✔
1334

1335
                        this._reader.ReadNext();
13,984✔
1336

1337
                        bool end = false;
13,984✔
1338
                        while (this._reader.DxfCode != DxfCode.Start)
125,856✔
1339
                        {
125,856✔
1340
                                switch (this._reader.Code)
125,856✔
1341
                                {
1342
                                        case 1 when this._reader.ValueAsString.Equals("GRIDFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
13,984✔
1343
                                                break;
13,984✔
1344
                                        case 340:
1345
                                                template.BorderLinetypePairs.Add(new Tuple<TableEntity.CellBorder, ulong>(border, this._reader.ValueAsHandle));
13,984✔
1346
                                                break;
13,984✔
1347
                                        case 309:
1348
                                                end = this._reader.ValueAsString.Equals("GRIDFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
13,984✔
1349
                                                break;
13,984✔
1350
                                        default:
1351
                                                if (!this.tryAssignCurrentValue(border, map))
83,904!
NEW
1352
                                                {
×
NEW
1353
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readGridFormat)} method.", NotificationType.None);
×
NEW
1354
                                                }
×
1355
                                                break;
83,904✔
1356
                                }
1357

1358
                                if (end)
125,856✔
1359
                                {
13,984✔
1360
                                        break;
13,984✔
1361
                                }
1362

1363
                                this._reader.ReadNext();
111,872✔
1364
                        }
111,872✔
1365
                }
13,984✔
1366

1367
                private void readCellMargin(CadCellStyleTemplate template)
1368
                {
3,344✔
1369
                        var style = template.Format as TableEntity.CellStyle;
3,344✔
1370

1371
                        this._reader.ReadNext();
3,344✔
1372

1373
                        bool end = false;
3,344✔
1374
                        int i = 0;
3,344✔
1375
                        while (this._reader.DxfCode != DxfCode.Start)
26,752✔
1376
                        {
26,752✔
1377
                                switch (this._reader.Code)
26,752!
1378
                                {
1379
                                        case 1 when this._reader.ValueAsString.Equals("CELLMARGIN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
3,344!
1380
                                                break;
3,344✔
1381
                                        case 40:
1382
                                                switch (i)
20,064✔
1383
                                                {
1384
                                                        case 0:
1385
                                                                style.VerticalMargin = this._reader.ValueAsDouble;
3,344✔
1386
                                                                break;
3,344✔
1387
                                                        case 1:
1388
                                                                style.HorizontalMargin = this._reader.ValueAsDouble;
3,344✔
1389
                                                                break;
3,344✔
1390
                                                        case 2:
1391
                                                                style.BottomMargin = this._reader.ValueAsDouble;
3,344✔
1392
                                                                break;
3,344✔
1393
                                                        case 3:
1394
                                                                style.RightMargin = this._reader.ValueAsDouble;
3,344✔
1395
                                                                break;
3,344✔
1396
                                                        case 4:
1397
                                                                style.MarginHorizontalSpacing = this._reader.ValueAsDouble;
3,344✔
1398
                                                                break;
3,344✔
1399
                                                        case 5:
1400
                                                                style.MarginVerticalSpacing = this._reader.ValueAsDouble;
3,344✔
1401
                                                                break;
3,344✔
1402
                                                }
1403

1404
                                                i++;
20,064✔
1405
                                                break;
20,064✔
1406
                                        case 309:
1407
                                                end = this._reader.ValueAsString.Equals("CELLMARGIN_END", StringComparison.InvariantCultureIgnoreCase);
3,344✔
1408
                                                break;
3,344✔
1409
                                        default:
NEW
1410
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellMargin)} method.", NotificationType.None);
×
NEW
1411
                                                break;
×
1412
                                }
1413

1414
                                if (end)
26,752✔
1415
                                {
3,344✔
1416
                                        break;
3,344✔
1417
                                }
1418

1419
                                this._reader.ReadNext();
23,408✔
1420
                        }
23,408✔
1421
                }
3,344✔
1422

1423
                private void readCustomData()
1424
                {
9,500✔
1425
                        this._reader.ReadNext();
9,500✔
1426

1427
                        int ndata = 0;
9,500✔
1428
                        bool end = false;
9,500✔
1429
                        while (this._reader.DxfCode != DxfCode.Start)
88,388✔
1430
                        {
88,236✔
1431
                                switch (this._reader.Code)
88,236✔
1432
                                {
1433
                                        case 1 when this._reader.ValueAsString.Equals("DATAMAP_BEGIN", StringComparison.InvariantCultureIgnoreCase):
9,500✔
1434
                                                break;
9,500✔
1435
                                        case 90:
1436
                                                ndata = this._reader.ValueAsInt;
9,652✔
1437
                                                break;
9,652✔
1438
                                        case 300:
1439
                                                //Name
1440
                                                break;
6,232✔
1441
                                        case 301 when this._reader.ValueAsString.Equals("DATAMAP_VALUE", StringComparison.InvariantCultureIgnoreCase):
6,232✔
1442
                                                this.readDataMapValue();
6,232✔
1443
                                                break;
6,232✔
1444
                                        case 309:
1445
                                                end = this._reader.ValueAsString.Equals("DATAMAP_END", StringComparison.InvariantCultureIgnoreCase);
9,348✔
1446
                                                break;
9,348✔
1447
                                        default:
1448
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCustomData)} method.", NotificationType.None);
47,272✔
1449
                                                break;
47,272✔
1450
                                }
1451

1452
                                if (end)
88,236✔
1453
                                {
9,348✔
1454
                                        break;
9,348✔
1455
                                }
1456

1457
                                this._reader.ReadNext();
78,888✔
1458
                        }
78,888✔
1459
                }
9,500✔
1460

1461
                private void readDataMapValue()
1462
                {
10,640✔
1463
                        TableEntity.CellValue value = new TableEntity.CellValue();
10,640✔
1464
                        var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
10,640✔
1465

1466
                        this._reader.ReadNext();
10,640✔
1467

1468
                        bool end = false;
10,640✔
1469
                        while (this._reader.DxfCode != DxfCode.Start)
392,160✔
1470
                        {
392,008✔
1471
                                switch (this._reader.Code)
392,008✔
1472
                                {
1473
                                        case 140:
1474
                                                break;
15,732✔
1475
                                        case 304:
1476
                                                end = this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.InvariantCultureIgnoreCase);
10,488✔
1477
                                                break;
10,488✔
1478
                                        default:
1479
                                                if (!this.tryAssignCurrentValue(value, map))
365,788✔
1480
                                                {
174,344✔
1481
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readDataMapValue)} method.", NotificationType.None);
174,344✔
1482
                                                }
174,344✔
1483
                                                break;
365,788✔
1484
                                }
1485

1486
                                if (end)
392,008✔
1487
                                {
10,488✔
1488
                                        break;
10,488✔
1489
                                }
1490

1491
                                this._reader.ReadNext();
381,520✔
1492
                        }
381,520✔
1493
                }
10,640✔
1494

1495
                private bool readVisualStyle(CadTemplate template, DxfMap map)
1496
                {
411,192✔
1497
                        switch (this._reader.Code)
411,192✔
1498
                        {
1499
                                // Undocumented codes
1500
                                case 176:
1501
                                case 177:
1502
                                case 420:
1503
                                        return true;
141,178✔
1504
                                default:
1505
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
270,014✔
1506
                        }
1507
                }
411,192✔
1508

1509
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
1510
                {
4,788✔
1511
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,788✔
1512
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,788✔
1513

1514
                        switch (this._reader.Code)
4,788✔
1515
                        {
1516
                                case 10:
1517
                                        filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
456✔
1518
                                        return true;
456✔
1519
                                case 20:
1520
                                        var pt = filter.BoundaryPoints.LastOrDefault();
456✔
1521
                                        filter.BoundaryPoints.Add(new CSMath.XY(pt.X, this._reader.ValueAsDouble));
456✔
1522
                                        return true;
456✔
1523
                                case 40:
1524
                                        if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
456!
1525
                                        {
×
1526
                                                filter.FrontDistance = this._reader.ValueAsDouble;
×
1527
                                                tmp.HasFrontPlane = true;
×
1528
                                        }
×
1529

1530
                                        double[] array = new double[16]
456✔
1531
                                        {
456✔
1532
                                                0.0, 0.0, 0.0, 0.0,
456✔
1533
                                                0.0, 0.0, 0.0, 0.0,
456✔
1534
                                                0.0, 0.0, 0.0, 0.0,
456✔
1535
                                                0.0, 0.0, 0.0, 1.0
456✔
1536
                                        };
456✔
1537

1538
                                        for (int i = 0; i < 12; i++)
11,856✔
1539
                                        {
5,472✔
1540
                                                array[i] = this._reader.ValueAsDouble;
5,472✔
1541

1542
                                                if (i < 11)
5,472✔
1543
                                                {
5,016✔
1544
                                                        this._reader.ReadNext();
5,016✔
1545
                                                }
5,016✔
1546
                                        }
5,472✔
1547

1548
                                        if (tmp.InsertTransformRead)
456!
1549
                                        {
×
1550
                                                filter.InsertTransform = new Matrix4(array);
×
1551
                                                tmp.InsertTransformRead = true;
×
1552
                                        }
×
1553
                                        else
1554
                                        {
456✔
1555
                                                filter.InverseInsertTransform = new Matrix4(array);
456✔
1556
                                        }
456✔
1557

1558
                                        return true;
456✔
1559
                                case 73:
1560
                                default:
1561
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
3,420✔
1562
                        }
1563
                }
4,788✔
1564

1565
                private bool readMLeaderStyle(CadTemplate template, DxfMap map)
1566
                {
21,648✔
1567
                        var tmp = template as CadMLeaderStyleTemplate;
21,648✔
1568

1569
                        switch (this._reader.Code)
21,648✔
1570
                        {
1571
                                case 179:
1572
                                        return true;
242✔
1573
                                case 340:
1574
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
472✔
1575
                                        return true;
472✔
1576
                                case 342:
1577
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
472✔
1578
                                        return true;
472✔
1579
                                default:
1580
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
20,462✔
1581
                        }
1582
                }
21,648✔
1583

1584
                private bool readXRecord(CadTemplate template, DxfMap map)
1585
                {
71,640✔
1586
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
71,640✔
1587

1588
                        switch (this._reader.Code)
71,640✔
1589
                        {
1590
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
18,632✔
1591
                                        this.readXRecordEntries(tmp);
18,632✔
1592
                                        return true;
18,632✔
1593
                                default:
1594
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
53,008✔
1595
                        }
1596
                }
71,640✔
1597

1598
                private void readXRecordEntries(CadXRecordTemplate template)
1599
                {
18,632✔
1600
                        this._reader.ReadNext();
18,632✔
1601

1602
                        while (this._reader.DxfCode != DxfCode.Start)
993,532✔
1603
                        {
974,900✔
1604
                                switch (this._reader.GroupCodeValue)
974,900!
1605
                                {
1606
                                        case GroupCodeValueType.Handle:
1607
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
×
1608
                                                break;
×
1609
                                        default:
1610
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
974,900✔
1611
                                                break;
974,900✔
1612
                                }
1613

1614
                                this._reader.ReadNext();
974,900✔
1615
                        }
974,900✔
1616
                }
18,632✔
1617

1618
                private bool readBookColor(CadTemplate template, DxfMap map)
1619
                {
1,634✔
1620
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,634✔
1621
                        BookColor color = tmp.CadObject as BookColor;
1,634✔
1622

1623
                        switch (this._reader.Code)
1,634✔
1624
                        {
1625
                                case 430:
1626
                                        color.Name = this._reader.ValueAsString;
190✔
1627
                                        return true;
190✔
1628
                                default:
1629
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,444✔
1630
                        }
1631
                }
1,634✔
1632

1633
                private bool readDictionary(CadTemplate template, DxfMap map)
1634
                {
219,815✔
1635
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
219,815✔
1636
                        CadDictionary cadDictionary = tmp.CadObject;
219,815✔
1637

1638
                        switch (this._reader.Code)
219,815✔
1639
                        {
1640
                                case 280:
1641
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
15,931✔
1642
                                        return true;
15,931✔
1643
                                case 281:
1644
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
23,530✔
1645
                                        return true;
23,530✔
1646
                                case 3:
1647
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
49,999✔
1648
                                        return true;
49,999✔
1649
                                case 350: // Soft-owner ID/handle to entry object 
1650
                                case 360: // Hard-owner ID/handle to entry object
1651
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
49,999✔
1652
                                        return true;
49,999✔
1653
                                default:
1654
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
80,356✔
1655
                        }
1656
                }
219,815✔
1657

1658
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
1659
                {
2,070✔
1660
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
2,070✔
1661

1662
                        switch (this._reader.Code)
2,070✔
1663
                        {
1664
                                case 340:
1665
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
230✔
1666
                                        return true;
230✔
1667
                                default:
1668
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,840!
1669
                                        {
1,840✔
1670
                                                return this.readDictionary(template, map);
1,840✔
1671
                                        }
1672
                                        return true;
×
1673
                        }
1674
                }
2,070✔
1675

1676
                private CadTemplate readSortentsTable()
1677
                {
684✔
1678
                        SortEntitiesTable sortTable = new SortEntitiesTable();
684✔
1679
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
684✔
1680

1681
                        //Jump the 0 marker
1682
                        this._reader.ReadNext();
684✔
1683

1684
                        this.readCommonObjectData(template);
684✔
1685

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

1688
                        //Jump the 100 marker
1689
                        this._reader.ReadNext();
684✔
1690

1691
                        (ulong?, ulong?) pair = (null, null);
684✔
1692

1693
                        while (this._reader.DxfCode != DxfCode.Start)
5,016✔
1694
                        {
4,332✔
1695
                                switch (this._reader.Code)
4,332!
1696
                                {
1697
                                        case 5:
1698
                                                pair.Item1 = this._reader.ValueAsHandle;
1,824✔
1699
                                                break;
1,824✔
1700
                                        case 330:
1701
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
684✔
1702
                                                break;
684✔
1703
                                        case 331:
1704
                                                pair.Item2 = this._reader.ValueAsHandle;
1,824✔
1705
                                                break;
1,824✔
1706
                                        default:
1707
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
1708
                                                break;
×
1709
                                }
1710

1711
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
4,332✔
1712
                                {
1,824✔
1713
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,824✔
1714
                                        pair = (null, null);
1,824✔
1715
                                }
1,824✔
1716

1717
                                this._reader.ReadNext();
4,332✔
1718
                        }
4,332✔
1719

1720
                        return template;
684✔
1721
                }
684✔
1722
        }
1723
}
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