B2021-091 Fix a null a reference error in Print. Optimize the check for printable Annotations.

This commit is contained in:
John Jenko 2021-08-27 17:59:35 +00:00
parent 79c5aa0c4d
commit 84c8442c66

View File

@ -1018,12 +1018,14 @@ namespace Volian.Print.Library
}
// Check if only one line, i.e. "Height < (1.2F * IParagraph.Leading". The Leading can be for six or seven lines per inch, so the 1.2
// multiplier accounts for both.
if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData.CenterOneLineOnly && ((MyItemInfo.MyPrevious == null && MyItemInfo.NextItem == null) || MyItemInfo.FormatStepData.SeparateBox || doAlign) && Height < (1.2F * IParagraph.Leading))
// B2021-091 added a null reference check - MyItemInfo was a section and didn't have FormatStepData
if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.CenterOneLineOnly && ((MyItemInfo.MyPrevious == null && MyItemInfo.NextItem == null) || MyItemInfo.FormatStepData.SeparateBox || doAlign) && Height < (1.2F * IParagraph.Leading))
IParagraph.Alignment = Element.ALIGN_CENTER;
// if this step is centered, but not part of the checklist or valvelist format, use itextsharp to center it.
// if it was part of the checklist or valvelist, then the centering is based on the column definitions for the table and
// was calculated when the paragraph was made.
if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData.StepPrintData.Justify == "Center" && !MyItemInfo.FormatStepData.StepLayoutData.AlignWithParentTab)
// B2021-091 added a null reference check - MyItemInfo was a section and didn't have FormatStepData
if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.StepPrintData.Justify == "Center" && !MyItemInfo.FormatStepData.StepLayoutData.AlignWithParentTab)
IParagraph.Alignment = Element.ALIGN_CENTER;
if (PrefixSpecialCharacter && IParagraph.Chunks.Count > 0)
{
@ -4553,8 +4555,36 @@ namespace Volian.Print.Library
get { return vlnParagraph._AnnotationFont; }
set { vlnParagraph._AnnotationFont = value; }
}
// Check to see if the procedure has any printable text in the annotations
private bool? _CanDoPrintableText = null;
public bool CanDoPrintableText
{
get
{
if (_CanDoPrintableText == null)
{
_CanDoPrintableText = false;
AnnotationTypeInfoList atil = AnnotationTypeInfoList.Get();
foreach (AnnotationTypeInfo ati in atil)
{
AnnotationTypeConfig atc = new AnnotationTypeConfig(ati.Config);
if (atc.PrintableText_XLocation != 0)
{
_CanDoPrintableText = true;
break;
}
}
}
return (bool)_CanDoPrintableText;
}
}
private void DoAnnotationPrintableText(PdfContentByte cb, ItemInfo itemInfo, float yoff)
{
// check to see if this procedure has any printable annotations.
// if it does not, then there is no need to spin through checking for the given itemInfo
if (!CanDoPrintableText) return;
// if this step has an Annotation and it has config data to define location, parse out '[xx]' and print it at the location
// this was added for VC Summer (unit 2 & 3) but is available for any data that has defined the location in the config (from the folder properties
// at the top node - annotationtype tab.
@ -5886,6 +5916,9 @@ namespace Volian.Print.Library
}
return;
}
// B2021-091 added a null reference check - itemInfo was a section and didn't have FormatStepData so just return
if (itemInfo.FormatStepData == null) return;
int? bxIndx = itemInfo.FormatStepData.StepLayoutData.STBoxindex;
float? colOvrd = itemInfo.FormatStepData.ColOverride;
if (itemInfo.IsBackgroundStep())//WolfCreekBackgroundFormat && IsHigh||IsNote||IsCaution or ImplicitOR