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

DomCR / ACadSharp / 29143042407

11 Jul 2026 06:34AM UTC coverage: 2.912% (-73.0%) from 75.918%
29143042407

push

github

web-flow
Merge pull request #1146 from ilCosmico/acds-read-payload-anchor

Read the AcDs payload area offset from the data segment header

264 of 12999 branches covered (2.03%)

Branch coverage included in aggregate %.

0 of 30 new or added lines in 1 file covered. (0.0%)

31243 existing lines in 465 files now uncovered.

1337 of 41984 relevant lines covered (3.18%)

5.38 hits per line

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

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

16
namespace ACadSharp.IO.DXF.DxfStreamReader;
17

18
internal class DxfObjectsSectionReader : DxfSectionReaderBase
19
{
20
        public delegate bool ReadObjectDelegate<T>(CadTemplate template, DxfMap map) where T : CadObject;
21

22
        public DxfObjectsSectionReader(IDxfStreamReader reader, DxfDocumentBuilder builder)
UNCOV
23
                : base(reader, builder)
×
UNCOV
24
        {
×
UNCOV
25
        }
×
26

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

32
                //Loop until the section ends
UNCOV
33
                while (this._reader.ValueAsString != DxfFileToken.EndSection)
×
UNCOV
34
                {
×
UNCOV
35
                        CadTemplate template = null;
×
36

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

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

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

UNCOV
52
                        if (template == null)
×
53
                                continue;
×
54

55
                        //Add the object and the template to the builder
UNCOV
56
                        this._builder.AddTemplate(template);
×
UNCOV
57
                }
×
UNCOV
58
        }
×
59

60
        private CadTemplate readObject()
UNCOV
61
        {
×
UNCOV
62
                this.currentSubclass = string.Empty;
×
UNCOV
63
                switch (this._reader.ValueAsString)
×
64
                {
65
                        case DxfFileToken.BlkRefObjectContextData:
66
                                return this.readObjectCodes<BlockReferenceObjectContextData>(new CadAnnotScaleObjectContextDataTemplate(new BlockReferenceObjectContextData()), this.readAnnotScaleObjectContextData);
×
67
                        case DxfFileToken.MTextAttributeObjectContextData:
68
                                return this.readObjectCodes<MTextAttributeObjectContextData>(new CadAnnotScaleObjectContextDataTemplate(new MTextAttributeObjectContextData()), this.readAnnotScaleObjectContextData);
×
69
                        case DxfFileToken.ObjectPlaceholder:
UNCOV
70
                                return this.readObjectCodes<AcdbPlaceHolder>(new CadNonGraphicalObjectTemplate(new AcdbPlaceHolder()), this.readObjectSubclassMap);
×
71
                        case DxfFileToken.ObjectDBColor:
UNCOV
72
                                return this.readObjectCodes<BookColor>(new CadNonGraphicalObjectTemplate(new BookColor()), this.readBookColor);
×
73
                        case DxfFileToken.ObjectDimensionAssociation:
UNCOV
74
                                return this.readObjectCodes<DimensionAssociation>(new CadDimensionAssociationTemplate(), this.readDimensionAssociation);
×
75
                        case DxfFileToken.ObjectDictionary:
UNCOV
76
                                return this.readObjectCodes<CadDictionary>(new CadDictionaryTemplate(), this.readDictionary);
×
77
                        case DxfFileToken.ObjectDictionaryWithDefault:
UNCOV
78
                                return this.readObjectCodes<CadDictionaryWithDefault>(new CadDictionaryWithDefaultTemplate(), this.readDictionaryWithDefault);
×
79
                        case DxfFileToken.ObjectLayout:
UNCOV
80
                                return this.readObjectCodes<Layout>(new CadLayoutTemplate(), this.readLayout);
×
81
                        case DxfFileToken.ObjectPlotSettings:
82
                                return this.readObjectCodes<PlotSettings>(new CadNonGraphicalObjectTemplate(new PlotSettings()), this.readPlotSettings);
×
83
                        case DxfFileToken.ObjectEvalGraph:
UNCOV
84
                                return this.readObjectCodes<EvaluationGraph>(new CadEvaluationGraphTemplate(), this.readEvaluationGraph);
×
85
                        case DxfFileToken.ObjectImageDefinition:
UNCOV
86
                                return this.readObjectCodes<ImageDefinition>(new CadNonGraphicalObjectTemplate(new ImageDefinition()), this.readObjectSubclassMap);
×
87
                        case DxfFileToken.ObjectDictionaryVar:
UNCOV
88
                                return this.readObjectCodes<DictionaryVariable>(new CadTemplate<DictionaryVariable>(new DictionaryVariable()), this.readObjectSubclassMap);
×
89
                        case DxfFileToken.ObjectPdfDefinition:
UNCOV
90
                                return this.readObjectCodes<PdfUnderlayDefinition>(new CadNonGraphicalObjectTemplate(new PdfUnderlayDefinition()), this.readObjectSubclassMap);
×
91
                        case DxfFileToken.ObjectSortEntsTable:
UNCOV
92
                                return this.readSortentsTable();
×
93
                        case DxfFileToken.ObjectImageDefinitionReactor:
UNCOV
94
                                return this.readObjectCodes<ImageDefinitionReactor>(new CadNonGraphicalObjectTemplate(new ImageDefinitionReactor()), this.readObjectSubclassMap);
×
95
                        case DxfFileToken.ObjectProxyObject:
96
                                return this.readObjectCodes<ProxyObject>(new CadProxyObjectTemplate(), this.readProxyObject);
×
97
                        case DxfFileToken.ObjectRasterVariables:
UNCOV
98
                                return this.readObjectCodes<RasterVariables>(new CadNonGraphicalObjectTemplate(new RasterVariables()), this.readObjectSubclassMap);
×
99
                        case DxfFileToken.ObjectGroup:
UNCOV
100
                                return this.readObjectCodes<Group>(new CadGroupTemplate(), this.readGroup);
×
101
                        case DxfFileToken.ObjectGeoData:
UNCOV
102
                                return this.readObjectCodes<GeoData>(new CadGeoDataTemplate(), this.readGeoData);
×
103
                        case DxfFileToken.ObjectMaterial:
UNCOV
104
                                return this.readObjectCodes<Material>(new CadMaterialTemplate(), this.readMaterial);
×
105
                        case DxfFileToken.ObjectScale:
UNCOV
106
                                return this.readObjectCodes<Scale>(new CadTemplate<Scale>(new Scale()), this.readScale);
×
107
                        case DxfFileToken.ObjectTableContent:
UNCOV
108
                                return this.readObjectCodes<TableContent>(new CadTableContentTemplate(), this.readTableContent);
×
109
                        case DxfFileToken.ObjectVisualStyle:
UNCOV
110
                                return this.readObjectCodes<VisualStyle>(new CadTemplate<VisualStyle>(new VisualStyle()), this.readVisualStyle);
×
111
                        case DxfFileToken.ObjectSpatialFilter:
UNCOV
112
                                return this.readObjectCodes<SpatialFilter>(new CadSpatialFilterTemplate(), this.readSpatialFilter);
×
113
                        case DxfFileToken.ObjectMLineStyle:
UNCOV
114
                                return this.readObjectCodes<MLineStyle>(new CadMLineStyleTemplate(), this.readMLineStyle);
×
115
                        case DxfFileToken.ObjectMLeaderStyle:
UNCOV
116
                                return this.readObjectCodes<MultiLeaderStyle>(new CadMLeaderStyleTemplate(), this.readMLeaderStyle);
×
117
                        case DxfFileToken.ObjectTableStyle:
UNCOV
118
                                return this.readObjectCodes<TableStyle>(new CadTableStyleTemplate(), this.readTableStyle);
×
119
                        case DxfFileToken.ObjectXRecord:
UNCOV
120
                                return this.readObjectCodes<XRecord>(new CadXRecordTemplate(), this.readXRecord);
×
121
                        case DxfFileToken.ObjectDynamicBlockPurgePreventer:
UNCOV
122
                                return this.readObjectCodes<DynamicBlockPurgePreventer>(new CadNonGraphicalObjectTemplate(new DynamicBlockPurgePreventer()), this.readObjectSubclassMap);
×
123
                        case DxfFileToken.ObjectBlockRepresentationData:
UNCOV
124
                                return this.readObjectCodes<BlockRepresentationData>(new CadBlockRepresentationDataTemplate(), this.readBlockRepresentationData);
×
125
                        case DxfFileToken.ObjectBlockGripLocationComponent:
UNCOV
126
                                return this.readObjectCodes<BlockGripExpression>(new CadBlockGripExpressionTemplate(), this.readBlockGripExpression);
×
127
                        case DxfFileToken.ObjectBlockVisibilityGrip:
UNCOV
128
                                return this.readObjectCodes<BlockVisibilityGrip>(new CadBlockVisibilityGripTemplate(), this.readBlockVisibilityGrip);
×
129
                        case DxfFileToken.ObjectBlockXYGrip:
UNCOV
130
                                return this.readObjectCodes<BlockXYGrip>(new CadBlockGripTemplate(new BlockXYGrip()), this.readBlockXYGrip);
×
131
                        case DxfFileToken.ObjectBlockVisibilityParameter:
UNCOV
132
                                return this.readObjectCodes<BlockVisibilityParameter>(new CadBlockVisibilityParameterTemplate(), this.readBlockVisibilityParameter);
×
133
                        case DxfFileToken.ObjectBlockRotationParameter:
UNCOV
134
                                return this.readObjectCodes<BlockRotationParameter>(new CadBlockRotationParameterTemplate(), this.readBlockRotationParameter);
×
135
                        case DxfFileToken.ObjectBlockLinearParameter:
UNCOV
136
                                return this.readObjectCodes<BlockLinearParameter>(new CadBlockLinearParameterTemplate(), this.readBlockLinearParameter);
×
137
                        case DxfFileToken.ObjectBlockLookupParameter:
UNCOV
138
                                return this.readObjectCodes<BlockLookupParameter>(new CadBlockLookupParameterTemplate(new BlockLookupParameter()), this.readBlockLookupParameter);
×
139
                        case DxfFileToken.ObjectBlockRotationGrip:
UNCOV
140
                                return this.readObjectCodes<BlockRotationGrip>(new CadBlockRotationGripTemplate(), this.readBlockRotationGrip);
×
141
                        case DxfFileToken.ObjectBlockMoveAction:
UNCOV
142
                                return this.readObjectCodes<BlockMoveAction>(new CadBlockMoveActionTemplate(), this.readBlockMoveAction);
×
143
                        case DxfFileToken.ObjectBlockRotateAction:
UNCOV
144
                                return this.readObjectCodes<BlockRotationAction>(new CadBlockRotationActionTemplate(), this.readBlockRotationAction);
×
145
                        case DxfFileToken.ObjectBlockPointParameter:
UNCOV
146
                                return this.readObjectCodes<BlockPointParameter>(new CadBlockPointParameterTemplate(), this.readBlockPointParameter);
×
147
                        case DxfFileToken.ObjectField:
148
                                return this.readObjectCodes<Field>(new CadFieldTemplate(new Field()), this.readField);
×
149
                        case DxfFileToken.ObjectFieldList:
150
                                return this.readObjectCodes<FieldList>(new CadFieldListTemplate(new FieldList()), this.readFieldList);
×
151
                        default:
UNCOV
152
                                DxfMap map = DxfMap.Create<CadObject>();
×
UNCOV
153
                                CadUnknownNonGraphicalObjectTemplate unknownEntityTemplate = null;
×
UNCOV
154
                                if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
×
UNCOV
155
                                {
×
UNCOV
156
                                        this._builder.Notify($"NonGraphicalObject not supported read as an UnknownNonGraphicalObject: {this._reader.ValueAsString}", NotificationType.NotImplemented);
×
UNCOV
157
                                        unknownEntityTemplate = new CadUnknownNonGraphicalObjectTemplate(new UnknownNonGraphicalObject(dxfClass));
×
UNCOV
158
                                }
×
159
                                else
160
                                {
×
161
                                        this._builder.Notify($"UnknownNonGraphicalObject not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
×
162
                                }
×
163

UNCOV
164
                                this._reader.ReadNext();
×
165

166
                                do
UNCOV
167
                                {
×
UNCOV
168
                                        if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
×
UNCOV
169
                                        {
×
UNCOV
170
                                                this.readCommonCodes(unknownEntityTemplate, out bool isExtendedData, map);
×
UNCOV
171
                                                if (isExtendedData)
×
172
                                                        continue;
×
UNCOV
173
                                        }
×
174

UNCOV
175
                                        this._reader.ReadNext();
×
UNCOV
176
                                }
×
UNCOV
177
                                while (this._reader.DxfCode != DxfCode.Start);
×
178

UNCOV
179
                                return unknownEntityTemplate;
×
180
                }
UNCOV
181
        }
×
182

183
        protected CadTemplate readObjectCodes<T>(CadTemplate template, ReadObjectDelegate<T> readObject)
184
                where T : CadObject
UNCOV
185
        {
×
UNCOV
186
                this._reader.ReadNext();
×
187

UNCOV
188
                DxfMap map = DxfMap.Create<T>();
×
189

UNCOV
190
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
191
                {
×
UNCOV
192
                        if (!readObject(template, map))
×
UNCOV
193
                        {
×
UNCOV
194
                                this.readCommonCodes(template, out bool isExtendedData, map);
×
UNCOV
195
                                if (isExtendedData)
×
UNCOV
196
                                        continue;
×
UNCOV
197
                        }
×
198

UNCOV
199
                        if (this.lockPointer)
×
UNCOV
200
                        {
×
UNCOV
201
                                this.lockPointer = false;
×
UNCOV
202
                                continue;
×
203
                        }
204

UNCOV
205
                        if (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
206
                        {
×
UNCOV
207
                                this._reader.ReadNext();
×
UNCOV
208
                        }
×
UNCOV
209
                }
×
210

UNCOV
211
                return template;
×
UNCOV
212
        }
×
213

214
        private bool readFieldList(CadTemplate template, DxfMap map)
215
        {
×
216
                var tmp = template as CadFieldListTemplate;
×
217

218
                switch (this._reader.Code)
×
219
                {
220
                        case 100 when this._reader.ValueAsString == DxfSubclassMarker.IdSet:
×
221
                                this.currentSubclass = this._reader.ValueAsString;
×
222
                                return true;
×
223
                        case 90 when this.currentSubclass == DxfSubclassMarker.IdSet:
×
224
                                return true;
×
225
                        case 330 when this.currentSubclass == DxfSubclassMarker.IdSet:
×
226
                                tmp.OwnedObjectsHandlers.Add(this._reader.ValueAsHandle);
×
227
                                return true;
×
228
                        default:
229
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.FieldList]);
×
230
                }
231
        }
