added check for null MacroDef

additional checks for checkoffs and logic support or NSP script Cautions with bullets
fixed pagelist processing issue when pagelist row has more than one token
support for NSP script Cautions
fixed problem where the END message was not printing for NSP (the Y location was negative – off the page)
This commit is contained in:
2011-12-07 14:04:53 +00:00
parent b48e39be12
commit f7cb594d76
5 changed files with 172 additions and 70 deletions

View File

@@ -561,6 +561,11 @@ namespace Volian.Print.Library
MatchCollection matches = regexFindToken.Matches(pageItem.Token);
if (matches.Count>0)
{
string plstr = "";
// When a pagelist line (row) has more than one token that is resolved to text, each resolved token text was place on top
// of each other. Use a temporary string (plstr) to process the pagelist tokens for each pagelist line (row) before adding
// it to the svgGroup.
plstr = pageItem.Token;
foreach (Match match in matches)
{
string token = match.Value;
@@ -569,9 +574,11 @@ namespace Volian.Print.Library
{
case "{!atom}":
// Add an Atom Figure to the SVG
plstr = plstr.Replace(token, "");
AddImage(svgGroup,160.5f, 170.5f,288f, 323f,"atom.bmp");
break;
case "{!cpllogo}":
plstr = plstr.Replace(token, "");
AddImage(svgGroup, 10f, 10f, 78.7f, 29.8f, "cpllogo.bmp");
break;
//case "{!domlogo}":
@@ -594,6 +601,7 @@ namespace Volian.Print.Library
case "{BOX7}":
case "{BOX8}":
case "{BOX9}":
plstr = plstr.Replace(token, "");
svgGroup.Add(PageItemToSvgUse(pageItem, FirstAndLast(token)));
break;
case "{PMODEBOX}": // need to set either 1 or 2 depending on number of columns
@@ -605,6 +613,7 @@ namespace Volian.Print.Library
else if (_MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.Two)
box = "2";
box = "{BOX" + box + "}";
plstr = plstr.Replace(token, "");
svgGroup.Add(PageItemToSvgUse(pageItem, FirstAndLast(box)));
break;
case "{DRAFTPAGE}":
@@ -627,14 +636,14 @@ namespace Volian.Print.Library
case "{PROCTITLE2}":
case "{COVERPROCTITLE}":
float linelen = (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength * (float)pageItem.Font.CPI / 12;
SplitTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text.ToUpper(), (int)linelen, token); //,rowAdj);
plstr = SplitTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text.ToUpper(), (int)linelen, token, plstr); //,rowAdj);
//SplitTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text, (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength, token);
break;
case "{COVERTITLE1}":
case "{COVERTITLE2}":
int ctlen = section.ActiveFormat.PlantFormat.FormatData.ProcData.CoverTitleLength??0;
float coverlinelen = ((ctlen == 0) ? (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength : ctlen) * (float)pageItem.Font.CPI / 12;
SplitCoverTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text, (int)coverlinelen, token);//, rowAdj);
plstr = SplitCoverTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text, (int)coverlinelen, token, plstr);//, rowAdj);
//SplitTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text, (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength, token);
break;
case "{EOPNUM}":
@@ -642,18 +651,21 @@ namespace Volian.Print.Library
string unitnum = MySection.MyDocVersion.DocVersionConfig.Unit_ProcedureNumber;
if (unitnum.Length > 0)
eopnum = unitnum.Replace("#", eopnum);
svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, eopnum)));
plstr = plstr.Replace(token, eopnum);
//svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, eopnum)));
//svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, section.MyProcedure.MyContent.Number)));
break;
case "{SECTIONLEVELTITLE}":
SplitTitle(svgGroup, pageItem, section.DisplayText, section.ActiveFormat.PlantFormat.FormatData.SectData.SectionTitleLength, token);
svgGroup.Add(PageItemToSvgText(pageItem, section.DisplayText));
plstr = SplitTitle(svgGroup, pageItem, section.DisplayText, section.ActiveFormat.PlantFormat.FormatData.SectData.SectionTitleLength, token, plstr);
//svgGroup.Add(PageItemToSvgText(pageItem, section.DisplayText));
break;
case "{SECTIONLEVELNUMBER}":
svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token,section.DisplayNumber)));
plstr = plstr.Replace(token, section.DisplayNumber);
//svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, section.DisplayNumber)));
break;
case "{UNITTEXT}":
svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token,MySection.MyDocVersion.DocVersionConfig.Unit_Text)));
plstr = plstr.Replace(token, MySection.MyDocVersion.DocVersionConfig.Unit_Text);
//svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, MySection.MyDocVersion.DocVersionConfig.Unit_Text)));
break;
case "{CHKOFFHEADING}":
int sindx = section.CheckOffHeadingIndex();
@@ -661,6 +673,7 @@ namespace Volian.Print.Library
// which is always '{NO HEADING}".
if (sindx > 0)
{
plstr = plstr.Replace(token, "");
svgGroup.Add(PageItemToSvgText(pageItem, section.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffHeaderList[sindx].CheckOffHeading, section.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffHeaderList[sindx].Font));
}
break;
@@ -673,7 +686,8 @@ namespace Volian.Print.Library
{
int indx = token.IndexOf("-");
string val = procConfig.GetValue("PSI", token.Substring(4,token.Length-5));
svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token,val)));
plstr = plstr.Replace(token, val);
//svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, val)));
}
}
else if (token.Contains(@"PS="))
@@ -683,7 +697,7 @@ namespace Volian.Print.Library
{
int indx = token.IndexOf("=");
int qindx = token.IndexOf("?", indx);
string pstok = token.Substring(indx + 1, qindx-indx-1);
string pstok = token.Substring(indx + 1, qindx - indx - 1);
string val = procConfig.GetValue("PSI", pstok);
int bindx = token.IndexOf("|", indx);
if (val == "Y")
@@ -693,7 +707,9 @@ namespace Volian.Print.Library
int eindx = token.IndexOf("}", bindx);
val = token.Substring(bindx + 1, eindx - bindx - 1);
}
if (val != null && val != "")svgGroup.Add(PageItemToSvgText(pageItem, val));
if (val != null && val != "")
plstr = plstr.Replace(token, val);
//if (val != null && val != "") svgGroup.Add(PageItemToSvgText(pageItem, val));
}
}
//else if (token.Contains(@"{DRV:Lpi "))
@@ -706,16 +722,20 @@ namespace Volian.Print.Library
// PrevRow = (float)pageItem.Row;
//}
else
svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token));
{
if (plstr != "")
svgGroup.Add(PageItemToSvgText(pageItem, plstr));
//svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token));
}
//_MyLog.InfoFormat("Token not processed {0}", token);
break;
}
}
} // end foreach matches
if (plstr != "")
svgGroup.Add(PageItemToSvgText(pageItem, plstr));
}
else
{
svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token));
}
}
// Proms page numbering designed requires a "{PAGE}" token to increment the page counter. So the easiest way
// to do that was to add a "{PAGE}" token to every page that is flagged as not to be printed.
@@ -729,14 +749,16 @@ namespace Volian.Print.Library
svgGroup.Add(new SvgImage(new System.Drawing.PointF(x, y), new System.Drawing.SizeF(w, h),
System.Windows.Forms.Application.StartupPath + @"\Resources\" + figure));
}
private void SplitTitle(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string match)
private string SplitTitle(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string match, string plstr)
//private void SplitTitle(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string match)
{
if (match == "{PROCTITLE2}") return;
if (len == null || ItemInfo.StripRtfFormatting(title).Length < len)
if (match == "{PROCTITLE2}") return plstr;
if (len == 0 || ItemInfo.StripRtfFormatting(title).Length < len)
{
if (match == "{PROCTITLE2}") return; // this would have been done in proctitle1
svgGroup.Add(PageItemToSvgText(pageItem, title));
return;
if (match == "{PROCTITLE2}") return plstr; // this would have been done in proctitle1
plstr = plstr.Replace(match, title);
//svgGroup.Add(PageItemToSvgText(pageItem, title));
return plstr;
}
// Otherwise determine how many line to split the text into
List<string> titleLines = SplitText(title, (int)len);
@@ -745,27 +767,35 @@ namespace Volian.Print.Library
// move down 6.
int adj = pageItem.Token.Contains("1") || pageItem.Token.Contains("2") ? 0 : -6;
float yOffset = adj * (titleLines.Count - 1);
int cnt = 0;
foreach (string line in titleLines)
{
svgGroup.Add(PageItemToSvgText(pageItem, line, yOffset));
cnt++;
if (cnt == 1)
plstr = plstr.Replace(match, line);
else
svgGroup.Add(PageItemToSvgText(pageItem, line, yOffset));
yOffset += 12;
}
return plstr;
}
private void SplitCoverTitle(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string match)
private string SplitCoverTitle(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string match, string plstr)
//private void SplitCoverTitle(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string match)
{
if (len == null || ItemInfo.StripRtfFormatting(title).Length < len)
{
if (match == "{COVERTITLE2}") return; // this would have been done in COVERTITLE1
svgGroup.Add(PageItemToSvgText(pageItem, title));
return;
if (match == "{COVERTITLE2}") return plstr; // this would have been done in COVERTITLE1
plstr = plstr.Replace(match, title);
//svgGroup.Add(PageItemToSvgText(pageItem, title));
return plstr;
}
// Otherwise determine how many line to split the text into
List<string> titleLines = SplitText(title, (int)len);
if (match == "{COVERTITLE1}")
{
svgGroup.Add(PageItemToSvgText(pageItem, titleLines[0]));
return;
plstr = plstr.Replace(match, titleLines[0]);
//svgGroup.Add(PageItemToSvgText(pageItem, titleLines[0]));
return plstr;
}
// if the token was proctitle, dont' adjust. If the token was PROCTITLE1/2 then
// move down 6.
@@ -780,6 +810,7 @@ namespace Volian.Print.Library
svgGroup.Add(PageItemToSvgText(pageItem, line, yOffset));
yOffset += 12;
}
return plstr;
}
private List<string> SplitText(string text, int len)
{