Changed an Error Message to provide the location where the error occured.

Added logic to keep un-numbered child steps together.
Changed the space on the first page to be yWithinMargins.
Changed an Error Message to provide the location where the error occured.
Changed the format of the Pagination Debug file to make comparison easier.
Used YTopMost to correctly determine how much space is left on a page.
Changed an Error Message to provide the location where the error occured.
Changed logic to keep from breaking in a caution or a note.
This commit is contained in:
Rich 2013-05-13 10:44:25 +00:00
parent dbf3129866
commit 11fe928774
4 changed files with 70 additions and 26 deletions

View File

@ -199,7 +199,14 @@ namespace Volian.Controls.Library
}
catch (Exception ex)
{
_MyLog.Error("DisplayText.CreateRTF Error doing DoROAdjustments", ex);
if (_MyItemInfo != null)
{
_MyLog.ErrorFormat("<<< ERROR >>> Error doing DoROAdjustments\r\n==>'RO Adjustments Error',{0},'{1}','{2}','{3}'"
, _MyItemInfo.ItemID, _MyItemInfo.MyDocVersion.MyFolder.Name, _MyItemInfo.ShortPath, ex.Message);
}
else
_MyLog.Error("DisplayText.CreateRTF Error doing DoROAdjustments", ex);
}
}
// if in print mode, view mode, or non-active richtextbox do replace words. Only if in

View File

