This commit is contained in:
Kathy Ruffing 2013-02-08 12:22:26 +00:00
parent 591f3df242
commit 7f58611e6b
4 changed files with 180 additions and 39 deletions

View File

@ -214,7 +214,8 @@ namespace VEPROMS.CSLA.Library
Partials = 0x10000, // Do replace even on partial matches
Plackeep = 0x20000, // Do replace in PlaceKeepers
InSecTitle = 0x40000
InSecTitle = 0x40000,
BeforeTrans = 0x80000 // Only do replace if the string occurs immediately before a transition.
}
public enum E_ArrowKeys : uint
{

View File

@ -5022,6 +5022,14 @@ namespace VEPROMS.CSLA.Library
return LazyLoad(ref _LowerCaseStepInTran, "@LowerCaseStepInTran");
}
}
private LazyLoad<bool> _BoldTransition;
public bool BoldTransition
{
get
{
return LazyLoad(ref _BoldTransition, "@BoldTransition");
}
}
}
#endregion
#region TransType

View File

@ -137,9 +137,11 @@ namespace Volian.Controls.Library
// lines (the 2 spaces after the first "\par " command and 1 space before 2nd "\par"). Tried other
// combinations that did not work.
if (_MyItemInfo.FormatStepData.Prefix != null && _MyItemInfo.FormatStepData.Prefix != "")
text = ReplaceLinesWithUnicode(_MyItemInfo.FormatStepData.Prefix) + @"\par " + text + @"\par ";
text = !_MyItemInfo.FormatStepData.Font.FontIsProportional() ? ReplaceLinesWithUnicode(_MyItemInfo.FormatStepData.Prefix) + @"\par " + text + @"\par ":
@"\par " + text + @"\par ";
if (_MyItemInfo.FormatStepData.Suffix != null && _MyItemInfo.FormatStepData.Suffix != "")
text = text + ReplaceLinesWithUnicode(_MyItemInfo.FormatStepData.Suffix);
text = text + (!_MyItemInfo.FormatStepData.Font.FontIsProportional() ? ReplaceLinesWithUnicode(_MyItemInfo.FormatStepData.Suffix) :
@"\par\par\par ");
}
text = CreateRtf(colorLinks, text, tableShouldBeOutlined, wordsShouldBeReplaced, numbersShouldBeFormated, tableHasBorder, ROsShouldBeAdjusted);
StartText = text;
@ -207,7 +209,7 @@ namespace Volian.Controls.Library
}
// Adjust RO display
if (ROsShouldBeAdjusted)
text = DoTransitionAdjustments(text);
text = DoTransitionAdjustments(text, _MyItemInfo.ActiveFormat.PlantFormat.FormatData.TransData.BoldTransition);
// add colors around links:
if (colorLinks)
text = DoColorLinks(text);
@ -390,7 +392,7 @@ namespace Volian.Controls.Library
}
return false;
}
private string DoTransitionAdjustments(string text)
private string DoTransitionAdjustments(string text, bool boldTran)
{
string strippedText = StaticStripRtfCommands(text);
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v \\]+)*\\v(\\[^v \\]+)* #Link:(ReferencedObject|Transition[^:]*?):[0-9]* ([0-9]*).*?\[END>");
@ -411,16 +413,22 @@ namespace Volian.Controls.Library
System.Text.RegularExpressions.Group g = m.Groups[3];
string beforeTran = retstr.Substring(0, g.Index);
string afterTran = retstr.Substring(g.Index + g.Length);
// if replacing text in the 'beforeTran' string, then do it here,
// i.e. there is a format flag 'BeforeTrans' that bolds text before the transition
// (in wst formats).
beforeTran = DoBeforeTransFlagSupport(beforeTran, _MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.ReplaceStrList);
string newvalue = g.ToString();
int indexLastSpace = newvalue.LastIndexOf(' ');
if (indexLastSpace >= 0)
// Use a "\x1" as a token to replace later. Insert the unicode char, whose length is
// more than 1 character was throwing of the regexp Matches index, so that the resulting
// string may have been incorrect.
retstr = beforeTran + newvalue.Substring(0, indexLastSpace) + "\x1" + newvalue.Substring(indexLastSpace + 1) + afterTran;
retstr = beforeTran + (boldTran ? @"\b " : null) + newvalue.Substring(0, indexLastSpace) + "\x1" + newvalue.Substring(indexLastSpace + 1) + (boldTran ? @"\b0" : null) + afterTran;
else
if (beforeTran.EndsWith(" ") )
retstr = ReplaceLastSpaceWithHardSpace(beforeTran) + newvalue + afterTran;
retstr = ReplaceLastSpaceWithHardSpace(beforeTran) + (boldTran ? @"\b " : null) + newvalue + (boldTran ? @"\b0" : null) + afterTran;
else
Console.Write("");// Don't know where to put the Hard Space
}
@ -428,6 +436,31 @@ namespace Volian.Controls.Library
}
return retstr.Replace("\x1", @"\u160?");
}
private string DoBeforeTransFlagSupport(string beforeTran, ReplaceStrList replaceStrList)
{
foreach (ReplaceStr repstr in replaceStrList)
{
if ((repstr.Flag & E_ReplaceFlags.BeforeTrans) > 0)
{
// the beforeTran string ends with the string that starts the transition comment, i.e.
// '\\v <START] \\v0 '. The replace word string needs to be before this:
int indx = beforeTran.LastIndexOf(@"\v <START]\v0");
if (indx > -1)
{
string findit = beforeTran.Substring(0, beforeTran.LastIndexOf(@"\v <START]\v0"));
if (findit != null && findit.Trim().ToUpper().EndsWith(repstr.ReplaceWord.ToUpper()))
{
int rindx = findit.Trim().ToUpper().IndexOf(repstr.ReplaceWord.ToUpper());
// don't replace string because case of words may be match replace with string.
beforeTran = findit.Substring(0, rindx) + @"\b " + findit.Substring(rindx) + @"\b0" + beforeTran.Substring(indx);
return beforeTran;
}
}
}
}
return beforeTran;
}
private string ReplaceLastSpaceWithHardSpace(string str)
{
int ind =str.LastIndexOf("<START]");

View File

@ -177,13 +177,13 @@ namespace Volian.Print.Library
if (doprint)retval = DrawText(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation);
if (MyItemInfo.IsHigh)
{
MyPageHelper.PageBookmarks.Add(MyItemInfo, MyItemInfo.MyTab.CleanText + " " + MyItemInfo.DisplayText,
MyPageHelper.PageBookmarks.Add(MyItemInfo, (MyItemInfo.MyTab == null)?"":MyItemInfo.MyTab.CleanText + " " + MyItemInfo.DisplayText,
new PdfDestination(PdfDestination.FITBH, yLocation + YVeryTop - YTopMost + SixLinesPerInch));
}
}
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.WolfcreekCKLFormat)
{
WCN_DrawBoxLines(cb, MyItemInfo, yPageStart, yTopMargin, yBottomMargin, yLocation);
DrawChkOrValveTableLines(cb, MyItemInfo, yPageStart, yTopMargin, yBottomMargin, yLocation);
}
if (MyItemInfo.IsSection)
{
@ -208,18 +208,15 @@ namespace Volian.Print.Library
//if (localYPageStart != yPageStart) DebugText.WriteLine("ParToPdf-yPagestartDiff:{0},{1},{2}", MyItemInfo.ItemID, localYPageStart, yPageStart);
return yPageStart;
}
// A few things need completed for the WCNCKL format check list boxes:
// 1) support pagination. This includes tacking on a continued message, breaking table where necessary
// and putting HLS on top of next page, along with its prefix/suffix.
// 2) support seven lines per inch - right now increments are hard coded at 12 = one line.
private void WCN_DrawBoxLines(PdfContentByte cb, ItemInfo ii, float yPageStart, float yTopMargin, float yBottomMargin, float yLocation)
private void DrawChkOrValveTableLines(PdfContentByte cb, ItemInfo ii, float yPageStart, float yTopMargin, float yBottomMargin, float yLocation)
{
if (!ii.IsStep || ii.IsCaution || ii.IsNote) return;
Box bx = ii.ActiveFormat.PlantFormat.FormatData.BoxList[0];
float lpi = MyPageHelper.YMultiplier == 1.0 ? SixLinesPerInch : _SevenLinesPerInch;
bool savedebug = Rtf2Pdf.PdfDebug;
Rtf2Pdf.PdfDebug = false;
System.Drawing.Font symbFont = new System.Drawing.Font("VESymbFix", 10);
System.Drawing.Font symbFont = new System.Drawing.Font("VESymbFix", (float)ii.FormatStepData.Font.Size);
iTextSharp.text.Font iSymblFont = Volian.Svg.Library.VolianPdf.GetFont(symbFont);
iSymblFont.Color = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black));
// The vertPos array from the format defines the column locations:
@ -239,37 +236,120 @@ namespace Volian.Print.Library
int countLine = 0;
string preSuf_Fix = (ii.FormatStepData.Prefix != null && ii.FormatStepData.Prefix != "") ? ii.FormatStepData.Prefix : null;
if (preSuf_Fix != null) countLine++; // account for a line of prefix (if no \par)
int hIndx = preSuf_Fix.IndexOf(@"{\par}");
while (preSuf_Fix != null && hIndx >= 0)
// if this is a proportional font, need to 'draw' the prefix/suffix. NOTE that the suffix should
// just list the headers and the prefix can be 'empty'.
if (ii.FormatStepData.Font.FontIsProportional())
{
hIndx = preSuf_Fix.IndexOf(@"{\par}", hIndx + 1);
countLine++;
}
preSuf_Fix = (ii.FormatStepData.Suffix != null && ii.FormatStepData.Suffix != "") ? ii.FormatStepData.Suffix : null;
if (preSuf_Fix != null) countLine++; // account for a line of suffix (if no \par)
hIndx = preSuf_Fix.IndexOf(@"{\par}");
while (preSuf_Fix != null && hIndx >= 0)
{
hIndx = preSuf_Fix.IndexOf(@"{\par}", hIndx + 1);
countLine++;
}
// get first and last vertpos for location of lines:
// for each line of text, draw the start & end box line:
countLine = (int)(this.Height / lpi) - countLine;
float yLocVertLine = yLocation - lpi/2;
for (int i = 0; i < countLine; i++)
{
Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
float yLocVertLine = yLocation + (lpi/2);
// Prefix, i.e. Top line:
Paragraph topLeftLine = new Paragraph(bx.BXULC, iSymblFont);
Rtf2Pdf.TextAt(cb, topLeftLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
Paragraph topRightLine = new Paragraph(bx.BXURC, iSymblFont);
Rtf2Pdf.TextAt(cb, topRightLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
Paragraph horzLine = new Paragraph(bx.BXHorz, iSymblFont);
float thPos = float.Parse(vertPos[0]) + csize;
while (thPos < float.Parse(vertPos[cntVertPos - 1]))
{
Rtf2Pdf.TextAt(cb, horzLine, thPos + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
thPos += csize;
}
// Vertical Lines around HLS
//int countLine = (int)(this.Height / lpi);
yLocVertLine = yLocation - (lpi / 2);
for (int i = 0; i < 1; i++)
{
Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
yLocVertLine -= lpi;
}
// Suffix, i.e. Column headers.
// first do left/right side chars above and below column headers
//countLine = (int)(this.Height / lpi);
Paragraph sideLeftLine = new Paragraph(bx.BXMLS, iSymblFont);
Rtf2Pdf.TextAt(cb, sideLeftLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
Rtf2Pdf.TextAt(cb, sideLeftLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine-(2*lpi), lWidth, 100, null, yBottomMargin);
Paragraph sideRightLine = new Paragraph(bx.BXMRS, iSymblFont);
Rtf2Pdf.TextAt(cb, sideRightLine, float.Parse(vertPos[6]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
Rtf2Pdf.TextAt(cb, sideRightLine, float.Parse(vertPos[6]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine - (2 * lpi), lWidth, 100, null, yBottomMargin);
// now do the lines with the 'T' type lines for top/bottom of vertical lines.
thPos = float.Parse(vertPos[0]) + csize;
while (thPos < float.Parse(vertPos[cntVertPos - 1]))
{
Rtf2Pdf.TextAt(cb, horzLine, thPos + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
Rtf2Pdf.TextAt(cb, horzLine, thPos + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine - (2 * lpi), lWidth, 100, null, yBottomMargin);
thPos += csize;
}
// now do the vertical bar between header words and the column header words.
yLocVertLine -= lpi;
string [] colHdrs = _MyItemInfo.FormatStepData.Suffix.Substring(_MyItemInfo.FormatStepData.Suffix.IndexOf(";")+1).Split(",".ToCharArray());
iTextSharp.text.Font iHdrFont = Volian.Svg.Library.VolianPdf.GetFont(_MyItemInfo.FormatStepData.Font.WindowsFont);
iHdrFont.Color = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black));
Paragraph topT = new Paragraph(bx.BXUMID, iSymblFont);
Paragraph crossT = new Paragraph(bx.BXMID, iSymblFont);
for (int i = 0; i < cntVertPos; i++)
{
// do vertical line:
Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[i]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
// do the column header text - center it:
if (i<colHdrs.Length)
{
Paragraph parColHdr = new Paragraph(colHdrs[i], iHdrFont);
// find the center point of column header and subtract 1/2 width of the text to locate the text.
float hloc = (float.Parse(vertPos[i]) + ((float.Parse(vertPos[i + 1]) - float.Parse(vertPos[i])) / 2));
Chunk chk = (Chunk)parColHdr.Chunks[0];
hloc = hloc - (chk.GetWidthPoint() / 2);
Rtf2Pdf.TextAt(cb, parColHdr, hloc + (float)ii.MyDocStyle.Layout.LeftMargin, yLocVertLine, lWidth, 100, null, yBottomMargin);
}
// Do the crosswise table characters, i.e. T and +
if (i > 0 && i < colHdrs.Length)
{
Rtf2Pdf.TextAt(cb, topT, float.Parse(vertPos[i]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine + lpi, lWidth, 100, null, yBottomMargin);
Rtf2Pdf.TextAt(cb, crossT, float.Parse(vertPos[i]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine - lpi, lWidth, 100, null, yBottomMargin);
}
}
}
else
#region OriginalHLS
{
int hIndx = preSuf_Fix.IndexOf(@"{\par}");
while (preSuf_Fix != null && hIndx >= 0)
{
hIndx = preSuf_Fix.IndexOf(@"{\par}", hIndx + 1);
countLine++;
}
preSuf_Fix = (ii.FormatStepData.Suffix != null && ii.FormatStepData.Suffix != "") ? ii.FormatStepData.Suffix : null;
if (preSuf_Fix != null) countLine++; // account for a line of suffix (if no \par)
hIndx = preSuf_Fix.IndexOf(@"{\par}");
while (preSuf_Fix != null && hIndx >= 0)
{
hIndx = preSuf_Fix.IndexOf(@"{\par}", hIndx + 1);
countLine++;
}
// get first and last vertpos for location of lines:
// for each line of text, draw the start & end box line:
countLine = (int)(this.Height / lpi) - countLine;
float yLocVertLine = yLocation - lpi / 2;
for (int i = 0; i < countLine; i++)
{
Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
yLocVertLine -= lpi;
}
}
#endregion OriginalHLS
}
else
{
// This section of code draws the lines around the substeps (the actual table part)
Paragraph horzLine = new Paragraph(ii.ActiveFormat.PlantFormat.FormatData.BoxList[0].BXHorz, iSymblFont);
bool bottomOfTable = (ii.NextItem == null || ii.NextItemCount == 0) ||
(MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].MyItemInfo.ItemID == ii.NextItem.ItemID);
Box bx = ii.ActiveFormat.PlantFormat.FormatData.BoxList[0];
// if bottom of table use different cross/beg/end chars than if in middle of table.
Paragraph leftLine = new Paragraph(bottomOfTable ? bx.BXLLC : bx.BXMLS, iSymblFont);
Paragraph rightLine = new Paragraph(bottomOfTable ? bx.BXLRC : bx.BXMRS, iSymblFont);
@ -360,7 +440,10 @@ namespace Volian.Print.Library
// multiplier accounts for both.
if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData.CenterOneLineOnly && MyItemInfo.MyPrevious == null && MyItemInfo.NextItem == null && Height < (1.2F * IParagraph.Leading))
IParagraph.Alignment = Element.ALIGN_CENTER;
if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData.StepPrintData.Justify == "Center")
// if this step is centered, but not part of the checklist or valvelist format, use itextsharp to center it.
// if it was part of the checklist or valvelist, then the centering is based on the column definitions for the table and
// was calculated when the paragraph was made.
if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData.StepPrintData.Justify == "Center" && !MyItemInfo.FormatStepData.StepLayoutData.AlignWithParentTab)
IParagraph.Alignment = Element.ALIGN_CENTER;
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo, yBottomMargin);
if (retval == 0) // problem occurred - paragraph was not able to be printed on page
@ -1080,7 +1163,18 @@ namespace Volian.Print.Library
{
int stplevl = TheStepLevel(itemInfo);
if (stplevl >= 0 && MyItemInfo.MyHLS.FormatStepData.VertPos[stplevl] > 0)
XOffset = float.Parse(MyItemInfo.MyHLS.FormatStepData.VertPos.Split(",".ToCharArray())[stplevl]) + (float)itemInfo.MyDocStyle.Layout.LeftMargin;
{
if (MyItemInfo.FormatStepData.StepPrintData.Justify == "Center")
{
string[] vertPos = MyItemInfo.MyHLS.FormatStepData.VertPos.Split(",".ToCharArray());
float hloc = (float.Parse(vertPos[stplevl]) + ((float.Parse(vertPos[stplevl + 1]) - float.Parse(vertPos[stplevl])) / 2));
Chunk chk = (Chunk)IParagraph.Chunks[0];
hloc = hloc - (chk.GetWidthPoint() / 2);
XOffset = hloc + (float)itemInfo.MyDocStyle.Layout.LeftMargin;
}
else
XOffset = float.Parse(MyItemInfo.MyHLS.FormatStepData.VertPos.Split(",".ToCharArray())[stplevl]) + (float)itemInfo.MyDocStyle.Layout.LeftMargin;
}
}
}
if (itemInfo.IsTablePart) // Not for grid, this is for old-style tables.
@ -2079,6 +2173,11 @@ namespace Volian.Print.Library
Width = ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, maxRNO);
Width += _WidthAdjust;
Width += adjwidth;
// if AlignHLSTabWithSect is set, we moved the starting x location of the HLS, and following steps
// to be under section header. Adjust the width accordingly, or the text may go out of the margin.
if (itemInfo.MyDocStyle.AlignHLSTabWithSect)
Width = Width - (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos;
}
else if (itemInfo.IsCaution || itemInfo.IsNote)
{