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,13 +1024,24 @@ 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.");
}
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); String data = (String)contents.getTransferData(DataFlavor.stringFlavor);
toTibetanMachineWeb(data, offset); toTibetanMachineWeb(data, offset);
@ -1040,7 +1051,8 @@ public void paste(int offset) {
for (int i=0; i<sd.getLength()-1; i++) { //getLength()-1 so that final newline is not included in paste for (int i=0; i<sd.getLength()-1; i++) { //getLength()-1 so that final newline is not included in paste
try { try {
String s = sd.getText(i,1); String s = sd.getText(i,1);
AttributeSet as = sd.getCharacterElement(i).getAttributes(); AttributeSet as
= sd.getCharacterElement(i).getAttributes();
getTibDoc().insertString(p1+i, s, as); getTibDoc().insertString(p1+i, s, as);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
ble.printStackTrace(); ble.printStackTrace();
@ -1048,6 +1060,7 @@ public void paste(int offset) {
} }
} }
} }
}
} 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();
} }
} }