Apache OpenOffice (AOO) Bugzilla – Full Text Issue Listing |
Summary: | Cannot paste (image) from clipboard copyed from .net | ||||||
---|---|---|---|---|---|---|---|
Product: | General | Reporter: | Unknown <non-migrated> | ||||
Component: | code | Assignee: | hdu <hdu> | ||||
Status: | RESOLVED FIXED | QA Contact: | |||||
Severity: | Trivial | ||||||
Priority: | P3 | CC: | damjan, issues, kamataki, kpalagin, robbin.knapp | ||||
Version: | OOo 2.3.1 | ||||||
Target Milestone: | --- | ||||||
Hardware: | All | ||||||
OS: | Windows XP | ||||||
Issue Type: | ENHANCEMENT | Latest Confirmation in: | --- | ||||
Developer Difficulty: | --- | ||||||
Attachments: |
|
Description
Unknown
2008-01-29 05:12:47 UTC
TM->JSK: Basic-Problem ? No problem reproducible when using UI. Please have a look, thanks ! Confirming with 2.3 - as described. Also can be easily reproduced with Paint .Net - http://www.getpaint.net/download.html. *** Issue 60445 has been marked as a duplicate of this issue. *** This should be a duplicate of the earlier one, and that one has more information. We also have this problem. When copying from Paint.NET the "Paste" menu item is greyed out in OOo, but not in other applications. Created attachment 51940 [details]
Tiny Test App to demonstrate clipboard issue
Shame people don't check the creation time of issues, but as the issue is still unresolved and it appears people are having trouble recreating it (not having .net), here is a simple test app to demonstrate it. The code for it is as below: Imports System.Drawing Public Class Form1 Dim clipBMP As Bitmap Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub createBMP(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles createBMPB.Click Try 'a very simple test routine to illustrate issue 'note you may need to import system.drawing 'the below makes use of GDI+ calls wrapped up in .net objects If Not (clipBMP Is Nothing) Then clipBMP.Dispose() 'otherwise you'll get a memory leak clipBMP = Nothing 'create a bitmap and get a handle on the graphics clipBMP = New Bitmap(250, 250) 'instantiate object and specifiy size Dim gr As Graphics = Graphics.FromImage(clipBMP) 'create a graphics object from the bitmap 'draw stuff on the bitmap Dim r As New Rectangle(10, 100, 230, 50) gr.Clear(Color.WhiteSmoke) Dim p As New Pen(Color.Black, 2) gr.DrawRectangle(p, r) gr.FillRectangle(Brushes.LightSteelBlue, r) Dim strFormat As New StringFormat strFormat.Alignment = StringAlignment.Center strFormat.LineAlignment = StringAlignment.Center gr.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias gr.DrawString("Hello Open Office", New Font("Arial Black", 14), Brushes.Black, r, strFormat) 'lets clear all the object as not all of them are managed and handled by GC p.Dispose() strFormat.Dispose() gr.Dispose() 'now we cause the picture box to be redrawn and as we handle 'the paint event we'll use the above bmp ;) bmpP.Invalidate() Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub copyBMPB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles copyBMPB.Click Try If (clipBMP Is Nothing) Then MsgBox("Please create a bitmpa first using the create button") Else 'create a dataobject Dim dataObj As DataObject = New DataObject 'add the bitmap dataObj.SetData(DataFormats.Bitmap, True, clipBMP) 'copy it to the clipboard Clipboard.SetDataObject(dataObj, True) 'now try and paste it into a document. you can under wordpad, microsoft office etc. 'but the paste icon does not appear in openoffice End If Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub bmpP_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles bmpP.Paint Try 'if we have a bmp we'll use it to draw the panel If Not (clipBMP Is Nothing) Then e.Graphics.DrawImageUnscaled (clipBMP, 0, 0) Catch ex As Exception MsgBox(ex.Message) End Try End Sub End Class It's all simple stuff really, and the library calls are used by all .net languages so it isn't a vb issue. My guess would be that open office doesn't like something in the header information of the clipboard bitmap, perhaps someone could test that? I'd point out that as Linux does'nt use GDI+ it uses it's own 2D system that running this under Linux would not be a proper test, ohh and it stands to reason that you'll nedd .net installed P.S. Win Vista used WPF for display and uses GDI+ under emulation so it may behave differently under win Vista Joerg, please consider this issue for 3.0, if possible. Thanks a lot. WBR, KP. Additional comments. Copying to wordpad first and then copying that to open office works. Microsoft seems to be aware of the problem, and it appears to be a problem in the .Net clipboard implementation: http://support.microsoft.com/?id=323530 Still it would be very nice if this could be supported. Im not so sure that microsoft issue is relevant. That issue is to do with putting information onto the clipboard in metafile format, which you specify in the dataFormat parameter in the setDataObject command. As we are specifying an image format (dataFormats.Bitmap) and not the metafile format i fail to see how that would be applicable. @Philipp: Is this something for you? I believe it could make a nice enhancement. @hro: windows clipboard is yours nowadays I think ? The .NET Clipboard implementation just puts two formats into the OLE clipboard which are visible for the OLE clipboard: "System.Drawing.Bitmap" which is not very usefull for non .NET applications and CF_BITMAP which contains a native GDI handle but not any flat storage with the image data. Windows internal clipboard implementation only does a conversion to CF_DIB for the old Win 3.x based clipboard API. OOo uses the OLE clipboard implementation (as .NET does) but only accepts formats where data is in a flat storage or in a metafile handle. Native device dependent bitmap handles are currently not supported as all know applications provide a CF_DIB (device independent bitmap) in a memory stream to the OLE clipboard but no application provided a CF_BITMAP format. Naturally OOo platform independent application code isn't able to deal with native GDI object handles, so we need an implementation in the system clipboard layer that does a conversion from a bitmap handle to the bitmap data. *** Issue 95178 has been marked as a duplicate of this issue. *** Tested in OOo 3.1. Problem still occurs. hdu: Please take over. Please consider existing files as well: in some ms documents paint.net images were pasted, and when we try to open the files in OOo, the images disappear. Tested in OOo 3.2. Problem still occurs. As a work-around for those developing .NET applications who want to be able copy images to the clipboard and have OOo cope with this, try deliberately sticking a DIB on the clipboard instead (or as well as) the System.Drawing.Bitmap. e.g. the following code will allow you to place a system.drawing.bitmap "bmp" on the clipboard in an OOo-compliant fashion. Dim ms As New IO.MemoryStream() Dim ms2 As New IO.MemoryStream() bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp) Dim b() As Byte = ms.GetBuffer() ms2.Write(b, 14, CInt(ms.Length - 14)) ms.Position = 0 Dim dataObject As New DataObject() dataObject.SetData(DataFormats.Bitmap, bmp) dataObject.SetData(DataFormats.Dib, ms2) Clipboard.SetDataObject(dataObject, False) (Adapted from http://www.ureader.com/msg/14721255.aspx) The bug can be reproduced with the test app attached on OOo 3.2.0, but cannot be reproduced on AOO 4.1.2 or SVN trunk. It must have been fixed some time ago. Resolving fixed. |