diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2018-12-12 18:09:12 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2018-12-12 22:54:45 +0100 |
commit | ee6787fc5597b7f730c4ee3a1f2a1b261d0a5644 (patch) | |
tree | b854f3773b37361f3817dff0ffe981d05bc23fdf /oox | |
parent | ec3ab1c671e00b9c32f6cdb529fb43e49f1e8689 (diff) |
oox smartart, continuous block process: read space width from constraint
The information is needed by the linear layout, but it's provided by a
child algorithm of type "space", with possibly multiple foreach atoms
in-between.
So start supporting a custom space factor by reading it from
constraints, but still assume a fixed layout node name, as it's tricky
to look that up.
Change-Id: I2aa8db8823694618d8ca6707ddcd71715a65b831
Reviewed-on: https://gerrit.libreoffice.org/65049
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index f99126be9bed..bea44faf8784 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -536,22 +536,9 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, const sal_Int32 nIncX = nDir==XML_fromL ? 1 : (nDir==XML_fromR ? -1 : 0); const sal_Int32 nIncY = nDir==XML_fromT ? 1 : (nDir==XML_fromB ? -1 : 0); - // TODO: get values from constraints sal_Int32 nCount = rShape->getChildren().size(); double fSpace = 0.3; - awt::Size aChildSize = rShape->getSize(); - if (nDir == XML_fromL || nDir == XML_fromR) - aChildSize.Width /= (nCount + (nCount-1)*fSpace); - else if (nDir == XML_fromT || nDir == XML_fromB) - aChildSize.Height /= (nCount + (nCount-1)*fSpace); - - awt::Point aCurrPos(0, 0); - if (nIncX == -1) - aCurrPos.X = rShape->getSize().Width - aChildSize.Width; - if (nIncY == -1) - aCurrPos.Y = rShape->getSize().Height - aChildSize.Height; - // Find out which constraint is relevant for which (internal) name. LayoutPropertyMap aProperties; for (const auto& rConstraint : rConstraints) @@ -562,8 +549,24 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, LayoutProperty& rProperty = aProperties[rConstraint.msForName]; if (rConstraint.mnType == XML_w) rProperty[XML_w] = rShape->getSize().Width * rConstraint.mfFactor; + + // TODO: get values from differently named constraints as well + if (rConstraint.msForName == "sibTrans" && rConstraint.mnType == XML_w) + fSpace = rConstraint.mfFactor; } + awt::Size aChildSize = rShape->getSize(); + if (nDir == XML_fromL || nDir == XML_fromR) + aChildSize.Width /= (nCount + (nCount-1)*fSpace); + else if (nDir == XML_fromT || nDir == XML_fromB) + aChildSize.Height /= (nCount + (nCount-1)*fSpace); + + awt::Point aCurrPos(0, 0); + if (nIncX == -1) + aCurrPos.X = rShape->getSize().Width - aChildSize.Width; + if (nIncY == -1) + aCurrPos.Y = rShape->getSize().Height - aChildSize.Height; + // See if children requested more than 100% space in total: scale // down in that case. sal_Int32 nTotalWidth = 0; |