summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2018-12-12 18:09:12 +0100
committerMiklos Vajna <vmiklos@collabora.com>2018-12-17 15:40:05 +0100
commit6f2b06a279ecfeeeb7948a6373dd85bc7b4041e3 (patch)
tree9fa6c604d37efa1c99f2acd0946352eb6bbe9df3 /oox
parent967f2ac350330a28a3fc2ec0993cbaf976e6cf60 (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 (cherry picked from commit ee6787fc5597b7f730c4ee3a1f2a1b261d0a5644) Reviewed-on: https://gerrit.libreoffice.org/65253
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.cxx29
1 files changed, 16 insertions, 13 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 74cd2ed7d06c..15a064f2d66b 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;