Bug 149468 - Scaling for draw:path-stretchpoint-x is wrongly triggered
Summary: Scaling for draw:path-stretchpoint-x is wrongly triggered
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL: https://docs.oasis-open.org/office/Op...
Whiteboard:
Keywords:
Depends on:
Blocks: ODF-export-invalid
  Show dependency treegraph
 
Reported: 2022-06-06 21:00 UTC by Regina Henschel
Modified: 2023-01-18 08:19 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
The left, yellow shape is faulty (12.73 KB, application/vnd.oasis.opendocument.presentation)
2022-06-06 21:00 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Regina Henschel 2022-06-06 21:00:19 UTC
Created attachment 180604 [details]
The left, yellow shape is faulty

The behavior for draw:path-stretchpoint-x is specified in 19.204 ODF 1.3 (see URL) as
"If specified, and if the x/y aspect ratio of the svg:viewBox 19.574 is lower than the x/y aspect ratio of the shape size then the whole path is stretched horizontally at draw:path-stretchpoint-x."

The attached document contains a yellow, a blue, a green and a red custom shape. The yellow and green shapes have an attribute draw:path-stretchpoint-x set. The blue and red shape have the same coordinates, but they have no draw:path-stretchpoint-x attribute. 

The yellow shape has the attributes svg:width="6cm", svg:height="3cm" and svg:viewBox="0 0 21600 10800". So its x/y aspect ratio of the svg:viewBox is 21600/10800=2 and the x/y aspect ratio of its size is 6cm/3cm=2.
So the values are equal and therefore there should be no stretching. That means it should look the same as the blue shape.

The green shape has the attributes svg:width="6cm", svg:height="6cm" and svg:viewBox="0 0 21600 21600". So its x/y aspect ratio of the svg:viewBox is 21600/21600=1 and the x/y aspect ratio of its size is 6cm/6cm=1.
Here it works.

The error is in method EnhancedCustomShape2d::SetPathSize()
689          fXRatio = static_cast<double>(aLogicRect.GetWidth()) / static_cast<double>(aLogicRect.GetHeight());
690          if ( fXRatio > 1 )
691              fXScale /= fXRatio;
692          else
693              fXRatio = 1.0;

Here it tests whether the shape width of the shape is larger than the shape height. But being ODF conform the ratio viewBoxWidht/viewBoxHeight has to be compared to ratio shapeWidth/shapeHeight.

Variable aLogicRect has the size of the shape and variables nCoordWidth and nCoordHeight have the size of viewBox. 

https://opengrok.libreoffice.org/xref/core/svx/source/customshapes/EnhancedCustomShape2d.cxx?r=0a1bfe1e#690
Comment 1 Regina Henschel 2022-06-06 21:13:10 UTC
There are more things wrong than the faulty condition, therefore it might be an easyHack, but not with difficultyBeginner.