Added some error handling to keep from crashing
Added code to support Opposite Unit replace words with and without ROs. Added logic to limit UpcaseAllRoUnits to only work for setpoints.
This commit is contained in:
parent
be08172cf8
commit
033b3514f8
@ -3637,12 +3637,15 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_TemplateColumnMode == null)
|
if (_TemplateColumnMode == null)
|
||||||
{
|
{
|
||||||
ItemInfo pi = ActiveParent as ItemInfo;
|
ItemInfo pi = ActiveParent as ItemInfo;
|
||||||
if (!pi.IsStep) // only steps are in template
|
if (pi != null)
|
||||||
_TemplateColumnMode = -1;
|
{
|
||||||
else if (pi.FormatStepData.UseOldTemplate)
|
if (!pi.IsStep) // only steps are in template
|
||||||
_TemplateColumnMode = pi.TemplateChildColumnMode;
|
_TemplateColumnMode = -1;
|
||||||
else
|
else if (pi.FormatStepData.UseOldTemplate)
|
||||||
_TemplateColumnMode = pi.TemplateColumnMode; // go up parents until find of columnmode or section
|
_TemplateColumnMode = pi.TemplateChildColumnMode;
|
||||||
|
else
|
||||||
|
_TemplateColumnMode = pi.TemplateColumnMode; // go up parents until find of columnmode or section
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return _TemplateColumnMode ?? -1;
|
return _TemplateColumnMode ?? -1;
|
||||||
}
|
}
|
||||||
|
@ -344,8 +344,71 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
text = FixDiffUnitROReplaceWords(text);
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string FixDiffUnitROReplaceWords(string text)
|
||||||
|
{
|
||||||
|
if (_MyFormat == null) return text;
|
||||||
|
ReplaceStrList rsl = _MyFormat.PlantFormat.FormatData.SectData.ReplaceStrList;
|
||||||
|
|
||||||
|
// The only way to get an 'empty' list is to have one 'dummy' replacestr, i.e. that has ReplaceWord as an empty string. If the
|
||||||
|
// ReplaceStrData xml node is empty, it does the inheritance and gets the 'base' format's list.
|
||||||
|
if (rsl.Count == 1 && (rsl[0].ReplaceWord == null || rsl[0].ReplaceWord == "")) return text;
|
||||||
|
// Loop through text looking for words to be replaced
|
||||||
|
List<ReplaceStr> partialReplaceList = new List<ReplaceStr>();
|
||||||
|
foreach (ReplaceStr rs in rsl)
|
||||||
|
{
|
||||||
|
if (rs.ReplaceWord.Contains("{RO}"))
|
||||||
|
{
|
||||||
|
if (_MyItemInfo.InList(34770,34771,34782,34882,34886,34916,34891,35121,36361))
|
||||||
|
Console.WriteLine("FixDiffUnitROReplaceWords jcb");
|
||||||
|
string oldvalue = text;
|
||||||
|
string replaceWord = rs.ReplaceWord;
|
||||||
|
string replaceWord2 = Regex.Replace( replaceWord,@"(\{RO\})([0-9,]+)(\{RO\})",@"\\v <START]\\v0 ($2)\\v");
|
||||||
|
string replaceWith = rs.ReplaceWith.Replace(@"\xA0",@"\'A0") + @"\v";
|
||||||
|
if (!rs.ReplaceWith.Contains(@"\b0") || _MyItemInfo.FormatStepData == null || (_MyItemInfo.FormatStepData.Font.Style & E_Style.Bold) == 0)
|
||||||
|
{
|
||||||
|
text = ReplaceOppositeUnitRO(text, replaceWord2, replaceWith);
|
||||||
|
if(replaceWord2.StartsWith("UNIT ") && text.Contains(@"UNIT\u160?"))
|
||||||
|
text = ReplaceOppositeUnitRO(text, replaceWord2.Replace("UNIT ",@"UNIT\\u160?"), replaceWith);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ReplaceOppositeUnitRO(string text, string replaceWord2, string replaceWith)
|
||||||
|
{
|
||||||
|
Match m = Regex.Match(text, replaceWord2, RegexOptions.IgnoreCase);
|
||||||
|
int offset = 0;
|
||||||
|
while (m.Success)
|
||||||
|
{
|
||||||
|
int len = m.Length;
|
||||||
|
if (FoundMatches.DiffUnit(m.Groups[1].Value, _MyItemInfo, ""))
|
||||||
|
{
|
||||||
|
text = text.Substring(0, offset + m.Index) + replaceWith + text.Substring(offset + m.Index + m.Length);
|
||||||
|
len = replaceWith.Length;
|
||||||
|
//text = text.Replace(replaceWord2, rs.ReplaceWith.Replace(@"\xA0",@"\'A0") + @"\v");
|
||||||
|
}
|
||||||
|
offset += m.Index + len;
|
||||||
|
m = Regex.Match(text.Substring(offset), replaceWord2, RegexOptions.IgnoreCase);
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
private Match FirstMatch(string text, string replaceWord2)
|
||||||
|
{
|
||||||
|
if(text.Contains(replaceWord2.Replace("(","").Replace(")","").Replace(@"\\",@"\")))
|
||||||
|
Console.WriteLine("here");
|
||||||
|
MatchCollection matches = Regex.Matches(text, replaceWord2, RegexOptions.IgnoreCase);
|
||||||
|
if (matches.Count > 0)
|
||||||
|
{
|
||||||
|
Match mm = Regex.Match(text, replaceWord2, RegexOptions.IgnoreCase);
|
||||||
|
return matches[0];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
private int FindUnderlineTerminator(string text)
|
private int FindUnderlineTerminator(string text)
|
||||||
{
|
{
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
@ -1298,7 +1361,7 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpcaseAllRoUnits - Uppercases ALL ROs units everywhere.
|
// UpcaseAllRoUnits - Uppercases ALL ROs units everywhere.
|
||||||
if (_MyItemInfo.ActiveFormat.PlantFormat.FormatData.ROData.UpcaseAllRoUnits)
|
if (isSetpoint && _MyItemInfo.ActiveFormat.PlantFormat.FormatData.ROData.UpcaseAllRoUnits)
|
||||||
return UpperCaseUnits(rtnstr);
|
return UpperCaseUnits(rtnstr);
|
||||||
|
|
||||||
//Forces the units for a RO to be uppercased for high level steps
|
//Forces the units for a RO to be uppercased for high level steps
|
||||||
@ -1895,6 +1958,8 @@ namespace Volian.Controls.Library
|
|||||||
{
|
{
|
||||||
//if(offset != 0 || foundMatch.MyMatch.Index != 0 || !foundMatch.MyWord.ReplaceWith.StartsWith(@"{\par}"))
|
//if(offset != 0 || foundMatch.MyMatch.Index != 0 || !foundMatch.MyWord.ReplaceWith.StartsWith(@"{\par}"))
|
||||||
//{
|
//{
|
||||||
|
if (((foundMatch.MyWord.Flag & E_ReplaceFlags.DiffUnit) == 0) || DiffUnit(foundMatch.MyWord.ReplaceWord,_MyItemInfo,"UNIT "))
|
||||||
|
{
|
||||||
string with = foundMatch.MyWord.ReplaceWith;
|
string with = foundMatch.MyWord.ReplaceWith;
|
||||||
if (offset == 0 && with.StartsWith(@"{\par}"))
|
if (offset == 0 && with.StartsWith(@"{\par}"))
|
||||||
if(StartsWith(text,foundMatch.MyMatch.Index,"",@"\ul ",@"\b ",@"* ",@"* \ul ",@"* \b ",@"*",@"*\ul ",@"*\b "))
|
if(StartsWith(text,foundMatch.MyMatch.Index,"",@"\ul ",@"\b ",@"* ",@"* \ul ",@"* \b ",@"*",@"*\ul ",@"*\b "))
|
||||||
@ -1940,16 +2005,21 @@ namespace Volian.Controls.Library
|
|||||||
with = with.Replace(@"\ulnone ", "");
|
with = with.Replace(@"\ulnone ", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
text = text.Substring(0, offset + foundMatch.MyMatch.Index) + with + text.Substring(offset + foundMatch.MyMatch.Index + foundMatch.MyMatch.Length);
|
text = text.Substring(0, offset + foundMatch.MyMatch.Index) + with + text.Substring(offset + foundMatch.MyMatch.Index + foundMatch.MyMatch.Length);
|
||||||
//offset += foundMatch.MyWord.ReplaceWith.Length - foundMatch.MyMatch.Length;
|
//offset += foundMatch.MyWord.ReplaceWith.Length - foundMatch.MyMatch.Length;
|
||||||
offset += with.Length - foundMatch.MyMatch.Length;
|
offset += with.Length - foundMatch.MyMatch.Length;
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
internal static bool DiffUnit(string unit,ItemInfo myItemInfo,string prefix)
|
||||||
|
{
|
||||||
|
if (unit.StartsWith(prefix))
|
||||||
|
return unit.Substring(prefix.Length) != myItemInfo.MyDocVersion.DocVersionConfig.Unit_Number;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
private bool VerifyNoHardSpace(string text, FoundMatch foundMatch, int offset)
|
private bool VerifyNoHardSpace(string text, FoundMatch foundMatch, int offset)
|
||||||
{
|
{
|
||||||
string begin = text.Substring(0, offset + foundMatch.MyMatch.Index);
|
string begin = text.Substring(0, offset + foundMatch.MyMatch.Index);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user