×
232

233
        private bool readField(CadTemplate template, DxfMap map)
234
        {
×
235
                var tmp = template as CadFieldTemplate;
×
236

237
                switch (this._reader.Code)
×
238
                {
239
                        case 3:
240
                                tmp.CadObject.FieldCode += this._reader.ValueAsString;
×
241
                                return true;
×
242
                        //98 Length of format string
243
                        case 98:
244
                                return true;
×
245
                        case 6:
246
                                string key = this._reader.ValueAsString;
×
247
                                var t = this.readCadValue(new CadValue());
×
248
                                tmp.CadObject.Values.Add(key, t.CadValue);
×
249
                                tmp.CadValueTemplates.Add(t);
×
250
                                return true;
×
251
                        case 7:
252
                                t = this.readCadValue(new CadValue());
×
253
                                tmp.CadObject.Value = t.CadValue;
×
254
                                tmp.CadValueTemplates.Add(t);
×
255
                                return true;
×
256
                        case 331:
257
                                tmp.CadObjectsHandles.Add(this._reader.ValueAsHandle);
×
258
                                return true;
×
259
                        case 360:
260
                                tmp.ChildrenHandles.Add(this._reader.ValueAsHandle);
×
261
                                return true;
×
262
                        default:
263
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Field]);
×
264
                }
265
        }
×
266

267
        private bool readProxyObject(CadTemplate template, DxfMap map)
268
        {
×
269
                CadProxyObjectTemplate tmp = template as CadProxyObjectTemplate;
×
270
                ProxyObject proxy = template.CadObject as ProxyObject;
×
271

272
                switch (this._reader.Code)
×
273
                {
274
                        case 90:
275
                        case 94:
276
                        //Undocumented
277
                        case 97:
278
                        case 71:
279
                                return true;
×
280
                        case 95:
281
                                int format = this._reader.ValueAsInt;
×
282
                                proxy.Version = (ACadVersion)(format & 0xFFFF);
×
283
                                proxy.MaintenanceVersion = (short)(format >> 16);
×
284
                                return true;
×
285
                        case 91:
286
                                var classId = this._reader.ValueAsShort;
×
287
                                if (this._builder.DocumentToBuild.Classes.TryGetByClassNumber(classId, out DxfClass dxfClass))
×
288
                                {
×
289
                                        proxy.DxfClass = dxfClass;
×
290
                                }
×
291
                                return true;
×
292
                        case 161:
293
                                return true;
×
294
                        case 162:
295
                                return true;
×
296
                        case 310:
297
                                if (proxy.BinaryData == null)
×
298
                                {
×
299
                                        proxy.BinaryData = new MemoryStream();
×
300
                                }
×
301
                                proxy.BinaryData.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
302
                                return true;
×
303
                        case 311:
304
                                if (proxy.Data == null)
×
305
                                {
×
306
                                        proxy.Data = new MemoryStream();
×
307
                                }
×
308
                                proxy.Data.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
309
                                return true;
×
310
                        case 330:
311
                        case 340:
312
                        case 350:
313
                        case 360:
314
                                tmp.Entries.Add(this._reader.ValueAsHandle);
×
315
                                return true;
×
316
                        default:
317
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.ProxyObject]);
×
318
                }
319
        }
×
320

321
        private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
UNCOV
322
        {
×
UNCOV
323
                switch (this._reader.Code)
×
324
                {
325
                        default:
UNCOV
326
                                if (string.IsNullOrEmpty(this.currentSubclass))
×
UNCOV
327
                                {
×
UNCOV
328
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
×
329
                                }
330
                                else
UNCOV
331
                                {
×
UNCOV
332
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[this.currentSubclass]);
×
333
                                }
334
                }
UNCOV
335
        }
×
336

337
        private bool readAnnotScaleObjectContextData(CadTemplate template, DxfMap map)
338
        {
×
339
                var tmp = template as CadAnnotScaleObjectContextDataTemplate;
×
340
                switch (this._reader.Code)
×
341
                {
342
                        case 340:
343
                                tmp.ScaleHandle = this._reader.ValueAsHandle;
×
344
                                return true;
×
345
                        default:
346
                                if (string.IsNullOrEmpty(this.currentSubclass))
×
347
                                {
×
348
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
×
349
                                }
350
                                else
351
                                {
×
352
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[this.currentSubclass]);
×
353
                                }
354
                }
355
        }
×
356

357
        private bool readPlotSettings(CadTemplate template, DxfMap map)
UNCOV
358
        {
×
UNCOV
359
                switch (this._reader.Code)
×
360
                {
361
                        default:
UNCOV
362
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
×
363
                }
UNCOV
364
        }
×
365

366
        private bool readEvaluationGraph(CadTemplate template, DxfMap map)
UNCOV
367
        {
×
UNCOV
368
                CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
×
UNCOV
369
                EvaluationGraph evGraph = tmp.CadObject;
×
370

UNCOV
371
                switch (this._reader.Code)
×
372
                {
373
                        case 91:
UNCOV
374
                                while (this._reader.Code == 91)
×
UNCOV
375
                                {
×
UNCOV
376
                                        GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
×
UNCOV
377
                                        EvaluationGraph.Node node = nodeTemplate.Node;
×
378

UNCOV
379
                                        node.Index = this._reader.ValueAsInt;
×
380

UNCOV
381
                                        this._reader.ExpectedCode(93);
×
UNCOV
382
                                        node.Flags = this._reader.ValueAsInt;
×
383

UNCOV
384
                                        this._reader.ExpectedCode(95);
×
UNCOV
385
                                        node.NextNodeIndex = this._reader.ValueAsInt;
×
386

UNCOV
387
                                        this._reader.ExpectedCode(360);
×
UNCOV
388
                                        nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
×
389

UNCOV
390
                                        this._reader.ExpectedCode(92);
×
UNCOV
391
                                        node.Data1 = this._reader.ValueAsInt;
×
UNCOV
392
                                        this._reader.ExpectedCode(92);
×
UNCOV
393
                                        node.Data2 = this._reader.ValueAsInt;
×
UNCOV
394
                                        this._reader.ExpectedCode(92);
×
UNCOV
395
                                        node.Data3 = this._reader.ValueAsInt;
×
UNCOV
396
                                        this._reader.ExpectedCode(92);
×
UNCOV
397
                                        node.Data4 = this._reader.ValueAsInt;
×
398

UNCOV
399
                                        this._reader.ReadNext();
×
400

UNCOV
401
                                        tmp.NodeTemplates.Add(nodeTemplate);
×
UNCOV
402
                                }
×
403

UNCOV
404
                                this.lockPointer = true;
×
UNCOV
405
                                return true;
×
406
                        case 92:
407
                                //Edges
UNCOV
408
                                while (this._reader.Code == 92)
×
UNCOV
409
                                {
×
UNCOV
410
                                        this._reader.ExpectedCode(93);
×
UNCOV
411
                                        this._reader.ExpectedCode(94);
×
UNCOV
412
                                        this._reader.ExpectedCode(91);
×
UNCOV
413
                                        this._reader.ExpectedCode(91);
×
UNCOV
414
                                        this._reader.ExpectedCode(92);
×
UNCOV
415
                                        this._reader.ExpectedCode(92);
×
UNCOV
416
                                        this._reader.ExpectedCode(92);
×
UNCOV
417
                                        this._reader.ExpectedCode(92);
×
UNCOV
418
                                        this._reader.ExpectedCode(92);
×
419

UNCOV
420
                                        this._reader.ReadNext();
×
UNCOV
421
                                }
×
422

UNCOV
423
                                this.lockPointer = true;
×
UNCOV
424
                                return true;
×
425
                        default:
UNCOV
426
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
×
427
                }
UNCOV
428
        }
×
429

430
        private bool readLayout(CadTemplate template, DxfMap map)
UNCOV
431
        {
×
UNCOV
432
                CadLayoutTemplate tmp = template as CadLayoutTemplate;
×
433

UNCOV
434
                switch (this._reader.Code)
×
435
                {
UNCOV
436
                        case 330 when template.OwnerHandle.HasValue:
×
UNCOV
437
                                tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
×
UNCOV
438
                                return true;
×
439
                        case 331:
UNCOV
440
                                tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
×
UNCOV
441
                                return true;
×
442
                        default:
UNCOV
443
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
×
UNCOV
444
                                {
×
UNCOV
445
                                        return this.readPlotSettings(template, map);
×
446
                                }
UNCOV
447
                                return true;
×
448
                }
UNCOV
449
        }
×
450

451
        private bool readGroup(CadTemplate template, DxfMap map)
UNCOV
452
        {
×
UNCOV
453
                CadGroupTemplate tmp = template as CadGroupTemplate;
×
454

UNCOV
455
                switch (this._reader.Code)
×
456
                {
457
                        case 70:
UNCOV
458
                                return true;
×
459
                        case 340:
UNCOV
460
                                tmp.Handles.Add(this._reader.ValueAsHandle);
×
UNCOV
461
                                return true;
×
462
                        default:
UNCOV
463
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
×
464
                }
UNCOV
465
        }
×
466

467
        private bool readGeoData(CadTemplate template, DxfMap map)
UNCOV
468
        {
×
UNCOV
469
                CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
×
470

UNCOV
471
                switch (this._reader.Code)
×
472
                {
UNCOV
473
                        case 40 when tmp.CadObject.Version == GeoDataVersion.R2009:
×
UNCOV
474
                                tmp.CadObject.ReferencePoint = new CSMath.XYZ(
×
UNCOV
475
                                        tmp.CadObject.ReferencePoint.X,
×
UNCOV
476
                                        this._reader.ValueAsDouble,
×
UNCOV
477
                                        tmp.CadObject.ReferencePoint.Z
×
UNCOV
478
                                        );
×
UNCOV
479
                                return true;
×
UNCOV
480
                        case 41 when tmp.CadObject.Version == GeoDataVersion.R2009:
×
UNCOV
481
                                tmp.CadObject.ReferencePoint = new CSMath.XYZ(
×
UNCOV
482
                                        this._reader.ValueAsDouble,
×
UNCOV
483
                                        tmp.CadObject.ReferencePoint.Y,
×
UNCOV
484
                                        tmp.CadObject.ReferencePoint.Z
×
UNCOV
485
                                        );
×
UNCOV
486
                                return true;
×
UNCOV
487
                        case 42 when tmp.CadObject.Version == GeoDataVersion.R2009:
×
UNCOV
488
                                tmp.CadObject.ReferencePoint = new CSMath.XYZ(
×
UNCOV
489
                                        tmp.CadObject.ReferencePoint.X,
×
UNCOV
490
                                        tmp.CadObject.ReferencePoint.Y,
×
UNCOV
491
                                        this._reader.ValueAsDouble
×
UNCOV
492
                                        );
×
UNCOV
493
                                return true;
×
UNCOV
494
                        case 46 when tmp.CadObject.Version == GeoDataVersion.R2009:
×
UNCOV
495
                                tmp.CadObject.HorizontalUnitScale = this._reader.ValueAsDouble;
×
UNCOV
496
                                return true;
×
UNCOV
497
                        case 52 when tmp.CadObject.Version == GeoDataVersion.R2009:
×
UNCOV
498
                                double angle = System.Math.PI / 2.0 - this._reader.ValueAsAngle;
×
UNCOV
499
                                tmp.CadObject.NorthDirection = new CSMath.XY(Math.Cos(angle), Math.Sin(angle));
×
UNCOV
500
                                return true;
×
501
                        // Number of Geo-Mesh points
502
                        case 93:
UNCOV
503
                                var npts = this._reader.ValueAsInt;
×
UNCOV
504
                                for (int i = 0; i < npts; i++)
×
UNCOV
505
                                {
×
UNCOV
506
                                        this._reader.ReadNext();
×
UNCOV
507
                                        double sourceX = this._reader.ValueAsDouble;
×
UNCOV
508
                                        this._reader.ReadNext();
×
UNCOV
509
                                        double sourceY = this._reader.ValueAsDouble;
×
510

UNCOV
511
                                        this._reader.ReadNext();
×
UNCOV
512
                                        double destX = this._reader.ValueAsDouble;
×
UNCOV
513
                                        this._reader.ReadNext();
×
UNCOV
514
                                        double destY = this._reader.ValueAsDouble;
×
515

UNCOV
516
                                        tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
×
UNCOV
517
                                        {
×
UNCOV
518
                                                Source = new CSMath.XY(sourceX, sourceY),
×
UNCOV
519
                                                Destination = new CSMath.XY(destX, destY)
×
UNCOV
520
                                        });
×
UNCOV
521
                                }
×
UNCOV
522
                                return true;
×
523
                        // Number of Geo-Mesh points
524
                        case 96:
UNCOV
525
                                var nfaces = this._reader.ValueAsInt;
×
UNCOV
526
                                for (int i = 0; i < nfaces; i++)
×
527
                                {
×
528
                                        this._reader.ReadNext();
×
529
                                        Debug.Assert(this._reader.Code == 97);
×
530
                                        int index1 = this._reader.ValueAsInt;
×
531
                                        this._reader.ReadNext();
×
532
                                        Debug.Assert(this._reader.Code == 98);
×
533
                                        int index2 = this._reader.ValueAsInt;
×
534
                                        this._reader.ReadNext();
×
535
                                        Debug.Assert(this._reader.Code == 99);
×
536
                                        int index3 = this._reader.ValueAsInt;
×
537

538
                                        tmp.CadObject.Faces.Add(new GeoData.GeoMeshFace
×
539
                                        {
×
540
                                                Index1 = index1,
×
541
                                                Index2 = index2,
×
542
                                                Index3 = index3
×
543
                                        });
×
544
                                }
×
UNCOV
545
                                return true;
×
546
                        case 303:
UNCOV
547
                                tmp.CadObject.CoordinateSystemDefinition += this._reader.ValueAsString;
×
UNCOV
548
                                return true;
×
549
                        //Obsolete codes for version GeoDataVersion.R2009
550
                        case 3:
551
                        case 4:
552
                        case 14:
553
                        case 24:
554
                        case 15:
555
                        case 25:
556
                        case 43:
557
                        case 44:
558
                        case 45:
559
                        case 94:
560
                        case 293:
561
                        case 16:
562
                        case 26:
563
                        case 17:
564
                        case 27:
565
                        case 54:
566
                        case 140:
567
                        case 304:
568
                        case 292:
UNCOV
569
                                return true;
×
570
                        default:
UNCOV
571
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
572
                }
UNCOV
573
        }
×
574

575
        private bool readMaterial(CadTemplate template, DxfMap map)
