Skip to content

Commit 842992f

Browse files
author
Florian Krabbenhoeft
committed
Migradoc/DocumentObjectModel/Tables: Replaced several NInt properties with int?, when relevant for tables.
NOTE: Part of table rendering speedup.
1 parent f2a13c3 commit 842992f

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

MigraDocCore.DocumentObjectModel/MigraDoc.DocumentObjectModel.Tables/Cell.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,22 +338,22 @@ public Shading Shading
338338
/// </summary>
339339
public int MergeRight
340340
{
341-
get { return this.mergeRight.Value; }
342-
set { this.mergeRight.Value = value; }
341+
get { return this.mergeRight ?? 0; }
342+
set { this.mergeRight = value; }
343343
}
344344
[DV]
345-
internal NInt mergeRight = NInt.NullValue;
345+
internal int? mergeRight;
346346

347347
/// <summary>
348348
/// Gets or sets the number of cells to be merged down.
349349
/// </summary>
350350
public int MergeDown
351351
{
352-
get { return this.mergeDown.Value; }
353-
set { this.mergeDown.Value = value; }
352+
get { return this.mergeDown ?? 0; }
353+
set { this.mergeDown = value; }
354354
}
355355
[DV]
356-
internal NInt mergeDown = NInt.NullValue;
356+
internal int? mergeDown;
357357

358358
/// <summary>
359359
/// Gets the collection of document objects that defines the cell.
@@ -405,10 +405,10 @@ internal override void Serialize(Serializer serializer)
405405
if (!this.IsNull("Format"))
406406
this.format.Serialize(serializer, "Format", null);
407407

408-
if (!this.mergeDown.IsNull)
408+
if (this.mergeDown.HasValue)
409409
serializer.WriteSimpleAttribute("MergeDown", this.MergeDown);
410410

411-
if (!this.mergeRight.IsNull)
411+
if (this.mergeRight.HasValue)
412412
serializer.WriteSimpleAttribute("MergeRight", this.MergeRight);
413413

414414
if (!this.verticalAlignment.IsNull)

MigraDocCore.DocumentObjectModel/MigraDoc.DocumentObjectModel.Tables/Column.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,16 @@ public int Index
115115
{
116116
get
117117
{
118-
if (IsNull("Index"))
118+
if (!index.HasValue)
119119
{
120120
Columns clms = this.Parent as Columns;
121-
SetValue("Index", clms.IndexOf(this));
121+
SetValue("Index", index = clms.IndexOf(this));
122122
}
123-
return index;
123+
return index ?? 0;
124124
}
125125
}
126126
[DV]
127-
internal NInt index = NInt.NullValue;
127+
internal int? index;
128128

129129
/// <summary>
130130
/// Gets a cell by its row index. The first cell has index 0.
@@ -134,7 +134,7 @@ public Cell this[int index]
134134
get
135135
{
136136
//Check.ArgumentOutOfRange(index >= 0 && index < table.Rows.Count, "index");
137-
return Table.Rows[index][this.index];
137+
return Table.Rows[index][this.index ?? 0];
138138
}
139139
}
140140

@@ -230,11 +230,11 @@ public Borders Borders
230230
/// </summary>
231231
public int KeepWith
232232
{
233-
get { return this.keepWith.Value; }
234-
set { this.keepWith.Value = value; }
233+
get { return this.keepWith ?? 0; }
234+
set { this.keepWith = value; }
235235
}
236236
[DV]
237-
internal NInt keepWith = NInt.NullValue;
237+
internal int? keepWith;
238238

239239
/// <summary>
240240
/// Gets or sets a value which define whether the column is a header.
@@ -309,7 +309,7 @@ internal override void Serialize(Serializer serializer)
309309
if (!this.width.IsNull)
310310
serializer.WriteSimpleAttribute("Width", this.Width);
311311

312-
if (!this.keepWith.IsNull)
312+
if (this.keepWith.HasValue)
313313
serializer.WriteSimpleAttribute("KeepWith", this.KeepWith);
314314

315315
if (!this.IsNull("Borders"))

MigraDocCore.DocumentObjectModel/MigraDoc.DocumentObjectModel.Tables/Row.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ public int Index
124124
if (!index.HasValue)
125125
{
126126
Rows rws = this.parent as Rows;
127-
SetValue("Index", rws.IndexOf(this));
127+
SetValue("Index", index = rws.IndexOf(this));
128128
}
129-
return index.Value;
129+
return index ?? 0;
130130
}
131131
}
132132
[DV]
@@ -286,11 +286,11 @@ public Shading Shading
286286
/// </summary>
287287
public int KeepWith
288288
{
289-
get { return this.keepWith.Value; }
290-
set { this.keepWith.Value = value; }
289+
get { return this.keepWith ?? 0; }
290+
set { this.keepWith = value; }
291291
}
292292
[DV]
293-
internal NInt keepWith = NInt.NullValue;
293+
internal int? keepWith;
294294

295295
/// <summary>
296296
/// Gets the Cells collection of the table.
@@ -360,7 +360,7 @@ internal override void Serialize(Serializer serializer)
360360
if (!this.verticalAlignment.IsNull)
361361
serializer.WriteSimpleAttribute("VerticalAlignment", this.VerticalAlignment);
362362

363-
if (!this.keepWith.IsNull)
363+
if (this.keepWith.HasValue)
364364
serializer.WriteSimpleAttribute("KeepWith", this.KeepWith);
365365

366366
//Borders & Shading

MigraDocCore.DocumentObjectModel/MigraDoc.DocumentObjectModel.Visitors/MergedCellList.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public Borders GetEffectiveBorders(Cell cell)
189189

190190
if (cell.mergeRight > 0)
191191
{
192-
Cell rightBorderCell = cell.Table[cell.Row.Index, cell.Column.Index + cell.mergeRight];
192+
Cell rightBorderCell = cell.Table[cell.Row.Index, cell.Column.Index + (cell.mergeRight ?? 0)];
193193
if (rightBorderCell.borders != null && rightBorderCell.borders.right != null)
194194
borders.Right = rightBorderCell.borders.right.Clone();
195195
else
@@ -198,7 +198,7 @@ public Borders GetEffectiveBorders(Cell cell)
198198

199199
if (cell.mergeDown > 0)
200200
{
201-
Cell bottomBorderCell = cell.Table[cell.Row.Index + cell.mergeDown, cell.Column.Index];
201+
Cell bottomBorderCell = cell.Table[cell.Row.Index + (cell.mergeDown ?? 0), cell.Column.Index];
202202
if (bottomBorderCell.borders != null && bottomBorderCell.borders.bottom != null)
203203
borders.Bottom = bottomBorderCell.borders.bottom.Clone();
204204
else

0 commit comments

Comments
 (0)