Prevent crash on running NextColumn element.

- FEHLERBEHEBUNG: Kein Absturz mehr, wenn zwei Spalten formatiert werden.
This commit is contained in:
Daniel Kraus 2015-08-30 20:36:59 +02:00
parent 6e969dacd9
commit 644c9a513b

View File

@ -121,6 +121,14 @@ namespace zaaReloaded2.Formatter
{ {
if (!CanRun) throw new NoLaboratoryDataException("No laboratory data to format."); if (!CanRun) throw new NoLaboratoryDataException("No laboratory data to format.");
// Create undo record and styles prior to iterating over the elements
// because a column switching element might trigger output to the
// document.
Globals.ThisAddIn.Application.UndoRecord.StartCustomRecord(
String.Format("Laborformatierung ({0})", Properties.Settings.Default.AddinName)
);
CreateStyles();
int current = 0; int current = 0;
while (current < Settings.Elements.Count) while (current < Settings.Elements.Count)
{ {
@ -146,11 +154,6 @@ namespace zaaReloaded2.Formatter
} }
} }
// Write everything to the Word document
Globals.ThisAddIn.Application.UndoRecord.StartCustomRecord(
String.Format("Laborformatierung ({0})", Properties.Settings.Default.AddinName)
);
CreateStyles();
_secondaryBuffer.Flush(); _secondaryBuffer.Flush();
Globals.ThisAddIn.Application.UndoRecord.EndCustomRecord(); Globals.ThisAddIn.Application.UndoRecord.EndCustomRecord();
} }