This commit is contained in:
Kathy Ruffing 2008-01-28 14:05:58 +00:00
parent 8225dc58af
commit e0599c2a56

View File

@ -56,7 +56,7 @@ namespace VEPROMS.CSLA.Library
// if in print mode or view mode, do replace words. Only if in edit mode are replace
// words left as is.
FormatInfo format = itemInfo.ActiveFormat;
if (epMode == E_EditPrintMode.PRINT || vwMode == E_ViewMode.VIEW) text = DoReplaceWords(text, format);
if (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View) text = DoReplaceWords(text, format);
// displayTextElement List items are created for anything that is handled differently in RTB, i.e.
// symbols, ros, trans, text.
@ -211,7 +211,44 @@ namespace VEPROMS.CSLA.Library
// Insert the link (ro or transition) to the item
if (!found)
{
Console.WriteLine("New ro or trans");
if (dte.Type == E_TextElementType.RO) // do ro
{
displayLinkElement l_dte = (displayLinkElement)dte;
Match m = Regex.Match(l_dte.Link, ".*[#]Link:([A-Za-z]*):(.*)");
//_RoUsageid = m.Groups[2].Value;
//_Roid = m.Groups[3].Value;
string linkstr = m.Groups[2].Value;
if (linkstr[0] == ' ') linkstr = linkstr.Substring(1, linkstr.Length - 1);
int roidindx = linkstr.IndexOf(" ", 1)+1;
string roid = linkstr.Substring(roidindx, linkstr.Length - roidindx);
ContentRoUsage cr = itm.MyContent.ContentRoUsages.Add(roid);
//int rou
//int trid = ct.TransitionID;
break;
}
else if (dte.Type == E_TextElementType.TRANS_Range || dte.Type == E_TextElementType.TRANS_Single)
{
displayLinkElement l_dte = (displayLinkElement)dte;
Match m = Regex.Match(l_dte.Link, ".*[#]Link:([A-Za-z]*):(.*)");
string linkstr = m.Groups[2].Value;
if (linkstr[0] == ' ') linkstr = linkstr.Substring(1, linkstr.Length - 1);
int type = System.Convert.ToInt32(linkstr.Substring(0,1));
int trindx = linkstr.IndexOf(" ", 2); // start past the space after the type.
int trindx2 = linkstr.IndexOf(" ", trindx + 1);
if (trindx2 == -1) trindx2 = linkstr.Length - 1;
int tr1 = System.Convert.ToInt32(linkstr.Substring(trindx + 1, trindx2 - trindx));
Item itm1 = Item.Get(tr1);
int tr2 = 0;
Item itm2 = null;
if (dte.Type == E_TextElementType.TRANS_Range)
{
tr2 = System.Convert.ToInt32(linkstr.Substring(trindx2,linkstr.Length-trindx2));
itm2 = Item.Get(tr2);
}
ContentTransition ct = itm.MyContent.ContentTransitions.Add(itm1, itm2);
ct.TranType = type;
int trid = ct.TransitionID;
}
}
}
}
@ -303,17 +340,23 @@ namespace VEPROMS.CSLA.Library
{
displayLinkElement vte = new displayLinkElement();
vte.Type = type;
// \protect {transition text} \v #Link:Transition(Range): 1 2 3\protect0\v0 where 1 2 3 are transition type and ids
// \protect {transition text} \v #Link:Transition(Range): 1 2 3\protect0\v0
// where 1 2 3 are transition type and ids
int indx = data.IndexOf("\\v #Link:Transition", startIndex);
vte.Text = data.Substring(startIndex + 9, indx - startIndex - 9); // get past \protect
int iend = data.IndexOf("\\protect0\\v0", indx);
if (iend == -1) iend = data.IndexOf("\\v0\\protect0", indx);
// get past \v #Link:Transition or \v #Link:TransitionRange
int bindx = indx + 3;
//if (type == E_TextElementType.TRANS_Range) bindx += 5;
// use '9' to get past \\protect
vte.Text = data.Substring(startIndex + 9, indx - startIndex - 9);
// the link is the text between the #Link... and the next '\\'.
int iend = data.IndexOf("\\", indx+1);
int bindx = data.IndexOf("#", indx);
vte.Link = data.Substring(bindx, iend - bindx);
DisplayTextElementList.Add(vte);
return iend + 11; // get past the \protect0\vo
// unfortunately, the rtf box may add the \protect0 \v0 in either order
// and with or without one or more spaces between then. The number of text
// characters = 11 for \protect0\v0 - find the number of spaces between them
// if any?
int nsp = 0;
for (int c = iend; c < iend + 11; c++) if (data[c] == ' ') nsp++;
return iend + 11 + nsp;
}
private int SaveROTE(string data, int startIndex)
{
@ -321,12 +364,20 @@ namespace VEPROMS.CSLA.Library
vte.Type = E_TextElementType.RO;
// \protect {rovalue} \v #Link:ReferencedObject (RoUsageId) {ROID}\protect0\v0
int indx = data.IndexOf("\\v #Link:ReferencedObject", startIndex);
vte.Text = data.Substring(startIndex + 9, indx - startIndex - 9); // get past \protect
int iend = data.IndexOf("\\protect0\\v0", indx);
if (iend == -1) iend = data.IndexOf("\\v0\\protect0", indx);
vte.Link = data.Substring(indx + 3, iend - indx - 3); // get past \v #Link:ReferencedObject
// use '9' to get past \\protect
vte.Text = data.Substring(startIndex + 9, indx - startIndex - 9);
// the link is the text between the #Link... and the next '\\'.
int iend = data.IndexOf("\\", indx);
int bindx = data.IndexOf("#", indx);
vte.Link = data.Substring(bindx, iend - bindx);
DisplayTextElementList.Add(vte);
return iend + 11; // get past the \protect0\vo
// unfortunately, the rtf box may add the \protect0 \v0 in either order
// and with or without one or more spaces between then. The number of text
// characters = 11 for \protect0\v0 - find the number of spaces between them
// if any?
int nsp = 0;
for (int c = iend; c < iend + 11; c++) if (data[c] == ' ') nsp++;
return iend + 11 + nsp;
}
private int FindRtfChar(string text, int startIndex)
{
@ -385,17 +436,17 @@ namespace VEPROMS.CSLA.Library
// 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)
if ((TextFont.Style & E_Style.Bold) > 0)
{
retval = Regex.Replace(retval, @"\\b0 ?", "");
retval = Regex.Replace(retval, @"\\b ?","");
}
if ((TextFont.Style & E_Style.UNDERLINE) > 0)
if ((TextFont.Style & E_Style.Underline) > 0)
{
retval = Regex.Replace(retval, @"\\ul0 ?", "");
retval = Regex.Replace(retval, @"\\ul ?", "");
}
if ((TextFont.Style & E_Style.ITALICS) > 0)
if ((TextFont.Style & E_Style.Italics) > 0)
{
retval = Regex.Replace(retval, @"\\i0 ?", "");
retval = Regex.Replace(retval, @"\\i ?", "");
@ -465,7 +516,9 @@ namespace VEPROMS.CSLA.Library
private string ToData_Trans(displayLinkElement vte)
{
char trchar = vte.Type == E_TextElementType.TRANS_Single ? '\x252C' : '\x2566';
int indx = vte.Type == E_TextElementType.TRANS_Single ? 16 : 21;
// depending on type, get past the #Link:Transition: or #Link:TransitionRange: part
// of text.
int indx = vte.Type == E_TextElementType.TRANS_Single ? 18 : 23;
return String.Format("{0}\\v TRAN\\v0 {1}\\v {2}\\v0", trchar, vte.Text, vte.Link.Substring(indx, vte.Link.Length-indx));
}
#endregion
@ -494,17 +547,17 @@ namespace VEPROMS.CSLA.Library
private string InsertRtfStyles()
{
StringBuilder sb = new StringBuilder(_itemInfo.MyContent.Text);
if ((TextFont.Style & E_Style.BOLD)>0)
if ((TextFont.Style & E_Style.Bold)>0)
{
sb.Insert(0, "\\b ");
sb.Append("\\b0 ");
}
if ((TextFont.Style & E_Style.UNDERLINE) > 0)
if ((TextFont.Style & E_Style.Underline) > 0)
{
sb.Insert(0, "\\ul ");
sb.Append("\\ul0 ");
}
if ((TextFont.Style & E_Style.ITALICS) > 0)
if ((TextFont.Style & E_Style.Italics) > 0)
{
sb.Insert(0, "\\i ");
sb.Append("\\i0 ");
@ -646,19 +699,19 @@ namespace VEPROMS.CSLA.Library
// note that the order of this check is important. Check in this order...
// background here
if (_itemInfo.IsHigh && (rs.Flag & E_ReplaceFlags.HIGH)>0) replaceit = true;
else if ((_itemInfo.IsTable || _itemInfo.IsFigure) && (rs.Flag & E_ReplaceFlags.TABLE) > 0) replaceit = true;
if (_itemInfo.IsHigh && (rs.Flag & E_ReplaceFlags.High)>0) replaceit = true;
else if ((_itemInfo.IsTable || _itemInfo.IsFigure) && (rs.Flag & E_ReplaceFlags.Table) > 0) replaceit = true;
else if (_itemInfo.IsInRNO && (rs.Flag & E_ReplaceFlags.RNO) > 0) replaceit = true;
else if (_itemInfo.IsCaution && (rs.Flag & E_ReplaceFlags.CAUTION) > 0) replaceit = true;
else if (_itemInfo.IsNote && (rs.Flag & E_ReplaceFlags.NOTE) > 0) replaceit = true;
else if (_itemInfo.IsInFirstLevelSubStep && (rs.Flag & E_ReplaceFlags.SUBSTEP) > 0) replaceit = true;
else if (_itemInfo.IsAccPages & (rs.Flag & E_ReplaceFlags.ATTACH) > 0) replaceit = true;
else if (_itemInfo.IsCaution && (rs.Flag & E_ReplaceFlags.Caution) > 0) replaceit = true;
else if (_itemInfo.IsNote && (rs.Flag & E_ReplaceFlags.Note) > 0) replaceit = true;
else if (_itemInfo.IsInFirstLevelSubStep && (rs.Flag & E_ReplaceFlags.Substep) > 0) replaceit = true;
else if (_itemInfo.IsAccPages & (rs.Flag & E_ReplaceFlags.Attach) > 0) replaceit = true;
if (replaceit)
{
// CASEINSENS: Do ReplaceWords for all words that match, regardless of case, and replace
// with the ReplaceWith string as is
if ((rs.Flag & E_ReplaceFlags.CASEINSENS) > 0)
if ((rs.Flag & E_ReplaceFlags.CaseInsens) > 0)
{
string res = "";
string fortest = Text.ToUpper();
@ -675,13 +728,13 @@ namespace VEPROMS.CSLA.Library
Text = res;
}
// CASEINSENSALL: Do ReplaceWords for all words that match the ReplaceWord, regardless of case
else if ((rs.Flag & E_ReplaceFlags.CASEINSENSALL) > 0)
else if ((rs.Flag & E_ReplaceFlags.CaseInsensAll) > 0)
{
// not in hlp
}
// CASEINSENSFIRST: Do ReplaceWords for all words that exactly match the ReplaceWord,
// except the case where the first character may be different
else if ((rs.Flag & E_ReplaceFlags.CASEINSENSFIRST) > 0)
else if ((rs.Flag & E_ReplaceFlags.CaseInsensFirst) > 0)
{
// not in hlp
}