Copying from Word XP used to crash Jskad sometimes. Now you get a

dialog box telling you something about RTF support in Java.
This commit is contained in:
dchandler 2003-05-15 01:41:56 +00:00
parent 5e55d05cfe
commit 17ea8fdf2a

View file

@ -1024,30 +1024,43 @@ public void paste(int offset) {
// random junk just after Jskad started up.
ThdlDebug.verify(null != in);
rtfEd.read(in, sd, 0);
boolean errorReading = false;
/** Added by AM, to fix copy-paste issues for Translation Tool.
Assumes that if roman is disabled and you are pasting something
in RTF but is not TibetanMachineWeb it most be wylie.
*/
if (!sd.getFont((sd.getCharacterElement(0).getAttributes())).getFamily().startsWith("TibetanMachineWeb") && !isRomanEnabled && contents.isDataFlavorSupported(DataFlavor.stringFlavor))
{
String data = (String)contents.getTransferData(DataFlavor.stringFlavor);
toTibetanMachineWeb(data, offset);
}
else
{
for (int i=0; i<sd.getLength()-1; i++) { //getLength()-1 so that final newline is not included in paste
try {
String s = sd.getText(i,1);
AttributeSet as = sd.getCharacterElement(i).getAttributes();
getTibDoc().insertString(p1+i, s, as);
} catch (BadLocationException ble) {
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
}
try {
rtfEd.read(in, sd, 0);
} catch (Exception e) {
errorReading = true;
JOptionPane.showMessageDialog(this,
"You cannot paste from the application from which you copied.\nIt uses an RTF format that is too advanced for the version\nof Java Jskad is running atop.");
}
if (!errorReading) {
/** Added by AM, to fix copy-paste issues for
Translation Tool. Assumes that if roman is
disabled and you are pasting something in RTF but
is not TibetanMachineWeb it most be wylie. */
if (!sd.getFont((sd.getCharacterElement(0).getAttributes())).getFamily().startsWith("TibetanMachineWeb")
&& !isRomanEnabled
&& contents.isDataFlavorSupported(DataFlavor.stringFlavor))
{
String data = (String)contents.getTransferData(DataFlavor.stringFlavor);
toTibetanMachineWeb(data, offset);
}
else
{
for (int i=0; i<sd.getLength()-1; i++) { //getLength()-1 so that final newline is not included in paste
try {
String s = sd.getText(i,1);
AttributeSet as
= sd.getCharacterElement(i).getAttributes();
getTibDoc().insertString(p1+i, s, as);
} catch (BadLocationException ble) {
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
}
}
} else if (contents.isDataFlavorSupported(DataFlavor.stringFlavor))
{
if (!isRomanEnabled) {
@ -1069,9 +1082,6 @@ public void paste(int offset) {
} catch (IllegalStateException ise) {
ise.printStackTrace();
ThdlDebug.noteIffyCode();
} catch (BadLocationException ble) {
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
}