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

DomCR / ACadSharp / 20814849836

08 Jan 2026 11:11AM UTC coverage: 77.141% (+0.09%) from 77.05%
20814849836

Pull #936

github

web-flow
Merge bd2f27d38 into 7f1bd3a9b
Pull Request #936: Table style dwg implementation

7887 of 11083 branches covered (71.16%)

Branch coverage included in aggregate %.

218 of 239 new or added lines in 11 files covered. (91.21%)

2 existing lines in 2 files now uncovered.

28744 of 36403 relevant lines covered (78.96%)

149874.68 hits per line

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

85.15
/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.Collections.Generic;
9
using System.Diagnostics;
10
using System.IO;
11
using System.Linq;
12
using static ACadSharp.IO.Templates.CadEvaluationGraphTemplate;
13
using static ACadSharp.IO.Templates.CadTableEntityTemplate;
14

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

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

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

31
                        //Loop until the section ends
32
                        while (this._reader.ValueAsString != DxfFileToken.EndSection)
77,155✔
33
                        {
76,949✔
34
                                CadTemplate template = null;
76,949✔
35

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

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

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

51
                                if (template == null)
76,949✔
52
                                        continue;
×
53

54
                                //Add the object and the template to the builder
55
                                this._builder.AddTemplate(template);
76,949✔
56
                        }
76,949✔
57
                }
206✔
58

59
                private CadTemplate readObject()
60
                {
76,949✔
61
                        switch (this._reader.ValueAsString)
76,949!
62
                        {
63
                                case DxfFileToken.ObjectPlaceholder:
64
                                        return this.readObjectCodes<AcdbPlaceHolder>(new CadNonGraphicalObjectTemplate(new AcdbPlaceHolder()), this.readObjectSubclassMap);
194✔
65
                                case DxfFileToken.ObjectDBColor:
66
                                        return this.readObjectCodes<BookColor>(new CadNonGraphicalObjectTemplate(new BookColor()), this.readBookColor);
192✔
67
                                case DxfFileToken.ObjectDictionary:
68
                                        return this.readObjectCodes<CadDictionary>(new CadDictionaryTemplate(), this.readDictionary);
21,200✔
69
                                case DxfFileToken.ObjectDictionaryWithDefault:
70
                                        return this.readObjectCodes<CadDictionaryWithDefault>(new CadDictionaryWithDefaultTemplate(), this.readDictionaryWithDefault);
194✔
71
                                case DxfFileToken.ObjectLayout:
72
                                        return this.readObjectCodes<Layout>(new CadLayoutTemplate(), this.readLayout);
798✔
73
                                case DxfFileToken.ObjectPlotSettings:
74
                                        return this.readObjectCodes<PlotSettings>(new CadNonGraphicalObjectTemplate(new PlotSettings()), this.readPlotSettings);
×
75
                                case DxfFileToken.ObjectEvalGraph:
76
                                        return this.readObjectCodes<EvaluationGraph>(new CadEvaluationGraphTemplate(), this.readEvaluationGraph);
448✔
77
                                case DxfFileToken.ObjectImageDefinition:
78
                                        return this.readObjectCodes<ImageDefinition>(new CadNonGraphicalObjectTemplate(new ImageDefinition()), this.readObjectSubclassMap);
192✔
79
                                case DxfFileToken.ObjectDictionaryVar:
80
                                        return this.readObjectCodes<DictionaryVariable>(new CadTemplate<DictionaryVariable>(new DictionaryVariable()), this.readObjectSubclassMap);
2,787✔
81
                                case DxfFileToken.ObjectPdfDefinition:
82
                                        return this.readObjectCodes<PdfUnderlayDefinition>(new CadNonGraphicalObjectTemplate(new PdfUnderlayDefinition()), this.readObjectSubclassMap);
192✔
83
                                case DxfFileToken.ObjectSortEntsTable:
84
                                        return this.readSortentsTable();
576✔
85
                                case DxfFileToken.ObjectImageDefinitionReactor:
86
                                        return this.readObjectCodes<ImageDefinitionReactor>(new CadNonGraphicalObjectTemplate(new ImageDefinitionReactor()), this.readObjectSubclassMap);
192✔
87
                                case DxfFileToken.ObjectProxyObject:
88
                                        return this.readObjectCodes<ProxyObject>(new CadNonGraphicalObjectTemplate(new ProxyObject()), this.readProxyObject);
×
89
                                case DxfFileToken.ObjectRasterVariables:
90
                                        return this.readObjectCodes<RasterVariables>(new CadNonGraphicalObjectTemplate(new RasterVariables()), this.readObjectSubclassMap);
192✔
91
                                case DxfFileToken.ObjectGroup:
92
                                        return this.readObjectCodes<Group>(new CadGroupTemplate(), this.readGroup);
384✔
93
                                case DxfFileToken.ObjectGeoData:
94
                                        return this.readObjectCodes<GeoData>(new CadGeoDataTemplate(), this.readGeoData);
2✔
95
                                case DxfFileToken.ObjectMaterial:
96
                                        return this.readObjectCodes<Material>(new CadMaterialTemplate(), this.readMaterial);
2,118✔
97
                                case DxfFileToken.ObjectScale:
98
                                        return this.readObjectCodes<Scale>(new CadTemplate<Scale>(new Scale()), this.readScale);
6,606✔
99
                                case DxfFileToken.ObjectTableContent:
100
                                        return this.readObjectCodes<TableContent>(new CadTableContentTemplate(), this.readTableContent);
320✔
101
                                case DxfFileToken.ObjectVisualStyle:
102
                                        return this.readObjectCodes<VisualStyle>(new CadTemplate<VisualStyle>(new VisualStyle()), this.readVisualStyle);
4,656✔
103
                                case DxfFileToken.ObjectSpatialFilter:
104
                                        return this.readObjectCodes<SpatialFilter>(new CadSpatialFilterTemplate(), this.readSpatialFilter);
192✔
105
                                case DxfFileToken.ObjectMLineStyle:
106
                                        return this.readObjectCodes<MLineStyle>(new CadMLineStyleTemplate(), this.readMLineStyle);
206✔
107
                                case DxfFileToken.ObjectMLeaderStyle:
108
                                        return this.readObjectCodes<MultiLeaderStyle>(new CadMLeaderStyleTemplate(), this.readMLeaderStyle);
400✔
109
                                case DxfFileToken.ObjectTableStyle:
110
                                        return this.readObjectCodes<TableStyle>(new CadTableStyleTemplate(), this.readTableStyle);
194✔
111
                                case DxfFileToken.ObjectXRecord:
112
                                        return this.readObjectCodes<XRecord>(new CadXRecordTemplate(), this.readXRecord);
28,882✔
113
                                default:
114
                                        DxfMap map = DxfMap.Create<CadObject>();
5,832✔
115
                                        CadUnknownNonGraphicalObjectTemplate unknownEntityTemplate = null;
5,832✔
116
                                        if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
5,832!
117
                                        {
5,832✔
118
                                                this._builder.Notify($"NonGraphicalObject not supported read as an UnknownNonGraphicalObject: {this._reader.ValueAsString}", NotificationType.NotImplemented);
5,832✔
119
                                                unknownEntityTemplate = new CadUnknownNonGraphicalObjectTemplate(new UnknownNonGraphicalObject(dxfClass));
5,832✔
120
                                        }
5,832✔
121
                                        else
122
                                        {
×
123
                                                this._builder.Notify($"UnknownNonGraphicalObject not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
×
124
                                        }
×
125

126
                                        this._reader.ReadNext();
5,832✔
127

128
                                        do
129
                                        {
281,891✔
130
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
281,891!
131
                                                {
34,320✔
132
                                                        this.readCommonCodes(unknownEntityTemplate, out bool isExtendedData, map);
34,320✔
133
                                                        if (isExtendedData)
34,320✔
134
                                                                continue;
24✔
135
                                                }
34,296✔
136

137
                                                this._reader.ReadNext();
281,867✔
138
                                        }
281,867✔
139
                                        while (this._reader.DxfCode != DxfCode.Start);
281,891✔
140

141
                                        return unknownEntityTemplate;
5,832✔
142
                        }
143
                }
76,949✔
144

145
                protected CadTemplate readObjectCodes<T>(CadTemplate template, ReadObjectDelegate<T> readObject)
146
                        where T : CadObject
147
                {
70,541✔
148
                        this._reader.ReadNext();
70,541✔
149

150
                        DxfMap map = DxfMap.Create<T>();
70,541✔
151

152
                        while (this._reader.DxfCode != DxfCode.Start)
1,004,893✔
153
                        {
934,352✔
154
                                if (!readObject(template, map))
934,352✔
155
                                {
223,649✔
156
                                        this.readCommonCodes(template, out bool isExtendedData, map);
223,649✔
157
                                        if (isExtendedData)
223,649✔
158
                                                continue;
2,981✔
159
                                }
220,668✔
160

161
                                if (this.lockPointer)
931,371✔
162
                                {
1,152✔
163
                                        this.lockPointer = false;
1,152✔
164
                                        continue;
1,152✔
165
                                }
166

167
                                if (this._reader.DxfCode != DxfCode.Start)
930,219✔
168
                                {
900,889✔
169
                                        this._reader.ReadNext();
900,889✔
170
                                }
900,889✔
171
                        }
930,219✔
172

173
                        return template;
70,541✔
174
                }
70,541✔
175

176
                private bool readProxyObject(CadTemplate template, DxfMap map)
177
                {
×
178
                        ProxyObject proxy = template.CadObject as ProxyObject;
×
179

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

223
                private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
224
                {
23,184✔
225
                        switch (this._reader.Code)
23,184✔
226
                        {
227
                                default:
228
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
23,184✔
229
                        }
230
                }
23,184✔
231

232
                private bool readPlotSettings(CadTemplate template, DxfMap map)
233
                {
25,252✔
234
                        switch (this._reader.Code)
25,252✔
235
                        {
236
                                default:
237
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
25,252✔
238
                        }
239
                }
25,252✔
240

241
                private bool readEvaluationGraph(CadTemplate template, DxfMap map)
242
                {
3,072✔
243
                        CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
3,072✔
244
                        EvaluationGraph evGraph = tmp.CadObject;
3,072✔
245

246
                        switch (this._reader.Code)
3,072✔
247
                        {
248
                                case 91:
249
                                        while (this._reader.Code == 91)
3,008✔
250
                                        {
2,560✔
251
                                                GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
2,560✔
252
                                                EvaluationGraph.Node node = nodeTemplate.Node;
2,560✔
253

254
                                                node.Index = this._reader.ValueAsInt;
2,560✔
255

256
                                                this._reader.ExpectedCode(93);
2,560✔
257
                                                node.Flags = this._reader.ValueAsInt;
2,560✔
258

259
                                                this._reader.ExpectedCode(95);
2,560✔
260
                                                node.NextNodeIndex = this._reader.ValueAsInt;
2,560✔
261

262
                                                this._reader.ExpectedCode(360);
2,560✔
263
                                                nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
2,560✔
264

265
                                                this._reader.ExpectedCode(92);
2,560✔
266
                                                node.Data1 = this._reader.ValueAsInt;
2,560✔
267
                                                this._reader.ExpectedCode(92);
2,560✔
268
                                                node.Data2 = this._reader.ValueAsInt;
2,560✔
269
                                                this._reader.ExpectedCode(92);
2,560✔
270
                                                node.Data3 = this._reader.ValueAsInt;
2,560✔
271
                                                this._reader.ExpectedCode(92);
2,560✔
272
                                                node.Data4 = this._reader.ValueAsInt;
2,560✔
273

274
                                                this._reader.ReadNext();
2,560✔
275

276
                                                tmp.NodeTemplates.Add(nodeTemplate);
2,560✔
277
                                        }
2,560✔
278

279
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
448✔
280
                                case 92:
281
                                        //Edges
282
                                        while (this._reader.Code == 92)
2,112✔
283
                                        {
1,920✔
284
                                                this._reader.ExpectedCode(93);
1,920✔
285
                                                this._reader.ExpectedCode(94);
1,920✔
286
                                                this._reader.ExpectedCode(91);
1,920✔
287
                                                this._reader.ExpectedCode(91);
1,920✔
288
                                                this._reader.ExpectedCode(92);
1,920✔
289
                                                this._reader.ExpectedCode(92);
1,920✔
290
                                                this._reader.ExpectedCode(92);
1,920✔
291
                                                this._reader.ExpectedCode(92);
1,920✔
292
                                                this._reader.ExpectedCode(92);
1,920✔
293

294
                                                this._reader.ReadNext();
1,920✔
295
                                        }
1,920✔
296

297
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
192✔
298
                                default:
299
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
2,432✔
300
                        }
301
                }
3,072✔
302

303
                private bool readLayout(CadTemplate template, DxfMap map)
304
                {
51,406✔
305
                        CadLayoutTemplate tmp = template as CadLayoutTemplate;
51,406✔
306

307
                        switch (this._reader.Code)
51,406✔
308
                        {
309
                                case 330:
310
                                        tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
1,596✔
311
                                        return true;
1,596✔
312
                                case 331:
313
                                        tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
770✔
314
                                        return true;
770✔
315
                                default:
316
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
49,040✔
317
                                        {
25,252✔
318
                                                return this.readPlotSettings(template, map);
25,252✔
319
                                        }
320
                                        return true;
23,788✔
321
                        }
322
                }
51,406✔
323

324
                private bool readGroup(CadTemplate template, DxfMap map)
325
                {
4,992✔
326
                        CadGroupTemplate tmp = template as CadGroupTemplate;
4,992✔
327

328
                        switch (this._reader.Code)
4,992✔
329
                        {
330
                                case 70:
331
                                        return true;
384✔
332
                                case 340:
333
                                        tmp.Handles.Add(this._reader.ValueAsHandle);
2,304✔
334
                                        return true;
2,304✔
335
                                default:
336
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,304✔
337
                        }
338
                }
4,992✔
339

340
                private bool readGeoData(CadTemplate template, DxfMap map)
341
                {
102✔
342
                        CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
343

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

384
                                                this._reader.ReadNext();
24✔
385
                                                double destX = this._reader.ValueAsDouble;
24✔
386
                                                this._reader.ReadNext();
24✔
387
                                                double destY = this._reader.ValueAsDouble;
24✔
388

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

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

448
                private bool readMaterial(CadTemplate template, DxfMap map)
449
                {
42,036✔
450
                        CadMaterialTemplate tmp = template as CadMaterialTemplate;
42,036✔
451
                        List<double> arr = null;
42,036✔
452

453
                        switch (this._reader.Code)
42,036!
454
                        {
455
                                case 43:
456
                                        arr = new();
1,346✔
457
                                        for (int i = 0; i < 16; i++)
45,764✔
458
                                        {
21,536✔
459
                                                Debug.Assert(this._reader.Code == 43);
21,536✔
460

461
                                                arr.Add(this._reader.ValueAsDouble);
21,536✔
462

463
                                                this._reader.ReadNext();
21,536✔
464
                                        }
21,536✔
465

466
                                        tmp.CadObject.DiffuseMatrix = new CSMath.Matrix4(arr.ToArray());
1,346✔
467
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,346✔
468
                                case 47:
469
                                        arr = new();
×
470
                                        for (int i = 0; i < 16; i++)
×
471
                                        {
×
472
                                                Debug.Assert(this._reader.Code == 47);
×
473

474
                                                arr.Add(this._reader.ValueAsDouble);
×
475

476
                                                this._reader.ReadNext();
×
477
                                        }
×
478

479
                                        tmp.CadObject.SpecularMatrix = new CSMath.Matrix4(arr.ToArray());
×
480
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
481
                                case 49:
482
                                        arr = new();
194✔
483
                                        for (int i = 0; i < 16; i++)
6,596✔
484
                                        {
3,104✔
485
                                                Debug.Assert(this._reader.Code == 49);
3,104✔
486

487
                                                arr.Add(this._reader.ValueAsDouble);
3,104✔
488

489
                                                this._reader.ReadNext();
3,104✔
490
                                        }
3,104✔
491

492
                                        tmp.CadObject.ReflectionMatrix = new CSMath.Matrix4(arr.ToArray());
194✔
493
                                        return this.checkObjectEnd(template, map, this.readMaterial);
194✔
494
                                case 142:
495
                                        arr = new();
194✔
496
                                        for (int i = 0; i < 16; i++)
6,596✔
497
                                        {
3,104✔
498
                                                Debug.Assert(this._reader.Code == 142);
3,104✔
499

500
                                                arr.Add(this._reader.ValueAsDouble);
3,104✔
501

502
                                                this._reader.ReadNext();
3,104✔
503
                                        }
3,104✔
504

505
                                        tmp.CadObject.OpacityMatrix = new CSMath.Matrix4(arr.ToArray());
194✔
506
                                        return this.checkObjectEnd(template, map, this.readMaterial);
194✔
507
                                case 144:
508
                                        arr = new();
1,154✔
509
                                        for (int i = 0; i < 16; i++)
39,236✔
510
                                        {
18,464✔
511
                                                Debug.Assert(this._reader.Code == 144);
18,464✔
512

513
                                                arr.Add(this._reader.ValueAsDouble);
18,464✔
514

515
                                                this._reader.ReadNext();
18,464✔
516
                                        }
18,464✔
517

518
                                        tmp.CadObject.BumpMatrix = new CSMath.Matrix4(arr.ToArray());
1,154✔
519
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,154✔
520
                                case 147:
521
                                        arr = new();
×
522
                                        for (int i = 0; i < 16; i++)
×
523
                                        {
×
524
                                                Debug.Assert(this._reader.Code == 147);
×
525

526
                                                arr.Add(this._reader.ValueAsDouble);
×
527

528
                                                this._reader.ReadNext();
×
529
                                        }
×
530

531
                                        tmp.CadObject.RefractionMatrix = new CSMath.Matrix4(arr.ToArray());
×
532
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
533
                                default:
534
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
39,148✔
535
                        }
536
                }
42,036✔
537

538
                private bool readScale(CadTemplate template, DxfMap map)
539
                {
59,250✔
540
                        switch (this._reader.Code)
59,250✔
541
                        {
542
                                // Undocumented codes
543
                                case 70:
544
                                        //Always 0
545
                                        return true;
6,606✔
546
                                default:
547
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
52,644✔
548
                        }
549
                }
59,250✔
550

551
                private void readLinkedData(CadTemplate template, DxfMap map)
552
                {
320✔
553
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
554
                        LinkedData linkedData = tmp.CadObject;
320✔
555

556
                        this._reader.ReadNext();
320✔
557

558
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
960!
559
                        {
640✔
560
                                switch (this._reader.Code)
640✔
561
                                {
562
                                        default:
563
                                                if (!this.tryAssignCurrentValue(linkedData, map.SubClasses[DxfSubclassMarker.LinkedData]))
640!
564
                                                {
×
565
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedData)} {this._reader.Position}.", NotificationType.None);
×
566
                                                }
×
567
                                                break;
640✔
568
                                }
569

570
                                this._reader.ReadNext();
640✔
571
                        }
640✔
572
                }
320✔
573

574
                private bool readTableContent(CadTemplate template, DxfMap map)
575
                {
2,368✔
576
                        switch (this._reader.Code)
2,368✔
577
                        {
578
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.TableContent, StringComparison.InvariantCultureIgnoreCase):
1,216✔
579
                                        this.readTableContentSubclass(template, map);
256✔
580
                                        this.lockPointer = true;
256✔
581
                                        return true;
256✔
582
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.FormattedTableData, StringComparison.InvariantCultureIgnoreCase):
960✔
583
                                        this.readFormattedTableDataSubclass(template, map);
256✔
584
                                        this.lockPointer = true;
256✔
585
                                        return true;
256✔
586
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedTableData, StringComparison.InvariantCultureIgnoreCase):
704✔
587
                                        this.readLinkedTableDataSubclass(template, map);
320✔
588
                                        this.lockPointer = true;
320✔
589
                                        return true;
320✔
590
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedData, StringComparison.InvariantCultureIgnoreCase):
384✔
591
                                        this.readLinkedData(template, map);
320✔
592
                                        this.lockPointer = true;
320✔
593
                                        return true;
320✔
594
                                default:
595
                                        return false;
1,216✔
596
                        }
597
                }
2,368✔
598

599
                private void readTableContentSubclass(CadTemplate template, DxfMap map)
600
                {
256✔
601
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
602
                        TableContent tableContent = tmp.CadObject;
256✔
603

604
                        this._reader.ReadNext();
256✔
605

606
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
512✔
607
                        {
256✔
608
                                switch (this._reader.Code)
256!
609
                                {
610
                                        case 340:
611
                                                tmp.SytleHandle = this._reader.ValueAsHandle;
256✔
612
                                                break;
256✔
613
                                        default:
614
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.TableContent]))
×
615
                                                {
×
616
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableContentSubclass)} {this._reader.Position}.", NotificationType.None);
×
617
                                                }
×
618
                                                break;
×
619
                                }
620

621
                                this._reader.ReadNext();
256✔
622
                        }
256✔
623
                }
256✔
624

625
                private void readFormattedTableDataSubclass(CadTemplate template, DxfMap map)
626
                {
256✔
627
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
256✔
628
                        FormattedTableData formattedTable = tmp.CadObject;
256✔
629

630
                        this._reader.ReadNext();
256✔
631

632
                        TableEntity.CellRange cellRange = null;
256✔
633
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
2,304!
634
                        {
2,048✔
635
                                switch (this._reader.Code)
2,048!
636
                                {
637
                                        case 90:
638
                                                break;
256✔
639
                                        case 91:
640
                                                if (cellRange == null)
384✔
641
                                                {
384✔
642
                                                        cellRange = new();
384✔
643
                                                        formattedTable.MergedCellRanges.Add(cellRange);
384✔
644
                                                }
384✔
645
                                                cellRange.TopRowIndex = this._reader.ValueAsInt;
384✔
646
                                                break;
384✔
647
                                        case 92:
648
                                                if (cellRange == null)
384!
649
                                                {
×
650
                                                        cellRange = new();
×
651
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
652
                                                }
×
653
                                                cellRange.LeftColumnIndex = this._reader.ValueAsInt;
384✔
654
                                                break;
384✔
655
                                        case 93:
656
                                                if (cellRange == null)
384!
657
                                                {
×
658
                                                        cellRange = new();
×
659
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
660
                                                }
×
661
                                                cellRange.BottomRowIndex = this._reader.ValueAsInt;
384✔
662
                                                break;
384✔
663
                                        case 94:
664
                                                if (cellRange == null)
384!
665
                                                {
×
666
                                                        cellRange = new();
×
667
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
668
                                                }
×
669
                                                cellRange.RightColumnIndex = this._reader.ValueAsInt;
384✔
670
                                                cellRange = null;
384✔
671
                                                break;
384✔
672
                                        case 300 when this._reader.ValueAsString.Equals("TABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
256!
673
                                                this.readStyleOverride(new CadCellStyleTemplate(formattedTable.CellStyleOverride));
256✔
674
                                                break;
256✔
675
                                        default:
676
                                                if (!this.tryAssignCurrentValue(formattedTable, map.SubClasses[DxfSubclassMarker.FormattedTableData]))
×
677
                                                {
×
678
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
×
679
                                                }
×
680
                                                break;
×
681
                                }
682

683
                                this._reader.ReadNext();
2,048✔
684
                        }
2,048✔
685
                }
256✔
686

687
                private void readLinkedTableDataSubclass(CadTemplate template, DxfMap map)
688
                {
320✔
689
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
320✔
690
                        TableContent tableContent = tmp.CadObject;
320✔
691

692
                        this._reader.ReadNext();
320✔
693

694
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
4,224!
695
                        {
3,904✔
696
                                switch (this._reader.Code)
3,904✔
697
                                {
698
                                        case 90:
699
                                                //Column count
700
                                                break;
320✔
701
                                        case 91:
702
                                                //Row count
703
                                                break;
320✔
704
                                        //Unknown
705
                                        case 92:
706
                                                break;
256✔
707
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumn, StringComparison.InvariantCultureIgnoreCase):
1,216✔
708
                                                //Read Column
709
                                                this.readTableColumn();
1,216✔
710
                                                break;
1,216✔
711
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRow, StringComparison.InvariantCultureIgnoreCase):
1,472✔
712
                                                //Read Row
713
                                                this.readTableRow();
1,472✔
714
                                                break;
1,472✔
715
                                        default:
716
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.LinkedTableData]))
320✔
717
                                                {
320✔
718
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
320✔
719
                                                }
320✔
720
                                                break;
320✔
721
                                }
722

723
                                this._reader.ReadNext();
3,904✔
724
                        }
3,904✔
725
                }
320✔
726

727

728
                private TableEntity.Column readTableColumn()
729
                {
1,216✔
730
                        this._reader.ReadNext();
1,216✔
731

732
                        TableEntity.Column column = new TableEntity.Column();
1,216✔
733

734
                        bool end = false;
1,216✔
735
                        while (this._reader.DxfCode != DxfCode.Start)
3,648!
736
                        {
3,648✔
737
                                switch (this._reader.Code)
3,648!
738
                                {
739
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
3,648✔
740
                                                this.readLinkedTableColumn(column);
1,216✔
741
                                                break;
1,216✔
742
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
2,432✔
743
                                                this.readFormattedTableColumn(column);
1,216✔
744
                                                break;
1,216✔
745
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumnBegin, StringComparison.InvariantCultureIgnoreCase):
1,216!
746
                                                this.readTableColumn(column);
1,216✔
747
                                                end = true;
1,216✔
748
                                                break;
1,216✔
749
                                        default:
750
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
751
                                                break;
×
752
                                }
753

754
                                if (end)
3,648✔
755
                                {
1,216✔
756
                                        return column;
1,216✔
757
                                }
758

759
                                this._reader.ReadNext();
2,432✔
760
                        }
2,432✔
761

762
                        return column;
×
763
                }
1,216✔
764

765
                private TableEntity.Row readTableRow()
766
                {
1,472✔
767
                        this._reader.ReadNext();
1,472✔
768

769
                        TableEntity.Row row = new TableEntity.Row();
1,472✔
770

771
                        bool end = false;
1,472✔
772
                        while (this._reader.DxfCode != DxfCode.Start)
11,904✔
773
                        {
11,840✔
774
                                switch (this._reader.Code)
11,840✔
775
                                {
776
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
6,016✔
777
                                                this.readLinkedTableRow(row);
1,536✔
778
                                                break;
1,536✔
779
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
4,480✔
780
                                                this.readFormattedTableRow(row);
1,408✔
781
                                                break;
1,408✔
782
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRowBegin, StringComparison.InvariantCultureIgnoreCase):
3,072✔
783
                                                this.readTableRow(row);
1,408✔
784
                                                end = true;
1,408✔
785
                                                break;
1,408✔
786
                                        default:
787
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
7,488✔
788
                                                break;
7,488✔
789
                                }
790

791
                                if (end)
11,840✔
792
                                {
1,408✔
793
                                        return row;
1,408✔
794
                                }
795

796
                                this._reader.ReadNext();
10,432✔
797
                        }
10,432✔
798

799
                        return row;
64✔
800
                }
1,472✔
801

802
                private void readTableRow(TableEntity.Row row)
803
                {
1,408✔
804
                        this._reader.ReadNext();
1,408✔
805

806
                        bool end = false;
1,408✔
807
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
808
                        {
4,224✔
809
                                switch (this._reader.Code)
4,224!
810
                                {
811
                                        case 40:
812
                                                row.Height = this._reader.ValueAsDouble;
1,408✔
813
                                                break;
1,408✔
814
                                        case 90:
815
                                                //styleID
816
                                                break;
1,408✔
817
                                        case 309:
818
                                                end = this._reader.ValueAsString.Equals("TABLEROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
819
                                                break;
1,408✔
820
                                        default:
821
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
×
822
                                                break;
×
823
                                }
824

825
                                if (end)
4,224✔
826
                                {
1,408✔
827
                                        break;
1,408✔
828
                                }
829

830
                                this._reader.ReadNext();
2,816✔
831
                        }
2,816✔
832
                }
1,408✔
833

834
                private void readFormattedTableRow(TableEntity.Row row)
835
                {
1,408✔
836
                        this._reader.ReadNext();
1,408✔
837

838
                        bool end = false;
1,408✔
839
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
840
                        {
4,224✔
841
                                switch (this._reader.Code)
4,224!
842
                                {
843
                                        case 300 when this._reader.ValueAsString.Equals("ROWTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,408!
844
                                                break;
1,408✔
845
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,408!
846
                                                this.readStyleOverride(new CadCellStyleTemplate(row.CellStyleOverride));
1,408✔
847
                                                break;
1,408✔
848
                                        case 309:
849
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATAROW_END", StringComparison.InvariantCultureIgnoreCase);
1,408✔
850
                                                break;
1,408✔
851
                                        default:
852
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableRow)} method.", NotificationType.None);
×
853
                                                break;
×
854
                                }
855

856
                                if (end)
4,224✔
857
                                {
1,408✔
858
                                        break;
1,408✔
859
                                }
860

861
                                this._reader.ReadNext();
2,816✔
862
                        }
2,816✔
863
                }
1,408✔
864

865
                private void readTableColumn(TableEntity.Column column)
866
                {
1,216✔
867
                        this._reader.ReadNext();
1,216✔
868

869
                        bool end = false;
1,216✔
870
                        while (this._reader.DxfCode != DxfCode.Start)
3,648✔
871
                        {
3,648✔
872
                                switch (this._reader.Code)
3,648!
873
                                {
874
                                        case 1 when this._reader.ValueAsString.Equals("TABLECOLUMN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
875
                                                break;
×
876
                                        case 1:
877
                                                end = true;
×
878
                                                break;
×
879
                                        case 40:
880
                                                column.Width = this._reader.ValueAsDouble;
1,216✔
881
                                                break;
1,216✔
882
                                        case 90:
883
                                                //StyleId
884
                                                break;
1,216✔
885
                                        case 309:
886
                                                end = this._reader.ValueAsString.Equals("TABLECOLUMN_END", StringComparison.InvariantCultureIgnoreCase);
1,216✔
887
                                                break;
1,216✔
888
                                        default:
889
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
890
                                                break;
×
891
                                }
892

893
                                if (end)
3,648✔
894
                                {
1,216✔
895
                                        break;
1,216✔
896
                                }
897

898
                                this._reader.ReadNext();
2,432✔
899
                        }
2,432✔
900
                }
1,216✔
901

902
                private void readLinkedTableColumn(TableEntity.Column column)
903
                {
1,216✔
904
                        this._reader.ReadNext();
1,216✔
905

906
                        bool end = false;
1,216✔
907
                        while (this._reader.DxfCode != DxfCode.Start)
4,864✔
908
                        {
4,864✔
909
                                switch (this._reader.Code)
4,864!
910
                                {
911
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
912
                                                break;
×
913
                                        case 1:
914
                                                end = true;
×
915
                                                break;
×
916
                                        case 91:
917
                                                column.CustomData = this._reader.ValueAsInt;
1,216✔
918
                                                break;
1,216✔
919
                                        case 300:
920
                                                column.Name = this._reader.ValueAsString;
1,216✔
921
                                                break;
1,216✔
922
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,216!
923
                                                this.readCustomData();
1,216✔
924
                                                break;
1,216✔
925
                                        case 309:
926
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,216✔
927
                                                break;
1,216✔
928
                                        default:
929
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableColumn)} method.", NotificationType.None);
×
930
                                                break;
×
931
                                }
932

933
                                if (end)
4,864✔
934
                                {
1,216✔
935
                                        break;
1,216✔
936
                                }
937

938
                                this._reader.ReadNext();
3,648✔
939
                        }
3,648✔
940
                }
1,216✔
941

942
                private void readLinkedTableRow(TableEntity.Row row)
943
                {
1,536✔
944
                        this._reader.ReadNext();
1,536✔
945

946
                        bool end = false;
1,536✔
947
                        while (this._reader.DxfCode != DxfCode.Start)
12,608✔
948
                        {
12,480✔
949
                                switch (this._reader.Code)
12,480!
950
                                {
951
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
✔
952
                                                break;
×
953
                                        case 90:
954
                                                break;
1,536✔
955
                                        case 91:
956
                                                row.CustomData = this._reader.ValueAsInt;
1,408✔
957
                                                break;
1,408✔
958
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectCell, StringComparison.InvariantCultureIgnoreCase):
5,376✔
959
                                                this.readCell();
5,376✔
960
                                                break;
5,376✔
961
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,408✔
962
                                                this.readCustomData();
1,408✔
963
                                                break;
1,408✔
964
                                        case 309:
965
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_END, StringComparison.InvariantCultureIgnoreCase);
1,408✔
966
                                                break;
1,408✔
967
                                        default:
968
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableRow)} method.", NotificationType.None);
1,344✔
969
                                                break;
1,344✔
970
                                }
971

972
                                if (end)
12,480✔
973
                                {
1,408✔
974
                                        break;
1,408✔
975
                                }
976

977
                                this._reader.ReadNext();
11,072✔
978
                        }
11,072✔
979
                }
1,536✔
980

981
                private TableEntity.Cell readCell()
982
                {
5,376✔
983
                        this._reader.ReadNext();
5,376✔
984

985
                        TableEntity.Cell cell = new TableEntity.Cell();
5,376✔
986
                        CadTableCellTemplate template = new CadTableCellTemplate(cell);
5,376✔
987

988
                        bool end = false;
5,376✔
989
                        while (this._reader.DxfCode != DxfCode.Start)
16,960✔
990
                        {
16,832✔
991
                                switch (this._reader.Code)
16,832✔
992
                                {
993
                                        case 1 when this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
15,872✔
994
                                                this.readLinkedTableCell(cell);
5,376✔
995
                                                break;
5,376✔
996
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
10,496✔
997
                                                this.readFormattedTableCell(cell);
5,248✔
998
                                                break;
5,248✔
999
                                        case 1 when this._reader.ValueAsString.Equals("TABLECELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248✔
1000
                                                this.readTableCell(cell);
5,248✔
1001
                                                end = true;
5,248✔
1002
                                                break;
5,248✔
1003
                                        default:
1004
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCell)} method.", NotificationType.None);
960✔
1005
                                                break;
960✔
1006
                                }
1007

1008
                                if (end)
16,832✔
1009
                                {
5,248✔
1010
                                        return cell;
5,248✔
1011
                                }
1012

1013
                                this._reader.ReadNext();
11,584✔
1014
                        }
11,584✔
1015

1016
                        return cell;
128✔
1017
                }
5,376✔
1018

1019
                private void readTableCell(TableEntity.Cell cell)
1020
                {
5,248✔
1021
                        var map = DxfClassMap.Create(cell.GetType(), "TABLECELL_BEGIN");
5,248✔
1022

1023
                        this._reader.ReadNext();
5,248✔
1024

1025
                        bool end = false;
5,248✔
1026
                        while (this._reader.DxfCode != DxfCode.Start)
16,384✔
1027
                        {
16,384✔
1028
                                switch (this._reader.Code)
16,384✔
1029
                                {
1030
                                        //Unknown
1031
                                        case 40:
1032
                                        case 41:
1033
                                                break;
256✔
1034
                                        case 309:
1035
                                                end = this._reader.ValueAsString.Equals("TABLECELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1036
                                                break;
5,248✔
1037
                                        case 330:
1038
                                                //Unknown handle
1039
                                                break;
128✔
1040
                                        default:
1041
                                                if (!this.tryAssignCurrentValue(cell, map))
10,752!
1042
                                                {
×
1043
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableCell)} {this._reader.Position}.", NotificationType.None);
×
1044
                                                }
×
1045
                                                break;
10,752✔
1046
                                }
1047

1048
                                if (end)
16,384✔
1049
                                {
5,248✔
1050
                                        break;
5,248✔
1051
                                }
1052

1053
                                this._reader.ReadNext();
11,136✔
1054
                        }
11,136✔
1055
                }
5,248✔
1056

1057
                private void readFormattedTableCell(TableEntity.Cell cell)
1058
                {
5,248✔
1059
                        var map = DxfClassMap.Create(cell.GetType(), "FORMATTEDTABLEDATACELL_BEGIN");
5,248✔
1060

1061
                        this._reader.ReadNext();
5,248✔
1062

1063
                        bool end = false;
5,248✔
1064
                        while (this._reader.DxfCode != DxfCode.Start)
10,496✔
1065
                        {
10,496✔
1066
                                switch (this._reader.Code)
10,496!
1067
                                {
1068
                                        case 300 when this._reader.ValueAsString.Equals("CELLTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,248!
1069
                                                this.readCellTableFormat(cell);
5,248✔
1070
                                                continue;
5,248✔
1071
                                        case 309:
1072
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1073
                                                break;
5,248✔
1074
                                        default:
1075
                                                if (!this.tryAssignCurrentValue(cell, map))
×
1076
                                                {
×
1077
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableCell)} {this._reader.Position}.", NotificationType.None);
×
1078
                                                }
×
1079
                                                break;
×
1080
                                }
1081

1082
                                if (end)
5,248!
1083
                                {
5,248✔
1084
                                        break;
5,248✔
1085
                                }
1086

1087
                                this._reader.ReadNext();
×
1088
                        }
×
1089
                }
5,248✔
1090

1091
                private void readCellTableFormat(TableEntity.Cell cell)
1092
                {
5,248✔
1093
                        var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
5,248✔
1094

1095
                        this._reader.ReadNext();
5,248✔
1096

1097
                        bool end = false;
5,248✔
1098
                        while (this._reader.Code == 1)
10,496✔
1099
                        {
5,248✔
1100
                                switch (this._reader.Code)
5,248!
1101
                                {
1102
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
5,248!
1103
                                                this.readStyleOverride(new CadCellStyleTemplate(cell.StyleOverride));
5,248✔
1104
                                                break;
5,248✔
1105
                                        case 1 when this._reader.ValueAsString.Equals("CELLSTYLE_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
1106
                                                this.readCellStyle(new CadCellStyleTemplate());
×
1107
                                                break;
×
1108
                                        default:
1109
                                                if (!this.tryAssignCurrentValue(cell, map))
×
1110
                                                {
×
1111
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellTableFormat)} {this._reader.Position}.", NotificationType.None);
×
1112
                                                }
×
1113
                                                break;
×
1114
                                }
1115

1116
                                if (end)
5,248!
1117
                                {
×
1118
                                        break;
×
1119
                                }
1120

1121
                                this._reader.ReadNext();
5,248✔
1122
                        }
5,248✔
1123
                }
5,248✔
1124

1125
                private void readCellStyle(CadCellStyleTemplate template)
1126
                {
×
1127
                        //var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
1128

1129
                        this._reader.ReadNext();
×
1130

1131
                        bool end = false;
×
1132
                        while (this._reader.Code != 1)
×
1133
                        {
×
1134
                                switch (this._reader.Code)
×
1135
                                {
1136
                                        case 309:
1137
                                                end = this._reader.ValueAsString.Equals("CELLSTYLE_END", StringComparison.InvariantCultureIgnoreCase);
×
1138
                                                break;
×
1139
                                        default:
1140
                                                //if (!this.tryAssignCurrentValue(cell, map))
1141
                                                {
×
1142
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellStyle)} {this._reader.Position}.", NotificationType.None);
×
1143
                                                }
×
1144
                                                break;
×
1145
                                }
1146

1147
                                if (end)
×
1148
                                {
×
1149
                                        break;
×
1150
                                }
1151

1152
                                this._reader.ReadNext();
×
1153
                        }
×
1154
                }
×
1155

1156
                private void readLinkedTableCell(TableEntity.Cell cell)
1157
                {
5,376✔
1158
                        var map = DxfClassMap.Create(cell.GetType(), "LINKEDTABLEDATACELL_BEGIN");
5,376✔
1159

1160
                        this._reader.ReadNext();
5,376✔
1161

1162
                        bool end = false;
5,376✔
1163
                        while (this._reader.DxfCode != DxfCode.Start)
53,888✔
1164
                        {
53,760✔
1165
                                switch (this._reader.Code)
53,760✔
1166
                                {
1167
                                        case 95:
1168
                                                //BL 95 Number of cell contents
1169
                                                break;
5,248✔
1170
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
5,376✔
1171
                                                this.readCustomData();
5,376✔
1172
                                                break;
5,376✔
1173
                                        case 302 when this._reader.ValueAsString.Equals("CONTENT", StringComparison.InvariantCultureIgnoreCase):
4,096✔
1174
                                                var c = this.readLinkedTableCellContent();
4,096✔
1175
                                                break;
4,096✔
1176
                                        case 309:
1177
                                                end = this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
5,248✔
1178
                                                break;
5,248✔
1179
                                        default:
1180
                                                if (!this.tryAssignCurrentValue(cell, map))
33,792✔
1181
                                                {
11,648✔
1182
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCell)} {this._reader.Position}.", NotificationType.None);
11,648✔
1183
                                                }
11,648✔
1184
                                                break;
33,792✔
1185
                                }
1186

1187
                                if (end)
53,760✔
1188
                                {
5,248✔
1189
                                        break;
5,248✔
1190
                                }
1191

1192
                                this._reader.ReadNext();
48,512✔
1193
                        }
48,512✔
1194
                }
5,376✔
1195

1196
                private CadTableCellContentTemplate readLinkedTableCellContent()
1197
                {
4,096✔
1198
                        TableEntity.CellContent content = new TableEntity.CellContent();
4,096✔
1199
                        CadTableCellContentTemplate template = new CadTableCellContentTemplate(content);
4,096✔
1200
                        var map = DxfClassMap.Create(content.GetType(), "CONTENT");
4,096✔
1201

1202
                        this._reader.ReadNext();
4,096✔
1203

1204
                        bool end = false;
4,096✔
1205
                        while (this._reader.DxfCode != DxfCode.Start)
8,192✔
1206
                        {
8,192✔
1207
                                switch (this._reader.Code)
8,192!
1208
                                {
1209
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,192✔
1210
                                                readFormattedCellContent();
4,096✔
1211
                                                end = true;
4,096✔
1212
                                                break;
4,096✔
1213
                                        case 1 when this._reader.ValueAsString.Equals("CELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
4,096!
1214
                                                readCellContent(template);
4,096✔
1215
                                                break;
4,096✔
1216
                                        default:
1217
                                                if (!this.tryAssignCurrentValue(content, map))
×
1218
                                                {
×
1219
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCellContent)} {this._reader.Position}.", NotificationType.None);
×
1220
                                                }
×
1221
                                                break;
×
1222
                                }
1223

1224
                                if (end)
8,192✔
1225
                                {
4,096✔
1226
                                        break;
4,096✔
1227
                                }
1228

1229
                                this._reader.ReadNext();
4,096✔
1230
                        }
4,096✔
1231

1232
                        return template;
4,096✔
1233
                }
4,096✔
1234

1235
                private void readCellContent(CadTableCellContentTemplate template)
1236
                {
4,096✔
1237
                        TableEntity.CellContent content = template.Content;
4,096✔
1238
                        var map = DxfClassMap.Create(content.GetType(), "CELLCONTENT_BEGIN");
4,096✔
1239

1240
                        this._reader.ReadNext();
4,096✔
1241

1242
                        bool end = false;
4,096✔
1243
                        while (this._reader.DxfCode != DxfCode.Start)
16,384✔
1244
                        {
16,384✔
1245
                                switch (this._reader.Code)
16,384✔
1246
                                {
1247
                                        case 91:
1248
                                                break;
4,096✔
1249
                                        case 300 when this._reader.ValueAsString.Equals("VALUE", StringComparison.InvariantCultureIgnoreCase):
3,712✔
1250
                                                this.readDataMapValue();
3,712✔
1251
                                                break;
3,712✔
1252
                                        case 309:
1253
                                                end = this._reader.ValueAsString.Equals("CELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
1254
                                                break;
4,096✔
1255
                                        case 340:
1256
                                                template.BlockRecordHandle = this._reader.ValueAsHandle;
384✔
1257
                                                break;
384✔
1258
                                        default:
1259
                                                if (!this.tryAssignCurrentValue(content, map))
4,096!
1260
                                                {
×
1261
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellContent)} {this._reader.Position}.", NotificationType.None);
×
1262
                                                }
×
1263
                                                break;
4,096✔
1264
                                }
1265

1266
                                if (end)
16,384✔
1267
                                {
4,096✔
1268
                                        break;
4,096✔
1269
                                }
1270

1271
                                this._reader.ReadNext();
12,288✔
1272
                        }
12,288✔
1273
                }
4,096✔
1274

1275
                private void readFormattedCellContent()
1276
                {
4,096✔
1277
                        TableEntity.ContentFormat format = new();
4,096✔
1278
                        CadTableCellContentFormatTemplate template = new CadTableCellContentFormatTemplate(format);
4,096✔
1279
                        var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
4,096✔
1280

1281
                        this._reader.ReadNext();
4,096✔
1282

1283
                        bool end = false;
4,096✔
1284
                        while (this._reader.DxfCode != DxfCode.Start)
12,288✔
1285
                        {
12,288✔
1286
                                switch (this._reader.Code)
12,288✔
1287
                                {
1288
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
4,096✔
1289
                                                readContentFormat(template);
4,096✔
1290
                                                break;
4,096✔
1291
                                        case 309:
1292
                                                end = this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,096✔
1293
                                                break;
4,096✔
1294
                                        default:
1295
                                                if (!this.tryAssignCurrentValue(format, map))
4,096!
1296
                                                {
×
1297
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedCellContent)} method.", NotificationType.None);
×
1298
                                                }
×
1299
                                                break;
4,096✔
1300
                                }
1301

1302
                                if (end)
12,288✔
1303
                                {
4,096✔
1304
                                        break;
4,096✔
1305
                                }
1306

1307
                                this._reader.ReadNext();
8,192✔
1308
                        }
8,192✔
1309
                }
4,096✔
1310

1311
                private void readContentFormat(CadTableCellContentFormatTemplate template)
