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)