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. // random junk just after Jskad started up.
ThdlDebug.verify(null != in); ThdlDebug.verify(null != in);
rtfEd.read(in, sd, 0); boolean errorReading = false;
/** Added by AM, to fix copy-paste issues for Translation Tool. try {
Assumes that if roman is disabled and you are pasting something rtfEd.read(in, sd, 0);
in RTF but is not TibetanMachineWeb it most be wylie. } catch (Exception e) {
*/ errorReading = true;
if (!sd.getFont((sd.getCharacterElement(0).getAttributes())).getFamily().startsWith("TibetanMachineWeb") && !isRomanEnabled && contents.isDataFlavorSupported(DataFlavor.stringFlavor)) 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.");
String data = (String)contents.getTransferData(DataFlavor.stringFlavor); }
toTibetanMachineWeb(data, offset);
} if (!errorReading) {
else /** Added by AM, to fix copy-paste issues for
{ Translation Tool. Assumes that if roman is
for (int i=0; i<sd.getLength()-1; i++) { //getLength()-1 so that final newline is not included in paste disabled and you are pasting something in RTF but
try { is not TibetanMachineWeb it most be wylie. */
String s = sd.getText(i,1); if (!sd.getFont((sd.getCharacterElement(0).getAttributes())).getFamily().startsWith("TibetanMachineWeb")
AttributeSet as = sd.getCharacterElement(i).getAttributes(); && !isRomanEnabled
getTibDoc().insertString(p1+i, s, as); && contents.isDataFlavorSupported(DataFlavor.stringFlavor))
} catch (BadLocationException ble) { {
ble.printStackTrace(); String data = (String)contents.getTransferData(DataFlavor.stringFlavor);
ThdlDebug.noteIffyCode(); 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)) } else if (contents.isDataFlavorSupported(DataFlavor.stringFlavor))
{ {
if (!isRomanEnabled) { if (!isRomanEnabled) {
@ -1069,9 +1082,6 @@ public void paste(int offset) {
} catch (IllegalStateException ise) { } catch (IllegalStateException ise) {
ise.printStackTrace(); ise.printStackTrace();
ThdlDebug.noteIffyCode(); ThdlDebug.noteIffyCode();
} catch (BadLocationException ble) {
ble.printStackTrace();
ThdlDebug.noteIffyCode();
} }
} }