UNCOV
576
        {
×
UNCOV
577
                CadMaterialTemplate tmp = template as CadMaterialTemplate;
×
UNCOV
578
                List<double> arr = null;
×
579

UNCOV
580
                switch (this._reader.Code)
×
581
                {
582
                        case 43:
UNCOV
583
                                arr = new();
×
UNCOV
584
                                for (int i = 0; i < 16; i++)
×
UNCOV
585
                                {
×
UNCOV
586
                                        Debug.Assert(this._reader.Code == 43);
×
587

UNCOV
588
                                        arr.Add(this._reader.ValueAsDouble);
×
589

UNCOV
590
                                        this._reader.ReadNext();
×
UNCOV
591
                                }
×
592

UNCOV
593
                                tmp.CadObject.DiffuseMatrix = new CSMath.Matrix4(arr.ToArray());
×
UNCOV
594
                                return this.checkObjectEnd(template, map, this.readMaterial);
×
595
                        case 47:
596
                                arr = new();
×
597
                                for (int i = 0; i < 16; i++)
×
598
                                {
×
599
                                        Debug.Assert(this._reader.Code == 47);
×
600

601
                                        arr.Add(this._reader.ValueAsDouble);
×
602

603
                                        this._reader.ReadNext();
×
604
                                }
×
605

606
                                tmp.CadObject.SpecularMatrix = new CSMath.Matrix4(arr.ToArray());
×
607
                                return this.checkObjectEnd(template, map, this.readMaterial);
×
608
                        case 49:
UNCOV
609
                                arr = new();
×
UNCOV
610
                                for (int i = 0; i < 16; i++)
×
UNCOV
611
                                {
×
UNCOV
612
                                        Debug.Assert(this._reader.Code == 49);
×
613

UNCOV
614
                                        arr.Add(this._reader.ValueAsDouble);
×
615

UNCOV
616
                                        this._reader.ReadNext();
×
UNCOV
617
                                }
×
618

UNCOV
619
                                tmp.CadObject.ReflectionMatrix = new CSMath.Matrix4(arr.ToArray());
×
UNCOV
620
                                return this.checkObjectEnd(template, map, this.readMaterial);
×
621
                        case 142:
UNCOV
622
                                arr = new();
×
UNCOV
623
                                for (int i = 0; i < 16; i++)
×
UNCOV
624
                                {
×
UNCOV
625
                                        Debug.Assert(this._reader.Code == 142);
×
626

UNCOV
627
                                        arr.Add(this._reader.ValueAsDouble);
×
628

UNCOV
629
                                        this._reader.ReadNext();
×
UNCOV
630
                                }
×
631

UNCOV
632
                                tmp.CadObject.OpacityMatrix = new CSMath.Matrix4(arr.ToArray());
×
UNCOV
633
                                return this.checkObjectEnd(template, map, this.readMaterial);
×
634
                        case 144:
UNCOV
635
                                arr = new();
×
UNCOV
636
                                for (int i = 0; i < 16; i++)
×
UNCOV
637
                                {
×
UNCOV
638
                                        Debug.Assert(this._reader.Code == 144);
×
639

UNCOV
640
                                        arr.Add(this._reader.ValueAsDouble);
×
641

UNCOV
642
                                        this._reader.ReadNext();
×
UNCOV
643
                                }
×
644

UNCOV
645
                                tmp.CadObject.BumpMatrix = new CSMath.Matrix4(arr.ToArray());
×
UNCOV
646
                                return this.checkObjectEnd(template, map, this.readMaterial);
×
647
                        case 147:
648
                                arr = new();
×
649
                                for (int i = 0; i < 16; i++)
×
650
                                {
×
651
                                        Debug.Assert(this._reader.Code == 147);
×
652

653
                                        arr.Add(this._reader.ValueAsDouble);
×
654

655
                                        this._reader.ReadNext();
×
656
                                }
×
657

658
                                tmp.CadObject.RefractionMatrix = new CSMath.Matrix4(arr.ToArray());
×
659
                                return this.checkObjectEnd(template, map, this.readMaterial);
×
660
                        default:
UNCOV
661
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
662
                }
UNCOV
663
        }
×
664

665
        private bool readScale(CadTemplate template, DxfMap map)
UNCOV
666
        {
×
UNCOV
667
                switch (this._reader.Code)
×
668
                {
669
                        // Undocumented codes
670
                        case 70:
671
                                //Always 0
UNCOV
672
                                return true;
×
673
                        default:
UNCOV
674
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
×
675
                }
UNCOV
676
        }
×
677

678
        private void readLinkedData(CadTemplate template, DxfMap map)
UNCOV
679
        {
×
UNCOV
680
                CadTableContentTemplate tmp = template as CadTableContentTemplate;
×
UNCOV
681
                LinkedData linkedData = tmp.CadObject;
×
682

UNCOV
683
                this._reader.ReadNext();
×
684

UNCOV
685
                while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
×
UNCOV
686
                {
×
UNCOV
687
                        switch (this._reader.Code)
×
688
                        {
689
                                default:
UNCOV
690
                                        if (!this.tryAssignCurrentValue(linkedData, map.SubClasses[DxfSubclassMarker.LinkedData]))
×
691
                                        {
×
692
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedData)} {this._reader.Position}.", NotificationType.None);
×
693
                                        }
×
UNCOV
694
                                        break;
×
695
                        }
696

UNCOV
697
                        this._reader.ReadNext();
×
UNCOV
698
                }
×
UNCOV
699
        }
×
700

701
        private bool readTableContent(CadTemplate template, DxfMap map)
UNCOV
702
        {
×
UNCOV
703
                switch (this._reader.Code)
×
704
                {
UNCOV
705
                        case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.TableContent, StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
706
                                this.readTableContentSubclass(template, map);
×
UNCOV
707
                                this.lockPointer = true;
×
UNCOV
708
                                return true;
×
UNCOV
709
                        case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.FormattedTableData, StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
710
                                this.readFormattedTableDataSubclass(template, map);
×
UNCOV
711
                                this.lockPointer = true;
×
UNCOV
712
                                return true;
×
UNCOV
713
                        case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedTableData, StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
714
                                this.readLinkedTableDataSubclass(template, map);
×
UNCOV
715
                                this.lockPointer = true;
×
UNCOV
716
                                return true;
×
UNCOV
717
                        case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedData, StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
718
                                this.readLinkedData(template, map);
×
UNCOV
719
                                this.lockPointer = true;
×
UNCOV
720
                                return true;
×
721
                        default:
UNCOV
722
                                return false;
×
723
                }
UNCOV
724
        }
×
725

726
        private void readTableContentSubclass(CadTemplate template, DxfMap map)
UNCOV
727
        {
×
UNCOV
728
                CadTableContentTemplate tmp = template as CadTableContentTemplate;
×
UNCOV
729
                TableContent tableContent = tmp.CadObject;
×
730

UNCOV
731
                this._reader.ReadNext();
×
732

UNCOV
733
                while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
×
UNCOV
734
                {
×
UNCOV
735
                        switch (this._reader.Code)
×
736
                        {
737
                                case 340:
UNCOV
738
                                        tmp.SytleHandle = this._reader.ValueAsHandle;
×
UNCOV
739
                                        break;
×
740
                                default:
741
                                        if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.TableContent]))
×
742
                                        {
×
743
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableContentSubclass)} {this._reader.Position}.", NotificationType.None);
×
744
                                        }
×
745
                                        break;
×
746
                        }
747

UNCOV
748
                        this._reader.ReadNext();
×
UNCOV
749
                }
×
UNCOV
750
        }
×
751

752
        private void readFormattedTableDataSubclass(CadTemplate template, DxfMap map)
UNCOV
753
        {
×
UNCOV
754
                CadTableContentTemplate tmp = template as CadTableContentTemplate;
×
UNCOV
755
                FormattedTableData formattedTable = tmp.CadObject;
×
756

UNCOV
757
                this._reader.ReadNext();
×
758

UNCOV
759
                TableEntity.CellRange cellRange = null;
×
UNCOV
760
                while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
×
UNCOV
761
                {
×
UNCOV
762
                        switch (this._reader.Code)
×
763
                        {
764
                                case 90:
UNCOV
765
                                        break;
×
766
                                case 91:
UNCOV
767
                                        if (cellRange == null)
×
UNCOV
768
                                        {
×
UNCOV
769
                                                cellRange = new();
×
UNCOV
770
                                                formattedTable.MergedCellRanges.Add(cellRange);
×
UNCOV
771
                                        }
×
UNCOV
772
                                        cellRange.TopRowIndex = this._reader.ValueAsInt;
×
UNCOV
773
                                        break;
×
774
                                case 92:
UNCOV
775
                                        if (cellRange == null)
×
776
                                        {
×
777
                                                cellRange = new();
×
778
                                                formattedTable.MergedCellRanges.Add(cellRange);
×
779
                                        }
×
UNCOV
780
                                        cellRange.LeftColumnIndex = this._reader.ValueAsInt;
×
UNCOV
781
                                        break;
×
782
                                case 93:
UNCOV
783
                                        if (cellRange == null)
×
784
                                        {
×
785
                                                cellRange = new();
×
786
                                                formattedTable.MergedCellRanges.Add(cellRange);
×
787
                                        }
×
UNCOV
788
                                        cellRange.BottomRowIndex = this._reader.ValueAsInt;
×
UNCOV
789
                                        break;
×
790
                                case 94:
UNCOV
791
                                        if (cellRange == null)
×
792
                                        {
×
793
                                                cellRange = new();
×
794
                                                formattedTable.MergedCellRanges.Add(cellRange);
×
795
                                        }
×
UNCOV
796
                                        cellRange.RightColumnIndex = this._reader.ValueAsInt;
×
UNCOV
797
                                        cellRange = null;
×
UNCOV
798
                                        break;
×
UNCOV
799
                                case 300 when this._reader.ValueAsString.Equals("TABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
800
                                        this.readStyleOverride(new CadCellStyleTemplate(formattedTable.CellStyleOverride));
×
UNCOV
801
                                        break;
×
802
                                default:
803
                                        if (!this.tryAssignCurrentValue(formattedTable, map.SubClasses[DxfSubclassMarker.FormattedTableData]))
×
804
                                        {
×
805
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
×
806
                                        }
×
807
                                        break;
×
808
                        }
809

UNCOV
810
                        this._reader.ReadNext();
×
UNCOV
811
                }
×
UNCOV
812
        }
×
813

814
        private void readLinkedTableDataSubclass(CadTemplate template, DxfMap map)
UNCOV
815
        {
×
UNCOV
816
                CadTableContentTemplate tmp = template as CadTableContentTemplate;
×
UNCOV
817
                TableContent tableContent = tmp.CadObject;
×
818

UNCOV
819
                this._reader.ReadNext();
×
820

UNCOV
821
                while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
×
UNCOV
822
                {
×
UNCOV
823
                        switch (this._reader.Code)
×
824
                        {
825
                                case 90:
826
                                        //Column count
UNCOV
827
                                        break;
×
828
                                case 91:
829
                                        //Row count
UNCOV
830
                                        break;
×
831
                                //Unknown
832
                                case 92:
UNCOV
833
                                        break;
×
UNCOV
834
                                case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumn, StringComparison.InvariantCultureIgnoreCase):
×
835
                                        //Read Column
UNCOV
836
                                        this.readTableColumn();
×
UNCOV
837
                                        break;
×
UNCOV
838
                                case 301 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRow, StringComparison.InvariantCultureIgnoreCase):
×
839
                                        //Read Row
UNCOV
840
                                        this.readTableRow();
×
UNCOV
841
                                        break;
×
842
                                default:
UNCOV
843
                                        if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.LinkedTableData]))
×
UNCOV
844
                                        {
×
UNCOV
845
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
×
UNCOV
846
                                        }
×
UNCOV
847
                                        break;
×
848
                        }
849

UNCOV
850
                        this._reader.ReadNext();
×
UNCOV
851
                }
×
UNCOV
852
        }
×
853

854

855
        private TableEntity.Column readTableColumn()
UNCOV
856
        {
×
UNCOV
857
                this._reader.ReadNext();
×
858

UNCOV
859
                TableEntity.Column column = new TableEntity.Column();
×
860

UNCOV
861
                bool end = false;
×
UNCOV
862
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
863
                {
×
UNCOV
864
                        switch (this._reader.Code)
×
865
                        {
UNCOV
866
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
867
                                        this.readLinkedTableColumn(column);
×
UNCOV
868
                                        break;
×
UNCOV
869
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
870
                                        this.readFormattedTableColumn(column);
×
UNCOV
871
                                        break;
×
UNCOV
872
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumnBegin, StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
873
                                        this.readTableColumn(column);
×
UNCOV
874
                                        end = true;
×
UNCOV
875
                                        break;
×
876
                                default:
877
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
878
                                        break;
×
879
                        }
880

UNCOV
881
                        if (end)
×
UNCOV
882
                        {
×
UNCOV
883
                                return column;
×
884
                        }
885

UNCOV
886
                        this._reader.ReadNext();
×
UNCOV
887
                }
×
888

889
                return column;
×
UNCOV
890
        }
×
891

892
        private TableEntity.Row readTableRow()
UNCOV
893
        {
×
UNCOV
894
                this._reader.ReadNext();
×
895

UNCOV
896
                TableEntity.Row row = new TableEntity.Row();
×
897

UNCOV
898
                bool end = false;
×
UNCOV
899
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
900
                {
×
UNCOV
901
                        switch (this._reader.Code)
×
902
                        {
UNCOV
903
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
904
                                        this.readLinkedTableRow(row);
×
UNCOV
905
                                        break;
×
UNCOV
906
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
907
                                        this.readFormattedTableRow(row);
×
UNCOV
908
                                        break;
×
UNCOV
909
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRowBegin, StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
910
                                        this.readTableRow(row);
×
UNCOV
911
                                        end = true;
×
UNCOV
912
                                        break;
×
913
                                default:
UNCOV
914
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
×
UNCOV
915
                                        break;
×
916
                        }
917

UNCOV
918
                        if (end)
×
UNCOV
919
                        {
×
UNCOV
920
                                return row;
×
921
                        }
922

UNCOV
923
                        this._reader.ReadNext();
×
UNCOV
924
                }
×
925

UNCOV
926
                return row;
×
UNCOV
927
        }
×
928

929
        private void readTableRow(TableEntity.Row row)
