B2022-098: ROs not being resolved in Word Sections

This commit is contained in:
Jake
2022-08-16 15:02:30 +00:00
parent 9bdaebadfc
commit ac8e8432b7
10 changed files with 913 additions and 302 deletions

View File

@@ -955,6 +955,7 @@ namespace VEPROMS.CSLA.Library
{
string fileNameOnly = null;
//B2020-127 don't try to parse out a file name from "?" (happens with the RO figure no longer exists)
// - this allows it to drop through and put an annotation on the step
if (ii.IsFigure && Text != null && Text.Length > 0 && value != "?")

View File

@@ -947,17 +947,13 @@ namespace VEPROMS.CSLA.Library
ROFstInfo rofst = null;
ROFSTLookup lookup = null;
string igPrefix = null;
string spPrefix = null;
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;
rofst = dvi.DocVersionAssociations[0].MyROFst;
igPrefix = dvi.DocVersionConfig.RODefaults_graphicsprefix;
spPrefix = dvi.DocVersionConfig.RODefaults_setpointprefix;
// The following code sets the DocVersionInfo and the OtherChild properties for the current RofstLookup instance (lookup), and also enables Caching
// When printing or converting word sections to pdf, any RoChild "value" is the Unit Specific Value for the SelectedSlave
lookup = rofst.GetROFSTLookup(dvi, Convert.ToString(sect.MyDocVersion.DocVersionConfig.SelectedSlave));
@@ -1161,8 +1157,10 @@ namespace VEPROMS.CSLA.Library
{
if (Volian.Base.Library.BaselineMetaFile.IsOpen && Volian.Base.Library.BaselineMetaFile.IncludeWordSecText) roTokenForBaseline = sel.Text;
if (statusChange != null) statusChange(VolianStatusType.Update, sel.Start, string.Format("{0} ROs Refreshed", roCount++));
ROFSTLookup.rochild roc = GetCachedRoByAccPageID(lookup, sel.Text, spPrefix, igPrefix, convertCaretToDeltaSymbol);
// B2022-088: [JPR] Find Doc Ro button not working in Word Sections
// B2022-098: [JPR] ROs not being resolved in Word Sections
ROFSTLookup.rochild roc = GetCachedRoByAccPageID(lookup, sel.Text, convertCaretToDeltaSymbol);
int roType = roc.type;
string roValue = roc.value;
@@ -1380,7 +1378,7 @@ namespace VEPROMS.CSLA.Library
}
}
private static ROFSTLookup.rochild GetCachedRoByAccPageID(ROFSTLookup lookup, string selText, string spPrefix, string igPrefix, bool convertCaretToDeltaSymbol)
private static ROFSTLookup.rochild GetCachedRoByAccPageID(ROFSTLookup lookup, string selText, bool convertCaretToDeltaSymbol)
{
string accPageBase = string.Empty;
string accPageExt = string.Empty;
@@ -1389,13 +1387,13 @@ namespace VEPROMS.CSLA.Library
{
ROFSTLookup.rochild roc = ROFSTLookup.GetEmptyRoChild();
string accPageKey = ROFSTLookup.FormatAccPageKey(selText, spPrefix, igPrefix, ref accPageBase, ref accPageExt, true);
string accPageKey = lookup.FormatAccPageKey(selText, ref accPageBase, ref accPageExt);
// Check if the Rochild is in the PrintCache (use base accPageID without specific extension)
if (!RoPrintCache.ContainsKey(accPageBase))
{
// Lookup RoChild Info from database
roc = lookup.GetROChildByAccPageID(accPageBase, spPrefix, igPrefix);
roc = lookup.GetROChildByAccPageID(accPageBase);
// Check if RO is valid
if (roc.ID < 0 || string.IsNullOrEmpty(roc.roid))
@@ -1415,7 +1413,8 @@ namespace VEPROMS.CSLA.Library
// All ROs at this point should have a specific accPageExt or the default (A/0041)
roc = (roc.children.Where(x => x.appid.EndsWith(accPageExt) && !string.IsNullOrEmpty(x.value)).Any()) ? roc.children.Where(x => x.appid.EndsWith(accPageExt)).Single() : roc.children.First();
if (roc.children != null && roc.children.Count() > 0)
roc = (roc.children.Where(x => x.appid.EndsWith(accPageExt) && !string.IsNullOrEmpty(x.value)).Any()) ? roc.children.Where(x => x.appid.EndsWith(accPageExt)).Single() : roc.children.First();
// Check the RoType
roc.type = ((roc.type & 4) == 4 && roc.value.StartsWith("<<G")) ? 4 : roc.type;
@@ -2033,7 +2032,9 @@ namespace VEPROMS.CSLA.Library
executeResult = find.Execute();
// B2022-053 if the found text does not begin with a "<" and end with a ">", then
// move past that text and try the Word Find function again.
if (executeResult && !sel.Text.StartsWith("<") && !sel.Text.EndsWith(">"))
// B2022-088: [JPR] Find Doc Ro button not working in Word Sections
// B2022-098: [JPR] ROs not being resolved in Word Sections
if (executeResult && !string.IsNullOrEmpty(sel.Text) && !sel.Text.StartsWith("<") && !sel.Text.EndsWith(">"))
{
sel.MoveStart(LBWdUnits.wdCharacter, sel.Text.Length - 1);
tryagain = true;

View File

@@ -882,10 +882,13 @@ namespace VEPROMS.CSLA.Library
if (this.ActiveSection != null)
{
string oldText = this.MyContent.Text;
string roval = lookup.GetTranslatedRoValue(rousage.ROID, this.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, this.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues);
ROFSTLookup.rochild roch = lookup.GetRoChild(rousage.ROID);
this.MyContent.FixContentText(rousage, roval, roch.type, rofstinfo, this);
string newText = this.MyContent.Text;
if (newText != oldText)
{
Content content = Content.Get(this.MyContent.ContentID);
@@ -936,8 +939,10 @@ namespace VEPROMS.CSLA.Library
{
ROCheckCount++;
string oldText = itemInfo.MyContent.Text;
string roval = lookup.GetTranslatedRoValue(rousage.ROID, sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues);
ROFSTLookup.rochild roch = lookup.GetRoChild(rousage.ROID);
itemInfo.MyContent.FixContentText(rousage, roval, roch.type, origROFst, itemInfo);
string newText = itemInfo.MyContent.Text;
@@ -1901,7 +1906,6 @@ namespace VEPROMS.CSLA.Library
return includeOnCAS;
}
}
// F2022-024 Time Critical Action Step
// determine if the the current step should automatically be placed on the Time Critical Action Summary
// Note, this logic only checks the format setting of the step. We will check the value of the Tag's Check Box later on.
@@ -1933,7 +1937,6 @@ namespace VEPROMS.CSLA.Library
return includeOnTCAS;
}
}
public bool IsSameType(ItemInfo cmpItmInfo)
{
return (((int)MyContent.Type) % 10000) == (((int)cmpItmInfo.MyContent.Type) % 10000);
@@ -2967,68 +2970,94 @@ namespace VEPROMS.CSLA.Library
}
//get { return ConvertToDisplayText(MyContent.Number); }
}
// for step designators (a redefined caution type used in Comanche Peak with the SameRowAsParentMultiLines format flag)
// we what to allow for a hard return to allow for multiple designator lines - jsj 5/21/2015
public static string ConvertToMulitLineStepDesignatorDisplayText(string txt)
{
string retval = txt;
retval = StripRtfFormatting(retval);
retval = StripLinks(retval);
retval = ReplaceSpecialCharacters(retval);
retval = retval.Replace("\u2011", "-");
retval = retval.Replace("\r\n", @"\line");
retval = retval.Replace("\n", @"\line");
if (!string.IsNullOrEmpty(retval))
{
retval = StripRtfFormatting(retval);
retval = StripLinks(retval);
retval = ReplaceSpecialCharacters(retval);
retval = retval.Replace("\u2011", "-");
retval = retval.Replace("\r\n", @"\line");
retval = retval.Replace("\n", @"\line");
}
return retval;
}
public static string ConvertToDisplayText(string txt)
{
return ConvertToDisplayText(txt, true);
}
public static string ConvertToDisplayText(string txt, bool stripRTF)
{
string retval = txt;
if (stripRTF) retval = StripRtfFormatting(retval);
retval = StripLinks(retval);
retval = ReplaceSpecialCharacters(retval);
retval = retval.Replace("\u2011", "-");
retval = retval.Replace("\u2572", @"\"); // replace backslash symbol with a backslash
retval = Regex.Replace(retval, @"\\line ?", ";"); // better handing of hard returns - replace with semi-colon for use on tree view
retval = retval.Replace("\r\n", ";");
retval = retval.Replace("\n", ";"); //added for consistency checking with approved version
if (!string.IsNullOrEmpty(retval))
{
if (stripRTF) retval = StripRtfFormatting(retval);
retval = StripLinks(retval);
retval = ReplaceSpecialCharacters(retval);
retval = retval.Replace("\u2011", "-");
retval = retval.Replace("\u2572", @"\"); // replace backslash symbol with a backslash
retval = Regex.Replace(retval, @"\\line ?", ";"); // better handing of hard returns - replace with semi-colon for use on tree view
retval = retval.Replace("\r\n", ";");
retval = retval.Replace("\n", ";"); //added for consistency checking with approved version
}
return retval;
}
public static string StripRtfFormatting(string rtf)
{
string retval = rtf;
// B2022-082: underline/bold of word removes space between 2 words in DisplayText
retval = Regex.Replace(retval, @"\\ulnone\\b0 ?", "");
retval = Regex.Replace(retval, @"\\b0\\ulnone ?", "");
retval = Regex.Replace(retval, @"\\b0 ?", "");
retval = Regex.Replace(retval, @"\\b ?", "");
retval = Regex.Replace(retval, @"\\ulnone ?", "");
retval = Regex.Replace(retval, @"\\ul0 ?", "");
retval = Regex.Replace(retval, @"\\ul ?", "");
retval = Regex.Replace(retval, @"\\i0 ?", "");
retval = Regex.Replace(retval, @"\\i ?", "");
//retval = Regex.Replace(retval, @"\\super ?", "");
//retval = Regex.Replace(retval, @"\\sub ?", "");
//retval = Regex.Replace(retval, @"\\nosupersub ?", "");
retval = Regex.Replace(retval, @"\\up[320] ?", "");
retval = Regex.Replace(retval, @"\\dn[320] ?", "");
retval = Regex.Replace(retval, @"\\li[0-9]+ ?", ""); // changed the * to a + to "\\line " for hard returns part of bug fix B2015-140
retval = Regex.Replace(retval, @"\\fi-[0-9]+ ?", "");
retval = Regex.Replace(retval, @"\\fs[0-9]+ ?", ""); // B2020-065: removed font size definition (introduced when allowing font sizes in tables)
if (!string.IsNullOrEmpty(retval))
{
// B2022-082: underline/bold of word removes space between 2 words in DisplayText
retval = Regex.Replace(retval, @"\\ulnone\\b0 ?", "");
retval = Regex.Replace(retval, @"\\b0\\ulnone ?", "");
retval = Regex.Replace(retval, @"\\b0 ?", "");
retval = Regex.Replace(retval, @"\\b ?", "");
retval = Regex.Replace(retval, @"\\ulnone ?", "");
retval = Regex.Replace(retval, @"\\ul0 ?", "");
retval = Regex.Replace(retval, @"\\ul ?", "");
retval = Regex.Replace(retval, @"\\i0 ?", "");
retval = Regex.Replace(retval, @"\\i ?", "");
//retval = Regex.Replace(retval, @"\\super ?", "");
//retval = Regex.Replace(retval, @"\\sub ?", "");
//retval = Regex.Replace(retval, @"\\nosupersub ?", "");
retval = Regex.Replace(retval, @"\\up[320] ?", "");
retval = Regex.Replace(retval, @"\\dn[320] ?", "");
retval = Regex.Replace(retval, @"\\li[0-9]+ ?", ""); // changed the * to a + to "\\line " for hard returns part of bug fix B2015-140
retval = Regex.Replace(retval, @"\\fi-[0-9]+ ?", "");
retval = Regex.Replace(retval, @"\\fs[0-9]+ ?", ""); // B2020-065: removed font size definition (introduced when allowing font sizes in tables)
}
return retval;
}
public static string StripLinks(string rtf)
{
string retval = rtf;
retval = Regex.Replace(retval, @"\\v.*?\\v0 ?", "");
retval = retval.Replace("\u252C", "");// Unicode 9516 Transition
retval = retval.Replace("\u2566", "");// Unicode 9574 Transition
retval = retval.Replace("\u0015", "");// Unicode 21 RO
if (!string.IsNullOrEmpty(retval))
{
retval = Regex.Replace(retval, @"\\v.*?\\v0 ?", "");
retval = retval.Replace("\u252C", "");// Unicode 9516 Transition
retval = retval.Replace("\u2566", "");// Unicode 9574 Transition
retval = retval.Replace("\u0015", "");// Unicode 21 RO
}
return retval;
}
private static string ReplaceSpecialCharacter(Match m)
{
StringBuilder sb = new StringBuilder();
@@ -3036,6 +3065,7 @@ namespace VEPROMS.CSLA.Library
sb.Append((char)i);
return sb.ToString();
}
private static string ReplaceSpecialHexCharacter(Match m)
{
StringBuilder sb = new StringBuilder();
@@ -3043,14 +3073,21 @@ namespace VEPROMS.CSLA.Library
sb.Append((char)i);
return sb.ToString();
}
private static string ReplaceSpecialCharacters(string rtf)
{
string retval = rtf;
retval = retval.Replace("`", "\u00B0");// Degree
retval = Regex.Replace(retval, @"\\u[0-9]+[?]", new MatchEvaluator(ReplaceSpecialCharacter));
retval = Regex.Replace(retval, @"\\'[0-9A-Fa-f][0-9A-Fa-f]", new MatchEvaluator(ReplaceSpecialHexCharacter));
if (!string.IsNullOrEmpty(retval))
{
retval = retval.Replace("`", "\u00B0");// Degree
retval = Regex.Replace(retval, @"\\u[0-9]+[?]", new MatchEvaluator(ReplaceSpecialCharacter));
retval = Regex.Replace(retval, @"\\'[0-9A-Fa-f][0-9A-Fa-f]", new MatchEvaluator(ReplaceSpecialHexCharacter));
}
return retval;
}
//public void ShowThis(string title)
//{
// Console.WriteLine("'{0}',,,,'i{1}','u{2}',{3},'{4}','{5}','{6}','{7}'", title, ItemID, MyItemInfoUnique, PreviousID, this, _MyPrevious, _MyParent, _ActiveParent);
@@ -3174,38 +3211,47 @@ namespace VEPROMS.CSLA.Library
{
return RemoveRtfStyles(rtf, ActiveFormat);
}
public string RemoveRtfStyles(string rtf, FormatInfo fmt)
{
string retval = rtf;
VE_Font TextFont = GetItemFont(fmt);
if (TextFont != null)
if (!string.IsNullOrEmpty(retval))
{
// remove rtf commands for any styles that were added. Note that if
// the entire item has a style, and also contains 'pieces' of text with
// the same style, the underlying rtf box removes the embedded rtf commands,
// for example, if the entire step is bolded, and 'THEN' has bold on/off
// surrounding it, the rtf box removes the bold around the 'THEN'
// These remove the command with a following space or the command alone,
// either case may exist, because if there are rtf commands following the
// style command, there will be no space character following the style command.
if (((TextFont.Style & E_Style.Bold) > 0) || ((TextFont.Style & E_Style.MmBold) > 0))
VE_Font TextFont = GetItemFont(fmt);
if (TextFont != null)
{
retval = RemoveToken(retval, @"\\b0");
retval = RemoveToken(retval, @"\\b");
}
if ((TextFont.Style & E_Style.Underline) > 0)
{
retval = RemoveToken(retval, @"\\ulnone");
retval = RemoveToken(retval, @"\\ul");
}
if ((TextFont.Style & E_Style.Italics) > 0)
{
retval = RemoveToken(retval, @"\\i0");
retval = RemoveToken(retval, @"\\i");
// remove rtf commands for any styles that were added. Note that if
// the entire item has a style, and also contains 'pieces' of text with
// the same style, the underlying rtf box removes the embedded rtf commands,
// for example, if the entire step is bolded, and 'THEN' has bold on/off
// surrounding it, the rtf box removes the bold around the 'THEN'
// These remove the command with a following space or the command alone,
// either case may exist, because if there are rtf commands following the
// style command, there will be no space character following the style command.
if (((TextFont.Style & E_Style.Bold) > 0) || ((TextFont.Style & E_Style.MmBold) > 0))
{
retval = RemoveToken(retval, @"\\b0");
retval = RemoveToken(retval, @"\\b");
}
if ((TextFont.Style & E_Style.Underline) > 0)
{
retval = RemoveToken(retval, @"\\ulnone");
retval = RemoveToken(retval, @"\\ul");
}
if ((TextFont.Style & E_Style.Italics) > 0)
{
retval = RemoveToken(retval, @"\\i0");
retval = RemoveToken(retval, @"\\i");
}
}
}
return retval;
}
public bool SameRowAsParent
{
get
@@ -4483,7 +4529,7 @@ namespace VEPROMS.CSLA.Library
}
}
}
macroindx = tbformat.IndexOf("{!diamond1}");
macroindx = tbformat.IndexOf("{!diamond1}");
if (macroindx > -1) //i found it
{
cltext = cltext == null ? tbformat.Remove(macroindx, 11) : cltext.Remove(macroindx, 11);
@@ -4578,7 +4624,7 @@ namespace VEPROMS.CSLA.Library
}
else
{
newtab = @"\ul " + newtab.Substring(0, newtab.IndexOf(":") + 1) + @"\ulnone " + newtab.Substring(newtab.IndexOf(":") + 1);
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:
@@ -5067,7 +5113,7 @@ namespace VEPROMS.CSLA.Library
private string ReplaceStepToken(string tbformat)
{
if (tbformat.Trim().EndsWith("`"))
if (!string.IsNullOrEmpty(tbformat) && tbformat.Trim().EndsWith("`"))
{
ItemInfo tmp = this;
string sep = string.Empty;
@@ -5080,6 +5126,7 @@ namespace VEPROMS.CSLA.Library
} while (!tmp.IsHigh);
tbformat = tbformat.Replace("`", " " + hlsOrdinal);
}
return tbformat;
}

View File

@@ -530,21 +530,26 @@ namespace VEPROMS.CSLA.Library
private static List<string> GetROIDsFromLookup(ROFstInfo rofst, List<string> ChangedFiles, DocVersionInfo docver)
{
List<string> roids = new List<string>();
ROFSTLookup myLookup = new ROFSTLookup(rofst.ROFstID, docver);
// B2022-026 RO Memory Reduction code - get only the Image type of ROs
ROFSTLookup.rochild[] children = myLookup.GetRoChildrenByType(E_ROValueType.Image);
if (children != null && children.Length > 0)
// B2022-088: [JPR] Find Doc Ro button not working in Word Sections
// B2022-098: [JPR] ROs not being resolved in Word Sections
if(rofst != null && ChangedFiles != null && ChangedFiles.Count > 0)
{
for (int i = 0; i < children.Length; i++)
{
string filename = children[i].value;
filename = filename.Substring(0, filename.IndexOf('\n'));
ROFSTLookup myLookup = new ROFSTLookup(rofst.ROFstID, docver);
// B2022-026 RO Memory Reduction code - get only the Image type of ROs
ROFSTLookup.rochild[] children = myLookup.GetRoChildrenByType(E_ROValueType.Image);
if (ChangedFiles.Contains(filename))
if (children != null && children.Length > 0)
{
for (int i = 0; i < children.Length; i++)
{
roids.Add(children[i].roid);
string filename = children[i].value;
filename = filename.Substring(0, filename.IndexOf('\n'));
if (ChangedFiles.Contains(filename))
{
roids.Add(children[i].roid);
}
}
}
}
@@ -600,11 +605,14 @@ namespace VEPROMS.CSLA.Library
{
Dictionary<string, int> myRoImagesList = new Dictionary<string, int>();
foreach (ROImageInfo myROImage in myROImages)
if (myROImages != null)
{
myRoImagesList.Add(ROImageKey(myROImage.FileName, myROImage.DTS), myROImage.ImageID);
foreach (ROImageInfo myROImage in myROImages)
{
myRoImagesList.Add(ROImageKey(myROImage.FileName, myROImage.DTS), myROImage.ImageID);
}
}
return myRoImagesList;
}
@@ -616,12 +624,18 @@ namespace VEPROMS.CSLA.Library
private static string buildImageIDString(List<int> myROImageIDs)
{
StringBuilder sb = new StringBuilder();
string sep = "";
foreach (int imageID in myROImageIDs)
// B2022-088: [JPR] Find Doc Ro button not working in Word Sections
// B2022-098: [JPR] ROs not being resolved in Word Sections
if (myROImageIDs != null)
{
sb.Append(sep + imageID.ToString());
sep = ",";
string sep = string.Empty;
foreach (int imageID in myROImageIDs)
{
sb.Append(sep + imageID.ToString());
sep = ",";
}
}
return sb.ToString();