@ -71,7 +71,9 @@ namespace Volian.Print.Library
vlnParagraph firstChild = ChildrenBelow.Count > 0 ? ChildrenBelow[0] : null;
// Steps that have the smart template (the WCNCKL format for example), always include two children.
if (MyItemInfo.IsHigh && MyItemInfo.FormatStepData.UseSmartTemplate && ChildrenBelow.Count > 1)
firstChild = ChildrenBelow[1];
firstChild = ChildrenBelow[1];
if (firstChild != null && !firstChild.MyItemInfo.IsNumbered) // If not numbered get the last child
firstChild = firstChild.MyParent.ChildrenBelow[firstChild.MyParent.ChildrenBelow.Count - 1];
float ySizeIncludingFirst = firstChild == null ? YSize : firstChild.YSize + (firstChild.YTopMost - YTopMost);
bool KeepStepsOnPage = MyItemInfo.ActiveFormat.MyStepSectionLayoutData.KeepStepsOnPage;
if (MyItemInfo.IsStepSection)
@ -108,7 +110,18 @@ namespace Volian.Print.Library
//if (ySizeIncludingFirst > (yLocation - yBottomMargin) && ySizeIncludingFirst < yPageSize)
vlnParagraph firstStepChild = firstChild;
//while (firstStepChild.MyItemInfo.IsSection && firstStepChild.ChildrenBelow.Count > 0) firstStepChild = firstStepChild.ChildrenBelow[0];
while (firstStepChild.ChildrenBelow.Count > 0 && (firstStepChild.MyItemInfo.IsSection || firstStepChild.MyItemInfo.IsHigh)) firstStepChild = firstStepChild.ChildrenBelow[0];
if(firstStepChild.MyItemInfo.IsNumbered)
while (firstStepChild.ChildrenBelow.Count > 0 && (firstStepChild.MyItemInfo.IsSection || firstStepChild.MyItemInfo.IsHigh))
{
firstStepChild = firstStepChild.ChildrenBelow[0];
if (!firstStepChild.MyItemInfo.IsNumbered)
{
firstStepChild = firstStepChild.MyParent.ChildrenBelow[firstStepChild.MyParent.ChildrenBelow.Count-1];
break;
}
}
else
firstStepChild = firstStepChild.MyParent.ChildrenBelow[firstStepChild.MyParent.ChildrenBelow.Count-1];
float ySizeIncludingFirstStep = firstStepChild.YSize + (firstStepChild.YTopMost - YTopMost);
bool firstSubstepExceedsSpaceAvailable = ySizeIncludingFirstStep > yWithinMargins;
if (KeepStepsOnPage && firstSubstepExceedsSpaceAvailable && !isFirstChild)
@ -192,15 +205,19 @@ namespace Volian.Print.Library
// yPageSize is space on next page. This may be different if the format flag 'UseOnAllButFirst' is
// set.
// yWithinMargins is space available on current page.
if(firstStep == "Yes")
ShowPageBreak(8, "First HLS has to split on current page", firstStep, YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
else
ShowPageBreak(6, "HLS will have to split on current page", "Special", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
// if the HLS is part of a Smart Template (i.e. WCNCKL table), don't add in an extra line because
// that makes pagination work incorrectly because the Smart Template has a 'table' line after the
// text.
float ySpaceOnFirstPage = yWithinMargins + (MyItemInfo.FormatStepData.UseSmartTemplate ? 0 : SixLinesPerInch);
if (firstStep == "Yes")
{
ySpaceOnFirstPage = yWithinMargins; // Accounts for Section Title Line
ShowPageBreak(8, "First HLS has to split on current page", firstStep, YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
}
else
ShowPageBreak(6, "HLS will have to split on current page", "Special", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
//BuildPageBreakList(yWithinMargins + SixLinesPerInch, yPageSizeNextPage + yExtra2, KeepStepsOnPage); // Case 5 - Determine items where page break(s) occur
BuildPageBreakList(yWithinMargins + (MyItemInfo.FormatStepData.UseSmartTemplate?0:SixLinesPerInch), yPageSize + yExtra2, KeepStepsOnPage); // Case 5 - Determine items where page break(s) occur
BuildPageBreakList(ySpaceOnFirstPage, yPageSize + yExtra2, KeepStepsOnPage); // Case 5 - Determine items where page break(s) occur
return 0; // Stay on this page
}
@ -253,7 +270,10 @@ namespace Volian.Print.Library
yPageStart = yTopMargin + YVeryTop;
yLocation = yPageStart - YOffset;
//MyItemInfo.ItemID, YSize, yPageSize, yLocation
DebugPagination.WriteLine("-1,'Yes','Forced Pagination',{0},{1},,{3},{4}", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.DBSequence);
//_MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination - ItemID = {0}\r\nLocation = '{1}'", MyItemInfo.ItemID, MyItemInfo.ShortPath);
_MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination\r\n==>'Forced Pagination',{0},'{1}','{2}'"
, MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath);
DebugPagination.WriteLine("------,'Yes','Forced Pagination',{0},{1},,{3},{4}", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.DBSequence);
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo, yBottomMargin);
}
private void ShowPageBreak(int instance, string message, string breakOrNot, float YSize, float yPageSize, float yWithinMargins, bool manualPageBreak)
@ -261,7 +281,7 @@ namespace Volian.Print.Library
if (breakOrNot != "No")
{
// DebugPagination.WriteLine("{0}", MyItemInfo.DBSequence); //,instance);
DebugPagination.WriteLine("{0},'{1}',{2},'{3}','{4}',{5},{6},{7},{8},{9}",
DebugPagination.WriteLine("{0:D6},'{1}',{2},'{3}','{4}',{5},{6},{7},{8},{9}",
MyPageHelper.MyPdfContentByte.PdfWriter.CurrentPageNumber - (breakOrNot == "Yes" ? 0 : 1),
MyItemInfo.ShortPath, instance,
(manualPageBreak ? "Manual " : "") + message, breakOrNot,
@ -297,7 +317,7 @@ namespace Volian.Print.Library
vlnParagraph paraBreak = FindPageBreak(yStart, ySpaceOnCurPage, yLowerLimit, myList);
if (paraBreak == null) break;
// yTopNew is y Location of this page break. YTopMost is top of HLS, including any Cautions/Notes/Boxes/etc
float yTopNew = paraBreak.YVeryTop - YTopMost;
float yTopNew = paraBreak.YTopMost - YTopMost;
RemoveProcessedParagraphs(myList, yTopNew - yTop);
yTop = yTopNew;
MyPageHelper.ParaBreaks.Add(paraBreak);

View File

@ -330,7 +330,7 @@ namespace Volian.Print.Library
{
SectionInfo mySection = myProcedure.Sections[i] as SectionInfo;
if (!mySection.DisplayText.ToUpper().Contains("FOLDOUT"))
{
{
if (mySection.MyDocStyle.Final != null && mySection.MyDocStyle.Final.Message != null && mySection.MyDocStyle.Final.Message.Length > 0)
return mySection.ItemID;
else
@ -453,7 +453,7 @@ namespace Volian.Print.Library
{
PrintTextMessage(cb, "No Proms Output", _TextLayer);
cb.PdfDocument.NewPage(); // only have 16bit pages left (for DebugMode)
DebugPagination.WriteLine("{0},'{1}'",
DebugPagination.WriteLine("{0:D6},'{1}'",
_MyHelper.MyPdfContentByte.PdfWriter.CurrentPageNumber, "No PROMS Output");
}
}
@ -528,7 +528,7 @@ namespace Volian.Print.Library
float yoff = 0;
if (_MyHelper.DidFirstPageDocStyle) yoff = origYoff - (float)mySection.MyDocStyle.Layout.TopMargin;
AddImportedPageToLayer(cb.PdfWriter.DirectContent, _MSWordLayer, fgPage, (float)(mySection.MyDocStyle.Layout.MSWordXAdj??0), (float)(mySection.MyDocStyle.Layout.MSWordYAdj??0)+yoff);
DebugPagination.WriteLine("{0},'{1}',{2}",
DebugPagination.WriteLine("{0:D6},'{1}',{2}",
_MyHelper.MyPdfContentByte.PdfWriter.CurrentPageNumber, mySection.ShortPath,pageNumber);
}
@ -832,7 +832,7 @@ namespace Volian.Print.Library
if (doimport2)
{
AddImportedPageToLayer(cb.PdfWriter.DirectContent, textLayer, fgPage, 0, 0);
DebugPagination.WriteLine("{0},'{1}',{2}",
DebugPagination.WriteLine("{0:D6},'{1}',{2}",
myPageHelper.MyPdfContentByte.PdfWriter.CurrentPageNumber, "Foldout", 1);
}
}

View File

@ -78,15 +78,15 @@ namespace Volian.Print.Library
{
if (bxIndx != null)
{
if (box != null) box.Height = yoff - box.YOffset; // new height, with children
box = new vlnBox();
box.MyBox = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx];
int ln = 1; // a format flag determines whether there is a space before the note/caution.
if (childItemInfo.FormatStepData.OneLineBeforeTab) ln++;
if (childItemInfo.MixCautionNotesDiffType()) ln += 2;
box.YOffset = yoff + ((ln - 1) * vlnPrintObject.SixLinesPerInch);
yoff += ln * vlnPrintObject.SixLinesPerInch;
}
if (box != null) box.Height = yoff - box.YOffset; // new height, with children
box = new vlnBox();
box.MyBox = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx];
int ln = 1; // a format flag determines whether there is a space before the note/caution.
if (childItemInfo.FormatStepData.OneLineBeforeTab) ln++;
if (childItemInfo.MixCautionNotesDiffType()) ln += 2;
box.YOffset = yoff + ((ln - 1) * vlnPrintObject.SixLinesPerInch);
yoff += ln * vlnPrintObject.SixLinesPerInch;
}
}
bxIndex = bxIndx;
}
@ -454,7 +454,10 @@ namespace Volian.Print.Library
DebugText.WriteLine("{0},'{1}','{2}','<<END>>',{3}", MyItemInfo.ItemID, MyItemInfo.ShortPath,MyItemInfo.MyContent.Text,XOffset);
float retval = Rtf2Pdf.GridAt(cb, MyGrid, XOffset, yLocation, Width, 100, DebugInfo, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless"));
if (MyGrid.Height > (yTopMargin - yBottomMargin))
_MyLog.InfoFormat("\r\nTable is too big to fit on page, expect pagination problems. Table is in High Level Step {0}\r\n", MyItemInfo.MyHLS);
{
_MyLog.ErrorFormat("<<< ERROR >>> Table is too big to fit on page, expect pagination problems\r\n==>'Table Too Big',{0},'{1}','{2}',{3},{4}"
, MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath, MyGrid.Height,(yTopMargin - yBottomMargin));
}
return retval;
}
@ -2379,7 +2382,8 @@ namespace Volian.Print.Library
int level = paraLoc.StepLevel;
if (KeepStepsOnPage && paraLoc.MyParagraph.MyItemInfo.MyContent.Type == 20001)
{
if (paraLoc.MyParagraph.MyItemInfo.MyPrevious == null)
if (DontBreakHere(paraLoc))
//if (paraLoc.MyParagraph.MyItemInfo.MyPrevious == null) // First substep
level = 0;
else
level = 1;
@ -2388,6 +2392,19 @@ namespace Volian.Print.Library
}
return myList;
}
private bool DontBreakHere(ParagraphLocation paraLoc)
{
if (paraLoc.MyParagraph.MyItemInfo.MyPrevious == null) // First substep
return true;
vlnParagraph myPara = paraLoc.MyParagraph;
while (!myPara.MyItemInfo.IsHigh)
{
if (myPara.MyItemInfo.IsCaution) return true;
if (myPara.MyItemInfo.IsNote) return true;
myPara = myPara.MyParent;
}
return false;
}
}
public class ParagraphLocation
{