This commit is contained in:
2013-04-15 12:29:14 +00:00
parent 462a93f53d
commit f9d3af6941
2 changed files with 68 additions and 30 deletions

View File

@@ -431,10 +431,13 @@ namespace Volian.Controls.Library
// was confusing the 'handle' of the rtf box.
//Console.WriteLine("'font',{0}", Font);
//if(Text == "")SelectionFont = Font; // Initialize SelectionFont
if (MyItemInfo != null)
if (FieldToEdit == E_FieldToEdit.StepText)
{
if (MyItemInfo.IsStep) Font = MyFontFamily == null ? MyItemInfo.FormatStepData.Font.WindowsFont:new Font(MyFontFamily, MyItemInfo.FormatStepData.Font.WindowsFont.Size, MyItemInfo.FormatStepData.Font.WindowsFont.Style);
else Font = Font = MyFontFamily == null ? MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font.WindowsFont : new Font(MyFontFamily, MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font.WindowsFont.Size, MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font.WindowsFont.Style);
if (MyItemInfo != null)
{
if (MyItemInfo.IsStep) Font = MyFontFamily == null ? MyItemInfo.FormatStepData.Font.WindowsFont : new Font(MyFontFamily, MyItemInfo.FormatStepData.Font.WindowsFont.Size, MyItemInfo.FormatStepData.Font.WindowsFont.Style);
else Font = Font = MyFontFamily == null ? MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font.WindowsFont : new Font(MyFontFamily, MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font.WindowsFont.Size, MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font.WindowsFont.Style);
}
}
RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT);
ReadOnly = VwMode == E_ViewMode.View || ActiveMode == false;
@@ -1037,7 +1040,7 @@ namespace Volian.Controls.Library
}
private string GetAddSymbolText(string symtxt)
{
return (@"{\f0\fs" + this.Font.SizeInPoints * 2 + @" " + symtxt + @"}");
return (@"{\f0\fs" + this.Font.SizeInPoints * 2 + @" " + symtxt + @"}");
}
public void AddRtfLink(string linkUrl, string linkValue)
{
@@ -1804,13 +1807,21 @@ namespace Volian.Controls.Library
// handle the clipboard copy and cut when a Transition or RO is selected
// For now, we are coping/cutting just the displayed text to the clipboard (like 16-bit VE-PROMS)
string ts = GetSelectedDisplayableText();
if (ts!=null&&ts!="") Clipboard.SetText(GetSelectedDisplayableText());
if (ts != null && ts != "") Clipboard.SetText(GetSelectedDisplayableText());
e.Handled = true;
e.SuppressKeyPress = true;
if (ts!=null&&ts!=""&&e.KeyCode == Keys.X) // cut to clipboard - delete the selected text
if (ts != null && ts != "" && e.KeyCode == Keys.X) // cut to clipboard - delete the selected text
HandleDeleteKeyWithSelectedText(e, null);
break;
case Keys.V:
// NOTE that if in a Properties Dialog StepRTB (for numbers and titles) or in a Procedure Specific
// Information (PSI) Dialog, i.e. any non-EditItem/Step editor field, the following code is run
// for the ctrl-V. For EditItems & Grid cells, the code in StepTabRibbon's btnPaste_Click is
// run. The way this occurs is that in the designer for StepTabRibbon (StepTabRibbon.designer.cs),
// the line of code:
// this.btnPaste.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlV);
// maps the Ctrl-V to btnPaste for those StepRTB's that are associated with the StepTabRibbon, i.e.
// EditItems & Grid cells.
IDataObject iData = Clipboard.GetDataObject();
if (!iData.GetDataPresent(DataFormats.Text) && !iData.GetDataPresent(DataFormats.Rtf))
{
@@ -1818,7 +1829,8 @@ namespace Volian.Controls.Library
}
else
{
Paste();
// if contains bad rtf (from Word), paste as text, otherwise, do the paste here.
if (!PasteRtfAsText(true)) Paste();
if (SelectionLength == 0) SelectionFont = MyStyleFont.WindowsFont;
}
e.Handled = true;
@@ -2141,7 +2153,34 @@ namespace Volian.Controls.Library
SendKeys.Send(keys); // With .Net Framework 3.0 this can be replaced with EditingCommands
// http://msdn.microsoft.com/en-us/library/ms771634.aspx
}
public bool PasteRtfAsText(bool PasteNoReturnsSetting)
{
// check if rtf is coming from Word, i.e. if it has 'SCHEMAS.MICROSOFT.COM/OFFICE/WORD'.
// If it is coming from Word, it will be pasted as text so as not to get any rtf commands
// that PROMS does not support such as odd Fonts, other symbols, etc. This isn't a complete
// solution, clipboard data may come from other 3rd-party tools and unsupported Rtf may get
// pasted in. But the hope is that this will happen less often than getting it from MS Word.
IDataObject myDO = Clipboard.GetDataObject();
string tmpForLink = myDO.GetData(DataFormats.Rtf).ToString();
if (tmpForLink.ToUpper().Contains(@"SCHEMAS.MICROSOFT.COM/OFFICE/WORD"))
{
SelectedText = GetPasteText(PasteNoReturnsSetting, myDO);
return true;
}
return false;
}
public string GetPasteText(bool PasteNoReturnsSetting, IDataObject myDO)
{
string ptext = myDO.GetData(DataFormats.Text).ToString();
ptext = ptext.TrimEnd("\r\n\t ".ToCharArray());
if (PasteNoReturnsSetting) ptext = ptext.Replace("\r\n", " ");
ptext = ptext.Replace("\u2013", "-"); // Replace EN Dash with hyphen
ptext = ptext.Replace("\u2014", "-"); // Replace EM Dash with hyphen
ptext = ptext.Replace("\u2011", "-"); // Replace non-breaking hyphen with hyphen
ptext = ptext.Replace((char)0xb7, '?'); // bullet comes in as a b7, which we don't support either
return ptext;
}
private void DoDeleteEndBetweenLinks()
{
DebugSelection("Beginning");