fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / oox / source / drawingml / diagram / diagramlayoutatoms.cxx
blob2953660ea4421f6866671e7d205e69d921a495c9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "diagramlayoutatoms.hxx"
22 #include <functional>
23 #include <boost/bind.hpp>
25 #include <basegfx/numeric/ftools.hxx>
27 #include "oox/helper/attributelist.hxx"
28 #include "oox/drawingml/fillproperties.hxx"
29 #include "oox/drawingml/lineproperties.hxx"
30 #include "oox/drawingml/textbody.hxx"
31 #include "oox/drawingml/textparagraph.hxx"
32 #include "oox/drawingml/textrun.hxx"
33 #include "oox/drawingml/customshapeproperties.hxx"
34 #include "layoutnodecontext.hxx"
36 using namespace ::com::sun::star;
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::xml::sax;
39 using namespace ::oox::core;
41 namespace oox { namespace drawingml {
44 IteratorAttr::IteratorAttr( )
45 : mnAxis( 0 )
46 , mnCnt( -1 )
47 , mbHideLastTrans( false )
48 , mnPtType( 0 )
49 , mnSt( 0 )
50 , mnStep( 1 )
54 void IteratorAttr::loadFromXAttr( const Reference< XFastAttributeList >& xAttr )
56 AttributeList attr( xAttr );
57 mnAxis = xAttr->getOptionalValueToken( XML_axis, 0 );
58 mnCnt = attr.getInteger( XML_cnt, -1 );
59 mbHideLastTrans = attr.getBool( XML_hideLastTrans, false );
60 mnPtType = xAttr->getOptionalValueToken( XML_ptType, 0 );
61 mnSt = attr.getInteger( XML_st, 0 );
62 mnStep = attr.getInteger( XML_step, 1 );
67 ConditionAttr::ConditionAttr()
68 : mnFunc( 0 )
69 , mnArg( 0 )
70 , mnOp( 0 )
76 void ConditionAttr::loadFromXAttr( const Reference< XFastAttributeList >& xAttr )
78 mnFunc = xAttr->getOptionalValueToken( XML_func, 0 );
79 // mnArg will be -1 for "none" or any other unknown value
80 mnArg = LayoutNodeContext::tagToVarIdx( xAttr->getOptionalValueToken( XML_arg, XML_none ) );
81 mnOp = xAttr->getOptionalValueToken( XML_op, 0 );
82 msVal = xAttr->getOptionalValue( XML_val );
86 void LayoutAtom::dump(int level)
88 OSL_TRACE( "level = %d - %s of type %s", level,
89 OUSTRING_TO_CSTR( msName ),
90 typeid(*this).name() );
91 const std::vector<LayoutAtomPtr>& pChildren=getChildren();
92 std::for_each( pChildren.begin(), pChildren.end(),
93 boost::bind( &LayoutAtom::dump, _1, level + 1 ) );
97 ForEachAtom::ForEachAtom(const Reference< XFastAttributeList >& xAttributes)
99 maIter.loadFromXAttr(xAttributes);
102 void ForEachAtom::accept( LayoutAtomVisitor& rVisitor )
104 rVisitor.visit(*this);
107 void ChooseAtom::accept( LayoutAtomVisitor& rVisitor )
109 rVisitor.visit(*this);
112 ConditionAtom::ConditionAtom(const Reference< XFastAttributeList >& xAttributes) :
113 mbElse( false )
115 maIter.loadFromXAttr( xAttributes );
116 maCond.loadFromXAttr( xAttributes );
119 const std::vector<LayoutAtomPtr>& ConditionAtom::getChildren() const
121 bool bDecisionVar=true;
122 // HACK
123 if( maCond.mnFunc == XML_var && maCond.mnArg == XML_dir && maCond.mnOp == XML_equ && maCond.msVal != "norm" )
124 bDecisionVar=false;
126 if( bDecisionVar )
127 return mpChildNodes;
128 else
129 return mpElseChildNodes;
132 void ConditionAtom::accept( LayoutAtomVisitor& rVisitor )
134 rVisitor.visit(*this);
137 void ConditionAtom::addChild( const LayoutAtomPtr & pNode )
139 if( mbElse )
140 mpElseChildNodes.push_back( pNode );
141 else
142 mpChildNodes.push_back( pNode );
145 void ConstraintAtom::accept( LayoutAtomVisitor& rVisitor )
147 rVisitor.visit(*this);
150 void AlgAtom::accept( LayoutAtomVisitor& rVisitor )
152 rVisitor.visit(*this);
155 void AlgAtom::layoutShape( const ShapePtr& rShape,
156 const Diagram& /*rDgm*/,
157 const OUString& rName ) const
159 switch(mnType)
161 case XML_composite:
163 if( rShape->getChildren().empty() )
165 rShape->setSize(awt::Size(50,50));
166 break;
169 // just put stuff below each other
170 const sal_Int32 nIncX=0;
171 const sal_Int32 nIncY=1;
173 std::vector<ShapePtr>::const_iterator aCurrShape=rShape->getChildren().begin();
174 const std::vector<ShapePtr>::const_iterator aLastShape=rShape->getChildren().end();
176 // find biggest shape
177 awt::Size aMaxSize;
178 while( aCurrShape != aLastShape )
180 const awt::Size& sz=(*aCurrShape)->getSize();
182 aMaxSize.Width = std::max(
183 aMaxSize.Width,
184 sz.Width);
185 aMaxSize.Height = std::max(
186 aMaxSize.Height,
187 sz.Height);
189 ++aCurrShape;
192 aCurrShape=rShape->getChildren().begin();
193 const awt::Point aStartPos=(*aCurrShape)->getPosition();
194 awt::Point aCurrPos=aStartPos;
195 awt::Size aTotalSize;
196 aTotalSize.Width = aMaxSize.Width;
197 while( aCurrShape != aLastShape )
199 const awt::Size& sz=(*aCurrShape)->getSize();
200 (*aCurrShape)->setPosition(aCurrPos);
201 (*aCurrShape)->setSize(
202 awt::Size(aMaxSize.Width,
203 sz.Height));
205 aTotalSize.Height = std::max(
206 aTotalSize.Height,
207 aCurrPos.Y + sz.Height);
209 aCurrPos.X += nIncX*sz.Width;
210 aCurrPos.Y += nIncY*sz.Height;
212 ++aCurrShape;
215 rShape->setSize(aTotalSize);
216 break;
219 case XML_conn:
220 break;
222 case XML_cycle:
224 if( rShape->getChildren().empty() )
226 rShape->setSize(awt::Size(50,50));
227 break;
230 const sal_Int32 nStartAngle=maMap.count(XML_stAng) ? maMap.find(XML_stAng)->second : 0;
231 const sal_Int32 nSpanAngle=maMap.count(XML_spanAng) ? maMap.find(XML_spanAng)->second : 360;
233 std::vector<ShapePtr>::const_iterator aCurrShape=rShape->getChildren().begin();
234 const std::vector<ShapePtr>::const_iterator aLastShape=rShape->getChildren().end();
235 const sal_Int32 nShapes=aLastShape-aCurrShape;
237 // find biggest shape
238 awt::Size aMaxSize;
239 while( aCurrShape != aLastShape )
241 const awt::Size& sz=(*aCurrShape)->getSize();
243 aMaxSize.Width = std::max(
244 aMaxSize.Width,
245 sz.Width);
246 aMaxSize.Height = std::max(
247 aMaxSize.Height,
248 sz.Height);
250 ++aCurrShape;
253 // layout shapes
254 const sal_Int32 nMaxDim=std::max(aMaxSize.Width,aMaxSize.Height);
255 awt::Size aTotalSize;
256 aCurrShape=rShape->getChildren().begin();
257 for( sal_Int32 i=0; i<nShapes; ++i, ++aCurrShape )
259 const awt::Size& sz=(*aCurrShape)->getSize();
261 const double r=nShapes*nMaxDim/F_2PI * 360.0/nSpanAngle;
262 const awt::Point aCurrPos(
263 r + r*sin( (double(i)*nSpanAngle/nShapes + nStartAngle)*F_PI180 ),
264 r - r*cos( (double(i)*nSpanAngle/nShapes + nStartAngle)*F_PI180 ) );
265 (*aCurrShape)->setPosition(aCurrPos);
267 aTotalSize.Width = std::max(
268 aTotalSize.Width,
269 aCurrPos.X + sz.Width);
270 aTotalSize.Height = std::max(
271 aTotalSize.Height,
272 aCurrPos.Y + sz.Height);
275 rShape->setSize(aTotalSize);
276 break;
279 case XML_hierChild:
280 case XML_hierRoot:
281 break;
283 case XML_lin:
285 if( rShape->getChildren().empty() )
287 rShape->setSize(awt::Size(50,50));
288 break;
291 const sal_Int32 nDir=maMap.count(XML_linDir) ? maMap.find(XML_linDir)->second : XML_fromL;
292 const sal_Int32 nIncX=nDir==XML_fromL ? 1 : (nDir==XML_fromR ? -1 : 0);
293 const sal_Int32 nIncY=nDir==XML_fromT ? 1 : (nDir==XML_fromB ? -1 : 0);
295 std::vector<ShapePtr>::const_iterator aCurrShape=rShape->getChildren().begin();
296 const std::vector<ShapePtr>::const_iterator aLastShape=rShape->getChildren().end();
297 const awt::Point aStartPos=(*aCurrShape)->getPosition();
298 awt::Point aCurrPos=aStartPos;
299 awt::Size aTotalSize;
300 while( aCurrShape != aLastShape )
302 const awt::Size& sz=(*aCurrShape)->getSize();
303 (*aCurrShape)->setPosition(aCurrPos);
305 aTotalSize.Width = std::max(
306 aTotalSize.Width,
307 aCurrPos.X + sz.Width);
308 aTotalSize.Height = std::max(
309 aTotalSize.Height,
310 aCurrPos.Y + sz.Height);
312 // HACK: the spacing is arbitrary
313 aCurrPos.X += nIncX*(sz.Width+5);
314 aCurrPos.Y += nIncY*(sz.Height+5);
316 ++aCurrShape;
319 rShape->setSize(aTotalSize);
320 break;
323 case XML_pyra:
324 case XML_snake:
325 break;
327 case XML_sp:
328 // HACK. Handled one level higher. Or rather, planned to
329 break;
331 case XML_tx:
333 TextBodyPtr pTextBody=rShape->getTextBody();
334 if( !pTextBody ||
335 pTextBody->getParagraphs().empty() ||
336 pTextBody->getParagraphs().front()->getRuns().empty() )
338 rShape->setSize(awt::Size(5,5));
339 break;
342 // HACK - count chars & paragraphs to come up with *some*
343 // notion of necessary size
344 const sal_Int32 nHackyFontHeight=50;
345 const sal_Int32 nHackyFontWidth=20;
346 awt::Size aTotalSize;
347 for( sal_uInt32 nPara=0; nPara<pTextBody->getParagraphs().size(); ++nPara )
349 aTotalSize.Height += nHackyFontHeight;
351 sal_Int32 nLocalWidth=0;
352 for( sal_uInt32 nRun=0; nRun<pTextBody->getParagraphs().at(nPara)->getRuns().size(); ++nRun )
353 nLocalWidth +=
354 pTextBody->getParagraphs().at(nPara)->getRuns().at(nRun)->getText().getLength()
355 * nHackyFontWidth;
357 aTotalSize.Width = std::max(
358 aTotalSize.Width,
359 nLocalWidth);
362 rShape->setSize(aTotalSize);
365 default:
366 break;
369 OSL_TRACE("Layouting shape %s: (%d,%d,%d,%d)",
370 OUSTRING_TO_CSTR( rName ),
371 rShape->getPosition().X,
372 rShape->getPosition().Y,
373 rShape->getSize().Width,
374 rShape->getSize().Height);
377 void LayoutNode::accept( LayoutAtomVisitor& rVisitor )
379 rVisitor.visit(*this);
382 bool LayoutNode::setupShape( const ShapePtr& rShape, const Diagram& rDgm, sal_uInt32 nIdx ) const
384 // find the data node to grab text from
385 DiagramData::PointsNameMap::const_iterator aDataNode=rDgm.getData()->getPointsPresNameMap().find(msName);
386 if( aDataNode != rDgm.getData()->getPointsPresNameMap().end() &&
387 aDataNode->second.size() > nIdx )
389 OSL_TRACE( "Filling content from %d th layout node named \"%s\", modelId \"%s\"",
390 nIdx,
391 OUSTRING_TO_CSTR( msName ),
392 OUSTRING_TO_CSTR( aDataNode->second.at(nIdx)->msModelId ) );
394 // got the presentation node - now, need the actual data node:
395 const DiagramData::StringMap::const_iterator aNodeName=rDgm.getData()->getPresOfNameMap().find(
396 aDataNode->second.at(nIdx)->msModelId);
397 if( aNodeName != rDgm.getData()->getPresOfNameMap().end() )
399 DiagramData::StringMap::value_type::second_type::const_iterator aVecIter=aNodeName->second.begin();
400 const DiagramData::StringMap::value_type::second_type::const_iterator aVecEnd=aNodeName->second.end();
401 while( aVecIter != aVecEnd )
403 DiagramData::PointNameMap::const_iterator aDataNode2=rDgm.getData()->getPointNameMap().find(aVecIter->first);
404 if( aVecIter->second == 0 )
406 // grab shape attr from topmost element(s)
407 rShape->getShapeProperties() = aDataNode2->second->mpShape->getShapeProperties();
408 rShape->getLineProperties() = aDataNode2->second->mpShape->getLineProperties();
409 rShape->getFillProperties() = aDataNode2->second->mpShape->getFillProperties();
410 rShape->getCustomShapeProperties() = aDataNode2->second->mpShape->getCustomShapeProperties();
411 rShape->setMasterTextListStyle( aDataNode2->second->mpShape->getMasterTextListStyle() );
413 OSL_TRACE( "Custom shape with preset type %d added for layout node named \"%s\"",
414 rShape->getCustomShapeProperties()->getShapePresetType(),
415 OUSTRING_TO_CSTR( msName ) );
418 // append text with right outline level
419 if( aDataNode2->second->mpShape->getTextBody() &&
420 !aDataNode2->second->mpShape->getTextBody()->getParagraphs().empty() &&
421 !aDataNode2->second->mpShape->getTextBody()->getParagraphs().front()->getRuns().empty() )
423 TextBodyPtr pTextBody=rShape->getTextBody();
424 if( !pTextBody )
426 pTextBody.reset( new TextBody() );
428 // also copy text attrs
429 pTextBody->getTextListStyle() =
430 aDataNode2->second->mpShape->getTextBody()->getTextListStyle();
431 pTextBody->getTextProperties() =
432 aDataNode2->second->mpShape->getTextBody()->getTextProperties();
434 rShape->setTextBody(pTextBody);
437 TextParagraph& rPara=pTextBody->addParagraph();
438 if( aVecIter->second != -1 )
439 rPara.getProperties().setLevel(aVecIter->second);
441 rPara.addRun(
442 aDataNode2->second->mpShape->getTextBody()->getParagraphs().front()->getRuns().front());
443 rPara.getProperties().apply(
444 aDataNode2->second->mpShape->getTextBody()->getParagraphs().front()->getProperties());
447 ++aVecIter;
450 else
452 OSL_TRACE("ShapeCreationVisitor::visit: no data node name found while processing shape type %d for layout node named \"%s\"",
453 rShape->getCustomShapeProperties()->getShapePresetType(),
454 OUSTRING_TO_CSTR( msName ) );
457 // TODO(Q1): apply styling & coloring - taking
458 // layout node's styleLbl for both style & color
459 // now, but docs are a bit unclear on this
460 if( !msStyleLabel.isEmpty() )
462 OSL_TRACE("setting style with label %s",
463 OUSTRING_TO_CSTR( msStyleLabel ) );
465 const DiagramQStyleMap::const_iterator aStyle=rDgm.getStyles().find(msStyleLabel);
466 if( aStyle != rDgm.getStyles().end() )
468 rShape->getShapeStyleRefs()[XML_fillRef] = aStyle->second.maFillStyle;
469 OSL_TRACE("added fill style with id %d", aStyle->second.maFillStyle.mnThemedIdx);
470 rShape->getShapeStyleRefs()[XML_lnRef] = aStyle->second.maLineStyle;
471 OSL_TRACE("added line style with id %d", aStyle->second.maLineStyle.mnThemedIdx);
472 rShape->getShapeStyleRefs()[XML_effectRef] = aStyle->second.maEffectStyle;
473 OSL_TRACE("added effect style with id %d", aStyle->second.maEffectStyle.mnThemedIdx);
474 rShape->getShapeStyleRefs()[XML_fontRef] = aStyle->second.maTextStyle;
475 OSL_TRACE("added fontref style with id %d", aStyle->second.maTextStyle.mnThemedIdx);
476 Color aColor=aStyle->second.maTextStyle.maPhClr;
477 OSL_TRACE("added fontref color with alpha %d", aColor.getTransparency() );
480 const DiagramColorMap::const_iterator aColor=rDgm.getColors().find(msStyleLabel);
481 if( aColor != rDgm.getColors().end() )
483 const DiagramColor& rColor=aColor->second;
484 if( rColor.maFillColor.isUsed() )
485 rShape->getShapeStyleRefs()[XML_fillRef].maPhClr = rColor.maFillColor;
486 if( rColor.maLineColor.isUsed() )
487 rShape->getShapeStyleRefs()[XML_lnRef].maPhClr = rColor.maLineColor;
488 if( rColor.maEffectColor.isUsed() )
489 rShape->getShapeStyleRefs()[XML_effectRef].maPhClr = rColor.maEffectColor;
490 if( rColor.maTextFillColor.isUsed() )
491 rShape->getShapeStyleRefs()[XML_fontRef].maPhClr = rColor.maTextFillColor;
495 // even if no data node found, successful anyway. it's
496 // contained at the layoutnode
497 return true;
499 else
501 OSL_TRACE("ShapeCreationVisitor::visit: no text found while processing shape type %d for layout node named \"%s\"",
502 rShape->getCustomShapeProperties()->getShapePresetType(),
503 OUSTRING_TO_CSTR( msName ) );
506 return false;
509 ///////////////////////////////////////////////////////////////////////
511 // Visitation
514 class ShapeLayoutingVisitor : public LayoutAtomVisitor
516 ShapePtr mpParentShape;
517 const Diagram& mrDgm;
518 OUString maName;
520 virtual void visit(ConstraintAtom& rAtom);
521 virtual void visit(AlgAtom& rAtom);
522 virtual void visit(ForEachAtom& rAtom);
523 virtual void visit(ConditionAtom& rAtom);
524 virtual void visit(ChooseAtom& rAtom);
525 virtual void visit(LayoutNode& rAtom);
527 public:
528 ShapeLayoutingVisitor(const ShapePtr& rParentShape,
529 const Diagram& rDgm,
530 const OUString& rName) :
531 mpParentShape(rParentShape),
532 mrDgm(rDgm),
533 maName(rName)
536 void defaultVisit(LayoutAtom& rAtom);
539 class ShallowPresNameVisitor : public LayoutAtomVisitor
541 const Diagram& mrDgm;
542 size_t mnCnt;
544 void defaultVisit(LayoutAtom& rAtom);
545 virtual void visit(ConstraintAtom& rAtom);
546 virtual void visit(AlgAtom& rAtom);
547 virtual void visit(ForEachAtom& rAtom);
548 virtual void visit(ConditionAtom& rAtom);
549 virtual void visit(ChooseAtom& rAtom);
550 virtual void visit(LayoutNode& rAtom);
552 public:
553 ShallowPresNameVisitor(const Diagram& rDgm) :
554 mrDgm(rDgm),
555 mnCnt(0)
558 size_t getCount() const
559 { return mnCnt; }
562 void ShapeCreationVisitor::defaultVisit(LayoutAtom& rAtom)
564 const std::vector<LayoutAtomPtr>& pChildren=rAtom.getChildren();
565 std::for_each( pChildren.begin(), pChildren.end(),
566 boost::bind( &LayoutAtom::accept,
568 boost::ref(*this)) );
571 void ShapeCreationVisitor::visit(ConstraintAtom& /*rAtom*/)
573 // TODO: eval the constraints
576 void ShapeCreationVisitor::visit(AlgAtom& rAtom)
578 defaultVisit(rAtom);
581 void ShapeCreationVisitor::visit(ForEachAtom& rAtom)
583 const std::vector<LayoutAtomPtr>& pChildren=rAtom.getChildren();
585 sal_Int32 nChildren=1;
586 if( rAtom.iterator().mnPtType == XML_node )
588 // cound child data nodes - check all child Atoms for "name"
589 // attribute that is contained in diagram's
590 // getPointsPresNameMap()
591 ShallowPresNameVisitor aVisitor(mrDgm);
592 std::for_each( pChildren.begin(), pChildren.end(),
593 boost::bind( &LayoutAtom::accept,
595 boost::ref(aVisitor)) );
596 nChildren = aVisitor.getCount();
599 const sal_Int32 nCnt = std::min(
600 nChildren,
601 rAtom.iterator().mnCnt==-1 ? nChildren : rAtom.iterator().mnCnt);
603 const sal_Int32 nOldIdx=mnCurrIdx;
604 const sal_Int32 nStep=rAtom.iterator().mnStep;
605 for( mnCurrIdx=0; mnCurrIdx<nCnt && nStep>0; mnCurrIdx+=nStep )
607 // TODO there is likely some conditions
608 std::for_each( pChildren.begin(), pChildren.end(),
609 boost::bind( &LayoutAtom::accept,
611 boost::ref(*this)) );
614 // and restore idx
615 mnCurrIdx = nOldIdx;
618 void ShapeCreationVisitor::visit(ConditionAtom& rAtom)
620 defaultVisit(rAtom);
623 void ShapeCreationVisitor::visit(ChooseAtom& rAtom)
625 defaultVisit(rAtom);
628 void ShapeCreationVisitor::visit(LayoutNode& rAtom)
630 ShapePtr pCurrParent(mpParentShape);
631 ShapePtr pCurrShape(rAtom.getShape());
632 if( pCurrShape )
634 OSL_TRACE("ShapeCreationVisitor::visit: processing shape type %d",
635 pCurrShape->getCustomShapeProperties()->getShapePresetType() );
637 // TODO(F3): cloned shape shares all properties by reference,
638 // don't change them!
639 ShapePtr pClonedShape(
640 new Shape( pCurrShape ));
642 if( rAtom.setupShape(pClonedShape, mrDgm, mnCurrIdx) )
644 pCurrParent->addChild(pClonedShape);
645 pCurrParent = pClonedShape;
648 else
650 OSL_TRACE("ShapeCreationVisitor::visit: no shape set while processing layoutnode named %s",
651 OUSTRING_TO_CSTR( rAtom.getName() ) );
654 // set new parent for children
655 ShapePtr pPreviousParent(mpParentShape);
656 mpParentShape=pCurrParent;
658 // process children
659 defaultVisit(rAtom);
661 // restore parent
662 mpParentShape=pPreviousParent;
664 // layout shapes - now all child shapes are created
665 ShapeLayoutingVisitor aLayoutingVisitor(pCurrParent,
666 mrDgm,
667 rAtom.getName());
668 aLayoutingVisitor.defaultVisit(rAtom);
671 void ShapeLayoutingVisitor::defaultVisit(LayoutAtom& rAtom)
673 // visit all children, one of them need to be the layout algoritm
674 const std::vector<LayoutAtomPtr>& pChildren=rAtom.getChildren();
675 std::for_each( pChildren.begin(), pChildren.end(),
676 boost::bind( &LayoutAtom::accept,
678 boost::ref(*this)) );
681 void ShapeLayoutingVisitor::visit(ConstraintAtom& /*rAtom*/)
683 // stop processing
686 void ShapeLayoutingVisitor::visit(AlgAtom& rAtom)
688 rAtom.layoutShape(mpParentShape,mrDgm,maName);
691 void ShapeLayoutingVisitor::visit(ForEachAtom& /*rAtom*/)
693 // stop processing
696 void ShapeLayoutingVisitor::visit(ConditionAtom& rAtom)
698 defaultVisit(rAtom);
701 void ShapeLayoutingVisitor::visit(ChooseAtom& rAtom)
703 defaultVisit(rAtom);
706 void ShapeLayoutingVisitor::visit(LayoutNode& /*rAtom*/)
708 // stop processing - only traverse Condition/Choose atoms
711 void ShallowPresNameVisitor::defaultVisit(LayoutAtom& rAtom)
713 // visit all children, at least one of them needs to have proper
714 // name set
715 const std::vector<LayoutAtomPtr>& pChildren=rAtom.getChildren();
716 std::for_each( pChildren.begin(), pChildren.end(),
717 boost::bind( &LayoutAtom::accept,
719 boost::ref(*this)) );
722 void ShallowPresNameVisitor::visit(ConstraintAtom& /*rAtom*/)
724 // stop processing
727 void ShallowPresNameVisitor::visit(AlgAtom& /*rAtom*/)
729 // stop processing
732 void ShallowPresNameVisitor::visit(ForEachAtom& rAtom)
734 defaultVisit(rAtom);
737 void ShallowPresNameVisitor::visit(ConditionAtom& rAtom)
739 defaultVisit(rAtom);
742 void ShallowPresNameVisitor::visit(ChooseAtom& rAtom)
744 defaultVisit(rAtom);
747 void ShallowPresNameVisitor::visit(LayoutNode& rAtom)
749 DiagramData::PointsNameMap::const_iterator aDataNode=
750 mrDgm.getData()->getPointsPresNameMap().find(rAtom.getName());
751 if( aDataNode != mrDgm.getData()->getPointsPresNameMap().end() )
752 mnCnt = std::max(mnCnt,
753 aDataNode->second.size());
758 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */