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

DomCR / ACadSharp / 19269943512

11 Nov 2025 03:11PM UTC coverage: 78.156% (+0.2%) from 78.002%
19269943512

push

github

web-flow
Merge pull request #831 from DomCR/table-entity-refactor

Table entity refactor

7383 of 10235 branches covered (72.13%)

Branch coverage included in aggregate %.

731 of 859 new or added lines in 16 files covered. (85.1%)

14 existing lines in 4 files now uncovered.

27606 of 34533 relevant lines covered (79.94%)

98649.31 hits per line

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

84.82
/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);
7,844✔
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);
242✔
117
                                        }
242✔
118

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

121
                                        do
122
                                        {
384,614✔
123
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
384,614✔
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,566✔
131
                                        }
384,566✔
132
                                        while (this._reader.DxfCode != DxfCode.Start);
384,614✔
133

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

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

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

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

154
                                if (this.lockPointer)
895,232✔
155
                                {
1,368✔
156
                                        this.lockPointer = false;
1,368✔
157
                                        continue;
1,368✔
158
                                }
159

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

166
                        return template;
63,140✔
167
                }
63,140✔
168

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

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

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

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

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

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

247
                                                node.Index = this._reader.ValueAsInt;
3,040✔
248

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

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

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

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

267
                                                this._reader.ReadNext();
3,040✔
268

269
                                                tmp.NodeTemplates.Add(nodeTemplate);
3,040✔
270
                                        }
3,040✔
271

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

287
                                                this._reader.ReadNext();
2,280✔
288
                                        }
2,280✔
289

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

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

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

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

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

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

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

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

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

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

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

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

459
                        this._reader.ReadNext();
380✔
460

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

473
                                this._reader.ReadNext();
760✔
474
                        }
760✔
475
                }
380✔
476

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

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

507
                        this._reader.ReadNext();
304✔
508

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

524
                                this._reader.ReadNext();
304✔
525
                        }
304✔
526
                }
304✔
527

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

533
                        this._reader.ReadNext();
304✔
534

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

586
                                this._reader.ReadNext();
2,432✔
587
                        }
2,432✔
588
                }
304✔
589

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

595
                        this._reader.ReadNext();
380✔
596

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

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

630

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

956
                                this._reader.ReadNext();
13,224✔
957
                        }
13,224✔
958
                }
6,232✔
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 11:
1474
                                        case 21:
1475
                                        case 31:
1476
                                                //Value as point
1477
                                                break;
912✔
1478
                                        case 91:
1479
                                        case 92:
1480
                                                //Value as int
1481
                                                break;
46,208✔
1482
                                        case 140:
1483
                                                //Value as double
1484
                                                break;
15,732✔
1485
                                        case 310:
1486
                                                //Value as byte array
1487
                                                break;
304✔
1488
                                        case 304:
1489
                                                end = this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.InvariantCultureIgnoreCase);
10,488✔
1490
                                                break;
10,488✔
1491
                                        default:
1492
                                                if (!this.tryAssignCurrentValue(value, map))
318,364✔
1493
                                                {
126,920✔
1494
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readDataMapValue)} method.", NotificationType.None);
126,920✔
1495
                                                }
126,920✔
1496
                                                break;
318,364✔
1497
                                }
1498

1499
                                if (end)
392,008✔
1500
                                {
10,488✔
1501
                                        break;
10,488✔
1502
                                }
1503

1504
                                this._reader.ReadNext();
381,520✔
1505
                        }
381,520✔
1506
                }
10,640✔
1507

1508
                private bool readVisualStyle(CadTemplate template, DxfMap map)
1509
                {
411,192✔
1510
                        switch (this._reader.Code)
411,192✔
1511
                        {
1512
                                // Undocumented codes
1513
                                case 176:
1514
                                case 177:
1515
                                case 420:
1516
                                        return true;
141,178✔
1517
                                default:
1518
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
270,014✔
1519
                        }
1520
                }
411,192✔
1521

1522
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
1523
                {
4,788✔
1524
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,788✔
1525
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,788✔
1526

1527
                        switch (this._reader.Code)
4,788✔
1528
                        {
1529
                                case 10:
1530
                                        filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
456✔
1531
                                        return true;
456✔
1532
                                case 20:
1533
                                        var pt = filter.BoundaryPoints.LastOrDefault();
456✔
1534
                                        filter.BoundaryPoints.Add(new CSMath.XY(pt.X, this._reader.ValueAsDouble));
456✔
1535
                                        return true;
456✔
1536
                                case 40:
1537
                                        if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
456!
1538
                                        {
×
1539
                                                filter.FrontDistance = this._reader.ValueAsDouble;
×
1540
                                                tmp.HasFrontPlane = true;
×
1541
                                        }
×
1542

1543
                                        double[] array = new double[16]
456✔
1544
                                        {
456✔
1545
                                                0.0, 0.0, 0.0, 0.0,
456✔
1546
                                                0.0, 0.0, 0.0, 0.0,
456✔
1547
                                                0.0, 0.0, 0.0, 0.0,
456✔
1548
                                                0.0, 0.0, 0.0, 1.0
456✔
1549
                                        };
456✔
1550

1551
                                        for (int i = 0; i < 12; i++)
11,856✔
1552
                                        {
5,472✔
1553
                                                array[i] = this._reader.ValueAsDouble;
5,472✔
1554

1555
                                                if (i < 11)
5,472✔
1556
                                                {
5,016✔
1557
                                                        this._reader.ReadNext();
5,016✔
1558
                                                }
5,016✔
1559
                                        }
5,472✔
1560

1561
                                        if (tmp.InsertTransformRead)
456!
1562
                                        {
×
1563
                                                filter.InsertTransform = new Matrix4(array);
×
1564
                                                tmp.InsertTransformRead = true;
×
1565
                                        }
×
1566
                                        else
1567
                                        {
456✔
1568
                                                filter.InverseInsertTransform = new Matrix4(array);
456✔
1569
                                        }
456✔
1570

1571
                                        return true;
456✔
1572
                                case 73:
1573
                                default:
1574
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
3,420✔
1575
                        }
1576
                }