UNCOV
930
        {
×
UNCOV
931
                this._reader.ReadNext();
×
932

UNCOV
933
                bool end = false;
×
UNCOV
934
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
935
                {
×
UNCOV
936
                        switch (this._reader.Code)
×
937
                        {
938
                                case 40:
UNCOV
939
                                        row.Height = this._reader.ValueAsDouble;
×
UNCOV
940
                                        break;
×
941
                                case 90:
942
                                        //styleID
UNCOV
943
                                        break;
×
944
                                case 309:
UNCOV
945
                                        end = this._reader.ValueAsString.Equals("TABLEROW_END", StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
946
                                        break;
×
947
                                default:
948
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
×
949
                                        break;
×
950
                        }
951

UNCOV
952
                        if (end)
×
UNCOV
953
                        {
×
UNCOV
954
                                break;
×
955
                        }
956

UNCOV
957
                        this._reader.ReadNext();
×
UNCOV
958
                }
×
UNCOV
959
        }
×
960

961
        private void readFormattedTableRow(TableEntity.Row row)
UNCOV
962
        {
×
UNCOV
963
                this._reader.ReadNext();
×
964

UNCOV
965
                bool end = false;
×
UNCOV
966
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
967
                {
×
UNCOV
968
                        switch (this._reader.Code)
×
969
                        {
UNCOV
970
                                case 300 when this._reader.ValueAsString.Equals("ROWTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
971
                                        break;
×
UNCOV
972
                                case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
973
                                        this.readStyleOverride(new CadCellStyleTemplate(row.CellStyleOverride));
×
UNCOV
974
                                        break;
×
975
                                case 309:
UNCOV
976
                                        end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATAROW_END", StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
977
                                        break;
×
978
                                default:
979
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableRow)} method.", NotificationType.None);
×
980
                                        break;
×
981
                        }
982

UNCOV
983
                        if (end)
×
UNCOV
984
                        {
×
UNCOV
985
                                break;
×
986
                        }
987

UNCOV
988
                        this._reader.ReadNext();
×
UNCOV
989
                }
×
UNCOV
990
        }
×
991

992
        private void readTableColumn(TableEntity.Column column)
UNCOV
993
        {
×
UNCOV
994
                this._reader.ReadNext();
×
995

UNCOV
996
                bool end = false;
×
UNCOV
997
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
998
                {
×
UNCOV
999
                        switch (this._reader.Code)
×
1000
                        {
1001
                                case 1 when this._reader.ValueAsString.Equals("TABLECOLUMN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
1002
                                        break;
×
1003
                                case 1:
1004
                                        end = true;
×
1005
                                        break;
×
1006
                                case 40:
UNCOV
1007
                                        column.Width = this._reader.ValueAsDouble;
×
UNCOV
1008
                                        break;
×
1009
                                case 90:
1010
                                        //StyleId
UNCOV
1011
                                        break;
×
1012
                                case 309:
UNCOV
1013
                                        end = this._reader.ValueAsString.Equals("TABLECOLUMN_END", StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
1014
                                        break;
×
1015
                                default:
1016
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
1017
                                        break;
×
1018
                        }
1019

UNCOV
1020
                        if (end)
×
UNCOV
1021
                        {
×
UNCOV
1022
                                break;
×
1023
                        }
1024

UNCOV
1025
                        this._reader.ReadNext();
×
UNCOV
1026
                }
×
UNCOV
1027
        }
×
1028

1029
        private void readLinkedTableColumn(TableEntity.Column column)
UNCOV
1030
        {
×
UNCOV
1031
                this._reader.ReadNext();
×
1032

UNCOV
1033
                bool end = false;
×
UNCOV
1034
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
1035
                {
×
UNCOV
1036
                        switch (this._reader.Code)
×
1037
                        {
1038
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
1039
                                        break;
×
1040
                                case 1:
1041
                                        end = true;
×
1042
                                        break;
×
1043
                                case 91:
UNCOV
1044
                                        column.CustomData = this._reader.ValueAsInt;
×
UNCOV
1045
                                        break;
×
1046
                                case 300:
UNCOV
1047
                                        column.Name = this._reader.ValueAsString;
×
UNCOV
1048
                                        break;
×
UNCOV
1049
                                case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1050
                                        this.readCustomData();
×
UNCOV
1051
                                        break;
×
1052
                                case 309:
UNCOV
1053
                                        end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
1054
                                        break;
×
1055
                                default:
1056
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableColumn)} method.", NotificationType.None);
×
1057
                                        break;
×
1058
                        }
1059

UNCOV
1060
                        if (end)
×
UNCOV
1061
                        {
×
UNCOV
1062
                                break;
×
1063
                        }
1064

UNCOV
1065
                        this._reader.ReadNext();
×
UNCOV
1066
                }
×
UNCOV
1067
        }
×
1068

1069
        private void readLinkedTableRow(TableEntity.Row row)
UNCOV
1070
        {
×
UNCOV
1071
                this._reader.ReadNext();
×
1072

UNCOV
1073
                bool end = false;
×
UNCOV
1074
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
1075
                {
×
UNCOV
1076
                        switch (this._reader.Code)
×
1077
                        {
1078
                                case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
1079
                                        break;
×
1080
                                case 90:
UNCOV
1081
                                        break;
×
1082
                                case 91:
UNCOV
1083
                                        row.CustomData = this._reader.ValueAsInt;
×
UNCOV
1084
                                        break;
×
UNCOV
1085
                                case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectCell, StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1086
                                        this.readCell();
×
UNCOV
1087
                                        break;
×
UNCOV
1088
                                case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1089
                                        this.readCustomData();
×
UNCOV
1090
                                        break;
×
1091
                                case 309:
UNCOV
1092
                                        end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_END, StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
1093
                                        break;
×
1094
                                default:
UNCOV
1095
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableRow)} method.", NotificationType.None);
×
UNCOV
1096
                                        break;
×
1097
                        }
1098

UNCOV
1099
                        if (end)
×
UNCOV
1100
                        {
×
UNCOV
1101
                                break;
×
1102
                        }
1103

UNCOV
1104
                        this._reader.ReadNext();
×
UNCOV
1105
                }
×
UNCOV
1106
        }
×
1107

1108
        private TableEntity.Cell readCell()
UNCOV
1109
        {
×
UNCOV
1110
                this._reader.ReadNext();
×
1111

UNCOV
1112
                TableEntity.Cell cell = new TableEntity.Cell();
×
UNCOV
1113
                CadTableCellTemplate template = new CadTableCellTemplate(cell);
×
1114

UNCOV
1115
                bool end = false;
×
UNCOV
1116
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
1117
                {
×
UNCOV
1118
                        switch (this._reader.Code)
×
1119
                        {
UNCOV
1120
                                case 1 when this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1121
                                        this.readLinkedTableCell(cell);
×
UNCOV
1122
                                        break;
×
UNCOV
1123
                                case 1 when this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1124
                                        this.readFormattedTableCell(cell);
×
UNCOV
1125
                                        break;
×
UNCOV
1126
                                case 1 when this._reader.ValueAsString.Equals("TABLECELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1127
                                        this.readTableCell(cell);
×
UNCOV
1128
                                        end = true;
×
UNCOV
1129
                                        break;
×
1130
                                default:
UNCOV
1131
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCell)} method.", NotificationType.None);
×
UNCOV
1132
                                        break;
×
1133
                        }
1134

UNCOV
1135
                        if (end)
×
UNCOV
1136
                        {
×
UNCOV
1137
                                return cell;
×
1138
                        }
1139

UNCOV
1140
                        this._reader.ReadNext();
×
UNCOV
1141
                }
×
1142

UNCOV
1143
                return cell;
×
UNCOV
1144
        }
×
1145

1146
        private void readTableCell(TableEntity.Cell cell)
UNCOV
1147
        {
×
UNCOV
1148
                var map = DxfClassMap.Create(cell.GetType(), "TABLECELL_BEGIN");
×
1149

UNCOV
1150
                this._reader.ReadNext();
×
1151

UNCOV
1152
                bool end = false;
×
UNCOV
1153
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
1154
                {
×
UNCOV
1155
                        switch (this._reader.Code)
×
1156
                        {
1157
                                //Unknown
1158
                                case 40:
1159
                                case 41:
UNCOV
1160
                                        break;
×
1161
                                case 309:
UNCOV
1162
                                        end = this._reader.ValueAsString.Equals("TABLECELL_END", StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
1163
                                        break;
×
1164
                                case 330:
1165
                                        //Unknown handle
UNCOV
1166
                                        break;
×
1167
                                default:
UNCOV
1168
                                        if (!this.tryAssignCurrentValue(cell, map))
×
1169
                                        {
×
1170
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableCell)} {this._reader.Position}.", NotificationType.None);
×
1171
                                        }
×
UNCOV
1172
                                        break;
×
1173
                        }
1174

UNCOV
1175
                        if (end)
×
UNCOV
1176
                        {
×
UNCOV
1177
                                break;
×
1178
                        }
1179

UNCOV
1180
                        this._reader.ReadNext();
×
UNCOV
1181
                }
×
UNCOV
1182
        }
×
1183

1184
        private void readFormattedTableCell(TableEntity.Cell cell)
UNCOV
1185
        {
×
UNCOV
1186
                var map = DxfClassMap.Create(cell.GetType(), "FORMATTEDTABLEDATACELL_BEGIN");
×
1187

UNCOV
1188
                this._reader.ReadNext();
×
1189

UNCOV
1190
                bool end = false;
×
UNCOV
1191
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
1192
                {
×
UNCOV
1193
                        switch (this._reader.Code)
×
1194
                        {
UNCOV
1195
                                case 300 when this._reader.ValueAsString.Equals("CELLTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1196
                                        this.readCellTableFormat(cell);
×
UNCOV
1197
                                        continue;
×
1198
                                case 309:
UNCOV
1199
                                        end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
1200
                                        break;
×
1201
                                default:
1202
                                        if (!this.tryAssignCurrentValue(cell, map))
×
1203
                                        {
×
1204
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableCell)} {this._reader.Position}.", NotificationType.None);
×
1205
                                        }
×
1206
                                        break;
×
1207
                        }
1208

UNCOV
1209
                        if (end)
×
UNCOV
1210
                        {
×
UNCOV
1211
                                break;
×
1212
                        }
1213

1214
                        this._reader.ReadNext();
×
1215
                }
×
UNCOV
1216
        }
×
1217

1218
        private void readCellTableFormat(TableEntity.Cell cell)
UNCOV
1219
        {
×
UNCOV
1220
                var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
×
1221

UNCOV
1222
                this._reader.ReadNext();
×
1223

UNCOV
1224
                bool end = false;
×
UNCOV
1225
                while (this._reader.Code == 1)
×
UNCOV
1226
                {
×
UNCOV
1227
                        switch (this._reader.Code)
×
1228
                        {
UNCOV
1229
                                case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1230
                                        this.readStyleOverride(new CadCellStyleTemplate(cell.StyleOverride));
×
UNCOV
1231
                                        break;
×
1232
                                case 1 when this._reader.ValueAsString.Equals("CELLSTYLE_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
1233
                                        this.readCellStyle(new CadCellStyleTemplate());
×
1234
                                        break;
×
1235
                                default:
1236
                                        if (!this.tryAssignCurrentValue(cell, map))
×
1237
                                        {
×
1238
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellTableFormat)} {this._reader.Position}.", NotificationType.None);
×
1239
                                        }
×
1240
                                        break;
×
1241
                        }
1242

UNCOV
1243
                        if (end)
×
1244
                        {
×
1245
                                break;
×
1246
                        }
1247

UNCOV
1248
                        this._reader.ReadNext();
×
UNCOV
1249
                }
×
UNCOV
1250
        }
×
1251

1252
        private void readCellStyle(CadCellStyleTemplate template)
1253
        {
×
1254
                //var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
1255

1256
                this._reader.ReadNext();
×
1257

1258
                bool end = false;
×
1259
                while (this._reader.Code != 1)
×
1260
                {
×
1261
                        switch (this._reader.Code)
×
1262
                        {
1263
                                case 309:
1264
                                        end = this._reader.ValueAsString.Equals("CELLSTYLE_END", StringComparison.InvariantCultureIgnoreCase);
×
1265
                                        break;
×
1266
                                default:
1267
                                        //if (!this.tryAssignCurrentValue(cell, map))
1268
                                        {
×
1269
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellStyle)} {this._reader.Position}.", NotificationType.None);
×
1270
                                        }
×
1271
                                        break;
×
1272
                        }
1273

1274
                        if (end)
×
1275
                        {
×
1276
                                break;
×
1277
                        }
1278

1279
                        this._reader.ReadNext();
×
1280
                }
×
1281
        }
×
1282

1283
        private void readLinkedTableCell(TableEntity.Cell cell)
UNCOV
1284
        {
×
UNCOV
1285
                var map = DxfClassMap.Create(cell.GetType(), "LINKEDTABLEDATACELL_BEGIN");
×
1286

UNCOV
1287
                this._reader.ReadNext();
×
1288

UNCOV
1289
                bool end = false;
×
UNCOV
1290
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
1291
                {
×
UNCOV
1292
                        switch (this._reader.Code)
×
1293
                        {
1294
                                case 95:
1295
                                        //BL 95 Number of cell contents
UNCOV
1296
                                        break;
×
UNCOV
1297
                                case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1298
                                        this.readCustomData();
×
UNCOV
1299
                                        break;
×
UNCOV
1300
                                case 302 when this._reader.ValueAsString.Equals("CONTENT", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1301
                                        var c = this.readLinkedTableCellContent();
×
UNCOV
1302
                                        break;
×
1303
                                case 309:
UNCOV
1304
                                        end = this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
1305
                                        break;
×
1306
                                default:
UNCOV
1307
                                        if (!this.tryAssignCurrentValue(cell, map))
×
UNCOV
1308
                                        {
×
UNCOV
1309
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCell)} {this._reader.Position}.", NotificationType.None);
×
UNCOV
1310
                                        }
×
UNCOV
1311
                                        break;
×
1312
                        }
1313

UNCOV
1314
                        if (end)
×
UNCOV
1315
                        {
×
UNCOV
1316
                                break;
×
1317
                        }
1318

UNCOV
1319
                        this._reader.ReadNext();
×
UNCOV
1320
                }
×
UNCOV
1321
        }
×
1322

1323
        private CadTableCellContentTemplate readLinkedTableCellContent()
UNCOV
1324
        {
×
UNCOV
1325
                TableEntity.CellContent content = new TableEntity.CellContent();
×
UNCOV
1326
                CadTableCellContentTemplate template = new CadTableCellContentTemplate(content);
×
UNCOV
1327
                var map = DxfClassMap.Create(content.GetType(), "CONTENT");
×
1328

UNCOV
1329
                this._reader.ReadNext();
×
1330

UNCOV
1331
                bool end = false;
×
UNCOV
1332
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
1333
                {
×
UNCOV
1334
                        switch (this._reader.Code)
×
1335
                        {
UNCOV
1336
                                case 1 when this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1337
                                        readFormattedCellContent();
×
UNCOV
1338
                                        end = true;
×
UNCOV
1339
                                        break;
×
UNCOV
1340
                                case 1 when this._reader.ValueAsString.Equals("CELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1341
                                        readCellContent(template);
×
UNCOV
1342
                                        break;
×
1343
                                default:
1344
                                        if (!this.tryAssignCurrentValue(content, map))
×
1345
                                        {
×
1346
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCellContent)} {this._reader.Position}.", NotificationType.None);
×
1347
                                        }
×
1348
                                        break;
×
1349
                        }
1350

UNCOV
1351
                        if (end)
×
UNCOV
1352
                        {
×
UNCOV
1353
                                break;
×
1354
                        }
1355

UNCOV
1356
                        this._reader.ReadNext();
×
UNCOV
1357
                }
