To comment on the following update, log in, then open the issue: http://www.openoffice.org/issues/show_bug.cgi?id=83004 Issue #|83004 Summary|cannot paste HTML data from any java application via c |lipboard Component|Word processor Version|OOo 2.3 Platform|PC URL| OS/Version|Windows, all Status|UNCONFIRMED Status whiteboard| Keywords| Resolution| Issue type|DEFECT Priority|P2 Subcomponent|editing Assigned to|mru Reported by|dmpl
------- Additional comments from [EMAIL PROTECTED] Fri Oct 26 13:18:41 +0000 2007 ------- STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Execute the code below to fill the clipboard. Try to paste in OpenOffice 2.3 Writer (or older version). Notice the error message "Requested clipboard format is not available". EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - The formatted text should be inserted. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.*; import java.io.IOException; public class HtmlStreamCopy { public static void main(String[] args) throws ClassNotFoundException { String htmlText = "The quick <font color='#78650d'>brown</font> <b>mouse</b> jumped over the lazy <b>cat</b>."; Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable htmlTransferable = new HtmlStreamCopy.HtmlInputStreamTransferable(htmlText); clipboard.setContents(htmlTransferable, null); } private static class HtmlInputStreamTransferable implements Transferable { private final DataFlavor _htmlDataFlavor; private final String _htmlText; public HtmlInputStreamTransferable(String htmlText) throws ClassNotFoundException { _htmlText = htmlText; _htmlDataFlavor = new DataFlavor("text/html; class=java.lang.String"); } public DataFlavor[] getTransferDataFlavors() { return new DataFlavor[]{_htmlDataFlavor}; } public boolean isDataFlavorSupported(DataFlavor flavor) { return "text/html".equals(flavor.getMimeType()); } public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { return _htmlText; } } } ---------- END SOURCE ---------- DISCUSSION: The reason copy & paste of text/html from Java to e.g. OpenOffice Writer doesn't work (tested with different JDK 1.4.2, 1.5 and 1.6 and Windows 2000, similar problem was reported also for Windows XP as issue 51267) seems to be that Java sets the StartHTML and EndHTML properties of the Windows HTML clipboard format to -1. See http://www.peterbuettner.de/develop/javasnippets/clipHtml/index.html If I use the Clipview app on that page and manually modify the StartHTML and EndHTML properties of the text/html copied from Java, I am able to paste it into OpenOffice Writer. --------------------------------------------------------------------- Please do not reply to this automatically generated notification from Issue Tracker. Please log onto the website and enter your comments. http://qa.openoffice.org/issue_handling/project_issues.html#notification --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]