4,788✔
1577

1578
                private bool readMLeaderStyle(CadTemplate template, DxfMap map)
1579
                {
21,648✔
1580
                        var tmp = template as CadMLeaderStyleTemplate;
21,648✔
1581

1582
                        switch (this._reader.Code)
21,648✔
1583
                        {
1584
                                case 179:
1585
                                        return true;
242✔
1586
                                case 340:
1587
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
472✔
1588
                                        return true;
472✔
1589
                                case 342:
1590
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
472✔
1591
                                        return true;
472✔
1592
                                default:
1593
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
20,462✔
1594
                        }
1595
                }
21,648✔
1596

1597
                private bool readXRecord(CadTemplate template, DxfMap map)
1598
                {
71,640✔
1599
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
71,640✔
1600

1601
                        switch (this._reader.Code)
71,640✔
1602
                        {
1603
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
18,632✔
1604
                                        this.readXRecordEntries(tmp);
18,632✔
1605
                                        return true;
18,632✔
1606
                                default:
1607
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
53,008✔
1608
                        }
1609
                }
71,640✔
1610

1611
                private void readXRecordEntries(CadXRecordTemplate template)
1612
                {
18,632✔
1613
                        this._reader.ReadNext();
18,632✔
1614

1615
                        while (this._reader.DxfCode != DxfCode.Start)
993,532✔
1616
                        {
974,900✔
1617
                                switch (this._reader.GroupCodeValue)
974,900!
1618
                                {
1619
                                        case GroupCodeValueType.Handle:
1620
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
×
1621
                                                break;
×
1622
                                        default:
1623
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
974,900✔
1624
                                                break;
974,900✔
1625
                                }
1626

1627
                                this._reader.ReadNext();
974,900✔
1628
                        }
974,900✔
1629
                }
18,632✔
1630

1631
                private bool readBookColor(CadTemplate template, DxfMap map)
1632
                {
1,634✔
1633
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,634✔
1634
                        BookColor color = tmp.CadObject as BookColor;
1,634✔
1635

1636
                        switch (this._reader.Code)
1,634✔
1637
                        {
1638
                                case 430:
1639
                                        color.Name = this._reader.ValueAsString;
190✔
1640
                                        return true;
190✔
1641
                                default:
1642
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,444✔
1643
                        }
1644
                }
1,634✔
1645

1646
                private bool readDictionary(CadTemplate template, DxfMap map)
1647
                {
219,815✔
1648
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
219,815✔
1649
                        CadDictionary cadDictionary = tmp.CadObject;
219,815✔
1650

1651
                        switch (this._reader.Code)
219,815✔
1652
                        {
1653
                                case 280:
1654
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
15,931✔
1655
                                        return true;
15,931✔
1656
                                case 281:
1657
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
23,530✔
1658
                                        return true;
23,530✔
1659
                                case 3:
1660
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
49,999✔
1661
                                        return true;
49,999✔
1662
                                case 350: // Soft-owner ID/handle to entry object 
1663
                                case 360: // Hard-owner ID/handle to entry object
1664
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
49,999✔
1665
                                        return true;
49,999✔
1666
                                default:
1667
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
80,356✔
1668
                        }
1669
                }
219,815✔
1670

1671
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
1672
                {
2,070✔
1673
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
2,070✔
1674

1675
                        switch (this._reader.Code)
2,070✔
1676
                        {
1677
                                case 340:
1678
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
230✔
1679
                                        return true;
230✔
1680
                                default:
1681
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,840!
1682
                                        {
1,840✔
1683
                                                return this.readDictionary(template, map);
1,840✔
1684
                                        }
1685
                                        return true;
×
1686
                        }
1687
                }
2,070✔
1688

1689
                private CadTemplate readSortentsTable()
1690
                {
684✔
1691
                        SortEntitiesTable sortTable = new SortEntitiesTable();
684✔
1692
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
684✔
1693

1694
                        //Jump the 0 marker
1695
                        this._reader.ReadNext();
684✔
1696

1697
                        this.readCommonObjectData(template);
684✔
1698

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

1701
                        //Jump the 100 marker
1702
                        this._reader.ReadNext();
684✔
1703

1704
                        (ulong?, ulong?) pair = (null, null);
684✔
1705

1706
                        while (this._reader.DxfCode != DxfCode.Start)
5,016✔
1707
                        {
4,332✔
1708
                                switch (this._reader.Code)
4,332!
1709
                                {
1710
                                        case 5:
1711
                                                pair.Item1 = this._reader.ValueAsHandle;
1,824✔
1712
                                                break;
1,824✔
1713
                                        case 330:
1714
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
684✔
1715
                                                break;
684✔
1716
                                        case 331:
1717
                                                pair.Item2 = this._reader.ValueAsHandle;
1,824✔
1718
                                                break;
1,824✔
1719
                                        default:
1720
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
1721
                                                break;
×
1722
                                }
1723

1724
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
4,332✔
1725
                                {
1,824✔
1726
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,824✔
1727
                                        pair = (null, null);
1,824✔
1728
                                }
1,824✔
1729

1730
                                this._reader.ReadNext();
4,332✔
1731
                        }
4,332✔
1732

1733
                        return template;
684✔
1734
                }
684✔
1735
        }
1736
}
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

© 2025 Coveralls, Inc