LibreOffice Module oox (master) 1
layoutatomvisitorbase.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21
22#include <sal/log.hxx>
23
24using namespace ::com::sun::star;
25using namespace ::com::sun::star::uno;
26
27namespace oox::drawingml {
28
30{
31 for (const auto& pAtom : rAtom.getChildren())
32 pAtom->accept(*this);
33}
34
36{
37 for (const auto& pChild : rAtom.getChildren())
38 {
39 const ConditionAtomPtr pCond = std::dynamic_pointer_cast<ConditionAtom>(pChild);
40 if (pCond && pCond->getDecision(mpCurrentNode))
41 {
42 SAL_INFO("oox.drawingml", "Entering if node: " << pCond->getName());
43 pCond->accept(*this);
44 break;
45 }
46 }
47}
48
50{
51 defaultVisit(rAtom);
52}
53
55{
56 if (!rAtom.getRef().isEmpty())
57 {
58 if (LayoutAtomPtr pRefAtom = rAtom.getRefAtom())
59 pRefAtom->accept(*this);
60 return;
61 }
62
63 if (rAtom.iterator().mbHideLastTrans && !rAtom.iterator().maAxis.empty() && rAtom.iterator().maAxis[0] == XML_followSib)
64 {
65 // If last transition is hidden and the axis is the follow sibling,
66 // then the last atom should not be visited.
68 return;
69 }
70
71 sal_Int32 nChildren = 1;
72 // Approximate the non-assistant type with the node type.
73 if (rAtom.iterator().mnPtType == XML_node || rAtom.iterator().mnPtType == XML_nonAsst)
74 {
75 // count child data nodes - check all child Atoms for "name"
76 // attribute that is contained in diagram's
77 // getPointsPresNameMap()
78 ShallowPresNameVisitor aVisitor(mrDgm, mpCurrentNode);
79 for (const auto& pAtom : rAtom.getChildren())
80 pAtom->accept(aVisitor);
81 nChildren = aVisitor.getCount();
82 }
83
84 const sal_Int32 nCnt = std::min(
85 nChildren,
86 rAtom.iterator().mnCnt==-1 ? nChildren : rAtom.iterator().mnCnt);
87
88 const sal_Int32 nOldIdx = mnCurrIdx;
89 const sal_Int32 nOldStep = mnCurrStep;
90 const sal_Int32 nOldCnt = mnCurrCnt;
91 const sal_Int32 nStep = rAtom.iterator().mnStep;
92 mnCurrStep = nStep;
93 mnCurrCnt = nCnt;
94 for( mnCurrIdx=0; mnCurrIdx<nCnt && nStep>0; mnCurrIdx+=nStep )
95 {
96 // TODO there is likely some conditions
97 for (const auto& pAtom : rAtom.getChildren())
98 pAtom->accept(*this);
99 }
100
101 // and restore idx
102 mnCurrIdx = nOldIdx;
103 mnCurrStep = nOldStep;
104 mnCurrCnt = nOldCnt;
105}
106
108{
109 // TODO: deduplicate code in descendants
110
111 // stop processing if it's not a child of previous LayoutNode
112
113 const DiagramData::PointsNameMap::const_iterator aDataNode
114 = mrDgm.getData()->getPointsPresNameMap().find(rAtom.getName());
115 if (aDataNode == mrDgm.getData()->getPointsPresNameMap().end()
116 || mnCurrIdx >= static_cast<sal_Int32>(aDataNode->second.size()))
117 return;
118
119 const svx::diagram::Point* pNewNode = aDataNode->second.at(mnCurrIdx);
120 if (!mpCurrentNode || !pNewNode)
121 return;
122
123 bool bIsChild = false;
124 for (const auto& aConnection : mrDgm.getData()->getConnections())
125 if (aConnection.msSourceId == mpCurrentNode->msModelId
126 && aConnection.msDestId == pNewNode->msModelId)
127 bIsChild = true;
128
129 if (!bIsChild)
130 return;
131
132 const svx::diagram::Point* pPreviousNode = mpCurrentNode;
133 mpCurrentNode = pNewNode;
134
135 defaultVisit(rAtom);
136
137 mpCurrentNode = pPreviousNode;
138}
139
141{
142 // stop processing
143}
144
146{
147 // stop processing
148}
149
151{
152 // stop processing
153}
154
156{
157 defaultVisit(rAtom);
158}
159
161{
162 DiagramData::PointsNameMap::const_iterator aDataNode =
163 mrDgm.getData()->getPointsPresNameMap().find(rAtom.getName());
164 if( aDataNode != mrDgm.getData()->getPointsPresNameMap().end() )
165 mnCnt = std::max(mnCnt,
166 aDataNode->second.size());
167}
168
170{
171 // stop processing
172}
173
174}
175
176/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const OoxDiagramDataPtr & getData() const
const OUString & getRef() const
void defaultVisit(LayoutAtom const &rAtom)
virtual void visit(ForEachAtom &rAtom) override
abstract Atom for the layout
const std::vector< LayoutAtomPtr > & getChildren() const
const OUString & getName() const
Represents one <dgm:rule> element.
virtual void visit(ConstraintAtom &rAtom) override
#define SAL_INFO(area, stream)
std::shared_ptr< ConditionAtom > ConditionAtomPtr
std::shared_ptr< LayoutAtom > LayoutAtomPtr
std::vector< sal_Int32 > maAxis