Issue 123983 - Particular picture cropped after copy / paste as GDI Metafile
Summary: Particular picture cropped after copy / paste as GDI Metafile
Alias: None
Product: Draw
Classification: Application
Component: editing (show other issues)
Version: 4.0.0
Hardware: All Windows 7
: P3 Normal (vote)
Target Milestone: 4.1.0
Assignee: Armin Le Grand
QA Contact:
Keywords: regression
Depends on:
Reported: 2014-01-07 07:10 UTC by Rainer Bielefeld
Modified: 2017-05-20 10:35 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: 4.1.0-dev
Developer Difficulty: ---

Sample Document (98.92 KB, application/pdf)
2014-01-07 07:10 UTC, Rainer Bielefeld
no flags Details
The reduced example, one page, one object (35.79 KB, application/
2014-01-22 15:35 UTC, Armin Le Grand
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description Rainer Bielefeld 2014-01-07 07:10:51 UTC
Created attachment 82230 [details]
Sample Document

Steps how to reproduce with server installation of "AOO 4.1.0-Dev – English  UI / English locale - [AOO410m1(Build:9750)  -  Rev. 1554003 - 2014-01-06]" on German WIN7 Home Premium (64bit)", own separate user profile:

0. Install Extension "PDF Import for AOO" Version 0.1.0
1. Open attached "ILC_130_ETH_2988803.pdf" From AOO Draw File dialog
   > PDF Import
2. Save as Sample.odg for further tests
3. click picture of green PLC device below Phoenix Contact logo on first page
4. <control+c> for copy
5. Click elsewhere on empty area on page
   > Control points disappear
6. Paste-Icon (Standard Toolbar) -> As GDI metafile
   > Copy of picture appears
   Expected: identical with source-picture
   Actual: much bigger and only top left quadrant shown

Additional info:
(a) Sample document has been created by opening a PDF created from public 
    Web page using FreePDF with AOo
(b) I ghink PDF import is not related, Sample.odg document works fine with
     OOo 3.1.1
(c)  Already reproducible with Sample.odg andserver installation of 
     "AOO 4.0.0-Dev  – English UI / German locale [AOO400m1(Build:9700) - 
     Rev. 1457992 – Rev.1457606  ((2013-03-19))]" on German WIN7 
     Home Premium (64bit)", own separate user profile
(d) Still worked fine with Sample.odg and server installation of AOO 3.4.1
Comment 1 Rainer Bielefeld 2014-01-07 08:31:37 UTC
(e) You can "uncrop" the pasted GDI metafile with crop handles without problems, 
    afterwards picture looks normal
(f) but "uncrop" with context menu will fail.
Comment 2 Armin Le Grand 2014-01-22 15:33:52 UTC
Checked with AOO410m1(Build:9750)  -  Rev. 1555399, happens as desribed.
Workaround: first convert object to metafile (works as expected), copy it then.
Probably the wrong PrefMapMode and PrefSize is set at the bitmap after creation from the PDF import, taking a look...
Comment 3 Armin Le Grand 2014-01-22 15:35:31 UTC
Created attachment 82363 [details]
The reduced example, one page, one object
Comment 4 Armin Le Grand 2014-01-22 17:02:26 UTC
When using 'original size' it can be seen that the size/scaling of the wrong metafile is not wrong in that aspect, but what is wanted is a 1:1 copy, including the current scaling/position of the object.
Problem is at metafile creation in SdrExchangeView::GetMarkedObjMetaFile where the single object selected case is optimized when it is a SdrGrafObj. That 'optimization' uses the Metafile it gets from the Graphic. That is not wrong in principle, but will have mapmode pixel and the pixel size set, so users of this cannot do other than show the original size (relative to DPI). The not-optimized case uses mapmode 100thmm and uses the current object size and position, thus when forcing to that version all works as expected.
I will try to repair the optimized version...
Comment 5 Armin Le Grand 2014-01-22 20:21:10 UTC
Tried various changes at various places, all that stuff with PrefMapMode and PrefSize at Bitmaps and Metafiles is quite fragile; at the end I decided to change the fallback Metafile creator at the Graphic directly; it was not in all cases (e.g. in this one) creating valid Metafiles since the PrefSize could be different from the Metafile content size when the PrefMapMode of the Bitmap and the size in pixels did not match. Now just copy the PrefMapMocde and PrefSize from the bitmap and do not use a VirtualDevice and no real pait commands. Preparing commit...
Comment 6 SVN Robot 2014-01-22 20:25:17 UTC
"alg" committed SVN revision 1560499 into trunk:
i123983 Corrected Graphic Metafile fallback creator
Comment 7 Armin Le Grand 2014-01-22 20:25:35 UTC
Okay, done.
Comment 8 Armin Le Grand 2014-01-22 20:40:56 UTC
forgot to set owner
Comment 9 Rainer Bielefeld 2014-04-25 17:27:23 UTC
Now works fine  with "AOO 4.1.0 RC4 – German UI / German locale [AOO410m18(Build:9764)  -   Rev. 1589052 2014-04-22 11:43:54]" on German WIN7 Home Premium (64bit)", “historic” 4. User Profile used for all predecessor versions