×
1358

UNCOV
1359
                return template;
×
UNCOV
1360
        }
×
1361

1362
        private void readCellContent(CadTableCellContentTemplate template)
UNCOV
1363
        {
×
UNCOV
1364
                TableEntity.CellContent content = template.Content;
×
UNCOV
1365
                var map = DxfClassMap.Create(content.GetType(), "CELLCONTENT_BEGIN");
×
1366

UNCOV
1367
                this._reader.ReadNext();
×
1368

UNCOV
1369
                bool end = false;
×
UNCOV
1370
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
1371
                {
×
UNCOV
1372
                        switch (this._reader.Code)
×
1373
                        {
1374
                                case 91:
UNCOV
1375
                                        break;
×
UNCOV
1376
                                case 300 when this._reader.ValueAsString.Equals("VALUE", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1377
                                        var valueTemplate = this.readCadValue(content.CadValue);
×
UNCOV
1378
                                        template.CadValueTemplate = valueTemplate;
×
UNCOV
1379
                                        break;
×
1380
                                case 309:
UNCOV
1381
                                        end = this._reader.ValueAsString.Equals("CELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
1382
                                        break;
×
1383
                                case 340:
UNCOV
1384
                                        template.BlockRecordHandle = this._reader.ValueAsHandle;
×
UNCOV
1385
                                        break;
×
1386
                                default:
UNCOV
1387
                                        if (!this.tryAssignCurrentValue(content, map))
×
1388
                                        {
×
1389
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellContent)} {this._reader.Position}.", NotificationType.None);
×
1390
                                        }
×
UNCOV
1391
                                        break;
×
1392
                        }
1393

UNCOV
1394
                        if (end)
×
UNCOV
1395
                        {
×
UNCOV
1396
                                break;
×
1397
                        }
1398

UNCOV
1399
                        this._reader.ReadNext();
×
UNCOV
1400
                }
×
UNCOV
1401
        }
×
1402

1403
        private void readFormattedCellContent()
UNCOV
1404
        {
×
UNCOV
1405
                TableStyle.ContentFormat format = new();
×
UNCOV
1406
                CellContentFormatTemplate template = new CellContentFormatTemplate(format);
×
UNCOV
1407
                var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
×
1408

UNCOV
1409
                this._reader.ReadNext();
×
1410

UNCOV
1411
                bool end = false;
×
UNCOV
1412
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
1413
                {
×
UNCOV
1414
                        switch (this._reader.Code)
×
1415
                        {
UNCOV
1416
                                case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1417
                                        readContentFormat(template);
×
UNCOV
1418
                                        break;
×
1419
                                case 309:
UNCOV
1420
                                        end = this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
1421
                                        break;
×
1422
                                default:
UNCOV
1423
                                        if (!this.tryAssignCurrentValue(format, map))
×
1424
                                        {
×
1425
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedCellContent)} method.", NotificationType.None);
×
1426
                                        }
×
UNCOV
1427
                                        break;
×
1428
                        }
1429

UNCOV
1430
                        if (end)
×
UNCOV
1431
                        {
×
UNCOV
1432
                                break;
×
1433
                        }
1434

UNCOV
1435
                        this._reader.ReadNext();
×
UNCOV
1436
                }
×
UNCOV
1437
        }
×
1438

1439
        private void readContentFormat(CellContentFormatTemplate template)
UNCOV
1440
        {
×
UNCOV
1441
                var format = template.Format;
×
UNCOV
1442
                var map = DxfClassMap.Create(format.GetType(), "CONTENTFORMAT_BEGIN");
×
1443

UNCOV
1444
                this._reader.ReadNext();
×
1445

UNCOV
1446
                bool end = false;
×
UNCOV
1447
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
1448
                {
×
UNCOV
1449
                        switch (this._reader.Code)
×
1450
                        {
UNCOV
1451
                                case 1 when this._reader.ValueAsString.Equals("CONTENTFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1452
                                        break;
×
1453
                                case 309:
UNCOV
1454
                                        end = this._reader.ValueAsString.Equals("CONTENTFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
1455
                                        break;
×
1456
                                case 340:
UNCOV
1457
                                        template.TextStyleHandle = this._reader.ValueAsHandle;
×
UNCOV
1458
                                        break;
×
1459
                                default:
UNCOV
1460
                                        if (!this.tryAssignCurrentValue(format, map))
×
1461
                                        {
×
1462
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readContentFormat)} method.", NotificationType.None);
×
1463
                                        }
×
UNCOV
1464
                                        break;
×
1465
                        }
1466

UNCOV
1467
                        if (end)
×
UNCOV
1468
                        {
×
UNCOV
1469
                                break;
×
1470
                        }
1471

UNCOV
1472
                        this._reader.ReadNext();
×
UNCOV
1473
                }
×
UNCOV
1474
        }
×
1475

1476
        private void readFormattedTableColumn(TableEntity.Column column)
UNCOV
1477
        {
×
UNCOV
1478
                this._reader.ReadNext();
×
1479

UNCOV
1480
                bool end = false;
×
UNCOV
1481
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
1482
                {
×
UNCOV
1483
                        switch (this._reader.Code)
×
1484
                        {
UNCOV
1485
                                case 300 when this._reader.ValueAsString.Equals("COLUMNTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1486
                                        break;
×
UNCOV
1487
                                case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1488
                                        this.readStyleOverride(new CadCellStyleTemplate(column.CellStyleOverride));
×
UNCOV
1489
                                        break;
×
1490
                                case 309:
UNCOV
1491
                                        end = this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
1492
                                        break;
×
1493
                                default:
1494
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableColumn)} method.", NotificationType.None);
×
1495
                                        break;
×
1496
                        }
1497

UNCOV
1498
                        if (end)
×
UNCOV
1499
                        {
×
UNCOV
1500
                                break;
×
1501
                        }
1502

UNCOV
1503
                        this._reader.ReadNext();
×
UNCOV
1504
                }
×
UNCOV
1505
        }
×
1506

1507
        private void readStyleOverride(CadCellStyleTemplate template)
UNCOV
1508
        {
×
UNCOV
1509
                var style = template.Format as TableStyle.CellStyle;
×
UNCOV
1510
                var mapstyle = DxfClassMap.Create(style.GetType(), "TABLEFORMAT_STYLE");
×
UNCOV
1511
                var mapformat = DxfClassMap.Create(typeof(TableStyle.ContentFormat), "TABLEFORMAT_BEGIN");
×
1512

UNCOV
1513
                this._reader.ReadNext();
×
1514

UNCOV
1515
                bool end = false;
×
UNCOV
1516
                var currBorder = TableStyle.CellEdgeFlags.Unknown;
×
UNCOV
1517
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
1518
                {
×
UNCOV
1519
                        switch (this._reader.Code)
×
1520
                        {
1521
                                case 95:
UNCOV
1522
                                        currBorder = (TableStyle.CellEdgeFlags)this._reader.ValueAsInt;
×
UNCOV
1523
                                        break;
×
UNCOV
1524
                                case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1525
                                        break;
×
UNCOV
1526
                                case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1527
                                        readContentFormat(new CellContentFormatTemplate(new TableStyle.ContentFormat()));
×
UNCOV
1528
                                        break;
×
UNCOV
1529
                                case 301 when this._reader.ValueAsString.Equals("MARGIN", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1530
                                        this.readCellMargin(template);
×
UNCOV
1531
                                        break;
×
UNCOV
1532
                                case 302 when this._reader.ValueAsString.Equals("GRIDFORMAT", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1533
                                        TableStyle.CellBorder border = new TableStyle.CellBorder(currBorder);
×
UNCOV
1534
                                        this.readGridFormat(template, border);
×
UNCOV
1535
                                        break;
×
1536
                                case 309:
UNCOV
1537
                                        end = this._reader.ValueAsString.Equals("TABLEFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
1538
                                        break;
×
1539
                                default:
UNCOV
1540
                                        if (!this.tryAssignCurrentValue(style, mapstyle) && !this.tryAssignCurrentValue(style, mapformat))
×
1541
                                        {
×
1542
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readStyleOverride)} method.", NotificationType.None);
×
1543
                                        }
×
UNCOV
1544
                                        break;
×
1545
                        }
1546

UNCOV
1547
                        if (end)
×
UNCOV
1548
                        {
×
UNCOV
1549
                                break;
×
1550
                        }
1551

UNCOV
1552
                        this._reader.ReadNext();
×
UNCOV
1553
                }
×
UNCOV
1554
        }
×
1555

1556
        private void readGridFormat(CadCellStyleTemplate template, TableStyle.CellBorder border)
UNCOV
1557
        {
×
UNCOV
1558
                var map = DxfClassMap.Create(border.GetType(), nameof(TableStyle.CellBorder));
×
1559

UNCOV
1560
                this._reader.ReadNext();
×
1561

UNCOV
1562
                bool end = false;
×
UNCOV
1563
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
1564
                {
×
UNCOV
1565
                        switch (this._reader.Code)
×
1566
                        {
UNCOV
1567
                                case 1 when this._reader.ValueAsString.Equals("GRIDFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1568
                                        break;
×
1569
                                case 62:
UNCOV
1570
                                        border.Color = new Color(this._reader.ValueAsShort);
×
UNCOV
1571
                                        break;
×
1572
                                case 92:
UNCOV
1573
                                        border.LineWeight = (LineWeightType)this._reader.ValueAsInt;
×
UNCOV
1574
                                        break;
×
1575
                                case 93:
UNCOV
1576
                                        border.IsInvisible = this._reader.ValueAsBool;
×
UNCOV
1577
                                        break;
×
1578
                                case 340:
UNCOV
1579
                                        template.BorderLineTypePairs.Add(new Tuple<TableStyle.CellBorder, ulong>(border, this._reader.ValueAsHandle));
×
UNCOV
1580
                                        break;
×
1581
                                case 309:
UNCOV
1582
                                        end = this._reader.ValueAsString.Equals("GRIDFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
1583
                                        break;
×
1584
                                default:
UNCOV
1585
                                        if (!this.tryAssignCurrentValue(border, map))
×
1586
                                        {
×
1587
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readGridFormat)} method.", NotificationType.None);
×
1588
                                        }
×
UNCOV
1589
                                        break;
×
1590
                        }
1591

UNCOV
1592
                        if (end)
×
UNCOV
1593
                        {
×
UNCOV
1594
                                break;
×
1595
                        }
1596

UNCOV
1597
                        this._reader.ReadNext();
×
UNCOV
1598
                }
×
UNCOV
1599
        }
×
1600

1601
        private void readCellMargin(CadCellStyleTemplate template)
UNCOV
1602
        {
×
UNCOV
1603
                var style = template.Format as TableStyle.CellStyle;
×
1604

UNCOV
1605
                this._reader.ReadNext();
×
1606

UNCOV
1607
                bool end = false;
×
UNCOV
1608
                int i = 0;
×
UNCOV
1609
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
1610
                {
×
UNCOV
1611
                        switch (this._reader.Code)
×
1612
                        {
UNCOV
1613
                                case 1 when this._reader.ValueAsString.Equals("CELLMARGIN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1614
                                        break;
×
1615
                                case 40:
UNCOV
1616
                                        switch (i)
×
1617
                                        {
1618
                                                case 0:
UNCOV
1619
                                                        style.VerticalMargin = this._reader.ValueAsDouble;
×
UNCOV
1620
                                                        break;
×
1621
                                                case 1:
UNCOV
1622
                                                        style.HorizontalMargin = this._reader.ValueAsDouble;
×
UNCOV
1623
                                                        break;
×
1624
                                                case 2:
UNCOV
1625
                                                        style.BottomMargin = this._reader.ValueAsDouble;
×
UNCOV
1626
                                                        break;
×
1627
                                                case 3:
UNCOV
1628
                                                        style.RightMargin = this._reader.ValueAsDouble;
×
UNCOV
1629
                                                        break;
×
1630
                                                case 4:
UNCOV
1631
                                                        style.MarginHorizontalSpacing = this._reader.ValueAsDouble;
×
UNCOV
1632
                                                        break;
×
1633
                                                case 5:
UNCOV
1634
                                                        style.MarginVerticalSpacing = this._reader.ValueAsDouble;
×
UNCOV
1635
                                                        break;
×
1636
                                        }
1637

UNCOV
1638
                                        i++;
×
UNCOV
1639
                                        break;
×
1640
                                case 309:
UNCOV
1641
                                        end = this._reader.ValueAsString.Equals("CELLMARGIN_END", StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
1642
                                        break;
×
1643
                                default:
1644
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellMargin)} method.", NotificationType.None);
×
1645
                                        break;
×
1646
                        }
1647

UNCOV
1648
                        if (end)
×
UNCOV
1649
                        {
×
UNCOV
1650
                                break;
×
1651
                        }
1652

UNCOV
1653
                        this._reader.ReadNext();
×
UNCOV
1654
                }
×
UNCOV
1655
        }
×
1656

1657
        private void readCustomData()
UNCOV
1658
        {
×
UNCOV
1659
                this._reader.ReadNext();
×
1660

UNCOV
1661
                int ndata = 0;
×
UNCOV
1662
                bool end = false;
×
UNCOV
1663
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
1664
                {
×
UNCOV
1665
                        switch (this._reader.Code)
×
1666
                        {
UNCOV
1667
                                case 1 when this._reader.ValueAsString.Equals("DATAMAP_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1668
                                        break;
×
1669
                                case 90:
UNCOV
1670
                                        ndata = this._reader.ValueAsInt;
×
UNCOV
1671
                                        break;
×
1672
                                case 300:
1673
                                        //Name
UNCOV
1674
                                        break;
×
UNCOV
1675
                                case 301 when this._reader.ValueAsString.Equals("DATAMAP_VALUE", StringComparison.InvariantCultureIgnoreCase):
×
UNCOV
1676
                                        this.readDataMapValue();
×
UNCOV
1677
                                        break;
×
1678
                                case 309:
UNCOV
1679
                                        end = this._reader.ValueAsString.Equals("DATAMAP_END", StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
1680
                                        break;
×
1681
                                default:
UNCOV
1682
                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCustomData)} method.", NotificationType.None);
×
UNCOV
1683
                                        break;
×
1684
                        }
1685

UNCOV
1686
                        if (end)
×
UNCOV
1687
                        {
×
UNCOV
1688
                                break;
×
1689
                        }
1690

UNCOV
1691
                        this._reader.ReadNext();
×
UNCOV
1692
                }
×
UNCOV
1693
        }
×
1694

1695
        private void readDataMapValue()
UNCOV
1696
        {
×
UNCOV
1697
                CadValue value = new();
×
UNCOV
1698
                var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
×
1699

UNCOV
1700
                this._reader.ReadNext();
×
1701

UNCOV
1702
                bool end = false;
×
UNCOV
1703
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
1704
                {
×
UNCOV
1705
                        switch (this._reader.Code)
×
1706
                        {
1707
                                case 11:
1708
                                case 21:
1709
                                case 31:
1710
                                        //Value as point
UNCOV
1711
                                        break;
×
1712
                                case 91:
1713
                                case 92:
1714
                                        //Value as int
UNCOV
1715
                                        break;
×
1716
                                case 140:
1717
                                        //Value as double
UNCOV
1718
                                        break;
×
1719
                                case 310:
1720
                                        //Value as byte array
UNCOV
1721
                                        break;
×
1722
                                case 304:
UNCOV
1723
                                        end = this._reader.ValueAsString.Equals(DxfFileToken.ValueEnd, StringComparison.InvariantCultureIgnoreCase);
×
UNCOV
1724
                                        break;
×
1725
                                default:
UNCOV
1726
                                        if (!this.tryAssignCurrentValue(value, map))
×
UNCOV
1727
                                        {
×
UNCOV
1728
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readDataMapValue)} method.", NotificationType.None);
×
UNCOV
1729
                                        }
×
UNCOV
1730
                                        break;
×
1731
                        }
1732

UNCOV
1733
                        if (end)
×
UNCOV
1734
                        {
×
UNCOV
1735
                                break;
×
1736
                        }
1737

UNCOV
1738
                        this._reader.ReadNext();
×
UNCOV
1739
                }
