fixing the copy-paste issue for the translation tool.

This commit is contained in:
amontano 2002-10-26 18:15:34 +00:00
parent b6b8cd73ff
commit 7336d27a33

View file

@ -953,16 +953,28 @@ public void paste(int offset) {
ThdlDebug.verify(null != in); ThdlDebug.verify(null != in);
rtfEd.read(in, sd, 0); rtfEd.read(in, sd, 0);
for (int i=0; i<sd.getLength()-1; i++) { //getLength()-1 so that final newline is not included in paste /** Added by AM, to fix copy-paste issues for Translation Tool.
try { Assumes that if roman is disabled and you are pasting something
String s = sd.getText(i,1); in RTF but is not TibetanMachineWeb it most be wylie.
AttributeSet as = sd.getCharacterElement(i).getAttributes(); */
doc.insertString(p1+i, s, as); if (!sd.getFont((sd.getCharacterElement(0).getAttributes())).getFamily().equals("TibetanMachineWeb") && !isRomanEnabled && 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();
doc.insertString(p1+i, s, as);
} catch (BadLocationException ble) {
ble.printStackTrace();
ThdlDebug.noteIffyCode();
}
}
} }
} else if (contents.isDataFlavorSupported(DataFlavor.stringFlavor)) } else if (contents.isDataFlavorSupported(DataFlavor.stringFlavor))
{ {