This commit is contained in:
parent
462a93f53d
commit
f9d3af6941
@ -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");
|
||||
|
@ -1271,9 +1271,8 @@ namespace Volian.Controls.Library
|
||||
IDataObject myDO = Clipboard.GetDataObject();
|
||||
RichTextBox myRtb = _MyStepRTB;
|
||||
Control ctrl = FindActiveControl(); // null if on property page for procedure & section number/title
|
||||
if (ctrl == null) return;
|
||||
//Console.WriteLine("Paste myRTB == ctrl {0}", myRtb.Equals(ctrl));
|
||||
if (!_MyStepRTB.Focused)
|
||||
|
||||
if (ctrl != null && !_MyStepRTB.Focused)
|
||||
{
|
||||
if (ctrl is RichTextBox)
|
||||
{
|
||||
@ -1298,35 +1297,35 @@ namespace Volian.Controls.Library
|
||||
return;
|
||||
}
|
||||
}
|
||||
//if (myDO.GetDataPresent(DataFormats.Rtf) && !_PastePlainTextOvrRide && !PastePlainTextSetting)
|
||||
// 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.
|
||||
if (myDO.GetDataPresent(DataFormats.Rtf) && (_PasteStepTextOvrRide || (!_PastePlainTextOvrRide && !PastePlainTextSetting)))
|
||||
{
|
||||
string tmpForLink = myDO.GetData(DataFormats.Rtf).ToString();
|
||||
tmpForLink = Regex.Replace(tmpForLink, @"#Link:ReferencedObject:[0-9]+ ", @"#Link:ReferencedObject:<NewID> ");
|
||||
tmpForLink = Regex.Replace(tmpForLink, @"#Link:Transition:([0-9]+) [0-9]+ ", @"#Link:Transition:$1 <NewID> ");
|
||||
tmpForLink = Regex.Replace(tmpForLink, @"#Link:TransitionRange:([0-9]+) [0-9]+ ", @"#Link:TransitionRange:$1 <NewID> ");
|
||||
tmpForLink = tmpForLink.Replace(@"\u8212 \'96", @"-"); // Replace EM Dash with hyphen
|
||||
tmpForLink = tmpForLink.Replace(@"\u8211 \'96", @"-"); // Replace EN Dash with hyphen
|
||||
tmpForLink = tmpForLink.Replace(@"\u8212 ", @"-"); // Replace EM Dash with hyphen
|
||||
tmpForLink = tmpForLink.Replace(@"\u8211 ", @"-"); // Replace EN Dash with hyphen
|
||||
myRtb.SelectedRtf = tmpForLink;
|
||||
if (tmpForLink.ToUpper().Contains(@"SCHEMAS.MICROSOFT.COM/OFFICE/WORD"))
|
||||
myRtb.SelectedText = _MyStepRTB.GetPasteText(PasteNoReturnsSetting, myDO);
|
||||
else
|
||||
{
|
||||
tmpForLink = Regex.Replace(tmpForLink, @"#Link:ReferencedObject:[0-9]+ ", @"#Link:ReferencedObject:<NewID> ");
|
||||
tmpForLink = Regex.Replace(tmpForLink, @"#Link:Transition:([0-9]+) [0-9]+ ", @"#Link:Transition:$1 <NewID> ");
|
||||
tmpForLink = Regex.Replace(tmpForLink, @"#Link:TransitionRange:([0-9]+) [0-9]+ ", @"#Link:TransitionRange:$1 <NewID> ");
|
||||
tmpForLink = tmpForLink.Replace(@"\u8212 \'96", @"-"); // Replace EM Dash with hyphen
|
||||
tmpForLink = tmpForLink.Replace(@"\u8211 \'96", @"-"); // Replace EN Dash with hyphen
|
||||
tmpForLink = tmpForLink.Replace(@"\u8212 ", @"-"); // Replace EM Dash with hyphen
|
||||
tmpForLink = tmpForLink.Replace(@"\u8211 ", @"-"); // Replace EN Dash with hyphen
|
||||
myRtb.SelectedRtf = tmpForLink;
|
||||
}
|
||||
|
||||
}
|
||||
else if (myDO.GetDataPresent(DataFormats.Text))
|
||||
{
|
||||
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
|
||||
myRtb.SelectedText = ptext;
|
||||
//myRtb.SelectedText = myDO.GetData(DataFormats.Text).ToString();
|
||||
}
|
||||
myRtb.SelectedText = _MyStepRTB.GetPasteText(PasteNoReturnsSetting, myDO);
|
||||
if (myRtb.SelectionLength == 0 && myRtb is StepRTB) myRtb.SelectionFont = (myRtb as StepRTB).MyStyleFont.WindowsFont;
|
||||
_PastePlainTextOvrRide = false;
|
||||
_PasteStepTextOvrRide = false;
|
||||
}
|
||||
|
||||
private void SaveErrorInLogProblemWithType(Control ctrl)
|
||||
{
|
||||
StringBuilder errormsg = new StringBuilder(string.Format("Failed clipboard action with control {0} a {1} ", ctrl.Name, ctrl.GetType().Name));
|
||||
|
Loading…
x
Reference in New Issue
Block a user