×
UNCOV
1740
        }
×
1741

1742
        private bool readVisualStyle(CadTemplate template, DxfMap map)
UNCOV
1743
        {
×
UNCOV
1744
                switch (this._reader.Code)
×
1745
                {
1746
                        // Undocumented codes
1747
                        case 176:
1748
                        case 177:
1749
                        case 420:
UNCOV
1750
                                return true;
×
1751
                        default:
1752
                                //Avoid noise while is not implemented
UNCOV
1753
                                return true;
×
1754
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
1755
                }
UNCOV
1756
        }
×
1757

1758
        private bool readSpatialFilter(CadTemplate template, DxfMap map)
UNCOV
1759
        {
×
UNCOV
1760
                CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
×
UNCOV
1761
                SpatialFilter filter = tmp.CadObject as SpatialFilter;
×
1762

UNCOV
1763
                switch (this._reader.Code)
×
1764
                {
1765
                        case 10:
UNCOV
1766
                                filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
×
UNCOV
1767
                                return true;
×
1768
                        case 20:
UNCOV
1769
                                var pt = filter.BoundaryPoints.LastOrDefault();
×
UNCOV
1770
                                filter.BoundaryPoints[filter.BoundaryPoints.Count - 1] = new CSMath.XY(pt.X, this._reader.ValueAsDouble);
×
UNCOV
1771
                                return true;
×
1772
                        case 40:
UNCOV
1773
                                if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
×
1774
                                {
×
1775
                                        filter.FrontDistance = this._reader.ValueAsDouble;
×
1776
                                        tmp.HasFrontPlane = true;
×
1777
                                        return true;
×
1778
                                }
1779

UNCOV
1780
                                double[] array = new double[16]
×
UNCOV
1781
                                {
×
UNCOV
1782
                                        0.0, 0.0, 0.0, 0.0,
×
UNCOV
1783
                                        0.0, 0.0, 0.0, 0.0,
×
UNCOV
1784
                                        0.0, 0.0, 0.0, 0.0,
×
UNCOV
1785
                                        0.0, 0.0, 0.0, 1.0
×
UNCOV
1786
                                };
×
1787

UNCOV
1788
                                for (int i = 0; i < 12; i++)
×
UNCOV
1789
                                {
×
UNCOV
1790
                                        array[i] = this._reader.ValueAsDouble;
×
1791

UNCOV
1792
                                        if (i < 11)
×
UNCOV
1793
                                        {
×
UNCOV
1794
                                                this._reader.ReadNext();
×
UNCOV
1795
                                        }
×
UNCOV
1796
                                }
×
1797

UNCOV
1798
                                if (tmp.InsertTransformRead)
×
1799
                                {
×
1800
                                        filter.InsertTransform = new Matrix4(array);
×
1801
                                        tmp.InsertTransformRead = true;
×
1802
                                }
×
1803
                                else
UNCOV
1804
                                {
×
UNCOV
1805
                                        filter.InverseInsertTransform = new Matrix4(array);
×
UNCOV
1806
                                }
×
1807

UNCOV
1808
                                return true;
×
1809
                        case 73:
1810
                        default:
UNCOV
1811
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
×
1812
                }
UNCOV
1813
        }
×
1814

1815
        private bool readMLineStyle(CadTemplate template, DxfMap map)
UNCOV
1816
        {
×
UNCOV
1817
                var tmp = template as CadMLineStyleTemplate;
×
UNCOV
1818
                var mLineStyle = template.CadObject as MLineStyle;
×
1819

UNCOV
1820
                switch (this._reader.Code)
×
1821
                {
1822
                        case 6:
UNCOV
1823
                                var t = tmp.ElementTemplates.LastOrDefault();
×
UNCOV
1824
                                if (t == null)
×
1825
                                {
×
1826
                                        return true;
×
1827
                                }
UNCOV
1828
                                t.LineTypeName = this._reader.ValueAsString;
×
UNCOV
1829
                                return true;
×
1830
                        case 49:
UNCOV
1831
                                MLineStyle.Element element = new MLineStyle.Element();
×
UNCOV
1832
                                CadMLineStyleTemplate.ElementTemplate elementTemplate = new CadMLineStyleTemplate.ElementTemplate(element);
×
UNCOV
1833
                                element.Offset = this._reader.ValueAsDouble;
×
1834

UNCOV
1835
                                tmp.ElementTemplates.Add(elementTemplate);
×
UNCOV
1836
                                mLineStyle.AddElement(element);
×
UNCOV
1837
                                return true;
×
1838
                        default:
UNCOV
1839
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
1840
                }
UNCOV
1841
        }
×
1842

1843
        private bool readTableStyle(CadTemplate template, DxfMap map)
UNCOV
1844
        {
×
UNCOV
1845
                var tmp = template as CadTableStyleTemplate;
×
UNCOV
1846
                var style = tmp.CadObject;
×
UNCOV
1847
                var cellStyle = tmp.CurrentCellStyleTemplate?.CellStyle;
×
1848

UNCOV
1849
                switch (this._reader.Code)
×
1850
                {
1851
                        case 7:
UNCOV
1852
                                tmp.CreateCurrentCellStyleTemplate();
×
UNCOV
1853
                                tmp.CurrentCellStyleTemplate.TextStyleName = this._reader.ValueAsString;
×
UNCOV
1854
                                return true;
×
1855
                        case 94:
1856
                                cellStyle.Alignment = this._reader.ValueAsInt;
×
1857
                                return true;
×
1858
                        case 62:
UNCOV
1859
                                cellStyle.Color = new Color(this._reader.ValueAsShort);
×
UNCOV
1860
                                return true;
×
1861
                        case 63:
UNCOV
1862
                                cellStyle.BackgroundColor = new Color(this._reader.ValueAsShort);
×
UNCOV
1863
                                return true;
×
1864
                        case 140:
UNCOV
1865
                                cellStyle.TextHeight = this._reader.ValueAsDouble;
×
UNCOV
1866
                                return true;
×
1867
                        case 170:
UNCOV
1868
                                cellStyle.CellAlignment = (TableStyle.CellAlignmentType)this._reader.ValueAsShort;
×
UNCOV
1869
                                return true;
×
1870
                        case 283:
UNCOV
1871
                                cellStyle.IsFillColorOn = this._reader.ValueAsBool;
×
UNCOV
1872
                                return true;
×
1873
                        case 90:
UNCOV
1874
                                cellStyle.Type = (TableStyle.CellStyleType)this._reader.ValueAsShort;
×
UNCOV
1875
                                return true;
×
1876
                        case 91:
UNCOV
1877
                                cellStyle.StyleClass = (TableStyle.CellStyleClass)this._reader.ValueAsShort;
×
UNCOV
1878
                                return true;
×
1879
                        case 1:
1880
                                //Undocumented
UNCOV
1881
                                return true;
×
1882
                        case 274:
UNCOV
1883
                                cellStyle.TopBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
×
UNCOV
1884
                                return true;
×
1885
                        case 275:
UNCOV
1886
                                cellStyle.HorizontalInsideBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
×
UNCOV
1887
                                return true;
×
1888
                        case 276:
UNCOV
1889
                                cellStyle.BottomBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
×
UNCOV
1890
                                return true;
×
1891
                        case 277:
UNCOV
1892
                                cellStyle.LeftBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
×
UNCOV
1893
                                return true;
×
1894
                        case 278:
UNCOV
1895
                                cellStyle.VerticalInsideBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
×
UNCOV
1896
                                return true;
×
1897
                        case 279:
UNCOV
1898
                                cellStyle.RightBorder.LineWeight = (LineWeightType)this._reader.ValueAsInt;
×
UNCOV
1899
                                return true;
×
1900
                        case 284:
UNCOV
1901
                                cellStyle.TopBorder.IsInvisible = this._reader.ValueAsBool;
×
UNCOV
1902
                                return true;
×
1903
                        case 285:
UNCOV
1904
                                cellStyle.HorizontalInsideBorder.IsInvisible = this._reader.ValueAsBool;
×
UNCOV
1905
                                return true;
×
1906
                        case 286:
UNCOV
1907
                                cellStyle.BottomBorder.IsInvisible = this._reader.ValueAsBool;
×
UNCOV
1908
                                return true;
×
1909
                        case 287:
UNCOV
1910
                                cellStyle.LeftBorder.IsInvisible = this._reader.ValueAsBool;
×
UNCOV
1911
                                return true;
×
1912
                        case 288:
UNCOV
1913
                                cellStyle.VerticalInsideBorder.IsInvisible = this._reader.ValueAsBool;
×
UNCOV
1914
                                return true;
×
1915
                        case 289:
UNCOV
1916
                                cellStyle.RightBorder.IsInvisible = this._reader.ValueAsBool;
×
UNCOV
1917
                                return true;
×
1918
                        case 64:
UNCOV
1919
                                cellStyle.TopBorder.Color = new Color(this._reader.ValueAsShort);
×
UNCOV
1920
                                return true;
×
1921
                        case 65:
UNCOV
1922
                                cellStyle.HorizontalInsideBorder.Color = new Color(this._reader.ValueAsShort);
×
UNCOV
1923
                                return true;
×
1924
                        case 66:
UNCOV
1925
                                cellStyle.BottomBorder.Color = new Color(this._reader.ValueAsShort);
×
UNCOV
1926
                                return true;
×
1927
                        case 67:
UNCOV
1928
                                cellStyle.LeftBorder.Color = new Color(this._reader.ValueAsShort);
×
UNCOV
1929
                                return true;
×
1930
                        case 68:
UNCOV
1931
                                cellStyle.VerticalInsideBorder.Color = new Color(this._reader.ValueAsShort);
×
UNCOV
1932
                                return true;
×
1933
                        case 69:
UNCOV
1934
                                cellStyle.RightBorder.Color = new Color(this._reader.ValueAsShort);
×
UNCOV
1935
                                return true;
×
1936
                        default:
UNCOV
1937
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
1938
                }
UNCOV
1939
        }
×
1940

1941
        private bool readMLeaderStyle(CadTemplate template, DxfMap map)
UNCOV
1942
        {
×
UNCOV
1943
                var tmp = template as CadMLeaderStyleTemplate;
×
1944

UNCOV
1945
                switch (this._reader.Code)
×
1946
                {
1947
                        case 179:
UNCOV
1948
                                return true;
×
1949
                        case 340:
UNCOV
1950
                                tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
×
UNCOV
1951
                                return true;
×
1952
                        case 342:
UNCOV
1953
                                tmp.MTextStyleHandle = this._reader.ValueAsHandle;
×
UNCOV
1954
                                return true;
×
1955
                        default:
UNCOV
1956
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
1957
                }
UNCOV
1958
        }
×
1959

1960
        private bool readEvaluationExpression(CadTemplate template, DxfMap map)
UNCOV
1961
        {
×
UNCOV
1962
                CadEvaluationExpressionTemplate tmp = template as CadEvaluationExpressionTemplate;
×
1963

UNCOV
1964
                switch (this._reader.Code)
×
1965
                {
1966
                        case 1:
UNCOV
1967
                                this._reader.ExpectedCode(70);
×
UNCOV
1968
                                this._reader.ExpectedCode(140);
×
UNCOV
1969
                                return true;
×
1970
                        default:
UNCOV
1971
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraphExpr]);
×
1972
                }
UNCOV
1973
        }
×
1974

1975
        private bool readBlockElement(CadTemplate template, DxfMap map)
UNCOV
1976
        {
×
UNCOV
1977
                CadBlockElementTemplate tmp = template as CadBlockElementTemplate;
×
1978

UNCOV
1979
                switch (this._reader.Code)
×
1980
                {
1981
                        default:
UNCOV
1982
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockElement]))
×
UNCOV
1983
                                {
×
UNCOV
1984
                                        return this.readEvaluationExpression(template, map);
×
1985
                                }
UNCOV
1986
                                return true;
×
1987
                }
UNCOV
1988
        }
×
1989

1990
        private bool readBlockAction(CadTemplate template, DxfMap map)
UNCOV
1991
        {
×
UNCOV
1992
                CadBlockActionTemplate tmp = template as CadBlockActionTemplate;
×
1993

UNCOV
1994
                switch (this._reader.Code)
×
1995
                {
1996
                        default:
UNCOV
1997
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockAction]))
×
UNCOV
1998
                                {
×
UNCOV
1999
                                        return this.readBlockElement(template, map);
×
2000
                                }
UNCOV
2001
                                return true;
×
2002
                }
UNCOV
2003
        }
×
2004

2005
        private bool readBlockActionBasePt(CadTemplate template, DxfMap map)
