Problems with SetSnapRect() for rotated and/or sheared custom shapes

Regina Henschel rb.henschel at t-online.de
Tue Nov 5 20:07:41 UTC 2019


Hi all,

Regina Henschel schrieb am 05-Nov-19 um 13:42:

> And I have found a comment in SdrObj
> /// SetSnapRect() tries to size the Object so that it fits into the
> /// passed Rect (without stroke width, ...)
> 
> The longer I think about it, the more I get convinced that I really have 
> to change SdrObjCustomShape::SetSnapRect() so that the input parameter 
> is used as snap rectangle. This means that some math is required in case 
> of rotation and shear.

After some math, it turns out, that "fits into the passed Rect" is not 
possible in all cases, if we want to keep rotation and shear angle.
With 'width' and 'height' of the passed rectangle and 'rot' the rotation 
angle of the custom shape, a suitable logical rectangle does not exists, 
if 'rot' is between arctan(width/height) and arctan(height/width).

Keeping rotation and shear angle is needed in case of 
SetVerticalWriting() and Undo(). For FitToCellSize() the current 
behavior is questionable for other kind of rotated shapes too and 
specification of the desired behavior is needed.

So my suggestion would be now, to keep SdrObjCustomShape::SetSnapRect() 
to use the passed rectangle as logical rectangle and change all callers 
so, that they pass a suitable rectangle.

Kind regards
Regina


More information about the LibreOffice mailing list