Added logic to support the UnderlineAfterDashSpace flag

beefed up logic to better handle a Note/Caution off of a High Level Step and off of a High Level RNO (all on the same step)
This commit is contained in:
John Jenko 2014-02-12 18:32:10 +00:00
parent d4e80da296
commit b904c19005
2 changed files with 56 additions and 6 deletions

View File

@ -136,6 +136,7 @@ namespace Volian.Controls.Library
int typ = ((int)itemInfo.MyContent.Type) % 10000;
bool tableHasBorder = tableShouldBeOutlined ? itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[typ].Type.IndexOf(@"Borderless") < 0 : false;
bool ROsShouldBeAdjusted = wordsShouldBeReplaced; // same logical value
bool underlineAfterDashSpace = (itemInfo.FormatStepData == null) ? false : itemInfo.FormatStepData.UnderlineAfterDashSpace;
if (epMode == E_EditPrintMode.Print && _MyItemInfo.IsStep)
{
if (_MyItemInfo.FormatStepData.UseSmartTemplate)
@ -151,7 +152,7 @@ namespace Volian.Controls.Library
@"\par\par\par ");
}
}
text = CreateRtf(colorLinks, text, tableShouldBeOutlined, wordsShouldBeReplaced, numbersShouldBeFormated, tableHasBorder, ROsShouldBeAdjusted);
text = CreateRtf(colorLinks, text, tableShouldBeOutlined, wordsShouldBeReplaced, numbersShouldBeFormated, tableHasBorder, ROsShouldBeAdjusted, underlineAfterDashSpace);
StartText = text;
}
@ -174,7 +175,7 @@ namespace Volian.Controls.Library
public DisplayText(string text, VE_Font vFont, bool colorLinks)
{
TextFont = vFont;
StartText = CreateRtf(colorLinks, text, false, false, false, false, false);
StartText = CreateRtf(colorLinks, text, false, false, false, false, false, false);
}
public DisplayText(ItemInfo itemInfo, string text, bool colorLinks)
{
@ -188,8 +189,9 @@ namespace Volian.Controls.Library
bool numbersShouldBeFormated = !_MyFormat.PlantFormat.FormatData.SectData.StepSectionData.FortranFormatNumbers;
int typ = ((int)itemInfo.MyContent.Type) % 10000;
bool ROsShouldBeAdjusted = wordsShouldBeReplaced; // same logical value
bool underlineAfterDashSpace = (itemInfo.FormatStepData == null) ? false : itemInfo.FormatStepData.UnderlineAfterDashSpace;
text = CreateRtf(colorLinks, text, false, wordsShouldBeReplaced, numbersShouldBeFormated, false, ROsShouldBeAdjusted);
text = CreateRtf(colorLinks, text, false, wordsShouldBeReplaced, numbersShouldBeFormated, false, ROsShouldBeAdjusted, underlineAfterDashSpace);
StartText = text;
// Shearon Harris Tables are Bold
if (itemInfo.IsTable && (TextFont.Style & E_Style.Bold) == E_Style.Bold)
@ -201,7 +203,12 @@ namespace Volian.Controls.Library
StartText = Regex.Replace(text, @"(\\viewkind.*?)(?= |\\u[0-9]+?|\\'[0-9A-F])", @"$1\b");
}
}
private string CreateRtf(bool colorLinks, string text, bool tableShouldBeOutlined, bool wordsShouldBeReplaced, bool numbersShouldBeFormated, bool tableHasBorder, bool ROsShouldBeAdjusted)
private bool InLinkedText(string text, int idx)
{
int endLink = text.Substring(0,idx).IndexOf(@"\[END>");
return (endLink > -1);
}
private string CreateRtf(bool colorLinks, string text, bool tableShouldBeOutlined, bool wordsShouldBeReplaced, bool numbersShouldBeFormated, bool tableHasBorder, bool ROsShouldBeAdjusted, bool underlineAfterDashSpace)
{
// Adjust RO display
if (ROsShouldBeAdjusted)
@ -296,9 +303,49 @@ namespace Volian.Controls.Library
indxsym = NextUnicode(text, indxsym + incrindx);//text.IndexOf(@"\u", indxsym + incrindx);
}
}
if (underlineAfterDashSpace)
{
MatchCollection mc = Regex.Matches(text, @"\\u8209\?\\f[0-9]+ ");
if (mc.Count > 0)
{
Match m = mc[0];
if (!InLinkedText(text, m.Index))
{
string str1 = text.Substring(0, m.Index + m.Length);
string str2 = text.Substring(m.Index + m.Length);
string str3 = "";
int iTerm = FindUnderlineTerminator(str2);
if (iTerm >= 0)
{
str3 = str2.Substring(iTerm);
str2 = str2.Substring(0, iTerm);
}
str2 = str2.Replace(@"\ulnone ", "");
str2 = str2.Replace(@"\ulnone", "");
str2 = str2.Replace(@"\ul ", "");
str2 = str2.Replace(@"\ul", "");
text = str1 + @"\ul " + str2 + @"\ulnone " + str3;
}
}
}
return text;
}
private int FindUnderlineTerminator(string text)
{
int idx = -1;
UnderlineTerminateList utl = _MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.UnderlineTerminateList;
foreach (UnderlineTerminate ut in utl)
{
MatchCollection mc = Regex.Matches(text, "(?<!Link|ReferencedObject|Transition|TransitionRange)" + ut.Text);
if (mc.Count > 0)
{
Match m = mc[mc.Count - 1];
if (idx < 0 || idx > m.Index)
idx = m.Index;
}
}
return idx;
}
private string DoSearchAndReplace(string text, string find, string replace)
{
return text.Replace(find, replace);

View File

@ -1918,7 +1918,10 @@ namespace Volian.Print.Library
yoff += adj;
if (MyTab != null) MyTab.YOffset = ChildrenRight[0].YOffset;
if (PartsRight.Count > 0) PartsRight[0].YOffset = ChildrenRight[0].YOffset;
YTopMost = ChildrenRight[0].ChildrenAbove[0].YOffset;
if (ChildrenAbove.Count == 0)
YTopMost = ChildrenRight[0].ChildrenAbove[0].YOffset;
else
YTopMost = ChildrenAbove[0].YOffset;
}
}
// Need code to determine if the table will overlap the Right Column if it does then