UNCOV
2006
        {
×
UNCOV
2007
                CadBlockActionBasePtTemplate tmp = template as CadBlockActionBasePtTemplate;
×
2008

UNCOV
2009
                switch (this._reader.Code)
×
2010
                {
2011
                        default:
UNCOV
2012
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockActionBasePt]))
×
UNCOV
2013
                                {
×
UNCOV
2014
                                        return this.readBlockAction(template, map);
×
2015
                                }
UNCOV
2016
                                return true;
×
2017
                }
UNCOV
2018
        }
×
2019

2020
        private bool readBlockPointParameter(CadTemplate template, DxfMap map)
UNCOV
2021
        {
×
UNCOV
2022
                CadBlockPointParameterTemplate tmp = template as CadBlockPointParameterTemplate;
×
2023

UNCOV
2024
                switch (this._reader.Code)
×
2025
                {
2026
                        default:
UNCOV
2027
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockPointParameter]))
×
UNCOV
2028
                                {
×
UNCOV
2029
                                        return this.readBlock1PtParameter(template, map);
×
2030
                                }
UNCOV
2031
                                return true;
×
2032
                }
UNCOV
2033
        }
×
2034

2035
        private bool readBlockMoveAction(CadTemplate template, DxfMap map)
UNCOV
2036
        {
×
UNCOV
2037
                CadBlockMoveActionTemplate tmp = template as CadBlockMoveActionTemplate;
×
UNCOV
2038
                BlockMoveAction action = tmp.CadObject as BlockMoveAction;
×
2039

UNCOV
2040
                switch (this._reader.Code)
×
2041
                {
2042
                        case 92:
UNCOV
2043
                                action.XDelta = this.readEvalConnection();
×
UNCOV
2044
                                return true;
×
2045
                        case 93:
UNCOV
2046
                                action.YDelta = this.readEvalConnection();
×
UNCOV
2047
                                return true;
×
2048
                        default:
UNCOV
2049
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockMoveAction]))
×
UNCOV
2050
                                {
×
UNCOV
2051
                                        return this.readBlockAction(template, map);
×
2052
                                }
UNCOV
2053
                                return true;
×
2054
                }
UNCOV
2055
        }
×
2056

2057
        private bool readBlockRotationAction(CadTemplate template, DxfMap map)
UNCOV
2058
        {
×
UNCOV
2059
                CadBlockRotationActionTemplate tmp = template as CadBlockRotationActionTemplate;
×
2060

UNCOV
2061
                switch (this._reader.Code)
×
2062
                {
2063
                        default:
UNCOV
2064
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockRotationAction]))
×
UNCOV
2065
                                {
×
UNCOV
2066
                                        return this.readBlockActionBasePt(template, map);
×
2067
                                }
UNCOV
2068
                                return true;
×
2069
                }
UNCOV
2070
        }
×
2071

2072
        private bool readBlockParameter(CadTemplate template, DxfMap map)
UNCOV
2073
        {
×
UNCOV
2074
                CadBlockParameterTemplate tmp = template as CadBlockParameterTemplate;
×
2075

UNCOV
2076
                switch (this._reader.Code)
×
2077
                {
2078
                        default:
UNCOV
2079
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockParameter]))
×
UNCOV
2080
                                {
×
UNCOV
2081
                                        return this.readBlockElement(template, map);
×
2082
                                }
UNCOV
2083
                                return true;
×
2084
                }
UNCOV
2085
        }
×
2086

2087
        private bool readBlock1PtParameter(CadTemplate template, DxfMap map)
UNCOV
2088
        {
×
UNCOV
2089
                CadBlock1PtParameterTemplate tmp = template as CadBlock1PtParameterTemplate;
×
2090

UNCOV
2091
                switch (this._reader.Code)
×
2092
                {
2093
                        case 170:
UNCOV
2094
                                this.readEvalParameterProperty(tmp.Block1PtParameter.DisplacementX);
×
UNCOV
2095
                                return true;
×
2096
                        case 171:
UNCOV
2097
                                this.readEvalParameterProperty(tmp.Block1PtParameter.DisplacementY);
×
UNCOV
2098
                                return true;
×
2099
                        default:
UNCOV
2100
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Block1PtParameter]))
×
UNCOV
2101
                                {
×
UNCOV
2102
                                        return this.readBlockParameter(template, map);
×
2103
                                }
UNCOV
2104
                                return true;
×
2105
                }
UNCOV
2106
        }
×
2107

2108
        private bool readBlock2PtParameter(CadTemplate template, DxfMap map)
UNCOV
2109
        {
×
UNCOV
2110
                var tmp = template as CadBlock2PtParameterTemplate;
×
2111

UNCOV
2112
                switch (this._reader.Code)
×
2113
                {
2114
                        case 170:
UNCOV
2115
                                short n = this._reader.ValueAsShort;
×
UNCOV
2116
                                for (int i = 0; i < n; i++)
×
UNCOV
2117
                                {
×
UNCOV
2118
                                        this._reader.ReadNext();
×
UNCOV
2119
                                        tmp.Block2PtParameter.GripIds[i] = this._reader.ValueAsShort;
×
UNCOV
2120
                                }
×
UNCOV
2121
                                return true;
×
2122
                        case 171:
UNCOV
2123
                                this.readEvalParameterProperty(tmp.Block2PtParameter.FirstPointDisplacementX);
×
UNCOV
2124
                                return true;
×
2125
                        case 172:
UNCOV
2126
                                this.readEvalParameterProperty(tmp.Block2PtParameter.FirstPointDisplacementY);
×
UNCOV
2127
                                return true;
×
2128
                        case 173:
UNCOV
2129
                                this.readEvalParameterProperty(tmp.Block2PtParameter.SecondPointDisplacementX);
×
UNCOV
2130
                                return true;
×
2131
                        case 174:
UNCOV
2132
                                this.readEvalParameterProperty(tmp.Block2PtParameter.SecondPointDisplacementY);
×
UNCOV
2133
                                return true;
×
2134
                        default:
UNCOV
2135
                                if (!this.tryAssignCurrentValue(template.CadObject, map))
×
UNCOV
2136
                                {
×
UNCOV
2137
                                        return this.readBlockParameter(template, map);
×
2138
                                }
2139
                                return true;
×
2140
                }
UNCOV
2141
        }
×
2142

2143
        private void readEvalParameterProperty(EvalParameterProperty property)
UNCOV
2144
        {
×
UNCOV
2145
                short nconnections = this._reader.ValueAsShort;
×
UNCOV
2146
                for (; nconnections > 0; nconnections--)
×
UNCOV
2147
                {
×
UNCOV
2148
                        this._reader.ReadNext();
×
UNCOV
2149
                        property.Connections.Add(this.readEvalConnection());
×
UNCOV
2150
                }
×
UNCOV
2151
        }
×
2152

2153
        private EvalConnection readEvalConnection()
UNCOV
2154
        {
×
UNCOV
2155
                EvalConnection connection = new EvalConnection();
×
2156
                // No dynamic reader for codes 9x and 30x
UNCOV
2157
                connection.Id = this._reader.ValueAsLong;
×
UNCOV
2158
                this._reader.ReadNext();
×
UNCOV
2159
                connection.Name = this._reader.ValueAsString;
×
2160

UNCOV
2161
                return connection;
×
UNCOV
2162
        }
×
2163

2164
        private bool readBlockVisibilityParameter(CadTemplate template, DxfMap map)
UNCOV
2165
        {
×
UNCOV
2166
                CadBlockVisibilityParameterTemplate tmp = template as CadBlockVisibilityParameterTemplate;
×
2167

UNCOV
2168
                switch (this._reader.Code)
×
2169
                {
2170
                        case 92:
UNCOV
2171
                                var stateCount = this._reader.ValueAsInt;
×
UNCOV
2172
                                for (int i = 0; i < stateCount; i++)
×
UNCOV
2173
                                {
×
UNCOV
2174
                                        this._reader.ReadNext();
×
UNCOV
2175
                                        tmp.StateTemplates.Add(this.readState());
×
UNCOV
2176
                                }
×
UNCOV
2177
                                return true;
×
UNCOV
2178
                        case 93 when this.currentSubclass == DxfSubclassMarker.BlockVisibilityParameter:
×
UNCOV
2179
                                var entityCount = this._reader.ValueAsInt;
×
UNCOV
2180
                                for (int i = 0; i < entityCount; i++)
×
UNCOV
2181
                                {
×
UNCOV
2182
                                        this._reader.ReadNext();
×
UNCOV
2183
                                        tmp.EntityHandles.Add(this._reader.ValueAsHandle);
×
UNCOV
2184
                                }
×
UNCOV
2185
                                return true;
×
2186
                        default:
UNCOV
2187
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityParameter]))
×
UNCOV
2188
                                {
×
UNCOV
2189
                                        return this.readBlock1PtParameter(template, map);
×
2190
                                }
UNCOV
2191
                                return true;
×
2192
                }
UNCOV
2193
        }
×
2194

2195
        private bool readBlockLinearParameter(CadTemplate template, DxfMap map)
UNCOV
2196
        {
×
UNCOV
2197
                var tmp = template as CadBlockLinearParameterTemplate;
×
2198

UNCOV
2199
                switch (this._reader.Code)
×
2200
                {
2201
                        default:
UNCOV
2202
                                if (!this.tryAssignCurrentValue(template.CadObject, map))
×
UNCOV
2203
                                {
×
UNCOV
2204
                                        return this.readBlock2PtParameter(template, map);
×
2205
                                }
UNCOV
2206
                                return true;
×
2207
                }
UNCOV
2208
        }
×
2209

2210
        private bool readBlockLookupParameter(CadTemplate template, DxfMap map)
UNCOV
2211
        {
×
UNCOV
2212
                switch (this._reader.Code)
×
2213
                {
2214
                        default:
UNCOV
2215
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockLookupParameter]))
×
UNCOV
2216
                                {
×
UNCOV
2217
                                        return this.readBlock1PtParameter(template, map);
×
2218
                                }
UNCOV
2219
                                return true;
×
2220
                }
UNCOV
2221
        }
×
2222

2223
        private bool readBlockRotationParameter(CadTemplate template, DxfMap map)
UNCOV
2224
        {
×
UNCOV
2225
                var tmp = template as CadBlockRotationParameterTemplate;
×
2226

UNCOV
2227
                switch (this._reader.Code)
×
2228
                {
2229
                        default:
UNCOV
2230
                                if (!this.tryAssignCurrentValue(template.CadObject, map))
×
UNCOV
2231
                                {
×
UNCOV
2232
                                        return this.readBlock2PtParameter(template, map);
×
2233
                                }
UNCOV
2234
                                return true;
×
2235
                }
UNCOV
2236
        }
×
2237

2238
        private CadBlockVisibilityParameterTemplate.StateTemplate readState()
UNCOV
2239
        {
×
UNCOV
2240
                var state = new BlockVisibilityParameter.State();
×
UNCOV
2241
                var template = new CadBlockVisibilityParameterTemplate.StateTemplate(state);
×
2242

UNCOV
2243
                List<int> expectedCodes = new List<int>();
×
UNCOV
2244
                expectedCodes.Add(303);
×
UNCOV
2245
                expectedCodes.Add(94);
×
UNCOV
2246
                expectedCodes.Add(95);
×
2247

UNCOV
2248
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
2249
                {
×
UNCOV
2250
                        expectedCodes.Remove(this._reader.Code);
×
2251

UNCOV
2252
                        switch (this._reader.Code)
×
2253
                        {
2254
                                case 303:
UNCOV
2255
                                        state.Name = this._reader.ValueAsString;
×
UNCOV
2256
                                        break;
×
2257
                                case 94:
UNCOV
2258
                                        var count = this._reader.ValueAsInt;
×
UNCOV
2259
                                        for (int i = 0; i < count; i++)
×
UNCOV
2260
                                        {
×
UNCOV
2261
                                                this._reader.ReadNext();
×
UNCOV
2262
                                                template.EntityHandles.Add(this._reader.ValueAsHandle);
×
UNCOV
2263
                                        }
×
UNCOV
2264
                                        break;
×
2265
                                case 95:
UNCOV
2266
                                        count = this._reader.ValueAsInt;
×
UNCOV
2267
                                        for (int i = 0; i < count; i++)
×
UNCOV
2268
                                        {
×
UNCOV
2269
                                                this._reader.ReadNext();
×
UNCOV
2270
                                                template.ExpressionHandles.Add(this._reader.ValueAsHandle);
×
UNCOV
2271
                                        }
×
UNCOV
2272
                                        break;
×
2273
                                default:
2274
                                        return template;
×
2275
                        }
2276

UNCOV
2277
                        if (!expectedCodes.Any())
×
UNCOV
2278
                        {
×
UNCOV
2279
                                break;
×
2280
                        }
2281

UNCOV
2282
                        this._reader.ReadNext();
×
UNCOV
2283
                }
×
2284

UNCOV
2285
                return template;
×
UNCOV
2286
        }
×
2287

2288
        private bool readBlockGrip(CadTemplate template, DxfMap map)
UNCOV
2289
        {
×
UNCOV
2290
                CadBlockGripTemplate tmp = template as CadBlockGripTemplate;
×
2291

UNCOV
2292
                switch (this._reader.Code)
×
2293
                {
2294
                        default:
UNCOV
2295
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGrip]))
×
UNCOV
2296
                                {
×
UNCOV
2297
                                        return this.readBlockElement(template, map);
×
2298
                                }
UNCOV
2299
                                return true;
×
2300
                }
UNCOV
2301
        }
×
2302

2303
        private bool readBlockRotationGrip(CadTemplate template, DxfMap map)
UNCOV
2304
        {
×
UNCOV
2305
                CadBlockRotationGripTemplate tmp = template as CadBlockRotationGripTemplate;
×
2306

UNCOV
2307
                switch (this._reader.Code)
×
2308
                {
2309
                        default:
UNCOV
2310
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockRotationGrip]))
×
UNCOV
2311
                                {
×
UNCOV
2312
                                        return this.readBlockGrip(template, map);
×
2313
                                }
2314
                                return true;
×
2315
                }
UNCOV
2316
        }
×
2317

2318
        private bool readBlockXYGrip(CadTemplate template, DxfMap map)
UNCOV
2319
        {
×
UNCOV
2320
                CadBlockGripTemplate tmp = template as CadBlockGripTemplate;
×
2321

UNCOV
2322
                switch (this._reader.Code)
×
2323
                {
2324
                        default:
UNCOV
2325
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockXYGrip]))
×
UNCOV
2326
                                {
×
UNCOV
2327
                                        return this.readBlockGrip(template, map);
×
2328
                                }
2329
                                return true;
×
2330
                }
UNCOV
2331
        }
×
2332

2333
        private bool readBlockVisibilityGrip(CadTemplate template, DxfMap map)
UNCOV
2334
        {
×
UNCOV
2335
                CadBlockVisibilityGripTemplate tmp = template as CadBlockVisibilityGripTemplate;
×
2336

UNCOV
2337
                switch (this._reader.Code)
×
2338
                {
2339
                        default:
UNCOV
2340
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockVisibilityGrip]))
×
UNCOV
2341
                                {
×
UNCOV
2342
                                        return this.readBlockGrip(template, map);
×
2343
                                }
2344
                                return true;
×
2345
                }
UNCOV
2346
        }
×
2347

2348
        private bool readBlockRepresentationData(CadTemplate template, DxfMap map)
UNCOV
2349
        {
×
UNCOV
2350
                CadBlockRepresentationDataTemplate tmp = template as CadBlockRepresentationDataTemplate;
×
2351

UNCOV
2352
                switch (this._reader.Code)
×
2353
                {
2354
                        case 340:
UNCOV
2355
                                tmp.BlockHandle = this._reader.ValueAsHandle;
×
UNCOV
2356
                                return true;
×
2357
                        default:
UNCOV
2358
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
2359
                }
UNCOV
2360
        }
×
2361

2362
        private bool readBlockGripExpression(CadTemplate template, DxfMap map)
UNCOV
2363
        {
×
UNCOV
2364
                CadBlockGripExpressionTemplate tmp = template as CadBlockGripExpressionTemplate;
×
2365

UNCOV
2366
                switch (this._reader.Code)
×
2367
                {
2368
                        default:
UNCOV
2369
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.BlockGripExpression]))
×
UNCOV
2370
                                {
×
UNCOV
2371
                                        return this.readEvaluationExpression(template, map);
×
2372
                                }
UNCOV
2373
                                return true;
×
2374
                }
UNCOV
2375
        }
×
2376

2377
        private bool readXRecord(CadTemplate template, DxfMap map)
UNCOV
2378
        {
×
UNCOV
2379
                CadXRecordTemplate tmp = template as CadXRecordTemplate;
×
2380

UNCOV
2381
                switch (this._reader.Code)
×
2382
                {
UNCOV
2383
                        case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
×
UNCOV
2384
                                this.readXRecordEntries(tmp);
×
UNCOV
2385
                                return true;
×
2386
                        default:
UNCOV
2387
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
×
2388
                }
UNCOV
2389
        }
×
2390

2391
        private void readXRecordEntries(CadXRecordTemplate template)
UNCOV
2392
        {
×
UNCOV
2393
                this._reader.ReadNext();
×
2394

UNCOV
2395
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
2396
                {
×
UNCOV
2397
                        switch (this._reader.GroupCodeValue)
×
2398
                        {
2399
                                case GroupCodeValueType.Point3D:
UNCOV
2400
                                        var code = this._reader.Code;
×
UNCOV
2401
                                        var x = this._reader.ValueAsDouble;
×
UNCOV
2402
                                        this._reader.ReadNext();
×
UNCOV
2403
                                        var y = this._reader.ValueAsDouble;
×
UNCOV
2404
                                        this._reader.ReadNext();
×
UNCOV
2405
                                        var z = this._reader.ValueAsDouble;
×
UNCOV
2406
                                        XYZ pt = new XYZ(x, y, z);
×
UNCOV
2407
                                        template.CadObject.CreateEntry(code, pt);
×
UNCOV
2408
                                        break;
×
2409
                                case GroupCodeValueType.Handle:
2410
                                case GroupCodeValueType.ObjectId:
2411
                                case GroupCodeValueType.ExtendedDataHandle:
UNCOV
2412
                                        template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
×
UNCOV
2413
                                        break;
×
2414
                                default:
UNCOV
2415
                                        template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
×
UNCOV
2416
                                        break;
×
2417
                        }
2418

UNCOV
2419
                        this._reader.ReadNext();
×
UNCOV
2420
                }
×
UNCOV
2421
        }
×
2422

2423
        private bool readBookColor(CadTemplate template, DxfMap map)
UNCOV
2424
        {
×
UNCOV
2425
                CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
×
UNCOV
2426
                BookColor color = tmp.CadObject as BookColor;
×
2427

UNCOV
2428
                switch (this._reader.Code)
×
2429
                {
2430
                        case 430:
UNCOV
2431
                                color.Name = this._reader.ValueAsString;
×
UNCOV
2432
                                return true;
×
2433
                        default:
UNCOV
2434
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
×
2435
                }
UNCOV
2436
        }
×
2437

2438
        private bool readDimensionAssociation(CadTemplate template, DxfMap map)
UNCOV
2439
        {
×
UNCOV
2440
                CadDimensionAssociationTemplate tmp = template as CadDimensionAssociationTemplate;
×
UNCOV
2441
                DimensionAssociation dimassoc = tmp.CadObject;
×
2442

UNCOV
2443
                switch (this._reader.Code)
×
2444
                {
UNCOV
2445
                        case 1 when this._reader.ValueAsString.Equals(DimensionAssociation.OsnapPointRefClassName):
×
UNCOV
2446
                                if (dimassoc.AssociativityFlags.HasFlag(AssociativityFlags.FirstPointReference)
×
UNCOV
2447
                                        && dimassoc.FirstPointRef == null)
×
UNCOV
2448
                                {
×
UNCOV
2449
                                        dimassoc.FirstPointRef = new DimensionAssociation.OsnapPointRef();
×
UNCOV
2450
                                        this.readOsnapPointRef(dimassoc.FirstPointRef);
×
UNCOV
2451
                                        this.lockPointer = true;
×
UNCOV
2452
                                        return true;
×
2453
                                }
2454

UNCOV
2455
                                if (dimassoc.AssociativityFlags.HasFlag(AssociativityFlags.SecondPointReference)
×
UNCOV
2456
                                        && dimassoc.SecondPointRef == null)
×
UNCOV
2457
                                {
×
UNCOV
2458
                                        dimassoc.SecondPointRef = new DimensionAssociation.OsnapPointRef();
×
UNCOV
2459
                                        this.readOsnapPointRef(dimassoc.SecondPointRef);
×
UNCOV
2460
                                        this.lockPointer = true;
×
UNCOV
2461
                                        return true;
×
2462
                                }
2463

2464
                                if (dimassoc.AssociativityFlags.HasFlag(AssociativityFlags.ThirdPointReference)
×
2465
                                        && dimassoc.ThirdPointRef == null)
×
2466
                                {
×
2467
                                        dimassoc.ThirdPointRef = new DimensionAssociation.OsnapPointRef();
×
2468
                                        this.readOsnapPointRef(dimassoc.ThirdPointRef);
×
2469
                                        this.lockPointer = true;
×
2470
                                        return true;
×
2471
                                }
2472

2473
                                if (dimassoc.AssociativityFlags.HasFlag(AssociativityFlags.FourthPointReference)
×
2474
                                        && dimassoc.FourthPointRef == null)
×
2475
                                {
×
2476
                                        dimassoc.FourthPointRef = new DimensionAssociation.OsnapPointRef();
×
2477
                                        this.readOsnapPointRef(dimassoc.FourthPointRef);
×
2478
                                        this.lockPointer = true;
×
2479
                                        return true;
×
2480
                                }
2481

2482
                                return true;
×
UNCOV
2483
                        case 330 when template.OwnerHandle.HasValue:
×
UNCOV
2484
                                tmp.DimensionHandle = this._reader.ValueAsHandle;
×
UNCOV
2485
                                return true;
×
2486
                        default:
UNCOV
2487
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
2488
                }
UNCOV
2489
        }
×
2490

2491
        private CadDimensionAssociationTemplate.OsnapPointRefTemplate readOsnapPointRef(DimensionAssociation.OsnapPointRef osnapPoint)
UNCOV
2492
        {
×
UNCOV
2493
                var template = new CadDimensionAssociationTemplate.OsnapPointRefTemplate(osnapPoint);
×
2494

UNCOV
2495
                this._reader.ReadNext();
×
2496

UNCOV
2497
                bool end = false;
×
UNCOV
2498
                while (!end)
×
UNCOV
2499
                {
×
UNCOV
2500
                        switch (this._reader.Code)
×
2501
                        {
2502
                                case 10:
UNCOV
2503
                                        osnapPoint.OsnapPoint = new XYZ(
×
UNCOV
2504
                                                this._reader.ValueAsDouble,
×
UNCOV
2505
                                                osnapPoint.OsnapPoint.Y,
×
UNCOV
2506
                                                osnapPoint.OsnapPoint.Z
×
UNCOV
2507
                                                );
×
UNCOV
2508
                                        break;
×
2509
                                case 20:
UNCOV
2510
                                        osnapPoint.OsnapPoint = new XYZ(
×
UNCOV
2511
                                                osnapPoint.OsnapPoint.X,
×
UNCOV
2512
                                                this._reader.ValueAsDouble,
×
UNCOV
2513
                                                osnapPoint.OsnapPoint.Z
×
UNCOV
2514
                                                );
×
UNCOV
2515
                                        break;
×
2516
                                case 30:
UNCOV
2517
                                        osnapPoint.OsnapPoint = new XYZ(
×
UNCOV
2518
                                        osnapPoint.OsnapPoint.X,
×
UNCOV
2519
                                        osnapPoint.OsnapPoint.Y,
×
UNCOV
2520
                                        this._reader.ValueAsDouble
×
UNCOV
2521
                                        );
×
UNCOV
2522
                                        break;
×
2523
                                case 40:
UNCOV
2524
                                        osnapPoint.GeometryParameter = this._reader.ValueAsDouble;
×
UNCOV
2525
                                        break;
×
2526
                                case 72:
UNCOV
2527
                                        osnapPoint.ObjectOsnapType = (ObjectOsnapType)this._reader.ValueAsShort;
×
UNCOV
2528
                                        break;
×
2529
                                case 73:
UNCOV
2530
                                        osnapPoint.SubentType = (SubentType)this._reader.ValueAsShort;
×
UNCOV
2531
                                        break;
×
2532
                                case 74:
2533
                                        osnapPoint.IntersectionSubType = (SubentType)this._reader.ValueAsShort;
×
2534
                                        break;
×
2535
                                case 75:
UNCOV
2536
                                        osnapPoint.HasLastPointRef = this._reader.ValueAsBool;
×
UNCOV
2537
                                        break;
×
2538
                                case 91:
UNCOV
2539
                                        osnapPoint.GsMarker = this._reader.ValueAsInt;
×
UNCOV
2540
                                        break;
×
2541
                                case 92:
2542
                                        osnapPoint.IntersectionGsMarker = this._reader.ValueAsInt;
×
2543
                                        break;
×
2544
                                case 331:
UNCOV
2545
                                        template.ObjectHandle = this._reader.ValueAsHandle;
×
UNCOV
2546
                                        break;
×
2547
                                case 302:
2548
                                case 332:
2549
                                        //What are these?
2550
                                        break;
×
2551
                                default:
UNCOV
2552
                                        end = true;
×
UNCOV
2553
                                        continue;
×
2554
                        }
2555

UNCOV
2556
                        this._reader.ReadNext();
×
UNCOV
2557
                }
×
2558

UNCOV
2559
                return template;
×
UNCOV
2560
        }
×
2561

2562
        private bool readDictionary(CadTemplate template, DxfMap map)
UNCOV
2563
        {
×
UNCOV
2564
                CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
×
UNCOV
2565
                CadDictionary cadDictionary = tmp.CadObject;
×
2566

UNCOV
2567
                switch (this._reader.Code)
×
2568
                {
2569
                        case 280:
UNCOV
2570
                                cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
×
UNCOV
2571
                                return true;
×
2572
                        case 281:
UNCOV
2573
                                cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
×
UNCOV
2574
                                return true;
×
2575
                        case 3:
UNCOV
2576
                                tmp.Entries.Add(this._reader.ValueAsString, null);
×
UNCOV
2577
                                return true;
×
2578
                        case 350: // Soft-owner ID/handle to entry object 
2579
                        case 360: // Hard-owner ID/handle to entry object
UNCOV
2580
                                tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
×
UNCOV
2581
                                return true;
×
2582
                        default:
UNCOV
2583
                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
×
2584
                }
UNCOV
2585
        }
×
2586

2587
        private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
UNCOV
2588
        {
×
UNCOV
2589
                CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
×
2590

UNCOV
2591
                switch (this._reader.Code)
×
2592
                {
2593
                        case 340:
UNCOV
2594
                                tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
×
UNCOV
2595
                                return true;
×
2596
                        default:
UNCOV
2597
                                if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
×
UNCOV
2598
                                {
×
UNCOV
2599
                                        return this.readDictionary(template, map);
×
2600
                                }
2601
                                return true;
×
2602
                }
UNCOV
2603
        }
×
2604

2605
        private CadTemplate readSortentsTable()
UNCOV
2606
        {
×
UNCOV
2607
                SortEntitiesTable sortTable = new SortEntitiesTable();
×
UNCOV
2608
                CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
×
2609

2610
                //Jump the 0 marker
UNCOV
2611
                this._reader.ReadNext();
×
2612

UNCOV
2613
                this.readCommonObjectData(template);
×
2614

UNCOV
2615
                System.Diagnostics.Debug.Assert(DxfSubclassMarker.SortentsTable == this._reader.ValueAsString);
×
2616

2617
                //Jump the 100 marker
UNCOV
2618
                this._reader.ReadNext();
×
2619

UNCOV
2620
                (ulong?, ulong?) pair = (null, null);
×
2621

UNCOV
2622
                while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
2623
                {
×
UNCOV
2624
                        switch (this._reader.Code)
×
2625
                        {
2626
                                case 5:
UNCOV
2627
                                        pair.Item1 = this._reader.ValueAsHandle;
×
UNCOV
2628
                                        break;
×
2629
                                case 330:
UNCOV
2630
                                        template.BlockOwnerHandle = this._reader.ValueAsHandle;
×
UNCOV
2631
                                        break;
×
2632
                                case 331:
UNCOV
2633
                                        pair.Item2 = this._reader.ValueAsHandle;
×
UNCOV
2634
                                        break;
×
2635
                                default:
2636
                                        this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
2637
                                        break;
×
2638
                        }
2639

UNCOV
2640
                        if (pair.Item1.HasValue && pair.Item2.HasValue)
×
UNCOV
2641
                        {
×
UNCOV
2642
                                template.Values.Add((pair.Item1.Value, pair.Item2.Value));
×
UNCOV
2643
                                pair = (null, null);
×
UNCOV
2644
                        }
×
2645

UNCOV
2646
                        this._reader.ReadNext();
×
UNCOV
2647
                }
×
2648

UNCOV
2649
                return template;
×
UNCOV
2650
        }
×
2651
}
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