Kaydet (Commit) b083b080 authored tarafından Miklos Vajna's avatar Miklos Vajna

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/62395Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins
üst e21ece71
......@@ -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);
......
......@@ -371,6 +371,15 @@ void SdImportTestSmartArt::testVertialBoxList()
// 'actual: 0'.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xShapeGroup->getCount());
uno::Reference<drawing::XShapes> xFirstChild(xShapeGroup->getByIndex(0), uno::UNO_QUERY);
CPPUNIT_ASSERT(xFirstChild.is());
uno::Reference<drawing::XShape> xParentText(xFirstChild->getByIndex(1), uno::UNO_QUERY);
CPPUNIT_ASSERT(xParentText.is());
// Without the accompanying fix in place, this test would have failed with
// 'actual: 7361', i.e. the width was not the 70% of the parent as the
// constraint wanted.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(11852), xParentText->getSize().Width);
uno::Reference<drawing::XShape> xSecondChild(xShapeGroup->getByIndex(1), uno::UNO_QUERY);
CPPUNIT_ASSERT(xSecondChild.is());
// Without the accompanying fix in place, this test would have failed with
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment