C2018-003 corrected use of MyActiveSection vs ActiveSection and added NULL checks

This commit is contained in:
2018-10-08 15:30:05 +00:00
parent b1e6d50716
commit 37fb880794
7 changed files with 85 additions and 73 deletions

View File

@@ -776,7 +776,7 @@ namespace VEPROMS.CSLA.Library
public static string ToPDFReplaceROs(DocumentInfo doc, List<string> roids, ItemInfo sect, VolianStatusChange statusChange)
{
//ItemInfo sect = doc.DocumentEntries[0].MyContent.ContentItems[0];
if (Volian.Base.Library.BaselineMetaFile.IsOpen && Volian.Base.Library.BaselineMetaFile.IncludeWordSecText) Volian.Base.Library.BaselineMetaFile.WriteLine("WrdSec SecNum=\"{0}\" SecTitle=\"{1}\" Itemid={2}", sect.MyActiveSection.DisplayNumber, sect.MyActiveSection.DisplayText, sect.ItemID);
if (Volian.Base.Library.BaselineMetaFile.IsOpen && Volian.Base.Library.BaselineMetaFile.IncludeWordSecText) Volian.Base.Library.BaselineMetaFile.WriteLine("WrdSec SecNum=\"{0}\" SecTitle=\"{1}\" Itemid={2}", sect.ActiveSection.DisplayNumber, sect.ActiveSection.DisplayText, sect.ItemID); // C2018-003 fixed use of getting the active section
return ToPDFReplaceROs(sect, false, roids, statusChange);
}
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
@@ -797,7 +797,7 @@ namespace VEPROMS.CSLA.Library
ROFSTLookup lookup = null;
string igPrefix = null;
string spPrefix = null;
bool convertCaretToDeltaSymbol = sect.MyActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta;
bool convertCaretToDeltaSymbol = (sect.ActiveSection != null) ? sect.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta : false; // C2018-003 fixed use of getting the active section
if (dvi.DocVersionAssociationCount > 0)
{
hasRos = true;
@@ -1038,7 +1038,8 @@ namespace VEPROMS.CSLA.Library
// An X/Y Plot RO type might have text preceding the Plot Commands
int pstart = val.IndexOf("<<G"); // find the starting Plot Command
// B2017-217 Added logic so that underscores are not converted to underline
AddPrecedingText(sel, val.Substring(0, pstart), 0.0F, sect.MyActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.ConvertUnderscoreToUnderline);// replace the RO token with what's in front of the X/Y Plot
// C2018-003 fixed use of getting the active section
AddPrecedingText(sel, val.Substring(0, pstart), 0.0F, (sect.ActiveSection != null)? sect.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.ConvertUnderscoreToUnderline : false);// replace the RO token with what's in front of the X/Y Plot
val = val.Substring(pstart); // set val to the start of the plot commands
pngFile = VlnSettings.TemporaryFolder + @"\XYPlot1.png"; //@"C:\Temp\XYPlot1.png";
RectangleF plotRect = CreatePlot(pngFile, val, 600F, FormForPlotGraphics);
@@ -1095,7 +1096,8 @@ namespace VEPROMS.CSLA.Library
float indent = (float)sel.get_Information(LBWdInformation.wdHorizontalPositionRelativeToTextBoundary);
if (Volian.Base.Library.BaselineMetaFile.IsOpen && Volian.Base.Library.BaselineMetaFile.IncludeWordSecText) txtForBaseline = txtForBaseline.Replace(roTokenForBaseline, val);
// B2017-217 Added logic so that underscores are not converted to underline
InsertROValue(sel, val, sect.ActiveFormat.PlantFormat.FormatData.ROData.UpRoIfPrevUpper, indent, sect.MyActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.ConvertUnderscoreToUnderline);
// C2018-003 fixed use of getting the active section
InsertROValue(sel, val, sect.ActiveFormat.PlantFormat.FormatData.ROData.UpRoIfPrevUpper, indent, (sect.ActiveSection != null)?sect.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.ConvertUnderscoreToUnderline:false);
}
sel = FindRO();
if (sel != null && sel.Start == lastStart)

View File

@@ -4138,7 +4138,7 @@ namespace VEPROMS.CSLA.Library
bool isAlpha = tbformat.ToUpper().Contains("ALPHA");
int ordinal = Ordinal;
bool useLinked = false; // if this is enhanced, and the LinkedTab isn't numeric, flag to use 'LinkedTab' for the tab.
if (MyActiveSection.IsEnhancedSection)
if (ActiveSection != null && ActiveSection.IsEnhancedSection) // C2018-003 fixed use of getting the active section
{
if (IsEnhancedStep)
try
@@ -4332,8 +4332,9 @@ namespace VEPROMS.CSLA.Library
newtab = @"\ul " + newtab.Substring(0, newtab.IndexOf(":") + 1) + @"\ulnone " + newtab.Substring(newtab.IndexOf(":") + 1);
}
// also see if there is the 'pagelist' string in this tab:
// C2018-003 fixed use of getting the active section
else if ((FormatStepData.TabData.Font.Style & E_Style.Underline) == E_Style.Underline &&
((MyActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) != E_DocStructStyle.DSS_PageListSpBckgrnd))
ActiveSection != null && ((ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) != E_DocStructStyle.DSS_PageListSpBckgrnd))
// the reason that the underline commands were not included in format file is that the '\' character
// is used as a separator and the following code will not impact other formats
HighLevelStepTabPageList = @"\ul " + FormatStepData.TabData.IdentAltPrint.Substring(0, indxnewtab).Trim() + @"\ulnone " + (tbformat.StartsWith(" ") ? "" : " ") + tbformat;
@@ -4485,7 +4486,7 @@ namespace VEPROMS.CSLA.Library
public int CurrentSectionLevel()
{
int countlev = 0;
if ((MyActiveSection.MyDocStyle.StructureStyle.Style ?? 0 & E_DocStructStyle.DSS_TreatAsTrueSectNum) != 0)
if (ActiveSection != null && (ActiveSection.MyDocStyle.StructureStyle.Style ?? 0 & E_DocStructStyle.DSS_TreatAsTrueSectNum) != 0) // C2018-003 fixed use of getting the active section
{
ItemInfo ii = ActiveSection.MyParent;
while (!ii.IsProcedure)