Issue 125211 - rectangle with gradient -> To Metafile -> Break fails
Summary: rectangle with gradient -> To Metafile -> Break fails
Alias: None
Product: Draw
Classification: Application
Component: editing (show other issues)
Version: 4.1.0
Hardware: PC Windows 7
: P3 Normal (vote)
Target Milestone: 4.2.0
Assignee: Armin Le Grand
QA Contact:
Keywords: regression
Depends on:
Reported: 2014-07-06 19:38 UTC by Regina Henschel
Modified: 2017-05-20 10:35 UTC (History)
1 user (show)

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


Note You need to log in before you can comment on or make changes to this issue.
Description Regina Henschel 2014-07-06 19:38:47 UTC
Take Draw document.
Draw a rectangle and fill it with a gradient, "linear magenta/green" for example.
Right click > Convert > To Metafile.
Right click > Break
Expected result: Get a polygon with gradient filling.
Seen result: Totally wrong. I get a shape with black filling and some shapes with hatch filling.

It has been OK with r1476029.
It is broken at least since r1482523.
Comment 1 Armin Le Grand 2014-07-07 10:05:53 UTC
Indeed, happens as described, very strange. Taking a look...
Comment 2 Armin Le Grand 2014-07-07 12:30:46 UTC
Same in AOO410 and AOO401. Works in AOO341, creates outline rect and a filled rect with the gradient as attribute (as expected). Digging deeper...
Comment 3 Armin Le Grand 2014-07-07 13:28:40 UTC
This a surprising error; it's an ages-old error in the metafile importer (ImpSdrGDIMetaFileImport). The cases where a gradient is to be set at an SdrObject the FillStyle is simply set *wrong* to XFILL_HATCH instead of XFILL_GRADIENT. I wonder that this was never detected earlier, sigh.
The next problem is that indeed 5 objects get created
- GradientA
- GradientB
- black-filled rectangle
- GradientC
- outline
This is because in the old days of VCL the gradients were painted by drawing the unmasked gradient (GradientB), XORing with black mask (black-filled rectangle) and painting the gradient again XORed (GradientC). Also a GradientEx action is in front of these (GradientA).
Additionally all this is bracketed with two comment actions of type 'XGRAD_SEQ_BEGIN/XGRAD_SEQ_END' which the importer tries to use in DoAction( MetaCommentAction& rAct, ...), but this goes wrong since it implies that the Next() mechanism at the metafile action list (from tools) is used which is not the case.
When correcting all this only one error remains: The object filled with the gradient has an outline. This happens due to the SfxItemSet being created to hold the attributes has no WhichID for XLineStyleItem, so setting this item at it just goes wrong. Changed that to use the SfxItemSet range from the target object, this cannot fail.
Checking with these changes again (and doing some more tests)...
Comment 4 SVN Robot 2014-07-07 15:22:03 UTC
"alg" committed SVN revision 1608485 into trunk:
i125211 corrected beaking metafiles with gradient actions
Comment 5 Armin Le Grand 2014-07-07 15:22:50 UTC
Checked, committed, done.
This one is too dangerous for AOO411, as can be seen from how long it was undiscovered and how dangerous changes in that area are.