B2017-122: Crash & pagination problems in GEN_SAMGS supplemental information facing page print
This commit is contained in:
parent
8ec9d416ff
commit
f96f11aa34
@ -99,14 +99,23 @@ namespace Volian.Print.Library
|
||||
}
|
||||
else if (MyItemInfo.MyDocStyle.SupplementalInformation && MyItemInfo.IsStep)
|
||||
{
|
||||
// if this is the first caution or note from a substep, if the substep has preferred page break, break at the first caution or note:
|
||||
if ((MyItemInfo.IsCaution || MyItemInfo.IsNote) && MyItemInfo.MyParent.IsSubStep)
|
||||
{
|
||||
StepConfig scs = MyItemInfo.MyParent.MyConfig as StepConfig;
|
||||
if (MyItemInfo.MyPrevious == null && scs.Step_PreferredPagebreak) return 2;
|
||||
}
|
||||
// Now see if there is a preferred page break on this step.
|
||||
StepConfig sci = MyItemInfo.MyConfig as StepConfig;
|
||||
if (sci.Step_PreferredPagebreak)
|
||||
{
|
||||
if (MyItemInfo.IsHigh) return 1;
|
||||
// if this is the top caution/note return 1 also. Cautions always are first, that is why the check does not need to know if on a
|
||||
// caution that there are notes, but check does need if on a note, are there cautions:
|
||||
if (MyItemInfo.IsCaution && MyItemInfo.MyPrevious == null) return 1;
|
||||
if (MyItemInfo.IsNote && (MyItemInfo.MyParent.Cautions == null || MyItemInfo.MyParent.Cautions.Count == 0) && MyItemInfo.MyPrevious == null) return 1;
|
||||
if (MyItemInfo.MyParent.IsHigh && MyItemInfo.IsCaution && MyItemInfo.MyPrevious == null) return 1;
|
||||
if (MyItemInfo.MyParent.IsHigh && MyItemInfo.IsNote && (MyItemInfo.MyParent.Cautions == null || MyItemInfo.MyParent.Cautions.Count == 0) && MyItemInfo.MyPrevious == null) return 1;
|
||||
// if this is a substep that has a preferredpage break, and it has caution/note that is where the page break had to go
|
||||
if (MyItemInfo.IsSubStep && ChildrenAbove != null && ChildrenAbove.Count > 0) return 0;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@ -878,7 +887,10 @@ namespace Volian.Print.Library
|
||||
// B2017-109: for supplemental information, if there is a preferred page break, account for it.
|
||||
if (myPreferredBreaks != null && myPreferredBreaks.Count > 0 && myPreferredBreaks.Keys[0] < paraBreak.YOffset)
|
||||
{
|
||||
paraBreak = myPreferredBreaks[myPreferredBreaks.Keys[0]];
|
||||
// B2017-122: don't use preferred break if the last break was before this break
|
||||
vlnParagraph prefBreak = myPreferredBreaks[myPreferredBreaks.Keys[0]];
|
||||
if (lastBreak == null || lastBreak.MyItemInfo.ShortPath.CompareTo(prefBreak.MyItemInfo.ShortPath) == -1)
|
||||
paraBreak = prefBreak;
|
||||
myPreferredBreaks.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
@ -1205,7 +1217,7 @@ namespace Volian.Print.Library
|
||||
// The following finds all of the preferred page breaks for this step & if found adds them to a
|
||||
// list of the location & the paragraph it is on. This is used so that pagination calculations
|
||||
// occur for steps following the preferred page break rather than starting on the page after
|
||||
// substep with preferred page break (B207-109)
|
||||
// substep with preferred page break (B2017-109)
|
||||
private SortedList<float, vlnParagraph> GetMyPreferredBreaks(StepLevelList myList)
|
||||
{
|
||||
if (!MyItemInfo.MyDocStyle.SupplementalInformation) return null;
|
||||
@ -1219,7 +1231,8 @@ namespace Volian.Print.Library
|
||||
if (sci != null && sci.Step_PreferredPagebreak)
|
||||
{
|
||||
if (sdpara == null) sdpara = new SortedList<float, vlnParagraph>();
|
||||
sdpara.Add(-yLocation, myPara);
|
||||
if (myPara.ChildrenAbove != null && myPara.ChildrenAbove.Count > 0) sdpara.Add(-yLocation, myPara.ChildrenAbove[0]);
|
||||
else sdpara.Add(-yLocation, myPara);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2058,6 +2058,15 @@ namespace Volian.Print.Library
|
||||
if (MyItemInfo.IsHigh && MyPageHelper.NotesToFootNotesHLS.ContainsKey(MyItemInfo.ItemID)) AddFootNote(cb);
|
||||
|
||||
yPageStart = ChildrenAbove.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin);
|
||||
// B2017-122: if doing supinfo pagebreaks, if there should be a break on a step (not hls) that has a caution/note do it here:
|
||||
if (!MyItemInfo.IsHigh && ChildrenAbove != null && ChildrenAbove.Count > 0 && MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.DoPageBreaks && MyPromsPrinter.NeedSupInfoBreak && MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0)
|
||||
{
|
||||
// if this has a caution/note with supinfo, that is id that needs to go in pagination list, unless it is in there.
|
||||
int aboveSupinfoId = ChildrenAboveHaveSupInfo();
|
||||
if (supInfoSect.StepSectPageBreaksForSupInfo.Contains(aboveSupinfoId)) aboveSupinfoId = -1;
|
||||
supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID);
|
||||
MyPromsPrinter.NeedSupInfoBreak = false;
|
||||
}
|
||||
yPageStart = ChildrenLeft.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin);
|
||||
|
||||
// Handle the PageBreakOnStep flag for a HLS. This will put out the page break right before
|
||||
@ -2211,6 +2220,14 @@ namespace Volian.Print.Library
|
||||
id = GetIdThatHasSupInfoItemsSibNext(sib, startid);
|
||||
if (id != -1) return id;
|
||||
|
||||
// B2017-122: if this is a note or caution off substep, check if substep has supinfo:
|
||||
if ((ii.IsNote || ii.IsCaution) && !ii.MyParent.IsHigh)
|
||||
{
|
||||
if (ii.MyParent.SupInfos != null && ii.MyParent.SupInfos.Count > 0) return ii.MyParent.SupInfos[0].ItemID;
|
||||
int sbfromNC = GetSubThatHasSupInfoItems(ii.MyParent, startid);
|
||||
if (sbfromNC != -1) return sbfromNC;
|
||||
}
|
||||
|
||||
// Go to the parent, and find its next and check if it or any of its substeps or next steps or any of their substeps have supinfo,
|
||||
// and if so, return the id.
|
||||
ItemInfo par = ii.MyParent;
|
||||
@ -2264,7 +2281,6 @@ namespace Volian.Print.Library
|
||||
}
|
||||
private int GetSubThatHasSupInfoItems(ItemInfo ii, int startid)
|
||||
{
|
||||
if (ii is StepInfo && ((ii as StepInfo).MyConfig as StepConfig).Step_PreferredPagebreak && ii.ItemID != startid) return -1;
|
||||
if (ii.MyContent.ContentParts != null)
|
||||
{
|
||||
foreach (PartInfo pi in ii.MyContent.ContentParts)
|
||||
@ -3656,88 +3672,91 @@ namespace Volian.Print.Library
|
||||
string erMsg = null;
|
||||
if (itemInfo.MyContent.Text != null) // ro image
|
||||
{
|
||||
ProcedureInfo proc = itemInfo.MyProcedure;
|
||||
DocVersionInfo dvi = proc.MyDocVersion;
|
||||
ROFstInfo rofst = dvi.DocVersionAssociations[0].MyROFst;
|
||||
//rofst.docVer = dvi;
|
||||
ROFSTLookup lookup = rofst.GetROFSTLookup(dvi);
|
||||
string linkInfoText = itemInfo.MyContent.Text.Replace(@"\v ", "");
|
||||
Match m = Regex.Match(linkInfoText, @"(.*)[#]Link:([A-Za-z]*):(.*)");
|
||||
string val = null;
|
||||
if (m.Length > 0) // if m.lengh is zero, then no match was found - no RO was entered in the figure substep
|
||||
if (itemInfo.MyContent.Text != "") // also check for text, there is an RO image then:
|
||||
{
|
||||
if (m.Groups.Count < 4)
|
||||
ProcedureInfo proc = itemInfo.MyProcedure;
|
||||
DocVersionInfo dvi = proc.MyDocVersion;
|
||||
ROFstInfo rofst = dvi.DocVersionAssociations[0].MyROFst;
|
||||
//rofst.docVer = dvi;
|
||||
ROFSTLookup lookup = rofst.GetROFSTLookup(dvi);
|
||||
string linkInfoText = itemInfo.MyContent.Text.Replace(@"\v ", "");
|
||||
Match m = Regex.Match(linkInfoText, @"(.*)[#]Link:([A-Za-z]*):(.*)");
|
||||
string val = null;
|
||||
if (m.Length > 0) // if m.lengh is zero, then no match was found - no RO was entered in the figure substep
|
||||
{
|
||||
//erMsg = "RO was not found during data migration.";
|
||||
// added newlines in the RO number (shown in figure substep type with figure RO)
|
||||
// if we are here, then there is no RO link information, use this number to find the RO image to print
|
||||
val = string.Format("{0}\n{1}\n{2}\n{3}",
|
||||
linkInfoText.Substring(0, linkInfoText.Length - 16),
|
||||
linkInfoText.Substring(linkInfoText.Length - 16, 8),
|
||||
linkInfoText.Substring(linkInfoText.Length - 8, 4),
|
||||
linkInfoText.Substring(linkInfoText.Length - 4, 4));
|
||||
val = val.Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\"); // replace dash and backslash symbols with dash and backslash characters
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] subs = m.Groups[3].Value.Split(" ".ToCharArray());
|
||||
val = lookup.GetRoValue(subs[1]);
|
||||
if (val == null || val == "?") val = lookup.GetRoValue(subs[1].Substring(0, 12));
|
||||
if (val == "?")
|
||||
if (m.Groups.Count < 4)
|
||||
{
|
||||
erMsg = string.Format("Referenced Object does not exist.");
|
||||
_MyLog.WarnFormat("\r\nMissing Referenced Object {0} in {1}", subs[1], itemInfo.ShortPath);
|
||||
yoff += 2 * SixLinesPerInch;
|
||||
//erMsg = "RO was not found during data migration.";
|
||||
// added newlines in the RO number (shown in figure substep type with figure RO)
|
||||
// if we are here, then there is no RO link information, use this number to find the RO image to print
|
||||
val = string.Format("{0}\n{1}\n{2}\n{3}",
|
||||
linkInfoText.Substring(0, linkInfoText.Length - 16),
|
||||
linkInfoText.Substring(linkInfoText.Length - 16, 8),
|
||||
linkInfoText.Substring(linkInfoText.Length - 8, 4),
|
||||
linkInfoText.Substring(linkInfoText.Length - 4, 4));
|
||||
val = val.Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\"); // replace dash and backslash symbols with dash and backslash characters
|
||||
}
|
||||
}
|
||||
}
|
||||
GC.Collect(); // memory garbage collection (Regex memory bug)
|
||||
if (val != null && val != "?")
|
||||
{
|
||||
string[] vals = val.Split("\n".ToCharArray());
|
||||
Width = Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) * MyItemInfo.FormatStepData.Font.CharsToTwips;
|
||||
int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier);
|
||||
// Check that the Height of figure isn't too big to fit on the page, if it is
|
||||
// set the Height to the printable part of page - Height of the HLS and an extra line
|
||||
// for between HLS & figure.
|
||||
float h1 = lines * SixLinesPerInch;
|
||||
float h2 = RoughSizeOfPage - MyParent.Height - SixLinesPerInch;
|
||||
Height = Math.Min(h1, h2);
|
||||
if (h1 > h2)
|
||||
{
|
||||
Width *= (h2 / h1);
|
||||
}
|
||||
StepConfig sc = new StepConfig(MyItemInfo as StepInfo);
|
||||
if (sc != null && sc.Step_ImageWidth != 0)
|
||||
{
|
||||
Width = sc.Step_ImageWidth;
|
||||
Height = sc.Step_ImageHeight;
|
||||
}
|
||||
yoff = AdjustLocIfLongerRNO(itemInfo, yoff, yoffRightParent);
|
||||
if (dropCheckoff)
|
||||
yForCheckoff += Height - SixLinesPerInch; // place checkoff on last row of text
|
||||
bool noborder = MyItemInfo.FormatStepData.Type.ToUpper().Contains("BORDERLESS");
|
||||
yoff += (Height + ((noborder ? 1 : 2) * SixLinesPerInch)); // RHM 20120925 - Eliminate extra space after Figure }
|
||||
try
|
||||
{
|
||||
ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]);
|
||||
if (roImage != null)
|
||||
ImageText = val;
|
||||
else
|
||||
{
|
||||
roImage = rofst.GetROImageByFilename(vals[0], MyItemInfo);// need code to go and get an ROImaage if it exists
|
||||
if (roImage == null)
|
||||
erMsg = string.Format("Image {0} does not exist.", vals[0]);
|
||||
else
|
||||
ImageText = val;
|
||||
string[] subs = m.Groups[3].Value.Split(" ".ToCharArray());
|
||||
val = lookup.GetRoValue(subs[1]);
|
||||
if (val == null || val == "?") val = lookup.GetRoValue(subs[1].Substring(0, 12));
|
||||
if (val == "?")
|
||||
{
|
||||
erMsg = string.Format("Referenced Object does not exist.");
|
||||
_MyLog.WarnFormat("\r\nMissing Referenced Object {0} in {1}", subs[1], itemInfo.ShortPath);
|
||||
yoff += 2 * SixLinesPerInch;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
GC.Collect(); // memory garbage collection (Regex memory bug)
|
||||
if (val != null && val != "?")
|
||||
{
|
||||
erMsg = string.Format("Image {0} does not exist, error = {1}.", vals[0], ex.Message);
|
||||
string[] vals = val.Split("\n".ToCharArray());
|
||||
Width = Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) * MyItemInfo.FormatStepData.Font.CharsToTwips;
|
||||
int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier);
|
||||
// Check that the Height of figure isn't too big to fit on the page, if it is
|
||||
// set the Height to the printable part of page - Height of the HLS and an extra line
|
||||
// for between HLS & figure.
|
||||
float h1 = lines * SixLinesPerInch;
|
||||
float h2 = RoughSizeOfPage - MyParent.Height - SixLinesPerInch;
|
||||
Height = Math.Min(h1, h2);
|
||||
if (h1 > h2)
|
||||
{
|
||||
Width *= (h2 / h1);
|
||||
}
|
||||
StepConfig sc = new StepConfig(MyItemInfo as StepInfo);
|
||||
if (sc != null && sc.Step_ImageWidth != 0)
|
||||
{
|
||||
Width = sc.Step_ImageWidth;
|
||||
Height = sc.Step_ImageHeight;
|
||||
}
|
||||
yoff = AdjustLocIfLongerRNO(itemInfo, yoff, yoffRightParent);
|
||||
if (dropCheckoff)
|
||||
yForCheckoff += Height - SixLinesPerInch; // place checkoff on last row of text
|
||||
bool noborder = MyItemInfo.FormatStepData.Type.ToUpper().Contains("BORDERLESS");
|
||||
yoff += (Height + ((noborder ? 1 : 2) * SixLinesPerInch)); // RHM 20120925 - Eliminate extra space after Figure }
|
||||
try
|
||||
{
|
||||
ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]);
|
||||
if (roImage != null)
|
||||
ImageText = val;
|
||||
else
|
||||
{
|
||||
roImage = rofst.GetROImageByFilename(vals[0], MyItemInfo);// need code to go and get an ROImaage if it exists
|
||||
if (roImage == null)
|
||||
erMsg = string.Format("Image {0} does not exist.", vals[0]);
|
||||
else
|
||||
ImageText = val;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
erMsg = string.Format("Image {0} does not exist, error = {1}.", vals[0], ex.Message);
|
||||
}
|
||||
}
|
||||
if (erMsg != null) Rtf = GetRtf(erMsg, itemInfo.ActiveFormat.PlantFormat.FormatData.Font);
|
||||
}
|
||||
if (erMsg != null) Rtf = GetRtf(erMsg, itemInfo.ActiveFormat.PlantFormat.FormatData.Font);
|
||||
CalculateXOffsetGridOrFigure(itemInfo, maxRNO, formatInfo);
|
||||
}
|
||||
else
|
||||
@ -5981,7 +6000,20 @@ namespace Volian.Print.Library
|
||||
// so text doesn't print out of right border.
|
||||
// B2017-027: Added a check for column mode - we only want to do this if in single column mode
|
||||
if (!MyItemInfo.MyParent.IsHigh && MyTab != null && MyTab.YOffset == YOffset && MyItemInfo.MyActiveSection.ColumnMode == 0)
|
||||
Width = MyHighLevelParagraph.Width - MyTab.Width - (MyTab.XOffset - MyHighLevelParagraph.XOffset) - 6;
|
||||
{
|
||||
// B2017-xxx if this is a caution/note off of a substep in the supinfo column, need to look up for its supinfo part, not
|
||||
// its HLS.
|
||||
if (MyItemInfo.IsInSupInfo)
|
||||
{
|
||||
vlnParagraph supinfopart = this;
|
||||
while (supinfopart.MyParent != null && !supinfopart.MyItemInfo.IsSupInfoPart) supinfopart = supinfopart.MyParent;
|
||||
XOffset = supinfopart.XOffset;
|
||||
MyTab.XOffset = XOffset - MyTab.Width - 10;
|
||||
Width = supinfopart.Width;
|
||||
}
|
||||
else
|
||||
Width = MyHighLevelParagraph.Width - MyTab.Width - (MyTab.XOffset - MyHighLevelParagraph.XOffset) - 6;
|
||||
}
|
||||
else
|
||||
Width = (float)formatInfo.MyStepSectionLayoutData.WidT - 6 - mycolT;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user