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

DomCR / ACadSharp / 19270644655

11 Nov 2025 03:36PM UTC coverage: 78.157% (+0.001%) from 78.156%
19270644655

Pull #869

github

web-flow
Merge 26da8c13b into 334e9de91
Pull Request #869: mlinestyle dxf

7391 of 10247 branches covered (72.13%)

Branch coverage included in aggregate %.

55 of 67 new or added lines in 3 files covered. (82.09%)

13 existing lines in 3 files now uncovered.

27628 of 34559 relevant lines covered (79.94%)

98591.96 hits per line

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

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

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

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

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

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

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

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

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

50
                                if (template == null)
71,910✔
UNCOV
51
                                        continue;
×
52

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

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

121
                                        this._reader.ReadNext();
7,844✔
122

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

132
                                                this._reader.ReadNext();
380,016✔
133
                                        }
380,016✔
134
                                        while (this._reader.DxfCode != DxfCode.Start);
380,064✔
135

136
                                        return unknownEntityTemplate;
7,844✔
137
                        }
138
                }
71,910✔
139

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

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

147
                        while (this._reader.DxfCode != DxfCode.Start)
968,773✔
148
                        {
905,391✔
149
                                if (!readObject(template, map))
905,391✔
150
                                {
306,457✔
151
                                        this.readCommonCodes(template, out bool isExtendedData, map);
306,457✔
152
                                        if (isExtendedData)
306,457✔
153
                                                continue;
6,069✔
154
                                }
300,388✔
155

156
                                if (this.lockPointer)
899,322✔
157
                                {
1,368✔
158
                                        this.lockPointer = false;
1,368✔
159
                                        continue;
1,368✔
160
                                }
161

162
                                if (this._reader.DxfCode != DxfCode.Start)
897,954✔
163
                                {
878,790✔
164
                                        this._reader.ReadNext();
878,790✔
165
                                }
878,790✔
166
                        }
897,954✔
167

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

628
                                this._reader.ReadNext();
4,636✔
629
                        }
4,636✔
630
                }
380✔
631

632

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

637
                        TableEntity.Column column = new TableEntity.Column();
1,444✔
638

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

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

664
                                this._reader.ReadNext();
2,888✔
665
                        }
2,888✔
666

667
                        return column;
×
668
                }
1,444✔
669

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

674
                        TableEntity.Row row = new TableEntity.Row();
1,748✔
675

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

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

701
                                this._reader.ReadNext();
12,388✔
702
                        }
12,388✔
703

704
                        return row;
76✔
705
                }
1,748✔
706

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

918
                                this._reader.ReadNext();
13,756✔
919
                        }
13,756✔
920

921
                        return cell;
152✔
922
                }
6,384✔
923

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

928
                        this._reader.ReadNext();
6,232✔
929

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

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

958
                                this._reader.ReadNext();
13,224✔
959
                        }
13,224✔
960
                }
6,232✔
961

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

966
                        this._reader.ReadNext();
6,232✔
967

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

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

992
                                this._reader.ReadNext();
×
993
                        }
×
994
                }
6,232✔
995

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

1000
                        this._reader.ReadNext();
6,232✔
1001

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

1021
                                if (end)
6,232!
1022
                                {
×
1023
                                        break;
×
1024
                                }
1025

1026
                                this._reader.ReadNext();
6,232✔
1027
                        }
6,232✔
1028
                }
6,232✔
1029

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

1034
                        this._reader.ReadNext();
×
1035

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

1052
                                if (end)
×
1053
                                {
×
1054
                                        break;
×
1055
                                }
1056

1057
                                this._reader.ReadNext();
×
1058
                        }
×
1059
                }
×
1060

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

1065
                        this._reader.ReadNext();
6,384✔
1066

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

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

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

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

1107
                        this._reader.ReadNext();
4,864✔
1108

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

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

1134
                                this._reader.ReadNext();
4,864✔
1135
                        }
4,864✔
1136

1137
                        return template;
4,864✔
1138
                }
4,864✔
1139

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

1145
                        this._reader.ReadNext();
4,864✔
1146

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

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

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

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

1186
                        this._reader.ReadNext();
4,864✔
1187

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

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

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

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

1221
                        this._reader.ReadNext();
11,400✔
1222

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

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

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

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

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

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

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

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

1290
                        this._reader.ReadNext();
9,652✔
1291

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

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

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

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

1337
                        this._reader.ReadNext();
13,984✔
1338

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

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

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

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

1373
                        this._reader.ReadNext();
3,344✔
1374

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

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

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

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

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

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

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

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

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

1468
                        this._reader.ReadNext();
10,640✔
1469

1470
                        bool end = false;
10,640✔
1471
                        while (this._reader.DxfCode != DxfCode.Start)
392,160✔
1472
                        {
392,008✔
1473
                                switch (this._reader.Code)
392,008✔
1474
                                {
1475
                                        case 11:
1476
                                        case 21:
1477
                                        case 31:
1478
                                                //Value as point
1479
                                                break;
912✔
1480
                                        case 91:
1481
                                        case 92:
1482
                                                //Value as int
1483
                                                break;
46,208✔
1484
                                        case 140:
1485
                                                //Value as double
1486
                                                break;
15,732✔
1487
                                        case 310:
1488
                                                //Value as byte array
1489
                                                break;
304✔
1490
                                        case 304:
1491
                                                end = this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.InvariantCultureIgnoreCase);
10,488✔
1492
                                                break;
10,488✔
1493
                                        default:
1494
                                                if (!this.tryAssignCurrentValue(value, map))
318,364✔
1495
                                                {
126,920✔
1496
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readDataMapValue)} method.", NotificationType.None);
126,920✔
1497
                                                }
126,920✔
1498
                                                break;
318,364✔
1499
                                }
1500

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

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

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

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

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

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

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

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

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

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

1580
                private bool readMLineStyle(CadTemplate template, DxfMap map)
1581
                {
4,090✔
1582
                        var tmp = template as CadMLineStyleTemplate;
4,090✔
1583
                        var mLineStyle = template.CadObject as MLineStyle;
4,090✔
1584

1585
                        switch (this._reader.Code)
4,090✔
1586
                        {
1587
                                case 6:
1588
                                        var t = tmp.ElementTemplates.LastOrDefault();
484✔
1589
                                        if (t == null)
484!
NEW
1590
                                        {
×
NEW
1591
                                                return true;
×
1592
                                        }
1593
                                        t.LineTypeName = this._reader.ValueAsString;
484✔
1594
                                        return true;
484✔
1595
                                case 49:
1596
                                        MLineStyle.Element element = new MLineStyle.Element();
484✔
1597
                                        CadMLineStyleTemplate.ElementTemplate elementTemplate = new CadMLineStyleTemplate.ElementTemplate(element);
484✔
1598
                                        element.Offset = this._reader.ValueAsDouble;
484✔
1599

1600
                                        tmp.ElementTemplates.Add(elementTemplate);
484✔
1601
                                        mLineStyle.AddElement(element);
484✔
1602
                                        return true;
484✔
1603
                                default:
1604
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
3,122✔
1605
                        }
1606
                }
4,090✔
1607

1608
                private bool readMLeaderStyle(CadTemplate template, DxfMap map)
1609
                {
21,648✔
1610
                        var tmp = template as CadMLeaderStyleTemplate;
21,648✔
1611

1612
                        switch (this._reader.Code)
21,648✔
1613
                        {
1614
                                case 179:
1615
                                        return true;
242✔
1616
                                case 340:
1617
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
472✔
1618
                                        return true;
472✔
1619
                                case 342:
1620
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
472✔
1621
                                        return true;
472✔
1622
                                default:
1623
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
20,462✔
1624
                        }
1625
                }
21,648✔
1626

1627
                private bool readXRecord(CadTemplate template, DxfMap map)
1628
                {
71,640✔
1629
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
71,640✔
1630

1631
                        switch (this._reader.Code)
71,640✔
1632
                        {
1633
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
18,632✔
1634
                                        this.readXRecordEntries(tmp);
18,632✔
1635
                                        return true;
18,632✔
1636
                                default:
1637
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
53,008✔
1638
                        }
1639
                }
71,640✔
1640

1641
                private void readXRecordEntries(CadXRecordTemplate template)
1642
                {
18,632✔
1643
                        this._reader.ReadNext();
18,632✔
1644

1645
                        while (this._reader.DxfCode != DxfCode.Start)
993,532✔
1646
                        {
974,900✔
1647
                                switch (this._reader.GroupCodeValue)
974,900!
1648
                                {
1649
                                        case GroupCodeValueType.Handle:
1650
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
×
1651
                                                break;
×
1652
                                        default:
1653
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
974,900✔
1654
                                                break;
974,900✔
1655
                                }
1656

1657
                                this._reader.ReadNext();
974,900✔
1658
                        }
974,900✔
1659
                }
18,632✔
1660

1661
                private bool readBookColor(CadTemplate template, DxfMap map)
1662
                {
1,634✔
1663
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,634✔
1664
                        BookColor color = tmp.CadObject as BookColor;
1,634✔
1665

1666
                        switch (this._reader.Code)
1,634✔
1667
                        {
1668
                                case 430:
1669
                                        color.Name = this._reader.ValueAsString;
190✔
1670
                                        return true;
190✔
1671
                                default:
1672
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,444✔
1673
                        }
1674
                }
1,634✔
1675

1676
                private bool readDictionary(CadTemplate template, DxfMap map)
1677
                {
219,815✔
1678
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
219,815✔
1679
                        CadDictionary cadDictionary = tmp.CadObject;
219,815✔
1680

1681
                        switch (this._reader.Code)
219,815✔
1682
                        {
1683
                                case 280:
1684
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
15,931✔
1685
                                        return true;
15,931✔
1686
                                case 281:
1687
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
23,530✔
1688
                                        return true;
23,530✔
1689
                                case 3:
1690
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
49,999✔
1691
                                        return true;
49,999✔
1692
                                case 350: // Soft-owner ID/handle to entry object 
1693
                                case 360: // Hard-owner ID/handle to entry object
1694
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
49,999✔
1695
                                        return true;
49,999✔
1696
                                default:
1697
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
80,356✔
1698
                        }
1699
                }
219,815✔
1700

1701
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
1702
                {
2,070✔
1703
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
2,070✔
1704

1705
                        switch (this._reader.Code)
2,070✔
1706
                        {
1707
                                case 340:
1708
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
230✔
1709
                                        return true;
230✔
1710
                                default:
1711
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,840!
1712
                                        {
1,840✔
1713
                                                return this.readDictionary(template, map);
1,840✔
1714
                                        }
1715
                                        return true;
×
1716
                        }
1717
                }
2,070✔
1718

1719
                private CadTemplate readSortentsTable()
1720
                {
684✔
1721
                        SortEntitiesTable sortTable = new SortEntitiesTable();
684✔
1722
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
684✔
1723

1724
                        //Jump the 0 marker
1725
                        this._reader.ReadNext();
684✔
1726

1727
                        this.readCommonObjectData(template);
684✔
1728

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

1731
                        //Jump the 100 marker
1732
                        this._reader.ReadNext();
684✔
1733

1734
                        (ulong?, ulong?) pair = (null, null);
684✔
1735

1736
                        while (this._reader.DxfCode != DxfCode.Start)
5,016✔
1737
                        {
4,332✔
1738
                                switch (this._reader.Code)
4,332!
1739
                                {
1740
                                        case 5:
1741
                                                pair.Item1 = this._reader.ValueAsHandle;
1,824✔
1742
                                                break;
1,824✔
1743
                                        case 330:
1744
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
684✔
1745
                                                break;
684✔
1746
                                        case 331:
1747
                                                pair.Item2 = this._reader.ValueAsHandle;
1,824✔
1748
                                                break;
1,824✔
1749
                                        default:
1750
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
1751
                                                break;
×
1752
                                }
1753

1754
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
4,332✔
1755
                                {
1,824✔
1756
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,824✔
1757
                                        pair = (null, null);
1,824✔
1758
                                }
1,824✔
1759

1760
                                this._reader.ReadNext();
4,332✔
1761
                        }
4,332✔
1762

1763
                        return template;
684✔
1764
                }
684✔
1765
        }
1766
}
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