Estimated read time: 3 minutes
Impress now has support for an improved auto-fit-of-text layout across multiple shapes, also the snake algorithm now handles width requests from constraints much better for SmartArt graphics from PPTX files. This builds on top of the previous improvements around SmartArt support.
Motivation
SmartArt allows declaring your content and requirements for a graphic, then the layout will take care of arranging that in a suitable way. It is allowed to ask for an automatic font size, which is small enough so that all the content fits into the shape. At the same time, you can ask that the font size is the same in multiple shapes. Impress lacked the ability to do the latter, leading to different font sizes in different shapes, all automatic inside a single shape.
Results so far
Here is how the automatic text scaling across multiple shapes works in practice:
You can see how the old output used to have unexpected large text in shape A, but now has the same text size as shape B. This is not applied unconditionally, shape C can request to have an independent, fixed font size.
You can see that the old output laid shapes all over the place, while the new output puts them to a 3 by 2 matrix. The reason this works is because now we parse width requests from constraints correctly. This means we give spacings a smaller width, real shapes a larger width, so the content fits in less rows and the layout looks like a grid, matching the reference rendering.
How is this implemented?
If you would like to know a bit more about how this works, continue reading… :-)
As for the autofit synchronization:
-
svx UNO API for shapes: expose what scaling factor is used for autofit scaling made it possible to know what is a good scaling factor for one shape
-
svx UNO API for shapes: allow setting a max factor for autofit text scale made it possible to set the scaling factor, overriding what it would calculate by itself. This is a trade-off: setting the scaling factor on the shape inside the document model has the benefit that the importer doesn’t duplicate any text measuring code. The cost is that now there is an UNO property that you can set, but the value of that won’t be retained if you save to ODF and load the document back. At least not currently
-
oox smartart: add support for syncing font heights of multiple shapes is the SmartArt code to use the above mentioned building blocks
-
oox smartart: handle <dgm:prSet … custT="1"/> made it possible to not perform auto-scaling for certain shapes, if they request so
Beyond that, for the snake rows:
-
oox smartart: snake algo: consider child’s aspect ratio request for cols/rows started to improve the grid calculation, so less vertical space is needed
-
oox smartart: snake algo: start parsing relative width constraints allows differentiating between space items on a snake path (small width) and shape items, which typically have a larger width
-
oox smartart: snake algo: apply constraints on child shape widths uses the information collected in the previous step, so the sample document is requesting the expected 3 by 2 grid
-
oox smartart: snake algo: make sure child shape height stays within parent finally makes sure that the content is not falling off the slide, which would make it impossible to read when projecting
Want to start using this?
You can get a snapshot / demo of Collabora Office and try it out yourself right now: try unstable snapshot. Collabora intends to continue supporting and contributing to LibreOffice, the code is merged so we expect all of this work will be available in TDF’s next release too (7.1).