Compare commits

...

3 Commits

4 changed files with 687 additions and 1000 deletions
-252
View File
@@ -422,150 +422,6 @@ namespace LBWordLibrary
return true; return true;
return false; 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;
List<string> alreadyProcessed = new List<string>();
List<string> fontHasSymbols = new List<string>();
foreach (Match problem in problems)
{
if (!alreadyProcessed.Contains(problem.Value))
{
myRange.Start = problem.Index + offset;
myRange.End = problem.Index + problem.Length + offset;
int newOffset = FindRangeOffset(myRange, problem, offset, end);
string fontName = myRange.Font.Name;
if (IsSymbolFont(fontName))
{
if( !fontHasSymbols.Contains(fontName))
{
fontHasSymbols.Add(fontName);
// Found symbol font
_MyLog.InfoFormat("Font '{0}' has Symbols", fontName);
}
//Console.WriteLine("Font '{0}' has Symbols", myRange.Font.Name);
//return true;
}
else
return myRange.Font.Name;
offset = newOffset;
alreadyProcessed.Add(problem.Value);
}
}
return null;
}
}
/// <summary>
/// Debug Tool - Return a string containing a list of the fonts that have symbol characters.
/// </summary>
public string FontsHaveSymbolCharacters
{
get
{
string sep = "";
StringBuilder sb = new StringBuilder();
List<string> fonts=new List<string>();
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 (!fonts.Contains(myRange.Font.Name))
{
fonts.Add(myRange.Font.Name);
sb.Append(sep + "'" + myRange.Font.Name + "'");
sep = ",";
}
offset = newOffset;
}
if (sb.Length > 0) return sb.ToString();
return null;
}
}
/// <summary>
/// Debug Tool - Return a list of symbol characters using VESYMB font.
/// </summary>
public string FontsHaveSymbolCharacters2
{
get
{
try
{
Dictionary<string, List<int>> fonts = new Dictionary<string, List<int>>();
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);
string sFont = myRange.Font.Name;
if (sFont.ToUpper().StartsWith("VESYM"))
{
if (!fonts.ContainsKey(sFont))
{
fonts.Add(sFont, new List<int>());
}
List<int> symbols = fonts[sFont];
string myTextSymb = GetRangeText(myRange);
foreach (char c in myTextSymb)
{
if (!symbols.Contains((int)c))
symbols.Add((int)c);
}
}
offset = newOffset;
}
if (fonts.Count > 0)
{
string sep = "";
StringBuilder sb = new StringBuilder();
foreach (string font in fonts.Keys)
{
sb.Append(sep + "'" + font + "'");
sep = ",";
foreach (int i in fonts[font])
{
sb.Append(sep);
sb.Append(i);
}
}
return sb.ToString();
}
}
catch (Exception ex)
{
Console.WriteLine("{0},{1},{2}", ex.GetType().Name, ex.Message, ex.StackTrace);
}
return null;
}
}
/// <summary> /// <summary>
/// Checks to see if the document contains symbol characters /// Checks to see if the document contains symbol characters
@@ -601,86 +457,7 @@ namespace LBWordLibrary
} }
} }
Regex _RegFindSymbol = new Regex("[\\uF020-\\uF07F]+"); Regex _RegFindSymbol = new Regex("[\\uF020-\\uF07F]+");
/// <summary>
/// FixSymbolCharacters - Fix any symbol characters in the document
/// </summary>
public void FixSymbolCharacters()
{
// 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);
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 (myRange.Font.Name == "")
{
int wrdStart = myRange.Start;
int wrdEnd = myRange.End;
int wrdMiddle = wrdStart;
while (myRange.Font.Name == "")
{
do
{
myRange.End = ++wrdMiddle;
} while(myRange.Font.Name != "");
myRange.End = wrdMiddle - 1;
ReplaceSymbolCharacters(myRange);
myRange.Start = wrdMiddle -1;
myRange.End = wrdEnd;
}
ReplaceSymbolCharacters(myRange);
}
else
{
ReplaceSymbolCharacters(myRange);
}
offset = newOffset;
}
}
/// <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> /// <summary>
/// Get the Range Text with error handling. myRange.Text sometimes will get a null reference exception. /// Get the Range Text with error handling. myRange.Text sometimes will get a null reference exception.
/// </summary> /// </summary>
@@ -737,35 +514,6 @@ namespace LBWordLibrary
return myRange.Start - problem.Index; return myRange.Start - problem.Index;
} }
/// <summary> /// <summary>
/// ReplaceSymbolCharacters Replaces any symbol characters in the specified range
/// </summary>
/// <param name="myRange"></param>
private static void ReplaceSymbolCharacters(LBRange myRange)
{
try
{
if (IsSymbolFont(myRange.Font.Name))
return;
string before = GetRangeText(myRange);
string updated = ReplaceSymbolCharacters(before);
myRange.Text = updated;
string after = GetRangeText(myRange);
if (after != updated) // If the Word text doesn't match try including a character before and after and do it again.
{
Console.WriteLine("'TryEntireRange Failed',{0},{1},'{2}','{3}','{4}'", myRange.Start, myRange.End, before, updated, after);
int end = myRange.End;
myRange.Start = myRange.Start - 1;
myRange.End = end + 1;
myRange.Text = ReplaceSymbolCharacters(GetRangeText(myRange));
Console.WriteLine("'TryEntireRange Failed',{0},{1},'{2}'", myRange.Start, myRange.End, GetRangeText(myRange));
}
}
catch (Exception ex)
{
Console.WriteLine("'TryEntireRange Exception',{0},{1},'{2}'", myRange.Start, myRange.End, ex.Message);
}
}
/// <summary>
/// ReplaceSymbolCharacters processes the string returned and changes any symbols (0xF0??) to normal characters /// ReplaceSymbolCharacters processes the string returned and changes any symbols (0xF0??) to normal characters
/// </summary> /// </summary>
/// <param name="str"></param> /// <param name="str"></param>
+1 -12
View File
@@ -83,7 +83,6 @@ namespace VEPROMS
this.lblUser = new DevComponents.DotNetBar.LabelItem(); this.lblUser = new DevComponents.DotNetBar.LabelItem();
this.lblLastChange = new DevComponents.DotNetBar.LabelItem(); this.lblLastChange = new DevComponents.DotNetBar.LabelItem();
this.btnStepRTF = new DevComponents.DotNetBar.ButtonItem(); this.btnStepRTF = new DevComponents.DotNetBar.ButtonItem();
this.btnFixMSWord = new DevComponents.DotNetBar.ButtonItem();
this.epAnnotations = new DevComponents.DotNetBar.ExpandablePanel(); this.epAnnotations = new DevComponents.DotNetBar.ExpandablePanel();
this.ctrlAnnotationDetails = new Volian.Controls.Library.AnnotationDetails(); this.ctrlAnnotationDetails = new Volian.Controls.Library.AnnotationDetails();
this.btnAnnoDetailsPushPin = new DevComponents.DotNetBar.ButtonX(); this.btnAnnoDetailsPushPin = new DevComponents.DotNetBar.ButtonX();
@@ -541,8 +540,7 @@ namespace VEPROMS
this.btnEditItem, this.btnEditItem,
this.lblUser, this.lblUser,
this.lblLastChange, this.lblLastChange,
this.btnStepRTF, this.btnStepRTF});
this.btnFixMSWord});
this.bottomBar.Location = new System.Drawing.Point(5, 573); this.bottomBar.Location = new System.Drawing.Point(5, 573);
this.bottomBar.Name = "bottomBar"; this.bottomBar.Name = "bottomBar";
this.bottomBar.Size = new System.Drawing.Size(1185, 25); this.bottomBar.Size = new System.Drawing.Size(1185, 25);
@@ -728,14 +726,6 @@ namespace VEPROMS
this.btnStepRTF.Text = "Step RTF"; this.btnStepRTF.Text = "Step RTF";
this.btnStepRTF.Click += new System.EventHandler(this.btnStepRTF_Click); this.btnStepRTF.Click += new System.EventHandler(this.btnStepRTF_Click);
// //
// btnFixMSWord
//
this.btnFixMSWord.ForeColor = System.Drawing.Color.Black;
this.btnFixMSWord.Name = "btnFixMSWord";
this.btnFixMSWord.Text = "Fix Symbol Fonts";
this.btnFixMSWord.Visible = false;
this.btnFixMSWord.Click += new System.EventHandler(this.btnFixMSWord_Click);
//
// epAnnotations // epAnnotations
// //
this.epAnnotations.CanvasColor = System.Drawing.SystemColors.Control; this.epAnnotations.CanvasColor = System.Drawing.SystemColors.Control;
@@ -1775,7 +1765,6 @@ namespace VEPROMS
private DevComponents.DotNetBar.ButtonItem btnItemInfo; private DevComponents.DotNetBar.ButtonItem btnItemInfo;
private DevComponents.DotNetBar.ButtonItem btnFilter; private DevComponents.DotNetBar.ButtonItem btnFilter;
private DevComponents.DotNetBar.TextBoxItem txtFilter; private DevComponents.DotNetBar.TextBoxItem txtFilter;
private DevComponents.DotNetBar.ButtonItem btnFixMSWord;
private Volian.Controls.Library.DisplayBookMarks displayBookMarks; private Volian.Controls.Library.DisplayBookMarks displayBookMarks;
//private DevComponents.DotNetBar.LabelItem lblLocked; //private DevComponents.DotNetBar.LabelItem lblLocked;
private DevComponents.DotNetBar.ButtonItem btnShortCuts; private DevComponents.DotNetBar.ButtonItem btnShortCuts;
+11 -26
View File
@@ -234,7 +234,7 @@ namespace VEPROMS
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
displayRO.TabControl = tc; // B2019-043 this was being passed in as a parameter for DisplayRO which caused issues with the Visual Studio designer displayRO.TabControl = tc; // B2019-043 this was being passed in as a parameter for DisplayRO which caused issues with the Visual Studio designer
SetupFolder(MyDocVersion.FolderID); SetupFolder(MyDocVersion.FolderID);
tc.MySessionInfo = MyParent.MySessionInfo; tc.MySessionInfo = MyParent.MySessionInfo;
displaySearch1.TopFolderID = myDocVersion.FolderID; displaySearch1.TopFolderID = myDocVersion.FolderID;
SelectedDVI = myDocVersion; SelectedDVI = myDocVersion;
@@ -1578,13 +1578,13 @@ namespace VEPROMS
} }
else else
{ {
SelectedROFst = myDTP.MyDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; SelectedROFst = myDTP.MyDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
} }
} }
} }
else if (tc.MyEditItem != null && displayRO.MyROFST != null && tc.MyEditItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].ROFstID != displayRO.MyROFST.ROFstID) else if (tc.MyEditItem != null && displayRO.MyROFST != null && tc.MyEditItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].ROFstID != displayRO.MyROFST.ROFstID)
{ {
SelectedROFst = tc.MyEditItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; SelectedROFst = tc.MyEditItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
} }
// need this to update RO Tree after UpdateRofst (B2015-226) // need this to update RO Tree after UpdateRofst (B2015-226)
@@ -1592,9 +1592,9 @@ namespace VEPROMS
if (displayRO.MyROFST != SelectedROFst) if (displayRO.MyROFST != SelectedROFst)
{ {
displayRO.MyROFST = SelectedROFst; displayRO.MyROFST = SelectedROFst;
// B2023-021: force Load of Step Prop/RO panel RO tree by passing in // B2023-021: force Load of Step Prop/RO panel RO tree by passing in
// true to LoadTree // true to LoadTree
displayRO.LoadTree(true); displayRO.LoadTree(true);
} }
} }
@@ -2396,8 +2396,8 @@ namespace VEPROMS
tv.MyUserInfo = MyUserInfo; tv.MyUserInfo = MyUserInfo;
StepTabRibbon.MySessionInfo = MySessionInfo; StepTabRibbon.MySessionInfo = MySessionInfo;
// Initialize Caption with Server name and Database name. // Initialize Caption with Server name and Database name.
SetCaption(tv.TopNode as VETreeNode); SetCaption(tv.TopNode as VETreeNode);
System.Threading.AutoResetEvent autoEvent = new System.Threading.AutoResetEvent(false); System.Threading.AutoResetEvent autoEvent = new System.Threading.AutoResetEvent(false);
//System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(MySessionInfo.PingSession); //System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(MySessionInfo.PingSession);
@@ -4553,7 +4553,7 @@ namespace VEPROMS
SetCaption(tv.SelectedNode as VETreeNode); SetCaption(tv.SelectedNode as VETreeNode);
displayApplicability.MyDisplayTabItem = tc.SelectedDisplayTabItem; displayApplicability.MyDisplayTabItem = tc.SelectedDisplayTabItem;
if (tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociationCount > 0) if (tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociationCount > 0)
{ {
displayRO.MyROFST = tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; displayRO.MyROFST = tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
} }
@@ -4628,8 +4628,6 @@ namespace VEPROMS
if (args != null && args.MyEditItem != null && !args.MyEditItem.MyStepPanel.ContainsFocus) if (args != null && args.MyEditItem != null && !args.MyEditItem.MyStepPanel.ContainsFocus)
return; return;
btnFixMSWord.Visible = (args != null && (args.MyItemInfo != null && args.MyEditItem == null));
if (_LastStepRTB != null && !_LastStepRTB.Disposing && !_LastStepRTB.Closed) if (_LastStepRTB != null && !_LastStepRTB.Disposing && !_LastStepRTB.Closed)
_LastStepRTB.EditModeChanged -= new StepRTBEvent(_LastStepRTB_EditModeChanged); _LastStepRTB.EditModeChanged -= new StepRTBEvent(_LastStepRTB_EditModeChanged);
@@ -4769,7 +4767,7 @@ namespace VEPROMS
displayRO.MyRTB = args.MyEditItem.MyStepRTB; displayRO.MyRTB = args.MyEditItem.MyStepRTB;
displayRO.LoadTree(); displayRO.LoadTree();
displayBookMarks.MyEditItem = args.MyEditItem; displayBookMarks.MyEditItem = args.MyEditItem;
displayHistory.MyEditItem = args.MyEditItem; displayHistory.MyEditItem = args.MyEditItem;
lblEditView.Text = args.MyEditItem.MyStepPanel.VwMode == E_ViewMode.Edit ? "Edit" : "View"; lblEditView.Text = args.MyEditItem.MyStepPanel.VwMode == E_ViewMode.Edit ? "Edit" : "View";
@@ -4932,7 +4930,7 @@ namespace VEPROMS
// B2022-026 RO Memory reduction coding (Jakes Merge) // B2022-026 RO Memory reduction coding (Jakes Merge)
displayRO.LoadTree(); displayRO.LoadTree();
} }
#endregion #endregion
@@ -5241,19 +5239,6 @@ namespace VEPROMS
Clipboard.SetDataObject(mydo); Clipboard.SetDataObject(mydo);
} }
} }
private void btnFixMSWord_Click(object sender, EventArgs e)
{
if (tc.SelectedDisplayTabItem != null && tc.SelectedDisplayTabItem.MyDSOTabPanel != null)
{
string btnText = btnFixMSWord.Text;
btnFixMSWord.FixedSize = btnFixMSWord.Size;
btnFixMSWord.Text = "Processing ...";
this.Cursor = Cursors.WaitCursor;
tc.SelectedDisplayTabItem.MyDSOTabPanel.FixSymbolCharacters();
btnFixMSWord.Text = btnText;
this.Cursor = Cursors.Default;
}
}
private void epAnnotations_Resize(object sender, EventArgs e) private void epAnnotations_Resize(object sender, EventArgs e)
{ {
File diff suppressed because it is too large Load Diff