WCNCKL: Improve pagination of checklists, i.e. don’t break if 1st substep doesn’t fit on page
WCNCLK: ‘SplitText’ moved out of file & use it from RtfTools
This commit is contained in:
parent
aa264a4e5d
commit
fbb2df544c
@ -500,6 +500,17 @@ namespace Volian.Print.Library
|
||||
, MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath);
|
||||
break;
|
||||
}
|
||||
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.WolfcreekCKLFormat)
|
||||
{
|
||||
if (!paraBreak.MyItemInfo.IsHigh // not a high level step
|
||||
&& paraBreak.MyParent.MyItemInfo.IsHigh // my parent is a hls
|
||||
&& paraBreak.MyItemInfo.MyPrevious == null // first substep
|
||||
&& paraBreak.MyParent.MyItemInfo.FormatStepData.UseSmartTemplate) // my parent has the checklist header
|
||||
{
|
||||
if (DebugPagination.IsOpen) DebugPagination.WriteLine("Breaking at parent of {0}", paraBreak.MyItemInfo.DisplayText);
|
||||
paraBreak = paraBreak.MyParent;
|
||||
}
|
||||
}
|
||||
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) // only do the following for Calvert Alarms
|
||||
{
|
||||
//if (lastBreak != null && lastBreak.MyItemInfo.InList(42656,42923)) Console.WriteLine("here");
|
||||
|
@ -1694,7 +1694,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
|
||||
// Otherwise determine how many line to split the text into
|
||||
List<string> titleLines = SplitText(title, (int)len);
|
||||
List<string> titleLines = Volian.Base.Library.RtfTools.SplitText(title, (int)len);
|
||||
|
||||
// Adjust y location based on which pagelist token & how many lines. Proctitle1 is adjusted if
|
||||
// there are more than 2 lines (proctitle1 should have it's own y location that is used if there are 1 or 2 lines.)
|
||||
@ -1738,7 +1738,7 @@ namespace Volian.Print.Library
|
||||
|
||||
float yoff = (float)pageItem.Row;
|
||||
|
||||
List<string> titleLines = SplitText(title, (int)len);
|
||||
List<string> titleLines = Volian.Base.Library.RtfTools.SplitText(title, (int)len);
|
||||
foreach (string line in titleLines)
|
||||
{
|
||||
svgGroup.Add(PageItemToSvgText(pageItem.Token, yoff, xoff, (E_Justify)pageItem.Justify, pageItem.Font, line, MySection));
|
||||
@ -1747,7 +1747,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
private string SplitTitleAndUnit(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string token, string plstr)
|
||||
{
|
||||
List<string> titleLines = SplitText(title, (int)len);
|
||||
List<string> titleLines = Volian.Base.Library.RtfTools.SplitText(title, (int)len);
|
||||
// Add a separate line with the Unit Number
|
||||
titleLines.Add("UNIT " + MySection.MyDocVersion.DocVersionConfig.Unit_Number);
|
||||
// Adjust y location based on which pagelist token & how many lines.
|
||||
@ -1803,7 +1803,7 @@ namespace Volian.Print.Library
|
||||
return plstr;
|
||||
}
|
||||
// Otherwise determine how many line to split the text into
|
||||
List<string> titleLines = SplitText(title, (int)len);
|
||||
List<string> titleLines = Volian.Base.Library.RtfTools.SplitText(title, (int)len);
|
||||
if (match == "{COVERTITLE1}" || match == "[COVERTITLE1]")
|
||||
{
|
||||
plstr = plstr.Replace(match, titleLines[0]);
|
||||
@ -1827,112 +1827,6 @@ namespace Volian.Print.Library
|
||||
}
|
||||
return plstr;
|
||||
}
|
||||
private List<string> SplitText(string text, int len)
|
||||
{
|
||||
List<string> results = new List<string>();
|
||||
if (text.Contains("\\LINE ") || text.Contains("\r\n"))
|
||||
{
|
||||
string[] mySplit = {"\\LINE ","\r\n"};
|
||||
return new List<string>(text.Split(mySplit, StringSplitOptions.None));
|
||||
|
||||
}
|
||||
int width = 0; // width of text, non-rtf
|
||||
int start = 0; // start of line (index into string 'text'), includes rtf
|
||||
int lastspace = 0; // location of lastspace (index into string 'text'), includes rtf
|
||||
int startNonRtf = 0; // start of line, non-rtf (used for determining starting position to determine width if there was a break)
|
||||
string rtfprefix = "";
|
||||
string nextprefix = "";
|
||||
for (int indx = 0; indx < text.Length; indx++)
|
||||
{
|
||||
if (text[indx] == '\\') //rtf command
|
||||
{
|
||||
// look for three things at beginning of string: hex, unicode, rtfcommand.
|
||||
Match m = Regex.Match(text.Substring(indx), @"^\\'[a-fA-F0-9][a-fA-F0-9]"); //hex
|
||||
if (m.Success)
|
||||
{
|
||||
indx += m.Length - 1;
|
||||
width++;
|
||||
}
|
||||
else
|
||||
{
|
||||
m = Regex.Match(text.Substring(indx), @"^\\[uU][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][?]"); // 3 char unicode, for example \u160? (hardspace)
|
||||
if (m.Success)
|
||||
{
|
||||
indx += m.Length - 1;
|
||||
width++;
|
||||
}
|
||||
else
|
||||
{
|
||||
m = Regex.Match(text.Substring(indx), @"^\\[uU][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][?]");
|
||||
if (m.Success)
|
||||
{
|
||||
indx += m.Length - 1;
|
||||
width++;
|
||||
}
|
||||
else
|
||||
{
|
||||
m = Regex.Match(text.Substring(indx), @"^\\[^ ]*? ");
|
||||
if (m.Success)
|
||||
{
|
||||
indx += m.Length - 1;
|
||||
rtfprefix = AdjustRtfPrefix(rtfprefix, m.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (text[indx] == ' ')
|
||||
{
|
||||
lastspace = indx;
|
||||
startNonRtf = width;
|
||||
}
|
||||
width++;
|
||||
if (width > len)
|
||||
{
|
||||
// what should be done if lastspace == 0
|
||||
// cannot find space char to split on, so break the word
|
||||
// not ideal but PROMS was bombing otherwise - jsj 7/7/2014
|
||||
if (lastspace == 0)
|
||||
{
|
||||
lastspace = indx;
|
||||
startNonRtf = width - 1;
|
||||
}
|
||||
results.Add(nextprefix+text.Substring(start, lastspace-start).Trim(" ".ToCharArray()));
|
||||
nextprefix = rtfprefix;
|
||||
if (nextprefix != "") nextprefix += " ";
|
||||
start = lastspace + 1;
|
||||
width = (width - startNonRtf - 1) > 0 ? width - startNonRtf - 1 : 0;
|
||||
lastspace = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (width > 0 || start < text.Length) results.Add(nextprefix + text.Substring(start).Trim(" ".ToCharArray()));
|
||||
return results;
|
||||
}
|
||||
|
||||
private string AdjustRtfPrefix(string rtfprefix, string rtfcommand)
|
||||
{
|
||||
if (rtfcommand.Contains(@"\ulnone") || rtfcommand.Contains(@"\ul0")) // off
|
||||
rtfprefix = rtfprefix.Replace(@"\ul","");
|
||||
else if (rtfcommand.Contains(@"\ul"))
|
||||
rtfprefix += @"\ul";
|
||||
if (rtfcommand.Contains(@"\up0") || rtfcommand.Contains(@"\dn0")) rtfprefix = rtfprefix.Replace(@"\up2", "").Replace(@"\dn2", "");
|
||||
else if (rtfcommand.Contains(@"\up")) rtfprefix += @"\up2";
|
||||
else if (rtfcommand.Contains(@"\dn")) rtfprefix += @"\dn2";
|
||||
if (rtfcommand.Contains(@"\b0"))
|
||||
rtfprefix = rtfprefix.Replace(@"\b", "");
|
||||
else if (rtfcommand.Contains(@"\b"))
|
||||
rtfprefix += @"\b";
|
||||
if (rtfcommand.Contains(@"\i0"))
|
||||
rtfprefix = rtfprefix.Replace(@"\i", "");
|
||||
else if (rtfcommand.Contains(@"\i"))
|
||||
rtfprefix += @"\i";
|
||||
return rtfprefix;
|
||||
}
|
||||
private int FindWidth(string title, int start, int len)
|
||||
{
|
||||
for (int ii = start + len; ii > start; ii--)
|
||||
|
Loading…
x
Reference in New Issue
Block a user