This commit is contained in:
Kathy Ruffing 2010-11-23 14:42:02 +00:00
parent 05b8809608
commit ecf6b5bfd1
2 changed files with 84 additions and 0 deletions

View File

@ -292,6 +292,12 @@ namespace LBWordLibrary
{
get { return (GetProperty("SaveFormat") as int? ?? 0); }
}
public Boolean Saved
{
get { return (GetProperty("Saved") as Boolean? ?? false); }
set { SetProperty("Saved", value); }
}
public String FullName
{
get { return (GetProperty("FullName").ToString()); }
@ -348,6 +354,14 @@ namespace LBWordLibrary
{
return new LBRange(InvokeMethod("Range", Start, End));
}
public Boolean Undo()
{
return InvokeMethod("Undo", Missing.Value) as Boolean? ?? false;
}
public Boolean Undo(object Times)
{
return InvokeMethod("Undo", Times) as Boolean? ?? false;
}
}
public partial class LBWindow : LBComObject
{

View File

@ -293,6 +293,39 @@ namespace LBWordLibrary
return true;
return false;
}
/// <summary>
/// If document contains symbol characters, returns problem font.
/// </summary>
public string FontHasSymbolCharacters
{
get
{
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);
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;
}
else
return myRange.Font.Name;
offset = newOffset;
}
return null;
}
}
/// <summary>
/// Checks to see if the document contains symbol characters
/// </summary>
@ -350,6 +383,43 @@ namespace LBWordLibrary
}
}
/// <summary>
/// Try to fix the first character in the symbol range F000 to F0FF. If it cannot be
/// fixed, it is an indicator that the font is not installed properly. Regardless of
/// whether there is success, the change is undone so that the document will not be
/// considered dirty, i.e. will not prompt user for save.
/// </summary>
/// <returns></returns>
public bool AttemptToFixASymbolCharacter()
{
// Set up range object to be used to process text
LBRange myRange = Range();
myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToLast, 100);
int end = myRange.End;
myRange.Start = 0;
string myText = GetRangeText(myRange);
MatchCollection problems = _RegFindSymbol.Matches(myText);
if (problems.Count>0)
{
Match problem = problems[0];
myRange.Start = problem.Index;
myRange.End = myRange.Start + 1;
if (IsSymbolFont(myRange.Font.Name)) return true; // if it's a symbol font already, no issue.
string before = GetRangeText(myRange);
string updated = ReplaceSymbolCharacters(before);
myRange.Text = updated;
string after = GetRangeText(myRange);
Undo(1);
//Console.WriteLine("Undo1 results = {0}", tst);
//tst = Undo(1);
//Console.WriteLine("Undo2 results = {0}", tst);
//tst = Undo(1);
//Console.WriteLine("Undo3 results = {0}", tst);
return (updated == after);
}
return true;
}
/// <summary>
/// Get the Range Text with error handling. myRange.Text sometimes will get a null reference exception.
/// </summary>
/// <param name="myRange"></param>