Apache OpenOffice (AOO) Bugzilla – Issue 115391
resizing a group of shapes set to "resize shape to fit text" messes up connectors and sizes
Last modified: 2017-05-20 10:35:29 UTC
When a group of shapes that have been set to resize to fit text is resized, the sizes of the shapes and the connectors get completely messed up. See the linked youtube video. The bug still exists in OOO330m13.
Created attachment 72846 [details] Resize this group of shapes and you'll see that sizes and connectors get messed up
Created attachment 72847 [details] Resize this group of shapes and you'll see that sizes and connectors get messed up -- this is a better sample. Tested for OOO330M13.
Reproducible. Reassigned.
Changed the importance to critical as "The bug make it impossible to work with the version of test on a feature." It is impossible to resize a drawing that contains connected shapes that are set with the "resize shape to fit text" option. Once the drawing is messed up, UNDO doesn't work. That leads to formatting loss which in the case of a flowchart is actual DATA LOSS.
ALG: Tried with connectors removed, same effect. Tried with single CoustomShapes, works well. Tried with a single CustomShape in a group, looks better, but undo does not go back to former size. Problem seems to be the resize on grouped CustomShapes, even with a single one. Taking a look...
ALG: There are differences in the interaction handling for CustomShapes; when not a group object, the overlay geometry is created based on the fallback-geometry of the CustomShape defined by SdrObjects where none of these uses a bTextFrame flag. When in a group, directly SdrObjCustomShape::Resize is used which has bTextFrame set. Wit bTextFrame set there seem to be errors in the handling of SdrTextObj::NbcResize at the bottom, the SetRectsDirty call is too late and the rcecalculations of MinTextSize fittings are based on the wrong (the old) rectangle. Checking if this can be cured with invalidating these rects early...
ALG: Problem is indeed the lower part of SdrTextObj::NbcResize; it uses NbcSetMinTextFrameWidth and NbcSetMinTextFrameHeight to adapt the sizes, but these trigger recalculations (over the path triggered by ItemChange) and thus lands in NbcAdjustTextFrameWidthAndHeight between these two calls (the call is triggered by hand afterwards anyways). Thus, the calulation is done with MinTextFrameWidth set but MinTextFrameHeight not. This leads to landing at SdrObjCustomShape::ImpCalculateTextFrame where in the 2nd if strange back-calculations are triggered which then create the wrong text frame sizes. Checking why/what/which/how/...
ALG: This is hard (old) stuff; the bool bTextFrame which is used to decide if e.g. NbcResize will update AutoGrowWidth/Height is used as a flag for the 'resize shape to fit text' setting; when this is set, bTextFrame is used at SdrTextObj (the class CustomShape is derived from) to change the behaviour to be close to a TextFrame. Also the Item used to remember that state is SdrTextAutoGrowHeightItem; this is *reused* compared to SdrTextObj where it does what the name says, see comment in svdoashp.hxx line 2556: // in context with the SdrObjCustomShape the SdrTextAutoGrowHeightItem == true -> Resize Shape to fit text, // the SdrTextAutoGrowWidthItem == true -> Word wrap text in Shape Ahhh(!). Also MinTextFrameWidth/Height for CustomShape relies on the text frame specific to the CustomShape (is fetched using GetTextBounds), not on the internal rect of the TextObject, thus all changes in the 'resize shape to fit text' mode wrongly resetted MinFrameTextWidth/Height to wrong values anyways. Experimenting now with different local virtual methods for adapting MinFrameTextWidth/Height for Text and CustomShapes...
ALG: I have now found a way to get it work as intended (resize group, but CustomShapes in mode 'resize shape to fit text' will stay at their size). This needs thorough testing of all CustomShape, TextShape and DrawShape stuff (since CustomShape and DrawShape are derived from TextShape, so both may be influenced). It's a tough problem (I told at the CustomShape development not to derive from SdrTextObj, and I will have to do this complex change in parallel in aw080 where most of the involved stuff is changed heavily)...
(In reply to Armin Le Grand from comment #9) > CustomShapes in mode 'resize shape to fit text' will stay at their size). This is the expected behavior. If the user wishes to change the sizes of shapes that derive from font size then he should change the size of the fonts or the complete object instead. Thanks. Really. This bug is preventing me from using Drawing for 7 years...
ALG: @axonis: Thanks for your ack, I fully agree. Good idea with the font size change, tried that out, works well :-) Did intense tests with all kinds of shapes, looks good. Preparing commit...
ALG: Committed, added some changes during adaption to aw080 (ongoing). Done in trunk, though.
"alg" committed SVN revision 1524700 into trunk: i115391 corected from isLocked to IsPasteResize which was used in modifiers f...
"alg" committed SVN revision 1524698 into trunk: i115391 corected from SetObejctItem to usage of local SfxItemSet
"alg" committed SVN revision 1524675 into trunk: i115391 better support for MinTextSize settings for TextShapes and CustomShapes
taking over for verification
Using recent Windows build bot installation set (rev. 1571677) I can verify the made fix. Resizing does not change the size of the 'resize to fit text' shapes inside the group. Undo works, too. Unset 'resize to fit text' for one of the shapes and resizing the group also results in the expected behavior. --> verified