1312
                {
9,600✔
1313
                        var format = template.Format;
9,600✔
1314
                        var map = DxfClassMap.Create(format.GetType(), "CONTENTFORMAT_BEGIN");
9,600✔
1315

1316
                        this._reader.ReadNext();
9,600✔
1317

1318
                        bool end = false;
9,600✔
1319
                        while (this._reader.DxfCode != DxfCode.Start)
124,800✔
1320
                        {
124,800✔
1321
                                switch (this._reader.Code)
124,800✔
1322
                                {
1323
                                        case 1 when this._reader.ValueAsString.Equals("CONTENTFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
9,600✔
1324
                                                break;
9,600✔
1325
                                        case 309:
1326
                                                end = this._reader.ValueAsString.Equals("CONTENTFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
9,600✔
1327
                                                break;
9,600✔
1328
                                        case 340:
1329
                                                template.TextStyleHandle = this._reader.ValueAsHandle;
9,600✔
1330
                                                break;
9,600✔
1331
                                        default:
1332
                                                if (!this.tryAssignCurrentValue(format, map))
96,000!
1333
                                                {
×
1334
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readContentFormat)} method.", NotificationType.None);
×
1335
                                                }
×
1336
                                                break;
96,000✔
1337
                                }
1338

1339
                                if (end)
124,800✔
1340
                                {
9,600✔
1341
                                        break;
9,600✔
1342
                                }
1343

1344
                                this._reader.ReadNext();
115,200✔
1345
                        }
115,200✔
1346
                }
9,600✔
1347

1348
                private void readFormattedTableColumn(TableEntity.Column column)
1349
                {
1,216✔
1350
                        this._reader.ReadNext();
1,216✔
1351

1352
                        bool end = false;
1,216✔
1353
                        while (this._reader.DxfCode != DxfCode.Start)
3,648✔
1354
                        {
3,648✔
1355
                                switch (this._reader.Code)
3,648!
1356
                                {
1357
                                        case 300 when this._reader.ValueAsString.Equals("COLUMNTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,216!
1358
                                                break;
1,216✔
1359
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,216!
1360
                                                this.readStyleOverride(new CadCellStyleTemplate(column.CellStyleOverride));
1,216✔
1361
                                                break;
1,216✔
1362
                                        case 309:
1363
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,216✔
1364
                                                break;
1,216✔
1365
                                        default:
1366
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableColumn)} method.", NotificationType.None);
×
1367
                                                break;
×
1368
                                }
1369

1370
                                if (end)
3,648✔
1371
                                {
1,216✔
1372
                                        break;
1,216✔
1373
                                }
1374

1375
                                this._reader.ReadNext();
2,432✔
1376
                        }
2,432✔
1377
                }
1,216✔
1378

1379
                private void readStyleOverride(CadCellStyleTemplate template)
1380
                {
8,128✔
1381
                        var style = template.Format as TableEntity.CellStyle;
8,128✔
1382
                        var mapstyle = DxfClassMap.Create(style.GetType(), "TABLEFORMAT_STYLE");
8,128✔
1383
                        var mapformat = DxfClassMap.Create(typeof(TableEntity.ContentFormat), "TABLEFORMAT_BEGIN");
8,128✔
1384

1385
                        this._reader.ReadNext();
8,128✔
1386

1387
                        bool end = false;
8,128✔
1388
                        TableEntity.CellEdgeFlags currBorder = TableEntity.CellEdgeFlags.Unknown;
8,128✔
1389
                        while (this._reader.DxfCode != DxfCode.Start)
89,536✔
1390
                        {
89,536✔
1391
                                switch (this._reader.Code)
89,536✔
1392
                                {
1393
                                        case 95:
1394
                                                currBorder = (TableEntity.CellEdgeFlags)this._reader.ValueAsInt;
11,776✔
1395
                                                break;
11,776✔
1396
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
256✔
1397
                                                break;
256✔
1398
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
5,504✔
1399
                                                readContentFormat(new CadTableCellContentFormatTemplate(new TableEntity.ContentFormat()));
5,504✔
1400
                                                break;
5,504✔
1401
                                        case 301 when this._reader.ValueAsString.Equals("MARGIN", StringComparison.InvariantCultureIgnoreCase):
2,816✔
1402
                                                this.readCellMargin(template);
2,816✔
1403
                                                break;
2,816✔
1404
                                        case 302 when this._reader.ValueAsString.Equals("GRIDFORMAT", StringComparison.InvariantCultureIgnoreCase):
11,776✔
1405
                                                TableEntity.CellBorder border = new TableEntity.CellBorder(currBorder);
11,776✔
1406
                                                this.readGridFormat(template, border);
11,776✔
1407
                                                break;
11,776✔
1408
                                        case 309:
1409
                                                end = this._reader.ValueAsString.Equals("TABLEFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
8,128✔
1410
                                                break;
8,128✔
1411
                                        default:
1412
                                                if (!this.tryAssignCurrentValue(style, mapstyle) && !this.tryAssignCurrentValue(style, mapformat))
49,280!
1413
                                                {
×
1414
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readStyleOverride)} method.", NotificationType.None);
×
1415
                                                }
×
1416
                                                break;
49,280✔
1417
                                }
1418

1419
                                if (end)
89,536✔
1420
                                {
8,128✔
1421
                                        break;
8,128✔
1422
                                }
1423

1424
                                this._reader.ReadNext();
81,408✔
1425
                        }
81,408✔
1426
                }
8,128✔
1427

1428
                private void readGridFormat(CadCellStyleTemplate template, TableEntity.CellBorder border)
1429
                {
11,776✔
1430
                        var map = DxfClassMap.Create(border.GetType(), nameof(TableEntity.CellBorder));
11,776✔
1431

1432
                        this._reader.ReadNext();
11,776✔
1433

1434
                        bool end = false;
11,776✔
1435
                        while (this._reader.DxfCode != DxfCode.Start)
105,984✔
1436
                        {
105,984✔
1437
                                switch (this._reader.Code)
105,984✔
1438
                                {
1439
                                        case 1 when this._reader.ValueAsString.Equals("GRIDFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
11,776✔
1440
                                                break;
11,776✔
1441
                                        case 62:
1442
                                                border.Color = new Color(this._reader.ValueAsShort);
11,776✔
1443
                                                break;
11,776✔
1444
                                        case 92:
1445
                                                border.LineWeight = (LineWeightType)this._reader.ValueAsInt;
11,776✔
1446
                                                break;
11,776✔
1447
                                        case 93:
1448
                                                border.IsInvisible = this._reader.ValueAsBool;
11,776✔
1449
                                                break;
11,776✔
1450
                                        case 340:
1451
                                                template.BorderLinetypePairs.Add(new Tuple<TableEntity.CellBorder, ulong>(border, this._reader.ValueAsHandle));
11,776✔
1452
                                                break;
11,776✔
1453
                                        case 309:
1454
                                                end = this._reader.ValueAsString.Equals("GRIDFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
11,776✔
1455
                                                break;
11,776✔
1456
                                        default:
1457
                                                if (!this.tryAssignCurrentValue(border, map))
35,328!
1458
                                                {
×
1459
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readGridFormat)} method.", NotificationType.None);
×
1460
                                                }
×
1461
                                                break;
35,328✔
1462
                                }
1463

1464
                                if (end)
105,984✔
1465
                                {
11,776✔
1466
                                        break;
11,776✔
1467
                                }
1468

1469
                                this._reader.ReadNext();
94,208✔
1470
                        }
94,208✔
1471
                }
11,776✔
1472

1473
                private void readCellMargin(CadCellStyleTemplate template)
1474
                {
2,816✔
1475
                        var style = template.Format as TableEntity.CellStyle;
2,816✔
1476

1477
                        this._reader.ReadNext();
2,816✔
1478

1479
                        bool end = false;
2,816✔
1480
                        int i = 0;
2,816✔
1481
                        while (this._reader.DxfCode != DxfCode.Start)
22,528✔
1482
                        {
22,528✔
1483
                                switch (this._reader.Code)
22,528!
1484
                                {
1485
                                        case 1 when this._reader.ValueAsString.Equals("CELLMARGIN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
2,816!
1486
                                                break;
2,816✔
1487
                                        case 40:
1488
                                                switch (i)
16,896✔
1489
                                                {
1490
                                                        case 0:
1491
                                                                style.VerticalMargin = this._reader.ValueAsDouble;
2,816✔
1492
                                                                break;
2,816✔
1493
                                                        case 1:
1494
                                                                style.HorizontalMargin = this._reader.ValueAsDouble;
2,816✔
1495
                                                                break;
2,816✔
1496
                                                        case 2:
1497
                                                                style.BottomMargin = this._reader.ValueAsDouble;
2,816✔
1498
                                                                break;
2,816✔
1499
                                                        case 3:
1500
                                                                style.RightMargin = this._reader.ValueAsDouble;
2,816✔
1501
                                                                break;
2,816✔
1502
                                                        case 4:
1503
                                                                style.MarginHorizontalSpacing = this._reader.ValueAsDouble;
2,816✔
1504
                                                                break;
2,816✔
1505
                                                        case 5:
1506
                                                                style.MarginVerticalSpacing = this._reader.ValueAsDouble;
2,816✔
1507
                                                                break;
2,816✔
1508
                                                }
1509

1510
                                                i++;
16,896✔
1511
                                                break;
16,896✔
1512
                                        case 309:
1513
                                                end = this._reader.ValueAsString.Equals("CELLMARGIN_END", StringComparison.InvariantCultureIgnoreCase);
2,816✔
1514
                                                break;
2,816✔
1515
                                        default:
1516
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellMargin)} method.", NotificationType.None);
×
1517
                                                break;
×
1518
                                }
1519

1520
                                if (end)
22,528✔
1521
                                {
2,816✔
1522
                                        break;
2,816✔
1523
                                }
1524

1525
                                this._reader.ReadNext();
19,712✔
1526
                        }
19,712✔
1527
                }
2,816✔
1528

1529
                private void readCustomData()
1530
                {
8,000✔
1531
                        this._reader.ReadNext();
8,000✔
1532

1533
                        int ndata = 0;
8,000✔
1534
                        bool end = false;
8,000✔
1535
                        while (this._reader.DxfCode != DxfCode.Start)
74,432✔
1536
                        {
74,304✔
1537
                                switch (this._reader.Code)
74,304✔
1538
                                {
1539
                                        case 1 when this._reader.ValueAsString.Equals("DATAMAP_BEGIN", StringComparison.InvariantCultureIgnoreCase):
8,000✔
1540
                                                break;
8,000✔
1541
                                        case 90:
1542
                                                ndata = this._reader.ValueAsInt;
8,128✔
1543
                                                break;
8,128✔
1544
                                        case 300:
1545
                                                //Name
1546
                                                break;
5,248✔
1547
                                        case 301 when this._reader.ValueAsString.Equals("DATAMAP_VALUE", StringComparison.InvariantCultureIgnoreCase):
5,248✔
1548
                                                this.readDataMapValue();
5,248✔
1549
                                                break;
5,248✔
1550
                                        case 309:
1551
                                                end = this._reader.ValueAsString.Equals("DATAMAP_END", StringComparison.InvariantCultureIgnoreCase);
7,872✔
1552
                                                break;
7,872✔
1553
                                        default:
1554
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCustomData)} method.", NotificationType.None);
39,808✔
1555
                                                break;
39,808✔
1556
                                }
1557

1558
                                if (end)
74,304✔
1559
                                {
7,872✔
1560
                                        break;
7,872✔
1561
                                }
1562

1563
                                this._reader.ReadNext();
66,432✔
1564
                        }
66,432✔
1565
                }
8,000✔
1566

1567
                private void readDataMapValue()
1568
                {
8,960✔
1569
                        TableEntity.CellValue value = new TableEntity.CellValue();
8,960✔
1570
                        var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
8,960✔
1571

1572
                        this._reader.ReadNext();
8,960✔
1573

1574
                        bool end = false;
8,960✔
1575
                        while (this._reader.DxfCode != DxfCode.Start)
330,240✔
1576
                        {
330,112✔
1577
                                switch (this._reader.Code)
330,112✔
1578
                                {
1579
                                        case 11:
1580
                                        case 21:
1581
                                        case 31:
1582
                                                //Value as point
1583
                                                break;
768✔
1584
                                        case 91:
1585
                                        case 92:
1586
                                                //Value as int
1587
                                                break;
38,912✔
1588
                                        case 140:
1589
                                                //Value as double
1590
                                                break;
13,248✔
1591
                                        case 310:
1592
                                                //Value as byte array
1593
                                                break;
256✔
1594
                                        case 304:
1595
                                                end = this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.InvariantCultureIgnoreCase);
8,832✔
1596
                                                break;
8,832✔
1597
                                        default:
1598
                                                if (!this.tryAssignCurrentValue(value, map))
268,096✔
1599
                                                {
106,880✔
1600
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readDataMapValue)} method.", NotificationType.None);
106,880✔
1601
                                                }
106,880✔
1602
                                                break;
268,096✔
1603
                                }
1604

1605
                                if (end)
330,112✔
1606
                                {
8,832✔
1607
                                        break;
8,832✔
1608
                                }
1609

1610
                                this._reader.ReadNext();
321,280✔
1611
                        }
321,280✔
1612
                }
8,960✔
1613

1614
                private bool readVisualStyle(CadTemplate template, DxfMap map)
1615
                {
370,140✔
1616
                        switch (this._reader.Code)
370,140✔
1617
                        {
1618
                                // Undocumented codes
1619
                                case 176:
1620
                                case 177:
1621
                                case 420:
1622
                                        return true;
119,122✔
1623
                                default:
1624
                                        //Avoid noise while is not implemented
1625
                                        return true;
251,018✔
1626
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
1627
                        }
1628
                }
370,140✔
1629

1630
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
1631
                {
4,032✔
1632
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,032✔
1633
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,032✔
1634

1635
                        switch (this._reader.Code)
4,032✔
1636
                        {
1637
                                case 10:
1638
                                        filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
384✔
1639
                                        return true;
384✔
1640
                                case 20:
1641
                                        var pt = filter.BoundaryPoints.LastOrDefault();
384✔
1642
                                        filter.BoundaryPoints.Add(new CSMath.XY(pt.X, this._reader.ValueAsDouble));
384✔
1643
                                        return true;
384✔
1644
                                case 40:
1645
                                        if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
384!
1646
                                        {
×
1647
                                                filter.FrontDistance = this._reader.ValueAsDouble;
×
1648
                                                tmp.HasFrontPlane = true;
×
1649
                                        }
×
1650

1651
                                        double[] array = new double[16]
384✔
1652
                                        {
384✔
1653
                                                0.0, 0.0, 0.0, 0.0,
384✔
1654
                                                0.0, 0.0, 0.0, 0.0,
384✔
1655
                                                0.0, 0.0, 0.0, 0.0,
384✔
1656
                                                0.0, 0.0, 0.0, 1.0
384✔
1657
                                        };
384✔
1658

1659
                                        for (int i = 0; i < 12; i++)
9,984✔
1660
                                        {
4,608✔
1661
                                                array[i] = this._reader.ValueAsDouble;
4,608✔
1662

1663
                                                if (i < 11)
4,608✔
1664
                                                {
4,224✔
1665
                                                        this._reader.ReadNext();
4,224✔
1666
                                                }
4,224✔
1667
                                        }
4,608✔
1668

1669
                                        if (tmp.InsertTransformRead)
384!
1670
                                        {
×
1671
                                                filter.InsertTransform = new Matrix4(array);
×
1672
                                                tmp.InsertTransformRead = true;
×
1673
                                        }
×
1674
                                        else
1675
                                        {
384✔
1676
                                                filter.InverseInsertTransform = new Matrix4(array);
384✔
1677
                                        }
384✔
1678

1679
                                        return true;
384✔
1680
                                case 73:
1681
                                default:
1682
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
2,880✔
1683
                        }
1684
                }
4,032✔
1685

1686
                private bool readMLineStyle(CadTemplate template, DxfMap map)
1687
                {
3,478✔
1688
                        var tmp = template as CadMLineStyleTemplate;
3,478✔
1689
                        var mLineStyle = template.CadObject as MLineStyle;
3,478✔
1690

1691
                        switch (this._reader.Code)
3,478✔
1692
                        {
1693
                                case 6:
1694
                                        var t = tmp.ElementTemplates.LastOrDefault();
412✔
1695
                                        if (t == null)
412!
1696
                                        {
×
1697
                                                return true;
×
1698
                                        }
1699
                                        t.LineTypeName = this._reader.ValueAsString;
412✔
1700
                                        return true;
412✔
1701
                                case 49:
1702
                                        MLineStyle.Element element = new MLineStyle.Element();
412✔
1703
                                        CadMLineStyleTemplate.ElementTemplate elementTemplate = new CadMLineStyleTemplate.ElementTemplate(element);
412✔
1704
                                        element.Offset = this._reader.ValueAsDouble;
412✔
1705

1706
                                        tmp.ElementTemplates.Add(elementTemplate);
412✔
1707
                                        mLineStyle.AddElement(element);
412✔
1708
                                        return true;
412✔
1709
                                default:
1710
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,654✔
1711
                        }
1712
                }
3,478✔
1713

1714
                private bool readTableStyle(CadTemplate template, DxfMap map)
1715
                {
17,563✔
1716
                        var tmp = template as CadTableStyleTemplate;
17,563✔
1717
                        var style = tmp.CadObject;
17,563✔
1718
                        var cellStyle = tmp.CurrentCellStyleTemplate?.CellStyle;
17,563✔
1719

1720
                        switch (this._reader.Code)
17,563!
1721
                        {
1722
                                case 7:
1723
                                        tmp.CreateCurrentCellStyleTemplate();
582✔
1724
                                        tmp.CurrentCellStyleTemplate.TextStyleName = this._reader.ValueAsString;
582✔
1725
                                        return true;
582✔
1726
                                case 94:
NEW
1727
                                        cellStyle.Alignment = this._reader.ValueAsInt;
×
NEW
1728
                                        return true;
×
1729
                                case 62:
1730
                                        cellStyle.Color = new Color(this._reader.ValueAsShort);
582✔
1731
                                        return true;
582✔
1732
                                case 63:
1733
                                        cellStyle.BackgroundColor = new Color(this._reader.ValueAsShort);
582✔
1734
                                        return true;
582✔
1735
                                case 140:
1736
                                        cellStyle.TextHeight = this._reader.ValueAsDouble;
582✔
1737
                                        return true;
582✔
1738
                                case 170:
1739
                                        cellStyle.CellAlignment = (TableEntity.Cell.CellAlignmentType)this._reader.ValueAsShort;
582✔
1740
                                        return true;
582✔
1741
                                case 283:
1742
                                        cellStyle.IsFillColorOn = this._reader.ValueAsBool;
582✔
1743
                                        return true;
582✔
1744
                                case 90:
1745
                                        cellStyle.Type = (TableEntity.CellStyleType)this._reader.ValueAsShort;
390✔
1746
                                        return true;
390✔
1747
                                case 91:
1748
                                        cellStyle.StyleClass = (TableEntity.CellStyleClass)this._reader.ValueAsShort;
390✔
1749
                                        return true;
390✔
1750
                                case 1:
1751
                                        //Undocumented
1752
                                        return true;
390✔
1753
                                case 274:
1754
                                        cellStyle.TopBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
582✔
1755
                                        return true;
582✔
1756
                                case 275:
1757
                                        cellStyle.HorizontalInsideBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
582✔
1758
                                        return true;
582✔
1759
                                case 276:
1760
                                        cellStyle.BottomBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
582✔
1761
                                        return true;
582✔
1762
                                case 277:
1763
                                        cellStyle.LeftBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
582✔
1764
                                        return true;
582✔
1765
                                case 278:
1766
                                        cellStyle.VerticalInsideBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
582✔
1767
                                        return true;
582✔
1768
                                case 279:
1769
                                        cellStyle.RightBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
582✔
1770
                                        return true;
582✔
1771
                                case 284:
1772
                                        cellStyle.TopBorder.IsInvisible = this._reader.ValueAsBool;
582✔
1773
                                        return true;
582✔
1774
                                case 285:
1775
                                        cellStyle.HorizontalInsideBorder.IsInvisible = this._reader.ValueAsBool;
582✔
1776
                                        return true;
582✔
1777
                                case 286:
1778
                                        cellStyle.BottomBorder.IsInvisible = this._reader.ValueAsBool;
582✔
1779
                                        return true;
582✔
1780
                                case 287:
1781
                                        cellStyle.LeftBorder.IsInvisible = this._reader.ValueAsBool;
582✔
1782
                                        return true;
582✔
1783
                                case 288:
1784
                                        cellStyle.VerticalInsideBorder.IsInvisible = this._reader.ValueAsBool;
582✔
1785
                                        return true;
582✔
1786
                                case 289:
1787
                                        cellStyle.RightBorder.IsInvisible = this._reader.ValueAsBool;
582✔
1788
                                        return true;
582✔
1789
                                case 64:
1790
                                        cellStyle.TopBorder.Color = new Color(this._reader.ValueAsShort);
582✔
1791
                                        return true;
582✔
1792
                                case 65:
1793
                                        cellStyle.HorizontalInsideBorder.Color = new Color(this._reader.ValueAsShort);
582✔
1794
                                        return true;
582✔
1795
                                case 66:
1796
                                        cellStyle.BottomBorder.Color = new Color(this._reader.ValueAsShort);
582✔
1797
                                        return true;
582✔
1798
                                case 67:
1799
                                        cellStyle.LeftBorder.Color = new Color(this._reader.ValueAsShort);
582✔
1800
                                        return true;
582✔
1801
                                case 68:
1802
                                        cellStyle.VerticalInsideBorder.Color = new Color(this._reader.ValueAsShort);
582✔
1803
                                        return true;
582✔
1804
                                case 69:
1805
                                        cellStyle.RightBorder.Color = new Color(this._reader.ValueAsShort);
582✔
1806
                                        return true;
582✔
1807
                                default:
1808
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,425✔
1809
                        }
1810
                }
17,563✔
1811

1812
                private bool readMLeaderStyle(CadTemplate template, DxfMap map)
1813
                {
18,348✔
1814
                        var tmp = template as CadMLeaderStyleTemplate;
18,348✔
1815

1816
                        switch (this._reader.Code)
18,348✔
1817
                        {
1818
                                case 179:
1819
                                        return true;
206✔
1820
                                case 340:
1821
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
400✔
1822
                                        return true;
400✔
1823
                                case 342:
1824
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
400✔
1825
                                        return true;
400✔
1826
                                default:
1827
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
17,342✔
1828
                        }
1829
                }
18,348✔
1830

1831
                private bool readXRecord(CadTemplate template, DxfMap map)
1832
                {
113,096✔
1833
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
113,096✔
1834

1835
                        switch (this._reader.Code)
113,096✔
1836
                        {
1837
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
28,882✔
1838
                                        this.readXRecordEntries(tmp);
28,882✔
1839
                                        return true;
28,882✔
1840
                                default:
1841
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
84,214✔
1842
                        }
1843
                }
113,096✔
1844

1845
                private void readXRecordEntries(CadXRecordTemplate template)
1846
                {
28,882✔
1847
                        this._reader.ReadNext();
28,882✔
1848

1849
                        while (this._reader.DxfCode != DxfCode.Start)
2,408,632✔
1850
                        {
2,379,750✔
1851
                                switch (this._reader.GroupCodeValue)
2,379,750✔
1852
                                {
1853
                                        case GroupCodeValueType.Point3D:
1854
                                                var code = this._reader.Code;
2,880✔
1855
                                                var x = this._reader.ValueAsDouble;
2,880✔
1856
                                                this._reader.ReadNext();
2,880✔
1857
                                                var y = this._reader.ValueAsDouble;
2,880✔
1858
                                                this._reader.ReadNext();
2,880✔
1859
                                                var z = this._reader.ValueAsDouble;
2,880✔
1860
                                                XYZ pt = new XYZ(x, y, z);
2,880✔
1861
                                                template.CadObject.CreateEntry(code, pt);
2,880✔
1862
                                                break;
2,880✔
1863
                                        case GroupCodeValueType.Handle:
1864
                                        case GroupCodeValueType.ObjectId:
1865
                                        case GroupCodeValueType.ExtendedDataHandle:
1866
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
12,038✔
1867
                                                break;
12,038✔
1868
                                        default:
1869
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
2,364,832✔
1870
                                                break;
2,364,832✔
1871
                                }
1872

1873
                                this._reader.ReadNext();
2,379,750✔
1874
                        }
2,379,750✔
1875
                }
28,882✔
1876

1877
                private bool readBookColor(CadTemplate template, DxfMap map)
1878
                {
1,376✔
1879
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,376✔
1880
                        BookColor color = tmp.CadObject as BookColor;
1,376✔
1881

1882
                        switch (this._reader.Code)
1,376✔
1883
                        {
1884
                                case 430:
1885
                                        color.Name = this._reader.ValueAsString;
160✔
1886
                                        return true;
160✔
1887
                                default:
1888
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,216✔
1889
                        }
1890
                }
1,376✔
1891

1892
                private bool readDictionary(CadTemplate template, DxfMap map)
1893
                {
222,795✔
1894
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
222,795✔
1895
                        CadDictionary cadDictionary = tmp.CadObject;
222,795✔
1896

1897
                        switch (this._reader.Code)
222,795✔
1898
                        {
1899
                                case 280:
1900
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
14,989✔
1901
                                        return true;
14,989✔
1902
                                case 281:
1903
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
21,394✔
1904
                                        return true;
21,394✔
1905
                                case 3:
1906
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
57,000✔
1907
                                        return true;
57,000✔
1908
                                case 350: // Soft-owner ID/handle to entry object 
1909
                                case 360: // Hard-owner ID/handle to entry object
1910
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
57,000✔
1911
                                        return true;
57,000✔
1912
                                default:
1913
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
72,412✔
1914
                        }
1915
                }
222,795✔
1916

1917
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
1918
                {
1,746✔
1919
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
1,746✔
1920

1921
                        switch (this._reader.Code)
1,746✔
1922
                        {
1923
                                case 340:
1924
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
194✔
1925
                                        return true;
194✔
1926
                                default:
1927
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,552!
1928
                                        {
1,552✔
1929
                                                return this.readDictionary(template, map);
1,552✔
1930
                                        }
1931
                                        return true;
×
1932
                        }
1933
                }
1,746✔
1934

1935
                private CadTemplate readSortentsTable()
1936
                {
576✔
1937
                        SortEntitiesTable sortTable = new SortEntitiesTable();
576✔
1938
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
576✔
1939

1940
                        //Jump the 0 marker
1941
                        this._reader.ReadNext();
576✔
1942

1943
                        this.readCommonObjectData(template);
576✔
1944

1945
                        System.Diagnostics.Debug.Assert(DxfSubclassMarker.SortentsTable == this._reader.ValueAsString);
576✔
1946

1947
                        //Jump the 100 marker
1948
                        this._reader.ReadNext();
576✔
1949

1950
                        (ulong?, ulong?) pair = (null, null);
576✔
1951

1952
                        while (this._reader.DxfCode != DxfCode.Start)
4,224✔
1953
                        {
3,648✔
1954
                                switch (this._reader.Code)
3,648!
1955
                                {
1956
                                        case 5:
1957
                                                pair.Item1 = this._reader.ValueAsHandle;
1,536✔
1958
                                                break;
1,536✔
1959
                                        case 330:
1960
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
576✔
1961
                                                break;
576✔
1962
                                        case 331:
1963
                                                pair.Item2 = this._reader.ValueAsHandle;
1,536✔
1964
                                                break;
1,536✔
1965
                                        default:
1966
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
1967
                                                break;
×
1968
                                }
1969

1970
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
3,648✔
1971
                                {
1,536✔
1972
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,536✔
1973
                                        pair = (null, null);
1,536✔
1974
                                }
1,536✔
1975

1976
                                this._reader.ReadNext();
3,648✔
1977
                        }
3,648✔
1978

1979
                        return template;
576✔
1980
                }
576✔
1981
        }
1982
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc