Added Name property for font
Added logic to keep appropriate symbols in word files
This commit is contained in:
parent
37688d042f
commit
b4cb2a0def
@ -536,6 +536,11 @@ namespace LBWordLibrary
|
||||
get { return (GetProperty("Size") as float? ?? 0); }
|
||||
set { SetProperty("Size", value); }
|
||||
}
|
||||
public String Name
|
||||
{
|
||||
get { return (GetProperty("Name").ToString()); }
|
||||
set { SetProperty("Name", value); }
|
||||
}
|
||||
}
|
||||
public enum LBWdInformation
|
||||
{
|
||||
|
@ -285,6 +285,14 @@ namespace LBWordLibrary
|
||||
return ReplaceSymbolCharacters(GetRangeText(myRange));
|
||||
}
|
||||
}
|
||||
private static string[] SymbolFontName = { "VolianDraw", "WingDings" };
|
||||
private static bool IsSymbolFont(string fontName)
|
||||
{
|
||||
foreach (string symbolFont in SymbolFontName)
|
||||
if (symbolFont.ToUpper() == fontName.ToUpper())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Checks to see if the document contains symbol characters
|
||||
/// </summary>
|
||||
@ -296,8 +304,24 @@ namespace LBWordLibrary
|
||||
LBRange myRange = Range();
|
||||
myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToLast, 100);
|
||||
myRange.Start = 0;
|
||||
int end = myRange.End;
|
||||
string myText = GetRangeText(myRange);
|
||||
return _RegFindSymbol.IsMatch(myText);
|
||||
//return _RegFindSymbol.IsMatch(myText);
|
||||
MatchCollection problems = _RegFindSymbol.Matches(myText);
|
||||
int offset = 0;
|
||||
foreach (Match problem in problems)
|
||||
{
|
||||
myRange.Start = problem.Index + offset;
|
||||
myRange.End = problem.Index + problem.Length + offset;
|
||||
int newOffset = FindRangeOffset(myRange, problem, offset, end);
|
||||
if (IsSymbolFont(myRange.Font.Name))
|
||||
{
|
||||
Console.WriteLine("Font '{0}' has Symbols", myRange.Font.Name);
|
||||
return true;
|
||||
}
|
||||
offset = newOffset;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Regex _RegFindSymbol = new Regex("[\\uF000-\\uF0FF]+");
|
||||
@ -383,6 +407,8 @@ namespace LBWordLibrary
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsSymbolFont(myRange.Font.Name))
|
||||
return;
|
||||
string before = GetRangeText(myRange);
|
||||
string updated = ReplaceSymbolCharacters(before);
|
||||
myRange.Text = updated;
|
||||
|
Loading…
x
Reference in New Issue
Block a user