Issue 112829

Summary: Copy & paste of OLE object to Gimp fails with error message
Product: General Reporter: plexi <microdmitry>
Component: codeAssignee: AOO issues mailing list <issues>
Status: RESOLVED FIXED QA Contact:
Severity: Trivial    
Priority: P5 (lowest) CC: Armin.Le.Grand, damjan, elish, issues, mseidel, rainerbielefeld_ooo_qa
Version: 3.4.0Keywords: usability
Target Milestone: 4.2.0   
Hardware: All   
OS: All   
See Also: https://issues.apache.org/ooo/show_bug.cgi?id=123063
Issue Type: DEFECT Latest Confirmation in: 4.2.0-dev
Developer Difficulty: ---
Attachments:
Description Flags
pasted graph
none
original data
none
auxilliary file
none
File 1 no password
none
Sample Document none

Description plexi 2010-07-01 00:35:07 UTC
This bug happens in Ubuntu Lucid, with OOo 3.2

Repro:
1. Fire up OOo Calc
2. Type in a few numbers
3. Insert a bar chart showing those numbers
4. Select the bar chart
5. Copy it to the clipboard
6. Try to paste it into e.g. GIMP

Result:
GIMP says there's nothing on the clipboard and refuses to paste.

Expected result:
I should be able to paste a bitmap of my chart into GIMP and save it from there. 
GNumeric can do this even, I expect this to "just work".
Comment 1 Edwin Sharp 2013-07-06 18:56:48 UTC
Can paste graph in Paint using Rev. 1499775 Win 7.

If GIMP refuses to paste it has a problem.

Closed this bug as FIXED and not as NOTABUG because till recently graph pasted incorrectly even within suite showing only area without data.
Comment 2 Edwin Sharp 2013-07-06 19:04:04 UTC
My conclusion was premature.
Values are incorrect.
Comment 3 Edwin Sharp 2013-07-06 19:11:53 UTC
Created attachment 81016 [details]
pasted graph

pasted graph with wrong numerical values
Comment 4 Edwin Sharp 2013-07-06 19:12:20 UTC
Created attachment 81017 [details]
original data
Comment 5 Edwin Sharp 2013-07-06 19:14:18 UTC
Created attachment 81018 [details]
auxilliary file

auxiliary file needed due to vlookup function in original data
Comment 6 Armin Le Grand 2013-07-09 13:49:48 UTC
ALG: Opening file from comment 4 asks for updating links to another file (probably file from comment 5), requires password for file 'File2.ods', please add password.
The original task is about getting a *bitmap* image in an external paint program when copy/pasting a chart, not about copying the chart between apps of AOO4.0.
Copy/Pasting between apps in AOO4.0 is #120559#.

To check for copy/paste between AOO4.0 apps I will need the password for file 'File2.ods'.

Copy/pasting with gimp is not reliable; I found myself some time ago that the clipboard support of gimp is varying from version to version, thus it is better to check with various graphic apps.

On win I checked:
- copy/pasting from Writer /test file from comment 3) to paint.net -> works well
- to gimp2.8 -> not directly from Writer, but as workaround it's possible to copy/paste to Draw/Impress, convert to bitmap there and copy/paste to Gimp.
- to MyPaint: Same as for Gimp.

Original bug is questionable: Is it intended to copy a chart from Writer to an external pixel program directly? It is possible from Draw/Impress directly, all others should get the chart first copied to Draw/Impress as workaround.
Comment 7 Armin Le Grand 2013-07-09 14:58:10 UTC
ALG: Using Paint from win7 directly (as reference for clipboard functionality): The chart can be directly copied from all apps (also checked that copying the chart from test doc from comment 3 to all other apps, works well without data loss). The question for other external paint programs is more what clipboard formats these support, AOO offers something useful in all cases.
Comment 8 Edwin Sharp 2013-07-09 15:34:38 UTC
password is scooter.
File is related to some other bug I reviewed, sorry.
Comment 9 Armin Le Grand 2013-07-09 16:11:47 UTC
ALG: Hi Edwin, thanks for the password, but - it does not work. It says 'the password is incorrect'. Please check with 'File1.ods'.
Comment 10 Edwin Sharp 2013-07-09 16:37:13 UTC
I check and recheck - scooter, like the famous German band :)
Comment 11 Armin Le Grand 2013-07-09 16:41:48 UTC
ALG: Edwin, I may be too lame to type that, but I cannot open 'File1.ods' from comment 4 using 'scooter' as password. What's going on ;-)
Comment 12 Edwin Sharp 2013-07-09 19:17:47 UTC
Created attachment 81046 [details]
File 1 no password

This is strange...
Only scooter opens the file.
This attachment is just save as without password.
Comment 13 Armin Le Grand 2013-07-10 09:14:18 UTC
ALG: Thanks Edwin, can open now. Still strange, and after load and update, the value '13' is not shown in the chart. After activating and toggling dataRanges/DataSeriesInRows and back to Columns it gets visible, a refresh problem...?

copy/pasting in calc or to new app does not lose any data (thus #120559# was successful), but changes the data labels on the Y-Axis from simple values to date format. Is that what you mean with 'wrong numerical values'? If yes, please check if we have a task for this or create a new one. This can also be reproduced by creating a chart as this newly just with fixed values and copy/pasting it.
- Does not happen in OOo3.3
- Does not happen in OOo3.2

Back to this task: I checked on mac; I do not know what app to use as standard regarding clipboard implementation, but it can be copied to some apps. The workaround converting to graphic is always possible.
Comment 14 Edwin Sharp 2013-07-10 09:35:57 UTC
(In reply to Armin Le Grand from comment #13)
> Is that what you mean with 'wrong numerical values'? If yes,
> please check if we have a task for this or create a new one. 

Yes - opened bug 122714
Comment 15 Rainer Bielefeld 2014-01-02 06:07:08 UTC
Additional Info:
---------------
(a) The original report was concerning a copy/paste problem of Charts to Gimp. 
    That never worked for me with OOo back to 1.1.5
(b) As Edwin stated, that might be a Gimp problem. 
(c) But from the same sample document opened with I can Copy / Paste the chart 
    object to Gimp
(c1) From Gnumeric
(c2) From SoftMaker FreeOffice (using an .xls)
(c3) Even from Lotus Symphony Release 3.0.1 Revision 20120110.2000
     Copy / Paste of Chart to Gimp works fine. 
     So this might be an OOo / AOO problem?
(d)  Already reproducible with  Pre-3.4.0 (OOo 1.1.5), but because of crippled  
     Version selector (Bug 123063) no useful info can be contributed
(d) all the same when I try to copy / paste a chart object from Writer to
    Gimp
(e) but the problem Copy/Paste to gimp is not limited to Chart objects. Fails 
    with same error message for copy / paste from AOO 4.0.1
(e1) Formula object from Writer, Calc, Draw
(e2) Spreadsheet object from writer (others not tested

I will obsolete all old Attachmets because they are only worrying hand do not have to do anything with the original report.
Comment 16 Rainer Bielefeld 2014-01-02 07:18:36 UTC
Created attachment 82198 [details]
Sample Document

Steps how to reproduce with "AOO 4.0.1   – German UI / German locale  [Rev. 1524958 2013-09-20 11:40:29]" on  German WIN7 Home Premium (64bit)", “historic”  4.0  User Profile used for all  predecessor versions

0. Launch Gimp
1. From AOO Start Center open attached sample document
2. Click Chart (or Formula)
3. <control+c> for Copy
4. Switch to Gimp
5. <Control+v> for paste
   (Alternatively: menu 'Edit -> Paste As -> New picture)
  Expected: new picture with chart image
  Actual: Error message: "Clipboard does not contain picture ..."            :-(
Comment 17 Armin Le Grand 2014-02-27 21:28:10 UTC
Works with 'Paint' and 'Paint.NET', but not with 'MyPaint' or 'Gimp2.8'. This shows that AOO offers (bitmap?) data that can be consumed. Need to check deeper...
Comment 18 damjan 2024-02-11 04:01:40 UTC
If your OS uses X11, the list of clipboard formats currently on the clipboard can be checked with this command:

$ xclip -selection clipboard -target TARGETS

When a chart is copied, the returned list of clipboard formats is:

---snip---
application/x-openoffice-embed-source-xml;windows_formatname="Star Embed Source (XML)"
application/x-openoffice-objectdescriptor-xml;windows_formatname="Star Object Descriptor (XML)";classname="12DCAE26-281F-416F-a234-c3086127382e";typename="Star Object Descriptor (XML)";viewaspect="1";width="16000";height="9000";posx="0";posy="0"
application/x-openoffice-gdimetafile;windows_formatname="GDIMetaFile"
application/x-openoffice-emf;windows_formatname="Image EMF"
application/x-openoffice-wmf;windows_formatname="Image WMF"
MULTIPLE
---snip---

which are all internal formats, completely useless to third-party apps like GIMP.

With LO I get a longer list:

---snip---
application/x-openoffice-embed-source-xml;windows_formatname="Star Embed Source (XML)"
application/x-openoffice-objectdescriptor-xml;windows_formatname="Star Object Descriptor (XML)";classname="12DCAE26-281F-416F-a234-c3086127382e";typename="Star Object Descriptor (XML)";viewaspect="1";width="16000";height="9000";posx="0";posy="0"
application/x-openoffice-gdimetafile;windows_formatname="GDIMetaFile"
application/x-openoffice-emf;windows_formatname="Image EMF"
application/x-openoffice-wmf;windows_formatname="Image WMF"
application/x-openoffice-bitmap;windows_formatname="Bitmap"
image/png
image/bmp
TARGETS
MULTIPLE
TIMESTAMP
SAVE_TARGETS
---snip---

where image/png or image/bmp are presumably what GIMP imports.

Gnumeric offers by far the longest list:

---snip---
TIMESTAMP
TARGETS
MULTIPLE
SAVE_TARGETS
application/x-gnumeric
application/x-goffice-graph
image/svg
image/svg+xml
image/png
image/avif
image/bmp
image/x-bmp
image/x-MS-bmp
image/x-icon
image/x-ico
image/x-win-bitmap
image/vnd.microsoft.icon
application/ico
image/ico
image/icon
text/ico
image/jpeg
image/jxl
image/tiff
---snip---

So what clipboard formats should we be exporting charts with?
1. Export as raster image formats like image/png and/or image/bmp. Possibly, but this requires rasterizing vector images before export to the clipboard, which is lossy.
2. Export as the official MIME types for WMF and EMF (image/wmf and image/emf) as per https://datatracker.ietf.org/doc/html/rfc7903, which third party applications should recognize better, unlike our private MIME types application/x-openoffice-wmf and application/x-openoffice-emf which are a mystery to all.
3. Export as other vector graphics formats, such as SVG.

Doing this:

$ xclip -selection clipboard -target 'application/x-openoffice-wmf;windows_formatname="Image WMF"' -o > /tmp/image.wmf

does allow GIMP to open /tmp/image.wmf successfully. However just because GIMP can open WMF files on disk, doesn't mean it can paste them, trying:

$ xclip -selection clipboard -target 'image/wmf' -in /tmp/image.wmf

still doesn't paste in GIMP, despite pasting the same contents successfully with xclip. Couldn't paste it in Inkscape either :-(. But I can finally paste into MyPaint. So it looks like GIMP and Inkscape do not support WMF on the clipboard, even though they can open them from files on disk.

Putting an SVG image on the clipboard, eg:

$ xclip -selection clipboard -target 'image/svg+xml' -in /usr/local/share/icons/gnome/scalable/emotes/face-angel-symbolic.svg

does allow GIMP and Inkscape and MyPaint to paste it successfully.

So for maximum interoperability we should export charts in:
- WMF and EMF, using the official MIME types, for some apps like MyPaint.
- SVG, for GIMP, Inkscape, and other apps.
Comment 19 damjan 2024-02-11 18:58:40 UTC
MyPaint seems extremely fussy and can only paste when "image/wmf" is the only format on the clipboard. GIMP and Inkscape cannot paste even then.

I am very close to getting SVG export to the clipboard implemented though, "image/svg+xml" shows up as a clipboard format, but pasting fails somewhere.
Comment 20 damjan 2024-02-13 05:42:53 UTC
It's working. Copying Calc charts and Draw figures into the clipboard, now does allow them to be pasted in GIMP and Inkscape in the lossless SVG format.

It took a while to figure out but was surprisingly easy to add, OpenOffice already has an SVG GraphicsConverter, all that was necessary was to declare the SVG clipboard format, and update the clipboard callbacks to use the SVG GraphicsConverter when the SVG format is requested.

I am just testing on Windows before I push my changes.
Comment 21 damjan 2024-02-14 04:32:17 UTC
Fixed by commit 61aee323790d0a1ed0745ee5a84b8885bcd0a559 in trunk, resolving FIXED.

Thank you for your bug report.
Comment 22 damjan 2024-02-14 04:33:29 UTC
Cherry-picked for AOO42X with commit ad6faf9749cad74c167c20bfc434a305f8fb5e15.