This commit is contained in:
2013-02-08 12:22:26 +00:00
parent 591f3df242
commit 7f58611e6b
4 changed files with 180 additions and 39 deletions

View File

@@ -137,9 +137,11 @@ namespace Volian.Controls.Library
// lines (the 2 spaces after the first "\par " command and 1 space before 2nd "\par"). Tried other
// combinations that did not work.
if (_MyItemInfo.FormatStepData.Prefix != null && _MyItemInfo.FormatStepData.Prefix != "")
text = ReplaceLinesWithUnicode(_MyItemInfo.FormatStepData.Prefix) + @"\par " + text + @"\par ";
text = !_MyItemInfo.FormatStepData.Font.FontIsProportional() ? ReplaceLinesWithUnicode(_MyItemInfo.FormatStepData.Prefix) + @"\par " + text + @"\par ":
@"\par " + text + @"\par ";
if (_MyItemInfo.FormatStepData.Suffix != null && _MyItemInfo.FormatStepData.Suffix != "")
text = text + ReplaceLinesWithUnicode(_MyItemInfo.FormatStepData.Suffix);
text = text + (!_MyItemInfo.FormatStepData.Font.FontIsProportional() ? ReplaceLinesWithUnicode(_MyItemInfo.FormatStepData.Suffix) :
@"\par\par\par ");
}
text = CreateRtf(colorLinks, text, tableShouldBeOutlined, wordsShouldBeReplaced, numbersShouldBeFormated, tableHasBorder, ROsShouldBeAdjusted);
StartText = text;
@@ -207,7 +209,7 @@ namespace Volian.Controls.Library
}
// Adjust RO display
if (ROsShouldBeAdjusted)
text = DoTransitionAdjustments(text);
text = DoTransitionAdjustments(text, _MyItemInfo.ActiveFormat.PlantFormat.FormatData.TransData.BoldTransition);
// add colors around links:
if (colorLinks)
text = DoColorLinks(text);
@@ -390,7 +392,7 @@ namespace Volian.Controls.Library
}
return false;
}
private string DoTransitionAdjustments(string text)
private string DoTransitionAdjustments(string text, bool boldTran)
{
string strippedText = StaticStripRtfCommands(text);
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v \\]+)*\\v(\\[^v \\]+)* #Link:(ReferencedObject|Transition[^:]*?):[0-9]* ([0-9]*).*?\[END>");
@@ -411,16 +413,22 @@ namespace Volian.Controls.Library
System.Text.RegularExpressions.Group g = m.Groups[3];
string beforeTran = retstr.Substring(0, g.Index);
string afterTran = retstr.Substring(g.Index + g.Length);
// if replacing text in the 'beforeTran' string, then do it here,
// i.e. there is a format flag 'BeforeTrans' that bolds text before the transition
// (in wst formats).
beforeTran = DoBeforeTransFlagSupport(beforeTran, _MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.ReplaceStrList);
string newvalue = g.ToString();
int indexLastSpace = newvalue.LastIndexOf(' ');
if (indexLastSpace >= 0)
// Use a "\x1" as a token to replace later. Insert the unicode char, whose length is
// more than 1 character was throwing of the regexp Matches index, so that the resulting
// string may have been incorrect.
retstr = beforeTran + newvalue.Substring(0, indexLastSpace) + "\x1" + newvalue.Substring(indexLastSpace + 1) + afterTran;
retstr = beforeTran + (boldTran ? @"\b " : null) + newvalue.Substring(0, indexLastSpace) + "\x1" + newvalue.Substring(indexLastSpace + 1) + (boldTran ? @"\b0" : null) + afterTran;
else
if (beforeTran.EndsWith(" ") )
retstr = ReplaceLastSpaceWithHardSpace(beforeTran) + newvalue + afterTran;
retstr = ReplaceLastSpaceWithHardSpace(beforeTran) + (boldTran ? @"\b " : null) + newvalue + (boldTran ? @"\b0" : null) + afterTran;
else
Console.Write("");// Don't know where to put the Hard Space
}
@@ -428,6 +436,31 @@ namespace Volian.Controls.Library
}
return retstr.Replace("\x1", @"\u160?");
}
private string DoBeforeTransFlagSupport(string beforeTran, ReplaceStrList replaceStrList)
{
foreach (ReplaceStr repstr in replaceStrList)
{
if ((repstr.Flag & E_ReplaceFlags.BeforeTrans) > 0)
{
// the beforeTran string ends with the string that starts the transition comment, i.e.
// '\\v <START] \\v0 '. The replace word string needs to be before this:
int indx = beforeTran.LastIndexOf(@"\v <START]\v0");
if (indx > -1)
{
string findit = beforeTran.Substring(0, beforeTran.LastIndexOf(@"\v <START]\v0"));
if (findit != null && findit.Trim().ToUpper().EndsWith(repstr.ReplaceWord.ToUpper()))
{
int rindx = findit.Trim().ToUpper().IndexOf(repstr.ReplaceWord.ToUpper());
// don't replace string because case of words may be match replace with string.
beforeTran = findit.Substring(0, rindx) + @"\b " + findit.Substring(rindx) + @"\b0" + beforeTran.Substring(indx);
return beforeTran;
}
}
}
}
return beforeTran;
}
private string ReplaceLastSpaceWithHardSpace(string str)
{
int ind =str.LastIndexOf("<START]");