diff --git a/zaaReloaded2/Formatter/DocumentWriter.cs b/zaaReloaded2/Formatter/DocumentWriter.cs index 6953f92..51dad02 100755 --- a/zaaReloaded2/Formatter/DocumentWriter.cs +++ b/zaaReloaded2/Formatter/DocumentWriter.cs @@ -53,6 +53,12 @@ namespace zaaReloaded2.Formatter /// public bool HasBufferedText { get { return _buffer.Length > 0; } } + /// + /// Gets or sets the desired paragraph style when flushing into + /// a Document. + /// + public string ParagraphStyle { get; set; } + #endregion #region Constructors @@ -113,7 +119,13 @@ namespace zaaReloaded2.Formatter if (Document != null) { - Document.Range().Text = _buffer.ToString(); + Document.ActiveWindow.Selection.ClearCharacterDirectFormatting(); + Document.ActiveWindow.Selection.ClearParagraphDirectFormatting(); + if (!string.IsNullOrEmpty(ParagraphStyle)) + { + Document.ActiveWindow.Selection.set_Style(ParagraphStyle); + } + Document.ActiveWindow.Selection.Range.Text = _buffer.ToString(); } if (Parent != null) { diff --git a/zaaReloaded2/Formatter/Formatter.cs b/zaaReloaded2/Formatter/Formatter.cs index cb2724f..b7bc89c 100755 --- a/zaaReloaded2/Formatter/Formatter.cs +++ b/zaaReloaded2/Formatter/Formatter.cs @@ -145,6 +145,8 @@ namespace zaaReloaded2.Formatter current++; } } + CreateParagraphStyle(); + _secondaryBuffer.ParagraphStyle = zaaReloaded2.Properties.Settings.Default.ParagraphStyleName; _secondaryBuffer.Flush(); } @@ -206,6 +208,34 @@ namespace zaaReloaded2.Formatter ProcessAllTimePoints(controlElement.FormatElements); } + /// + /// Creates a zaaReloaded2 paragraph style in the document. + /// + public void CreateParagraphStyle() + { + if (Document != null) + { + Style style; + // Don't see a better way to check for the existence of a particular + // paragraph style than by using a try...catch construction. + try + { + style = Document.Styles[Properties.Settings.Default.ParagraphStyleName]; + } + catch + { + style = Document.Styles.Add(Properties.Settings.Default.ParagraphStyleName); + style.Font.Size = 10; // pt + style.Font.Bold = 0; + style.Font.Italic = 0; + style.Font.Underline = 0; + style.ParagraphFormat.LeftIndent = 36; // pt + style.ParagraphFormat.FirstLineIndent = -36; // pt + style.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphJustify; + } + } + } + #endregion #region Protected methods diff --git a/zaaReloaded2/Properties/Settings.Designer.cs b/zaaReloaded2/Properties/Settings.Designer.cs index 902836a..1a3bccc 100755 --- a/zaaReloaded2/Properties/Settings.Designer.cs +++ b/zaaReloaded2/Properties/Settings.Designer.cs @@ -245,5 +245,14 @@ namespace zaaReloaded2.Properties { this["LastSettings"] = value; } } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("zaaReloaded2-Laborwerte")] + public string ParagraphStyleName { + get { + return ((string)(this["ParagraphStyleName"])); + } + } } } diff --git a/zaaReloaded2/Properties/Settings.settings b/zaaReloaded2/Properties/Settings.settings index 0fab6e4..d8eee1d 100755 --- a/zaaReloaded2/Properties/Settings.settings +++ b/zaaReloaded2/Properties/Settings.settings @@ -74,5 +74,8 @@ 00000000-0000-0000-0000-000000000000 + + zaaReloaded2-Laborwerte + \ No newline at end of file diff --git a/zaaReloaded2/app.config b/zaaReloaded2/app.config index a0c5181..abffe24 100755 --- a/zaaReloaded2/app.config +++ b/zaaReloaded2/app.config @@ -92,6 +92,9 @@ Medikamente: TAC, CSA, SIR, Vancomycin, Gentamicin, Tobramicin + + zaaReloaded2-Laborwerte +