This commit is contained in:
2013-06-07 11:11:54 +00:00
parent 92588ad059
commit 05f3fcf8a4
7 changed files with 182 additions and 85 deletions

View File

@@ -2172,13 +2172,31 @@ namespace Volian.Controls.Library
public string GetPasteText(bool PasteNoReturnsSetting, IDataObject myDO)
{
// allowable symbols are those symbols between 127-256 that the proms editor supports that
// can be pasted from word as is. These symbols are (in the order they are in the following
// string): degree, plus/minus, exponent 2, exponent 3, micro, quarter, half, divide:
char[] allowableSymbols = { '\xb0', '\xb1', '\xb2', '\xb3', '\xb5', '\xbc', '\xbd', '\xf7' };
string ptext = myDO.GetData(DataFormats.Text).ToString();
ptext = ptext.TrimEnd("\r\n\t ".ToCharArray());
if (PasteNoReturnsSetting) ptext = ptext.Replace("\r\n", " ");
StringBuilder sb = new StringBuilder(ptext);
bool didCharReplace = false;
for (int i = 0; i < ptext.Length; i++)
{
// if allowable, allow for it to pasted. Otherwise, replace that character with a '?'.
if ((sb[i] > 0x7e))
if ((ptext.Substring(i, 1).IndexOfAny(allowableSymbols) < 0))
{
sb[i] = '?';
didCharReplace = true;
}
}
ptext = sb.ToString();
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
if (didCharReplace)
MessageBox.Show("Replacing pasted characters that are not supported by Proms with a '?'.");
return ptext;
}
private void DoDeleteEndBetweenLinks()