Fixed issue with RO table in a Word section. If the RO token was spaced over, only the first row of the table would be spaced over.

This commit is contained in:
John Jenko 2015-03-18 12:21:57 +00:00
parent 77da149ce7
commit e24574e1b0

View File

@ -870,7 +870,7 @@ namespace VEPROMS.CSLA.Library
val = val.Replace("\xF8", "\xB0");
// An X/Y Plot RO type might have text preceding the Plot Commands
int pstart = val.IndexOf("<<G"); // find the starting Plot Command
AddPrecedingText(sel, val.Substring(0, pstart));// replace the RO token with what's in front of the X/Y Plot
AddPrecedingText(sel, val.Substring(0, pstart),0.0F);// replace the RO token with what's in front of the X/Y Plot
val = val.Substring(pstart); // set val to the start of the plot commands
//float width = 72 * Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) / 12.0F;
//float height = 72 * lines / 6.0F;
@ -933,7 +933,8 @@ namespace VEPROMS.CSLA.Library
}
//AddInfo("\tRO Found {0} = '{1}'", sel.Text, val);
// if val is null, then InsertROValue will put in "RO Not Found" for the value
InsertROValue(sel, val, sect.ActiveFormat.PlantFormat.FormatData.ROData.UpRoIfPrevUpper);
float indent = (float)sel.get_Information(LBWdInformation.wdHorizontalPositionRelativeToPage) - (float)sect.MyDocStyle.Layout.LeftMargin;;
InsertROValue(sel, val, sect.ActiveFormat.PlantFormat.FormatData.ROData.UpRoIfPrevUpper, indent);
}
sel = FindRO();
if (sel != null && sel.Start == lastStart)
@ -1055,7 +1056,7 @@ namespace VEPROMS.CSLA.Library
}
return indxClose;
}
public static void AddPrecedingText(LBSelection sel, string val)
public static void AddPrecedingText(LBSelection sel, string val, float indent)
{
if (val.IndexOf("_") == -1) // Is some of the text underlined?
{
@ -1064,52 +1065,66 @@ 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)
string[] parts = val.Split("_".ToCharArray());
bool firstLine = true;
foreach (string partq in parts)
{
string part = partq;
// 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 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"))
if (sel.Font.Underline != LBWdUnderline.wdUnderlineNone)
{
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);
sel.TypeText("_");
}
else // put out each part of the split text and toggle the underline on/off
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"))
{
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
{
// IP3 has a word attachment containing a table RO. The Accessory Page ID in the word document
// is spaced over several characters. When the RO value was printed, only the first line of the table
// was spaced over. The remaining lines were up against the left margin.
// this code will space over (indent) the remaining lines the same amount as the first line.
if (!firstLine) sel.ParagraphFormat.FirstLineIndent = indent;
if (firstLine && part.Contains("\r\n"))
{
// 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;
int idx = part.IndexOf("\r\n");
string beforeCR = part.Substring(0, idx + 2);
part = part.Substring(idx + 2);
sel.TypeText(beforeCR);
sel.ParagraphFormat.FirstLineIndent = indent;
}
//}
// 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)
@ -1283,7 +1298,7 @@ namespace VEPROMS.CSLA.Library
myFile.Delete();
return retval;
}
private static void InsertROValue(LBSelection sel, string roValue, bool upRoIfPrevUpper)
private static void InsertROValue(LBSelection sel, string roValue, bool upRoIfPrevUpper, float indent)
{
if (roValue == null)
{
@ -1331,7 +1346,7 @@ namespace VEPROMS.CSLA.Library
roValue = roValue.Replace(@"[XB3]", "\xB3");
sel.Text = roValue;
// look for toggling of '_' to turn underlining on/off:
AddPrecedingText(sel, roValue); // parse underlining
AddPrecedingText(sel, roValue, indent); // parse underlining
sel.Font.Color = LBWdColor.wdColorRed;
}
}