include/oox/helper/attributelist.hxx | 4 + oox/source/drawingml/diagram/diagram.cxx | 5 - oox/source/drawingml/diagram/diagram.hxx | 5 - oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 51 ++++++++--------- oox/source/drawingml/diagram/diagramlayoutatoms.hxx | 2 oox/source/drawingml/diagram/layoutatomvisitorbase.cxx | 2 oox/source/helper/attributelist.cxx | 13 ++++ 7 files changed, 44 insertions(+), 38 deletions(-)
New commits: commit f3e1a315cf95e6d798e031afdb9be879052f25f3 Author: Grzegorz Araminowicz <grzegorz.araminow...@collabora.com> AuthorDate: Tue Jul 2 16:53:40 2019 +0200 Commit: Grzegorz Araminowicz <grzegorz.araminow...@collabora.com> CommitDate: Thu Jul 11 09:00:59 2019 +0200 SmartArt: make if-node functions relative to current presentation node * maxDepth calculates maximum depth of associated data node children (instead of per-diagram max depth) * cnt counts children of associated data node (instead of looking up presOf node and if not found counting presentation node children) Change-Id: Ifb50510acb9e6a3d2655197102060ec1c207075b Reviewed-on: https://gerrit.libreoffice.org/75000 Tested-by: Jenkins Reviewed-by: Grzegorz Araminowicz <grzegorz.araminow...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/75391 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/include/oox/helper/attributelist.hxx b/include/oox/helper/attributelist.hxx index 524d7f769a51..2d65ad889699 100644 --- a/include/oox/helper/attributelist.hxx +++ b/include/oox/helper/attributelist.hxx @@ -20,6 +20,8 @@ #ifndef INCLUDED_OOX_HELPER_ATTRIBUTELIST_HXX #define INCLUDED_OOX_HELPER_ATTRIBUTELIST_HXX +#include <vector> + #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/util/DateTime.hpp> #include <oox/helper/helper.hxx> @@ -164,6 +166,8 @@ public: value if the attribute is missing or not convertible to a date/time value. */ css::util::DateTime getDateTime( sal_Int32 nAttrToken, const css::util::DateTime& rDefault ) const; + std::vector<sal_Int32> getTokenList(sal_Int32 nAttrToken) const; + private: css::uno::Reference< css::xml::sax::XFastAttributeList > mxAttribs; diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx index c53b983526a9..5b0f9eac69ea 100644 --- a/oox/source/drawingml/diagram/diagram.cxx +++ b/oox/source/drawingml/diagram/diagram.cxx @@ -68,8 +68,7 @@ void Point::dump() const } // dgm namespace DiagramData::DiagramData() : - mpFillProperties( new FillProperties ), - mnMaxDepth(0) + mpFillProperties( new FillProperties ) { } @@ -327,8 +326,6 @@ void Diagram::build( ) { const sal_Int32 nDepth = calcDepth(elem.second.msSourceId, getData()->getConnections()); elem.second.mnDepth = nDepth != 0 ? nDepth : -1; - if (nDepth > getData()->getMaxDepth()) - getData()->setMaxDepth(nDepth); } } #ifdef DEBUG_OOX_DIAGRAM diff --git a/oox/source/drawingml/diagram/diagram.hxx b/oox/source/drawingml/diagram/diagram.hxx index 2e4ceae304c8..abe8e87fc8d7 100644 --- a/oox/source/drawingml/diagram/diagram.hxx +++ b/oox/source/drawingml/diagram/diagram.hxx @@ -189,10 +189,6 @@ public: ::std::vector<OUString> &getExtDrawings() { return maExtDrawings; } const dgm::Point* getRootPoint() const; - sal_Int32 getMaxDepth() const - { return mnMaxDepth; } - void setMaxDepth(sal_Int32 nDepth) - { mnMaxDepth = nDepth; } void dump() const; private: FillPropertiesPtr mpFillProperties; @@ -202,7 +198,6 @@ private: PointsNameMap maPointsPresNameMap; ConnectionNameMap maConnectionNameMap; StringMap maPresOfNameMap; - sal_Int32 mnMaxDepth; }; typedef std::shared_ptr< DiagramData > DiagramDataPtr; diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index b5c7a23738f7..503f141a4fa7 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -228,8 +228,7 @@ void setHierChildConnPosSize(const oox::drawingml::ShapePtr& pShape) namespace oox { namespace drawingml { IteratorAttr::IteratorAttr( ) - : mnAxis( 0 ) - , mnCnt( -1 ) + : mnCnt( -1 ) , mbHideLastTrans( true ) , mnPtType( 0 ) , mnSt( 0 ) @@ -240,12 +239,15 @@ IteratorAttr::IteratorAttr( ) void IteratorAttr::loadFromXAttr( const Reference< XFastAttributeList >& xAttr ) { AttributeList attr( xAttr ); - mnAxis = xAttr->getOptionalValueToken( XML_axis, 0 ); + maAxis = attr.getTokenList(XML_axis); mnCnt = attr.getInteger( XML_cnt, -1 ); mbHideLastTrans = attr.getBool( XML_hideLastTrans, true ); - mnPtType = xAttr->getOptionalValueToken( XML_ptType, 0 ); mnSt = attr.getInteger( XML_st, 0 ); mnStep = attr.getInteger( XML_step, 1 ); + + // better to keep first token instead of error when multiple values + std::vector<sal_Int32> aPtTypes = attr.getTokenList(XML_ptType); + mnPtType = aPtTypes.empty() ? XML_all : aPtTypes.front(); } ConditionAttr::ConditionAttr() @@ -354,25 +356,26 @@ OUString navigate(const LayoutNode& rLayoutNode, sal_Int32 nType, const OUString return OUString(); } + +sal_Int32 calcMaxDepth(const OUString& rNodeName, const dgm::Connections& rConnections) +{ + sal_Int32 nMaxLength = 0; + for (auto const& aCxn : rConnections) + if (aCxn.mnType == XML_parOf && aCxn.msSourceId == rNodeName) + nMaxLength = std::max(nMaxLength, calcMaxDepth(aCxn.msDestId, rConnections) + 1); + + return nMaxLength; +} } sal_Int32 ConditionAtom::getNodeCount(const dgm::Point* pPresPoint) const { sal_Int32 nCount = 0; - OUString sNodeId = navigate(mrLayoutNode, XML_presOf, pPresPoint->msModelId, /*bSourceToDestination*/ false); + OUString sNodeId = pPresPoint->msPresentationAssociationId; - if (sNodeId.isEmpty()) - { - // The current layout node is not a presentation of anything. Look - // up the first presentation child of the layout node. - OUString sFirstPresChildId = navigate(mrLayoutNode, XML_presParOf, pPresPoint->msModelId, - /*bSourceToDestination*/ true); - if (!sFirstPresChildId.isEmpty()) - // It has a presentation child: is that a presentation of a - // model node? - sNodeId = navigate(mrLayoutNode, XML_presOf, sFirstPresChildId, - /*bSourceToDestination*/ false); - } + // HACK: special case - count children of first child + if (maIter.maAxis.size() == 2 && maIter.maAxis[0] == XML_ch && maIter.maAxis[1] == XML_ch) + sNodeId = navigate(mrLayoutNode, XML_parOf, sNodeId, /*bSourceToDestination*/ true); if (!sNodeId.isEmpty()) { @@ -380,14 +383,6 @@ sal_Int32 ConditionAtom::getNodeCount(const dgm::Point* pPresPoint) const if (aCxn.mnType == XML_parOf && aCxn.msSourceId == sNodeId) nCount++; } - else - { - // No presentation child is a presentation of a model node: just - // count presentation children. - for (const auto& aCxn : mrLayoutNode.getDiagram().getData()->getConnections()) - if (aCxn.mnType == XML_presParOf && aCxn.msSourceId == pPresPoint->msModelId) - nCount++; - } return nCount; } @@ -433,8 +428,10 @@ bool ConditionAtom::getDecision(const dgm::Point* pPresPoint) const return compareResult(maCond.mnOp, getNodeCount(pPresPoint), maCond.msVal.toInt32()); case XML_maxDepth: - // TODO: probably depth from current point - docs are unclear - return compareResult(maCond.mnOp, mrLayoutNode.getDiagram().getData()->getMaxDepth(), maCond.msVal.toInt32()); + { + sal_Int32 nMaxDepth = calcMaxDepth(pPresPoint->msPresentationAssociationId, mrLayoutNode.getDiagram().getData()->getConnections()); + return compareResult(maCond.mnOp, nMaxDepth, maCond.msVal.toInt32()); + } case XML_depth: case XML_pos: diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx index b4255927185b..f3833434950a 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx @@ -41,7 +41,7 @@ struct IteratorAttr // not sure this belong here, but wth void loadFromXAttr( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes ); - sal_Int32 mnAxis; + std::vector<sal_Int32> maAxis; sal_Int32 mnCnt; bool mbHideLastTrans; sal_Int32 mnPtType; diff --git a/oox/source/drawingml/diagram/layoutatomvisitorbase.cxx b/oox/source/drawingml/diagram/layoutatomvisitorbase.cxx index 49b1d801bee9..c8761ffa3d67 100644 --- a/oox/source/drawingml/diagram/layoutatomvisitorbase.cxx +++ b/oox/source/drawingml/diagram/layoutatomvisitorbase.cxx @@ -60,7 +60,7 @@ void LayoutAtomVisitorBase::visit(ForEachAtom& rAtom) return; } - if (rAtom.iterator().mbHideLastTrans && rAtom.iterator().mnAxis == XML_followSib) + if (rAtom.iterator().mbHideLastTrans && !rAtom.iterator().maAxis.empty() && rAtom.iterator().maAxis[0] == XML_followSib) { // If last transition is hidden and the axis is the follow sibling, // then the last atom should not be visited. diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx index 22aafdfcf70d..da58fc076672 100644 --- a/oox/source/helper/attributelist.cxx +++ b/oox/source/helper/attributelist.cxx @@ -310,6 +310,19 @@ util::DateTime AttributeList::getDateTime( sal_Int32 nAttrToken, const util::Dat return getDateTime( nAttrToken ).get( rDefault ); } +std::vector<sal_Int32> AttributeList::getTokenList(sal_Int32 nAttrToken) const +{ + std::vector<sal_Int32> aValues; + OUString sValue = getString(nAttrToken, ""); + sal_Int32 nIndex = 0; + do + { + aValues.push_back(AttributeConversion::decodeToken(sValue.getToken(0, ' ', nIndex))); + } while (nIndex >= 0); + + return aValues; +} + } // namespace oox /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits