diff options
-rw-r--r-- | oox/source/drawingml/diagram/datamodelcontext.cxx | 2 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/diagram.hxx | 3 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 41 | ||||
-rw-r--r-- | sd/qa/unit/import-tests-smartart.cxx | 9 |
4 files changed, 46 insertions, 9 deletions
diff --git a/oox/source/drawingml/diagram/datamodelcontext.cxx b/oox/source/drawingml/diagram/datamodelcontext.cxx index 326b4f933ed6..b98d0ee87ccf 100644 --- a/oox/source/drawingml/diagram/datamodelcontext.cxx +++ b/oox/source/drawingml/diagram/datamodelcontext.cxx @@ -111,7 +111,7 @@ public: mrPoint.mnDirection = rAttribs.getToken( XML_val, XML_norm ); break; case DGM_TOKEN( hierBranch ): - mrPoint.mnHierarchyBranch = rAttribs.getToken( XML_val, XML_std ); + mrPoint.moHierarchyBranch = rAttribs.getToken( XML_val ); break; case DGM_TOKEN( orgChart ): mrPoint.mbOrgChartEnabled = rAttribs.getBool( XML_val, false ); diff --git a/oox/source/drawingml/diagram/diagram.hxx b/oox/source/drawingml/diagram/diagram.hxx index 1a981a858c29..242ff09fa152 100644 --- a/oox/source/drawingml/diagram/diagram.hxx +++ b/oox/source/drawingml/diagram/diagram.hxx @@ -73,7 +73,6 @@ struct Point mnMaxChildren(-1), mnPreferredChildren(-1), mnDirection(XML_norm), - mnHierarchyBranch(XML_std), mnResizeHandles(XML_rel), mnCustomAngle(-1), mnPercentageNeighbourWidth(-1), @@ -118,7 +117,7 @@ struct Point sal_Int32 mnMaxChildren; sal_Int32 mnPreferredChildren; sal_Int32 mnDirection; - sal_Int32 mnHierarchyBranch; + OptValue<sal_Int32> moHierarchyBranch; sal_Int32 mnResizeHandles; sal_Int32 mnCustomAngle; sal_Int32 mnPercentageNeighbourWidth; diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index fc5b1c059410..4495ae8a570d 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -346,8 +346,32 @@ bool ConditionAtom::getDecision() const case XML_var: { const dgm::Point* pPoint = getPresNode(); - if (pPoint && maCond.mnArg == XML_dir) + if (!pPoint) + break; + + if (maCond.mnArg == XML_dir) return compareResult(maCond.mnOp, pPoint->mnDirection, maCond.mnVal); + else if (maCond.mnArg == XML_hierBranch) + { + sal_Int32 nHierarchyBranch = pPoint->moHierarchyBranch.get(XML_std); + if (!pPoint->moHierarchyBranch.has()) + { + // If <dgm:hierBranch> is missing in the current presentation + // point, ask the parent. + OUString aParent = navigate(mrLayoutNode, XML_presParOf, pPoint->msModelId, + /*bSourceToDestination*/ false); + DiagramData::PointNameMap& rPointNameMap + = mrLayoutNode.getDiagram().getData()->getPointNameMap(); + auto it = rPointNameMap.find(aParent); + if (it != rPointNameMap.end()) + { + const dgm::Point* pParent = it->second; + if (pParent->moHierarchyBranch.has()) + nHierarchyBranch = pParent->moHierarchyBranch.get(); + } + } + return compareResult(maCond.mnOp, nHierarchyBranch, maCond.mnVal); + } break; } @@ -595,6 +619,15 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, sal_Int32 nCount = rShape->getChildren().size(); + if (mnType == XML_hierChild) + { + // Connectors should not influence the size of non-connect + // shapes. + nCount = std::count_if( + rShape->getChildren().begin(), rShape->getChildren().end(), + [](const ShapePtr& pShape) { return pShape->getSubType() != XML_conn; }); + } + // A manager node's height should be independent from if it has // assistants and employees, compensate for that. bool bTop = mnType == XML_hierRoot && rShape->getInternalName() == "hierRoot1"; @@ -632,6 +665,12 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, pChild->setPosition(aChildPos); pChild->setSize(aChildSize); pChild->setChildSize(aChildSize); + + if (mnType == XML_hierChild && pChild->getSubType() == XML_conn) + // Connectors should not influence the position of + // non-connect shapes. + continue; + if (nDir == XML_fromT) aChildPos.Y += aChildSize.Height; else diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index 846a95ee6738..34b9ea439544 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -721,16 +721,15 @@ void SdImportTestSmartArt::testOrgChart() 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 - // 'Expected: 2; Actual : 1'. uno::Reference<drawing::XShapes> xEmployees(getChildShape(getChildShape(xGroup, 0), 2), uno::UNO_QUERY); CPPUNIT_ASSERT(xEmployees.is()); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xEmployees->getCount()); + // 4 children: connector, 1st employee, connector, 2nd employee. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xEmployees->getCount()); uno::Reference<text::XText> xEmployee( getChildShape( - getChildShape(getChildShape(getChildShape(getChildShape(xGroup, 0), 2), 0), 0), 0), + getChildShape(getChildShape(getChildShape(getChildShape(xGroup, 0), 2), 1), 0), 0), uno::UNO_QUERY); CPPUNIT_ASSERT(xEmployee.is()); CPPUNIT_ASSERT_EQUAL(OUString("Employee"), xEmployee->getString()); @@ -752,7 +751,7 @@ void SdImportTestSmartArt::testOrgChart() // the second employee was below the first one. uno::Reference<text::XText> xEmployee2( getChildShape( - getChildShape(getChildShape(getChildShape(getChildShape(xGroup, 0), 2), 1), 0), 0), + getChildShape(getChildShape(getChildShape(getChildShape(xGroup, 0), 2), 3), 0), 0), uno::UNO_QUERY); CPPUNIT_ASSERT(xEmployee2.is()); CPPUNIT_ASSERT_EQUAL(OUString("Employee2"), xEmployee2->getString()); |