B2017-109: Supplemental Information preferred page breaks causes incorrect pagination of following substeps

This commit is contained in:
2017-06-07 11:16:27 +00:00
parent 3d8ce13c6a
commit c6127c17ab
2 changed files with 75 additions and 13 deletions

View File

@@ -1552,7 +1552,6 @@ namespace Volian.Print.Library
// 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.StepSectPageBreaks.Add(aboveSupinfoId!=-1?ItemInfo.Get(aboveSupinfoId).MyParent.ItemID:MyItemInfo.ItemID);
supInfoSect.StepSectPageBreaksForSupInfo.Add(aboveSupinfoId!=-1?aboveSupinfoId:MyItemInfo.SupInfos[0].ItemID);
MyPromsPrinter.NeedSupInfoBreak = false;
}
@@ -2185,35 +2184,66 @@ namespace Volian.Print.Library
private int GetIdThatHasSupInfoItems(ItemInfo ii, int startid)
{
if (ii == null) return -1;
// if this item has supinfo, return its id
if (ii.SupInfos != null && ii.SupInfos.Count > 0) return ii.SupInfos[0].ItemID;
// see if any substeps of this item have supinfo, and if so, return the substep's id
int id = GetSubThatHasSupInfoItems(ii, startid);
if (id != -1) return id;
// Now go to the next item, check if it or any of its substeps have supinfo, and if so, return the id
ItemInfo sib = ii.NextItem;
while (sib != null)
id = GetIdThatHasSupInfoItemsSibNext(sib, startid);
if (id != -1) return id;
// 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;
if (!par.IsSection && par.NextItems != null && par.NextItems.Count > 0)
{
par = par.NextItem;
while (par != null && !par.IsSection)
{
id = GetIdThatHasSupInfoItemsSibNext(par, startid);
if (id != -1) return id;
par = par.MyParent;
if (!par.IsSection && par.NextItems != null && par.NextItems.Count > 0) par = par.NextItem;
else return -1;
}
}
return -1;
}
private int GetIdThatHasSupInfoItemsSibNext(ItemInfo ii, int startid)
{
int id = -1;
while (ii != null)
{
SectionInfo supInfoSect = ii.MyActiveSection as SectionInfo;
if (supInfoSect.StepSectPageBreaks.Contains(sib.ItemID)) return -1;
if (sib.SupInfos != null && sib.SupInfos.Count > 0)
// if there is a pagebreak on this step section step, quit looking for supinfos. The
// break has to occur here.
if (supInfoSect.StepSectPageBreaks.Contains(ii.ItemID)) return -1;
if (ii.SupInfos != null && ii.SupInfos.Count > 0)
{
// check if this is in the list of page breaks for supinfos, if not it may have one of its cautions/notes rather than its id:
if (!supInfoSect.StepSectPageBreaksForSupInfo.Contains(sib.SupInfos[0].ItemID))
if (!supInfoSect.StepSectPageBreaksForSupInfo.Contains(ii.SupInfos[0].ItemID))
{
if (sib.Cautions != null)
if (ii.Cautions != null)
{
foreach (ItemInfo caution in sib.Cautions)
foreach (ItemInfo caution in ii.Cautions)
if (caution.SupInfos != null && caution.SupInfos.Count > 0 && supInfoSect.StepSectPageBreaksForSupInfo.Contains(caution.SupInfos[0].ItemID)) return caution.SupInfos[0].ItemID;
}
if (sib.Notes != null)
if (ii.Notes != null)
{
foreach (ItemInfo note in sib.Notes)
foreach (ItemInfo note in ii.Notes)
if (note.SupInfos != null && note.SupInfos.Count > 0 && supInfoSect.StepSectPageBreaksForSupInfo.Contains(note.SupInfos[0].ItemID)) return note.SupInfos[0].ItemID;
}
}
return sib.SupInfos[0].ItemID;
return ii.SupInfos[0].ItemID;
}
id = GetSubThatHasSupInfoItems(sib, startid);
id = GetSubThatHasSupInfoItems(ii, startid);
if (id != -1) return id;
sib = sib.NextItem;
ii = ii.NextItem;
}
return -1;
}