summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-10-26 15:33:43 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-10-26 17:45:39 +0200
commitb083b0808121d19f398a9f6ead195ae7e14ed047 (patch)
tree676ccded3777e41ef9404d88525dfcfe3bb42de1 /oox
parente21ece71a70906526e2c3eceaac3bc0c93bb7831 (diff)
oox smartart, linear layout: take width from constraints
Finally the "parent text" of the test document now has correct width. Change-Id: I05c552dda66ad91f19cfc335b464549920269f69 Reviewed-on: https://gerrit.libreoffice.org/62395 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.cxx33
1 files changed, 31 insertions, 2 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index eeaa0812383d..e8665542b876 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -225,7 +225,7 @@ void AlgAtom::accept( LayoutAtomVisitor& rVisitor )
}
void AlgAtom::layoutShape( const ShapePtr& rShape,
- const std::vector<Constraint>& rConstraints ) const
+ const std::vector<Constraint>& rOwnConstraints ) const
{
// Algorithm result may depend on the parent constraints as well.
std::vector<Constraint> aParentConstraints;
@@ -239,6 +239,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
pConstraintAtom->parseConstraint(aParentConstraints);
}
}
+ const std::vector<Constraint>& rConstraints = rOwnConstraints.empty() ? aParentConstraints : rOwnConstraints;
switch(mnType)
{
@@ -381,10 +382,38 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
if (nIncY == -1)
aCurrPos.Y = rShape->getSize().Height - aChildSize.Height;
+ // Find out which contraint is relevant for which (internal) name.
+ LayoutPropertyMap aProperties;
+ for (const auto& rConstraint : rConstraints)
+ {
+ if (rConstraint.msForName.isEmpty())
+ continue;
+
+ LayoutProperty& rProperty = aProperties[rConstraint.msForName];
+ if (rConstraint.mnType == XML_w)
+ rProperty[XML_w] = rShape->getSize().Width * rConstraint.mfFactor;
+ }
+
for (auto & aCurrShape : rShape->getChildren())
{
+ // Extract properties relevant for this shape from constraints.
+ oox::OptValue<sal_Int32> oWidth;
+ auto it = aProperties.find(aCurrShape->getInternalName());
+ if (it != aProperties.end())
+ {
+ LayoutProperty& rProperty = it->second;
+ auto itProperty = rProperty.find(XML_w);
+ if (itProperty != rProperty.end())
+ oWidth = itProperty->second;
+ }
+
aCurrShape->setPosition(aCurrPos);
- aCurrShape->setSize(aChildSize);
+
+ awt::Size aSize = aChildSize;
+ if (oWidth.has())
+ aSize.Width = oWidth.get();
+ aCurrShape->setSize(aSize);
+
aCurrShape->setChildSize(aChildSize);
aCurrPos.X += nIncX * (aChildSize.Width + fSpace*aChildSize.Width);
aCurrPos.Y += nIncY * (aChildSize.Height + fSpace*aChildSize.Height);