From 238724db6c549c649134d06efc0f839a6a103287 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 25 Feb 2014 15:22:18 +0000 Subject: [PATCH] Added logic to handle RO table (in word section) that uses underbars to draw the horizontal lines. --- .../Extension/DocumentExt.cs | 73 +++++++++++-------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs index 5e99160a..752efc4f 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs @@ -1051,39 +1051,52 @@ namespace VEPROMS.CSLA.Library } // Back in the DOS days, an underbar was used to toggle underlining on/off // Spit the val text on the underbar characters - string[] parts = val.Split("_".ToCharArray()); - foreach (string part in parts) - { - // If there is a carrage return, and underline is turned on, then turn off the underline - if (sel.Font.Underline != LBWdUnderline.wdUnderlineNone && part.Contains("\r")) + string[] parts = val.Split("_".ToCharArray()); + foreach (string part in parts) { - int idx = part.IndexOf("\r"); - string part1 = part.Substring(0, idx); - string part2 = part.Substring(idx); - sel.TypeText(part1); - sel.Font.Underline = LBWdUnderline.wdUnderlineNone; - sel.TypeText(part2); - } - else // put out each part of the split text and toggle the underline on/off - { - // Farley had a case where the underlining of text with spaces at end of line was - // not underlining the spaces. To fix this, test for spaces at the end of text - // and ireplace last space with a hard space. Note that the underlying issue - // existed in MS Word, so this is a work around from our code to make MS Word work. - // The problem was in Farley's FNP-1-ECP-3.1, Table 1 - 'ro': W.4T. - if (part.EndsWith(" ")) + // if we have a row of underbar "_" chars then we will parts of empty strings. + // in this case, we want to output the underbar char and turn off underlining. + // Ex Commanche Peak RO table in ECA-1.1A Attachment 5 + if (part.Equals("")) + { + if (sel.Font.Underline != LBWdUnderline.wdUnderlineNone) + { + sel.Font.Underline = LBWdUnderline.wdUnderlineNone; + sel.TypeText("_"); + } + sel.TypeText("_"); + } + // If there is a carrage return, and underline is turned on, then turn off the underline + else if (sel.Font.Underline != LBWdUnderline.wdUnderlineNone && part.Contains("\r")) { - sel.TypeText(part.Substring(0,part.Length-1)); - sel.InsertSymbol(160); - } - else - sel.TypeText(part); - - if (sel.Font.Underline == LBWdUnderline.wdUnderlineNone) - sel.Font.Underline = LBWdUnderline.wdUnderlineSingle; - else + int idx = part.IndexOf("\r"); + string part1 = part.Substring(0, idx); + string part2 = part.Substring(idx); + sel.TypeText(part1); sel.Font.Underline = LBWdUnderline.wdUnderlineNone; - } + sel.TypeText(part2); + } + else // put out each part of the split text and toggle the underline on/off + { + // Farley had a case where the underlining of text with spaces at end of line was + // not underlining the spaces. To fix this, test for spaces at the end of text + // and ireplace last space with a hard space. Note that the underlying issue + // existed in MS Word, so this is a work around from our code to make MS Word work. + // The problem was in Farley's FNP-1-ECP-3.1, Table 1 - 'ro': W.4T. + if (part.EndsWith(" ")) + { + sel.TypeText(part.Substring(0, part.Length - 1)); + sel.InsertSymbol(160); + } + else + sel.TypeText(part); + + if (sel.Font.Underline == LBWdUnderline.wdUnderlineNone) + sel.Font.Underline = LBWdUnderline.wdUnderlineSingle; + else + sel.Font.Underline = LBWdUnderline.wdUnderlineNone; + } + //} } // We are done processing the text in val, if underline is on, turn it off if (sel.Font.Underline != LBWdUnderline.wdUnderlineNone)