Implement text styles.
- NEU: Überschriften und pathologische Werte werden jetzt besonders ausgezeichnet (fett).
This commit is contained in:
parent
4cb2999297
commit
92a8faa972
@ -186,6 +186,6 @@ namespace Tests.Controller.Elements
|
|||||||
return _markupStripper.Replace(s, string.Empty);
|
return _markupStripper.Replace(s, string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
static readonly Regex _markupStripper = new Regex(@"</?b>");
|
static readonly Regex _markupStripper = new Regex(@"<[^>]+>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,19 @@ namespace zaaReloaded2.Formatter
|
|||||||
/// depending on whether there is text in the buffer or not.
|
/// depending on whether there is text in the buffer or not.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
/// Linking several DocumentWriters permits a cascading work flow
|
/// Linking several DocumentWriters permits a cascading work flow
|
||||||
/// with several buffers.
|
/// with several buffers.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// Markup support: The DocumentWriter supports basic markup to control
|
||||||
|
/// the text styles in the Word document.
|
||||||
|
/// </para>
|
||||||
|
/// <list type="unordered">
|
||||||
|
/// <item><b> and </b> - bold/unbold</item>
|
||||||
|
/// <item><style:NAME> - set the paragraph or character style</item>
|
||||||
|
/// <item></style> - remove *character* style</item>
|
||||||
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
class DocumentWriter
|
class DocumentWriter
|
||||||
{
|
{
|
||||||
@ -54,12 +65,6 @@ namespace zaaReloaded2.Formatter
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool HasBufferedText { get { return _buffer.Length > 0; } }
|
public bool HasBufferedText { get { return _buffer.Length > 0; } }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the desired paragraph style when flushing into
|
|
||||||
/// a Document.
|
|
||||||
/// </summary>
|
|
||||||
public string ParagraphStyle { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns text without markup from the buffer.
|
/// Returns text without markup from the buffer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -137,10 +142,6 @@ namespace zaaReloaded2.Formatter
|
|||||||
Selection s = Document.ActiveWindow.Selection;
|
Selection s = Document.ActiveWindow.Selection;
|
||||||
s.ClearCharacterDirectFormatting();
|
s.ClearCharacterDirectFormatting();
|
||||||
s.ClearParagraphDirectFormatting();
|
s.ClearParagraphDirectFormatting();
|
||||||
if (!string.IsNullOrEmpty(ParagraphStyle))
|
|
||||||
{
|
|
||||||
s.set_Style(ParagraphStyle);
|
|
||||||
}
|
|
||||||
MarkupToDocument(_buffer.ToString());
|
MarkupToDocument(_buffer.ToString());
|
||||||
}
|
}
|
||||||
if (Parent != null)
|
if (Parent != null)
|
||||||
@ -187,22 +188,33 @@ namespace zaaReloaded2.Formatter
|
|||||||
/// Parses a string containing markup (e.g., "<b>", "</b>")
|
/// Parses a string containing markup (e.g., "<b>", "</b>")
|
||||||
/// and writes formatted text to the current Document.
|
/// and writes formatted text to the current Document.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="text"></param>
|
|
||||||
void MarkupToDocument(string text)
|
void MarkupToDocument(string text)
|
||||||
{
|
{
|
||||||
string[] substrings = _markupRegex.Split(text);
|
string[] substrings = _markupRegex.Split(text);
|
||||||
|
Selection sel = Document.ActiveWindow.Selection;
|
||||||
foreach (string substring in substrings)
|
foreach (string substring in substrings)
|
||||||
{
|
{
|
||||||
switch (substring)
|
switch (substring)
|
||||||
{
|
{
|
||||||
case "<b>":
|
case "<b>":
|
||||||
Document.ActiveWindow.Selection.Font.Bold = 1;
|
sel.Font.Bold = 1;
|
||||||
break;
|
break;
|
||||||
case "</b>":
|
case "</b>":
|
||||||
Document.ActiveWindow.Selection.Font.Bold = 0;
|
sel.Font.Bold = 0;
|
||||||
|
break;
|
||||||
|
case "</style>":
|
||||||
|
sel.ClearCharacterStyle();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Document.ActiveWindow.Selection.TypeText(substring);
|
Match styleMatch = _styleRegex.Match(substring);
|
||||||
|
if (styleMatch.Success)
|
||||||
|
{
|
||||||
|
sel.set_Style(styleMatch.Groups["style"].Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sel.TypeText(substring);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,7 +226,10 @@ namespace zaaReloaded2.Formatter
|
|||||||
|
|
||||||
StringBuilder _buffer;
|
StringBuilder _buffer;
|
||||||
// Put pattern in parentheses so they will not be discarded by Regex.Split
|
// Put pattern in parentheses so they will not be discarded by Regex.Split
|
||||||
static readonly Regex _markupRegex = new Regex(@"(</?b>)");
|
// The splitting pattern must not contain subgroups!
|
||||||
|
static readonly Regex _markupRegex = new Regex(@"(<[^>]+>)");
|
||||||
|
static readonly Regex _styleRegex = new Regex(@"<style:(?<style>[^>]+)>");
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -121,8 +121,7 @@ namespace zaaReloaded2.Formatter
|
|||||||
{
|
{
|
||||||
if (!CanRun) throw new NoLaboratoryDataException("No laboratory data to format.");
|
if (!CanRun) throw new NoLaboratoryDataException("No laboratory data to format.");
|
||||||
|
|
||||||
CreateParagraphStyle();
|
CreateStyles();
|
||||||
_secondaryBuffer.ParagraphStyle = zaaReloaded2.Properties.Settings.Default.ParagraphStyleName;
|
|
||||||
int current = 0;
|
int current = 0;
|
||||||
while (current < Settings.Elements.Count)
|
while (current < Settings.Elements.Count)
|
||||||
{
|
{
|
||||||
@ -242,9 +241,9 @@ namespace zaaReloaded2.Formatter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a zaaReloaded2 paragraph style in the document.
|
/// Creates a paragraph and character styles in the document.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CreateParagraphStyle()
|
public void CreateStyles()
|
||||||
{
|
{
|
||||||
if (Document != null)
|
if (Document != null)
|
||||||
{
|
{
|
||||||
@ -253,19 +252,55 @@ namespace zaaReloaded2.Formatter
|
|||||||
// paragraph style than by using a try...catch construction.
|
// paragraph style than by using a try...catch construction.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
style = Document.Styles[Properties.Settings.Default.ParagraphStyleName];
|
style = Document.Styles[Properties.Settings.Default.StyleParagraph];
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
style = Document.Styles.Add(Properties.Settings.Default.ParagraphStyleName);
|
// Add default paragraph style for laboratory
|
||||||
|
style = Document.Styles.Add(Properties.Settings.Default.StyleParagraph);
|
||||||
style.Font.Size = 10; // pt
|
style.Font.Size = 10; // pt
|
||||||
style.Font.Bold = 0;
|
style.Font.Bold = 0;
|
||||||
style.Font.Italic = 0;
|
style.Font.Italic = 0;
|
||||||
style.Font.Underline = 0;
|
style.Font.Underline = 0;
|
||||||
|
style.ParagraphFormat.SpaceAfter = 0;
|
||||||
|
style.ParagraphFormat.SpaceBefore = 0;
|
||||||
style.ParagraphFormat.LeftIndent = 36; // pt
|
style.ParagraphFormat.LeftIndent = 36; // pt
|
||||||
style.ParagraphFormat.FirstLineIndent = -36; // pt
|
style.ParagraphFormat.FirstLineIndent = -36; // pt
|
||||||
style.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphJustify;
|
style.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphJustify;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
style = Document.Styles[Properties.Settings.Default.StyleHeader];
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Add header paragraph style for laboratory
|
||||||
|
style = Document.Styles.Add(Properties.Settings.Default.StyleHeader);
|
||||||
|
style.Font.Size = 10; // pt
|
||||||
|
style.Font.Bold = 1;
|
||||||
|
style.Font.Italic = 0;
|
||||||
|
style.Font.Underline = WdUnderline.wdUnderlineSingle;
|
||||||
|
style.ParagraphFormat.SpaceAfter = 0;
|
||||||
|
style.ParagraphFormat.SpaceBefore = 12;
|
||||||
|
style.ParagraphFormat.LeftIndent = 36; // pt
|
||||||
|
style.ParagraphFormat.FirstLineIndent = -36; // pt
|
||||||
|
style.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphJustify;
|
||||||
|
style.set_NextParagraphStyle(Document.Styles[Properties.Settings.Default.StyleParagraph]);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
style = Document.Styles[Properties.Settings.Default.StyleAbnormal];
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Add character style for abnormal parameters
|
||||||
|
style = Document.Styles.Add(
|
||||||
|
Properties.Settings.Default.StyleAbnormal,
|
||||||
|
WdStyleType.wdStyleTypeCharacter);
|
||||||
|
style.Font.Bold = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,9 @@ namespace zaaReloaded2.Formatter
|
|||||||
);
|
);
|
||||||
if (!LabItem.IsNormal)
|
if (!LabItem.IsNormal)
|
||||||
{
|
{
|
||||||
output = String.Format("<b>{0}</b>", output);
|
output = String.Format(
|
||||||
|
"<b>{0}</b>",
|
||||||
|
output);
|
||||||
}
|
}
|
||||||
|
|
||||||
formatter.Write(output);
|
formatter.Write(output);
|
||||||
|
@ -68,10 +68,12 @@ namespace zaaReloaded2.Formatter
|
|||||||
|
|
||||||
static string FormatHeader(string text)
|
static string FormatHeader(string text)
|
||||||
{
|
{
|
||||||
return String.Format("{0}<b>Laborwerte vom {1}:</b>{2}",
|
return String.Format("{0}<style:{1}>Laborwerte vom {2}:{3}<style:{4}>",
|
||||||
Environment.NewLine,
|
Environment.NewLine,
|
||||||
|
Properties.Settings.Default.StyleHeader,
|
||||||
text,
|
text,
|
||||||
Environment.NewLine
|
Environment.NewLine,
|
||||||
|
Properties.Settings.Default.StyleParagraph
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
zaaReloaded2/Properties/Settings.Designer.cs
generated
22
zaaReloaded2/Properties/Settings.Designer.cs
generated
@ -250,9 +250,9 @@ namespace zaaReloaded2.Properties {
|
|||||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("zaaReloaded2-Laborwerte")]
|
[global::System.Configuration.DefaultSettingValueAttribute("zaaReloaded2-Laborwerte")]
|
||||||
public string ParagraphStyleName {
|
public string StyleParagraph {
|
||||||
get {
|
get {
|
||||||
return ((string)(this["ParagraphStyleName"]));
|
return ((string)(this["StyleParagraph"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,5 +303,23 @@ namespace zaaReloaded2.Properties {
|
|||||||
this["ImportExportPath"] = value;
|
this["ImportExportPath"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("zaaReloaded2-Überschrift")]
|
||||||
|
public string StyleHeader {
|
||||||
|
get {
|
||||||
|
return ((string)(this["StyleHeader"]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("zaaReloaded2-Pathologisch")]
|
||||||
|
public string StyleAbnormal {
|
||||||
|
get {
|
||||||
|
return ((string)(this["StyleAbnormal"]));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
<Setting Name="LastSettings" Type="System.Guid" Scope="User">
|
<Setting Name="LastSettings" Type="System.Guid" Scope="User">
|
||||||
<Value Profile="(Default)">00000000-0000-0000-0000-000000000000</Value>
|
<Value Profile="(Default)">00000000-0000-0000-0000-000000000000</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="ParagraphStyleName" Type="System.String" Scope="Application">
|
<Setting Name="StyleParagraph" Type="System.String" Scope="Application">
|
||||||
<Value Profile="(Default)">zaaReloaded2-Laborwerte</Value>
|
<Value Profile="(Default)">zaaReloaded2-Laborwerte</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="ReferenceStyle" Type="zaaReloaded2.Formatter.ReferenceStyle" Scope="Application">
|
<Setting Name="ReferenceStyle" Type="zaaReloaded2.Formatter.ReferenceStyle" Scope="Application">
|
||||||
@ -92,5 +92,11 @@
|
|||||||
<Setting Name="ImportExportPath" Type="System.String" Scope="User">
|
<Setting Name="ImportExportPath" Type="System.String" Scope="User">
|
||||||
<Value Profile="(Default)" />
|
<Value Profile="(Default)" />
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="StyleHeader" Type="System.String" Scope="Application">
|
||||||
|
<Value Profile="(Default)">zaaReloaded2-Überschrift</Value>
|
||||||
|
</Setting>
|
||||||
|
<Setting Name="StyleAbnormal" Type="System.String" Scope="Application">
|
||||||
|
<Value Profile="(Default)">zaaReloaded2-Pathologisch</Value>
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
@ -92,7 +92,7 @@
|
|||||||
<setting name="DefaultItemsDrugs" serializeAs="String">
|
<setting name="DefaultItemsDrugs" serializeAs="String">
|
||||||
<value>Medikamente: TAC, CSA, SIR, Vancomycin, Gentamicin, Tobramicin</value>
|
<value>Medikamente: TAC, CSA, SIR, Vancomycin, Gentamicin, Tobramicin</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="ParagraphStyleName" serializeAs="String">
|
<setting name="StyleParagraph" serializeAs="String">
|
||||||
<value>zaaReloaded2-Laborwerte</value>
|
<value>zaaReloaded2-Laborwerte</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="ReferenceStyle" serializeAs="String">
|
<setting name="ReferenceStyle" serializeAs="String">
|
||||||
@ -107,6 +107,12 @@
|
|||||||
<setting name="SerializationVersion" serializeAs="String">
|
<setting name="SerializationVersion" serializeAs="String">
|
||||||
<value>1</value>
|
<value>1</value>
|
||||||
</setting>
|
</setting>
|
||||||
|
<setting name="StyleHeader" serializeAs="String">
|
||||||
|
<value>zaaReloaded2-Überschrift</value>
|
||||||
|
</setting>
|
||||||
|
<setting name="StyleAbnormal" serializeAs="String">
|
||||||
|
<value>zaaReloaded2-Pathologisch</value>
|
||||||
|
</setting>
|
||||||
</zaaReloaded2.Properties.Settings>
|
</zaaReloaded2.Properties.Settings>
|
||||||
</applicationSettings>
|
</applicationSettings>
|
||||||
<userSettings>
|
<userSettings>
|
||||||
|
Loading…
Reference in New Issue
Block a user