This commit is contained in:
2010-03-25 14:48:46 +00:00
parent b10ade8a14
commit 2830a93e24
7 changed files with 164 additions and 31 deletions

View File

@@ -10,6 +10,7 @@ using System.Data.SqlClient;
using System.Xml;
using System.Drawing;
using System.Text.RegularExpressions;
using VEPROMS.CSLA.Library;
namespace VEPROMS.CSLA.Library
{
@@ -1074,6 +1075,86 @@ namespace VEPROMS.CSLA.Library
retval = Regex.Replace(retval, @"\\'[0-9A-Fa-f][0-9A-Fa-f]", new MatchEvaluator(ReplaceSpecialHexCharacter));
return retval;
}
public VE_Font GetItemFont()
{
return GetItemFont(ActiveFormat);
}
public VE_Font GetItemFont(FormatInfo fmt)
{
VE_Font font = null;
try
{
FormatInfo format = (ActiveFormat != null || fmt == null) ? ActiveFormat : fmt;//_MyItemInfo.ActiveFormat;
int type = (int)MyContent.Type;//_MyItemInfo.MyContent.Type;
switch (type / 10000)
{
case 0: // procedure
font = format.PlantFormat.FormatData.Font;
break;
case 1: // section
font = format.PlantFormat.FormatData.SectData.SectionHeader.Font;
break;
case 2: // step types
int typindx = type - 20000; // what to do for other types rather than steps
font = format.PlantFormat.FormatData.StepDataList[typindx].Font;
break;
}
}
catch (Exception ex)
{
Console.WriteLine("GetItemFont(): {0} - {1}", ex.GetType(), ex.Message);
}
return font;
}
private string RemoveToken(string str, string token)
{
// if this token is preceeded by another token and followed by a space
// leave the preceeding token the ending space
string retval = Regex.Replace(str, @"(\\[^ \\?\r\n\t]*)" + token + " ", "$1 ");
if (retval != str)
Console.WriteLine("leave the preceeding token the ending space");
// otherwise replace the token optionally followed by a space
retval = Regex.Replace(retval, token + " ?", "");
return retval;
}
public string RemoveRtfStyles(string rtf)
{
return RemoveRtfStyles(rtf, ActiveFormat);
}
public string RemoveRtfStyles(string rtf, FormatInfo fmt)
{
string retval = rtf;
VE_Font TextFont = GetItemFont(fmt);
if (TextFont != null)
{
// 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;
}
#endregion
#region Path and Parent
public string Path
@@ -1332,7 +1413,7 @@ namespace VEPROMS.CSLA.Library
}
}
public ItemInfo MyProcedure
public ProcedureInfo MyProcedure
{
get
{
@@ -1340,7 +1421,7 @@ namespace VEPROMS.CSLA.Library
ItemInfo tmp = this;
while (tmp.ActiveParent != null && tmp.ActiveParent.GetType() != typeof(DocVersionInfo))
tmp = (ItemInfo)tmp.ActiveParent;
return tmp;
return ProcedureInfo.Get(tmp.ItemID);
}
}
private IVEDrillDownReadOnly _ActiveParent = null;
@@ -1416,8 +1497,8 @@ namespace VEPROMS.CSLA.Library
{
get
{
if (_ActiveFormat == null)
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat);
if (_ActiveFormat == null) // jsj added check for NULL ActiveParent
_ActiveFormat = (LocalFormat != null ? LocalFormat : (ActiveParent != null)? ActiveParent.ActiveFormat : null);
//Console.WriteLine("Active {0}", (_ActiveFormat == null) ? "_ActiveFormat is null" : _ActiveFormat.Name);
return _ActiveFormat;
}
@@ -2012,6 +2093,7 @@ namespace VEPROMS.CSLA.Library
cm.Parameters.AddWithValue("@IncludeLinks", (int) criteria.IncludeLinks);
cm.Parameters.AddWithValue("@IncludeRtfFormatting", criteria.IncludeRtfFormatting ? 1 : 0);
cm.Parameters.AddWithValue("@IncludeSpecialCharacters", criteria.IncludeSpecialCharacters ? 1 : 0);
cm.CommandTimeout = 120;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read())