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

oox smartart, org chart: fix height of manager nodes without employees

Employees and/or assistants reduce the height of managers -- this effect
is wanted even if there are no employees/assistants.

Change-Id: I7bfcbf6819ee225aa2fbf21d4e064322912f8d5f
Reviewed-on: https://gerrit.libreoffice.org/66304Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
üst be78f86c
......@@ -552,6 +552,13 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
sal_Int32 nCount = rShape->getChildren().size();
// A manager node's height should be indepdenent from if it has
// assistants and employees, compensate for that.
bool bTop = mnType == XML_hierRoot && rShape->getInternalName() == "hierRoot1";
double fHeightScale = 1.0;
if (mnType == XML_hierRoot && nCount < 3 && bTop)
fHeightScale = fHeightScale * nCount / 3;
if (mnType == XML_hierRoot && nCount == 3)
{
// Order assistant nodes above employee nodes.
......@@ -563,7 +570,10 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
awt::Size aChildSize = rShape->getSize();
if (nDir == XML_fromT)
{
aChildSize.Height /= nCount;
aChildSize.Height *= fHeightScale;
}
else
aChildSize.Width /= nCount;
......
......@@ -718,6 +718,7 @@ void SdImportTestSmartArt::testOrgChart()
CPPUNIT_ASSERT(xManagerShape.is());
awt::Point aManagerPos = xManagerShape->getPosition();
awt::Size aManagerSize = xManagerShape->getSize();
// Make sure that the manager has 2 employees.
// Without the accompanying fix in place, this test would have failed with
......@@ -776,6 +777,20 @@ void SdImportTestSmartArt::testOrgChart()
// assistant shape was below the employee shape.
CPPUNIT_ASSERT_GREATER(aAssistantPos.Y, aEmployeePos.Y);
// Make sure the height of xManager and xManager2 is the same.
uno::Reference<text::XText> xManager2(
getChildShape(getChildShape(getChildShape(xGroup, 1), 0), 0), uno::UNO_QUERY);
CPPUNIT_ASSERT(xManager2.is());
CPPUNIT_ASSERT_EQUAL(OUString("Manager2"), xManager2->getString());
uno::Reference<drawing::XShape> xManager2Shape(xManager2, uno::UNO_QUERY);
CPPUNIT_ASSERT(xManager2Shape.is());
awt::Size aManager2Size = xManager2Shape->getSize();
// Without the accompanying fix in place, this test would have failed:
// xManager2's height was 3 times larger than xManager's height.
CPPUNIT_ASSERT_EQUAL(aManagerSize.Height, aManager2Size.Height);
xDocShRef->DoClose();
}
......
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