summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.cxx23
-rw-r--r--sd/qa/unit/import-tests-smartart.cxx8
2 files changed, 31 insertions, 0 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 5e36f08d06ab..36b361db9a3b 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -478,6 +478,11 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
LayoutProperty& rParent = aProperties[""];
sal_Int32 nParentXOffset = 0;
+
+ // Track min/max vertical positions, so we can center everything at the end, if needed.
+ sal_Int32 nVertMin = std::numeric_limits<sal_Int32>::max();
+ sal_Int32 nVertMax = 0;
+
if (mfAspectRatio != 1.0)
{
rParent[XML_w] = rShape->getSize().Width;
@@ -613,6 +618,24 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
aCurrShape->setSize(aSize);
aCurrShape->setChildSize(aSize);
aCurrShape->setPosition(aPos);
+
+ nVertMin = std::min(aPos.Y, nVertMin);
+ nVertMax = std::max(aPos.Y + aSize.Height, nVertMax);
+ }
+
+ // See if all vertical space is used or we have to center the content.
+ if (nVertMin >= 0 && nVertMax <= rParent[XML_h])
+ {
+ sal_Int32 nDiff = rParent[XML_h] - (nVertMax - nVertMin);
+ if (nDiff > 0)
+ {
+ for (auto& aCurrShape : rShape->getChildren())
+ {
+ awt::Point aPosition = aCurrShape->getPosition();
+ aPosition.Y += nDiff / 2;
+ aCurrShape->setPosition(aPosition);
+ }
+ }
}
break;
}
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index 67db3deb4cc6..f08b60c30193 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -1498,6 +1498,14 @@ void SdImportTestSmartArt::testFillColorList()
awt::Size aActualSize = xShape->getSize();
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2239), aActualSize.Height);
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected greater than: 1738 (2766)
+ // - Actual : 1738
+ // i.e. the columns were not centered vertically.
+ sal_Int32 nGroupTop = xGroup->getPosition().Y;
+ sal_Int32 nShapeTop = xShape->getPosition().Y;
+ CPPUNIT_ASSERT_GREATER(nGroupTop, nShapeTop);
+
xDocShRef->DoClose();
}