From 644c9a513bfce01431a18479d9621b9f8613bcc1 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Sun, 30 Aug 2015 20:36:59 +0200 Subject: [PATCH] Prevent crash on running NextColumn element. - FEHLERBEHEBUNG: Kein Absturz mehr, wenn zwei Spalten formatiert werden. --- zaaReloaded2/Formatter/Formatter.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/zaaReloaded2/Formatter/Formatter.cs b/zaaReloaded2/Formatter/Formatter.cs index 6639198..185e1cd 100755 --- a/zaaReloaded2/Formatter/Formatter.cs +++ b/zaaReloaded2/Formatter/Formatter.cs @@ -121,6 +121,14 @@ namespace zaaReloaded2.Formatter { 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; 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(); Globals.ThisAddIn.Application.UndoRecord.EndCustomRecord(); }