diff --git a/PROMS/VEPROMS.CSLA.Library/Format/ENums.cs b/PROMS/VEPROMS.CSLA.Library/Format/ENums.cs index 3b4aadce..457379df 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/ENums.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/ENums.cs @@ -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 { diff --git a/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs b/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs index e72de45d..f0729510 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs @@ -5022,6 +5022,14 @@ namespace VEPROMS.CSLA.Library return LazyLoad(ref _LowerCaseStepInTran, "@LowerCaseStepInTran"); } } + private LazyLoad _BoldTransition; + public bool BoldTransition + { + get + { + return LazyLoad(ref _BoldTransition, "@BoldTransition"); + } + } } #endregion #region TransType diff --git a/PROMS/Volian.Controls.Library/DisplayText.cs b/PROMS/Volian.Controls.Library/DisplayText.cs index 9fa0b476..be0bb209 100644 --- a/PROMS/Volian.Controls.Library/DisplayText.cs +++ b/PROMS/Volian.Controls.Library/DisplayText.cs @@ -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(@""); @@ -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 -1) + { + string findit = beforeTran.Substring(0, beforeTran.LastIndexOf(@"\v = 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 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) {