diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index 035c688c..f460040a 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -3176,12 +3176,16 @@ namespace Volian.Print.Library { // is the width of this table going to cause the table to overlap the RNO vlnParagraph parRno = FindParentRNO(); - float xparRno = parRno.XOffset; - if (parRno.MyTab != null) xparRno = parRno.MyTab.XOffset; - if (XOffset + Width > xparRno) + float xMinRno = FindMinXOffsetRno(parRno); + if (XOffset + Width > xMinRno - 12) // 12 = 2 characters, so that tables don't almost touch & look like an overlap { - yoff = yoffRightParent; - YOffset = yoff; + if ((float)MyItemInfo.MyDocStyle.Layout.LeftMargin + Width > xMinRno) + { + yoff = yoffRightParent; + YOffset = yoff; + } + else + XOffset = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin; } } // if the table does not have a border, only move down one line: @@ -3659,6 +3663,35 @@ namespace Volian.Print.Library if (XOffsetCenter != null) XOffset = (float)XOffsetCenter; ProfileTimer.Pop(profileDepth); } + private float FindMinXOffsetRno(vlnParagraph parRno) + { + // Find the minimum xoffset in the rno column that overlaps in the y direction with + // the table that is currently being processed. This is necessary in order to fix the + // case where the AER table overlaps an RNO table (or tab/text) + float xcur = 0; + // YOffset/Height is for the current table, check it against the rno's yoffset & height + // if aer & rno are within y range of each other + if (YOffset <= (parRno.YOffset + parRno.Height) && (YOffset + Height) >= parRno.YOffset) + { + xcur = parRno.XOffset; + if (parRno.MyTab != null) xcur = parRno.MyTab.XOffset; + } + // recursively look at steps in the rno column to get the smallest xoffset which will + // then be used to compare to table's xoffset/width to see if there is an overlap + if (parRno.ChildrenBelow != null) + { + foreach (vlnParagraph vp in parRno.ChildrenBelow) + { + // yoffset is past where the table is, so don't consider it: + if (vp.YOffset > (YOffset + Height)) return xcur; + + float xchild = FindMinXOffsetRno(vp); + if (xchild > 0 && (xcur == 0 || xchild < xcur)) + xcur = xchild; + } + } + return xcur; + } private void DoResponsibility(PdfContentByte cb, float yoff) // WCNTRN's text in 1st column (saved in config for HLS) { StepConfig sc2 = MyItemInfo.MyConfig as StepConfig;