Estimated read time: 3 minutes
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 declare conflicting requirements, and rules can specify how to resolve those conflicts. The below example document has shape widths defined in a way that multiple child shapes wants to have a width of 100%, but simply scaling down all child shapes does not give a correct result. Rules define what to scale down and what to leave unchanged.
Results so far
Here is how this works in practice:
How is this implemented?
If you would like to know a bit more about how this works, continue reading… :-)
The initial heavy-lifting is done in this commit, which parses the rules from the XML input.
Then once we had rule info around, the linear algorithm was improved to scale down child shapes based on rules (and not just all of them, equally).
Then it was necessary to scale spacings (between child shapes) based on rules as well.
It was also needed to limit the height request of a shape, since they should not leave the canvas of the SmartArt.
Finally it was necessary to support the "top" child order. This can be declared using the following markup:
<dgm:layoutNode ... chOrder="t">
This declares that an earlier shape in a linear layout is on top of a later shapes, not the opposite. The default is that newer shapes are on top of older shapes. This is not a visible problem usually, but once you start using negative widths in a linear layout, you can have overlapping shapes. The above example has 3 text shapes, which are overlapping with the "background" arrow shape. This is expressed by having 100% width for child shapes (OK to scale down), then a -100% width for a dummy shape (not scaling) and finally a 100% width for the background arrow (not scaling).
All in all, now the background arrow shape has a good position and size, and the text on the arrow is readable.
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 is a major contributor to LibreOffice and all of this work will be available in TDF’s next release too (7.1).