Replace a space with underline turned off after to a hard space with underline turned off after

Fixed B2014-086: Keystroke combinations in RTB should be not processed such as right align or center text.
This commit is contained in:
Kathy Ruffing 2014-12-16 15:26:39 +00:00
parent ce33728734
commit 882c4eb7b9
2 changed files with 85 additions and 51 deletions

View File

@ -1816,57 +1816,84 @@ namespace Volian.Controls.Library
if (e.Control) if (e.Control)
{ {
IsControlChar = true; IsControlChar = true;
switch (e.KeyCode) if (e.Shift)
{ {
case Keys.X: //ctrl-X switch (e.KeyCode)
case Keys.C: //ctrl-C {
// handle the clipboard copy and cut when a Transition or RO is selected // The following keys are supported in underlying RTB (with ctrl+shift key),
// For now, we are coping/cutting just the displayed text to the clipboard (like 16-bit VE-PROMS) // but PROMS should not do anything for that functionality:
string ts = GetSelectedDisplayableText(); case Keys.Add:
if (ts != null && ts != "") Clipboard.SetText(GetSelectedDisplayableText()); case Keys.Subtract:
e.Handled = true; case Keys.L:
e.SuppressKeyPress = true; e.Handled = true;
if (ts != null && ts != "" && e.KeyCode == Keys.X) // cut to clipboard - delete the selected text break;
HandleDeleteKeyWithSelectedText(e, null); }
break; }
case Keys.V: else
// 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 switch (e.KeyCode)
// 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), case Keys.X: //ctrl-X
// the line of code: case Keys.C: //ctrl-C
// this.btnPaste.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlV); // handle the clipboard copy and cut when a Transition or RO is selected
// maps the Ctrl-V to btnPaste for those StepRTB's that are associated with the StepTabRibbon, i.e. // For now, we are coping/cutting just the displayed text to the clipboard (like 16-bit VE-PROMS)
// EditItems & Grid cells. string ts = GetSelectedDisplayableText();
IDataObject iData = Clipboard.GetDataObject(); if (ts != null && ts != "") Clipboard.SetText(GetSelectedDisplayableText());
if (!iData.GetDataPresent(DataFormats.Text) && !iData.GetDataPresent(DataFormats.Rtf)) e.Handled = true;
{ e.SuppressKeyPress = true;
MessageBox.Show("Cannot paste, text has special characters or symbols that will not paste correctly."); if (ts != null && ts != "" && e.KeyCode == Keys.X) // cut to clipboard - delete the selected text
} HandleDeleteKeyWithSelectedText(e, null);
else break;
{ case Keys.V:
// if contains bad rtf (from Word), paste as text, otherwise, do the paste here. // NOTE that if in a Properties Dialog StepRTB (for numbers and titles) or in a Procedure Specific
if (!PasteRtfAsText(true)) Paste(); // Information (PSI) Dialog, i.e. any non-EditItem/Step editor field, the following code is run
if (SelectionLength == 0) SelectionFont = MyStyleFont.WindowsFont; // 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),
e.Handled = true; // the line of code:
return; // this.btnPaste.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlV);
case Keys.Home: // maps the Ctrl-V to btnPaste for those StepRTB's that are associated with the StepTabRibbon, i.e.
StepRTB_HomeEndPressed(e); // EditItems & Grid cells.
e.Handled = true; IDataObject iData = Clipboard.GetDataObject();
break; if (!iData.GetDataPresent(DataFormats.Text) && !iData.GetDataPresent(DataFormats.Rtf))
case Keys.End: {
StepRTB_HomeEndPressed(e); MessageBox.Show("Cannot paste, text has special characters or symbols that will not paste correctly.");
e.Handled = true; }
break; else
// 16bit Proms used 'ctrl-enter' for Hard returns. 32bit Proms uses 'shift-enter' {
// because the richtextbox does this by default. Also Word uses 'shift-enter' // if contains bad rtf (from Word), paste as text, otherwise, do the paste here.
// for Hard return. And Word uses 'ctrl-enter' for inserting of page break. So if (!PasteRtfAsText(true)) Paste();
// 'ctrl-enter' for 32bit will insert page break if (SelectionLength == 0) SelectionFont = MyStyleFont.WindowsFont;
case Keys.Enter: }
OnInsertPgBrk(this, new EventArgs()); e.Handled = true;
e.Handled = true; return;
break; case Keys.Home:
StepRTB_HomeEndPressed(e);
e.Handled = true;
break;
case Keys.End:
StepRTB_HomeEndPressed(e);
e.Handled = true;
break;
// 16bit Proms used 'ctrl-enter' for Hard returns. 32bit Proms uses 'shift-enter'
// because the richtextbox does this by default. Also Word uses 'shift-enter'
// for Hard return. And Word uses 'ctrl-enter' for inserting of page break. So
// 'ctrl-enter' for 32bit will insert page break
case Keys.Enter:
OnInsertPgBrk(this, new EventArgs());
e.Handled = true;
break;
// The following keys are supported in underlying RTB (with ctrl key), but PROMS should not
// do anything for that functionality:
case Keys.R: // Right Align text
case Keys.L: // Left Align text
case Keys.E: // Center Align text
case Keys.D1: // Single space text (D1 is the '1' key)
case Keys.D2: // Double space text
case Keys.D5: // 1.5 space text
case Keys.H: // Find (proms uses Ctrl+F for find)
e.Handled = true;
break;
}
} }
} }
if (((int)e.KeyCode) == 220) e.Handled = true; if (((int)e.KeyCode) == 220) e.Handled = true;

View File

@ -292,7 +292,14 @@ namespace Volian.Print.Library
_StatRTB.Width = (int)w; _StatRTB.Width = (int)w;
_StatRTB.Font = MyFlexGrid.Font; _StatRTB.Font = MyFlexGrid.Font;
if (str.StartsWith(@"{\rtf")) if (str.StartsWith(@"{\rtf"))
_StatRTB.Rtf = str.Replace(@"\~", @"\u160?"); // The 'Replace(@" \ulnone", @"\u160?\ulnone")' was added so that data in VEWCN SUR_WTC
// tables would print. There were a number of tables, for example in STN NB-106/8.1.6,
// that had a series of spaces underlined and these spaces were not underlined in the
// generated pdf. It seems that there is a problem somewhere in the rtb -> itextsharp
// level. This fixed the immediate problem. If there is 'b0' (bold off) after the
// space before the 'ulnone' the following won't work. Also, this change was not
// made in the non-table code. If the problem occurs there, it should be added.
_StatRTB.Rtf = str.Replace(@"\~", @"\u160?").Replace(@" \ulnone", @"\u160?\ulnone");
else else
_StatRTB.Text = str; _StatRTB.Text = str;
_StatRTB.SelectAll(); _StatRTB.SelectAll();