fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / oox / source / drawingml / diagram / diagramlayoutatoms.cxx
blob8edffb9dd2aa6d25ca48eedca6d56122e3564a7d
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 <osl/diagnose.h>
26 #include <basegfx/numeric/ftools.hxx>
28 #include "oox/helper/attributelist.hxx"
29 #include "oox/drawingml/fillproperties.hxx"
30 #include "oox/drawingml/lineproperties.hxx"
31 #include "drawingml/textbody.hxx"
32 #include "drawingml/textparagraph.hxx"
33 #include "drawingml/textrun.hxx"
34 #include "drawingml/customshapeproperties.hxx"
35 #include "layoutnodecontext.hxx"
37 using namespace ::com::sun::star;
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::xml::sax;
40 using namespace ::oox::core;
42 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 );
65 ConditionAttr::ConditionAttr()
66 : mnFunc( 0 )
67 , mnArg( 0 )
68 , mnOp( 0 )
73 void ConditionAttr::loadFromXAttr( const Reference< XFastAttributeList >& xAttr )
75 mnFunc = xAttr->getOptionalValueToken( XML_func, 0 );
76 // mnArg will be -1 for "none" or any other unknown value
77 mnArg = LayoutNodeContext::tagToVarIdx( xAttr->getOptionalValueToken( XML_arg, XML_none ) );
78 mnOp = xAttr->getOptionalValueToken( XML_op, 0 );
79 msVal = xAttr->getOptionalValue( XML_val );
82 void LayoutAtom::dump(int level)
84 OSL_TRACE( "level = %d - %s of type %s", level,
85 OUSTRING_TO_CSTR( msName ),
86 typeid(*this).name() );
87 const std::vector<LayoutAtomPtr>& pChildren=getChildren();
88 std::for_each( pChildren.begin(), pChildren.end(),
89 boost::bind( &LayoutAtom::dump, _1, level + 1 ) );
92 ForEachAtom::ForEachAtom(const Reference< XFastAttributeList >& xAttributes)
94 maIter.loadFromXAttr(xAttributes);
97 void ForEachAtom::accept( LayoutAtomVisitor& rVisitor )
99 rVisitor.visit(*this);
102 void ChooseAtom::accept( LayoutAtomVisitor& rVisitor )
104 rVisitor.visit(*this);
107 ConditionAtom::ConditionAtom(const Reference< XFastAttributeList >& xAttributes) :
108 mbElse( false )
110 maIter.loadFromXAttr( xAttributes );
111 maCond.loadFromXAttr( xAttributes );
114 const std::vector<LayoutAtomPtr>& ConditionAtom::getChildren() const
116 bool bDecisionVar=true;
117 // HACK
118 if( maCond.mnFunc == XML_var && maCond.mnArg == XML_dir && maCond.mnOp == XML_equ && maCond.msVal != "norm" )
119 bDecisionVar=false;
121 if( bDecisionVar )
122 return mpChildNodes;
123 else
124 return mpElseChildNodes;
127 void ConditionAtom::accept( LayoutAtomVisitor& rVisitor )
129 rVisitor.visit(*this);
132 void ConditionAtom::addChild( const LayoutAtomPtr & pNode )
134 if( mbElse )
135 mpElseChildNodes.push_back( pNode );
136 else
137 mpChildNodes.push_back( pNode );
140 void ConstraintAtom::accept( LayoutAtomVisitor& rVisitor )
142 rVisitor.visit(*this);
145 void AlgAtom::accept( LayoutAtomVisitor& rVisitor )
147 rVisitor.visit(*this);
150 void AlgAtom::layoutShape( const ShapePtr& rShape,
151 const Diagram& /*rDgm*/,
152 const OUString& rName ) const
154 switch(mnType)
156 case XML_composite:
158 if( rShape->getChildren().empty() )
160 rShape->setSize(awt::Size(50,50));
161 break;
164 // just put stuff below each other
165 const sal_Int32 nIncX=0;
166 const sal_Int32 nIncY=1;
168 std::vector<ShapePtr>::const_iterator aCurrShape=rShape->getChildren().begin();
169 const std::vector<ShapePtr>::const_iterator aLastShape=rShape->getChildren().end();
171 // find biggest shape
172 awt::Size aMaxSize;
173 while( aCurrShape != aLastShape )
175 const awt::Size& sz=(*aCurrShape)->getSize();
177 aMaxSize.Width = std::max(
178 aMaxSize.Width,
179 sz.Width);
180 aMaxSize.Height = std::max(
181 aMaxSize.Height,
182 sz.Height);
184 ++aCurrShape;
187 aCurrShape=rShape->getChildren().begin();
188 const awt::Point aStartPos=(*aCurrShape)->getPosition();
189 awt::Point aCurrPos=aStartPos;
190 awt::Size aTotalSize;
191 aTotalSize.Width = aMaxSize.Width;
192 while( aCurrShape != aLastShape )
194 const awt::Size& sz=(*aCurrShape)->getSize();
195 (*aCurrShape)->setPosition(aCurrPos);
196 (*aCurrShape)->setSize(
197 awt::Size(aMaxSize.Width,
198 sz.Height));
200 aTotalSize.Height = std::max(
201 aTotalSize.Height,
202 aCurrPos.Y + sz.Height);
204 aCurrPos.X += nIncX*sz.Width;
205 aCurrPos.Y += nIncY*sz.Height;
207 ++aCurrShape;
210 rShape->setSize(aTotalSize);
211 break;
214 case XML_conn:
215 break;
217 case XML_cycle:
219 if( rShape->getChildren().empty() )
221 rShape->setSize(awt::Size(50,50));
222 break;
225 const sal_Int32 nStartAngle=maMap.count(XML_stAng) ? maMap.find(XML_stAng)->second : 0;
226 const sal_Int32 nSpanAngle=maMap.count(XML_spanAng) ? maMap.find(XML_spanAng)->second : 360;
228 std::vector<ShapePtr>::const_iterator aCurrShape=rShape->getChildren().begin();
229 const std::vector<ShapePtr>::const_iterator aLastShape=rShape->getChildren().end();
230 const sal_Int32 nShapes=aLastShape-aCurrShape;
232 // find biggest shape
233 awt::Size aMaxSize;
234 while( aCurrShape != aLastShape )
236 const awt::Size& sz=(*aCurrShape)->getSize();
238 aMaxSize.Width = std::max(
239 aMaxSize.Width,
240 sz.Width);
241 aMaxSize.Height = std::max(
242 aMaxSize.Height,
243 sz.Height);
245 ++aCurrShape;
248 // layout shapes
249 const sal_Int32 nMaxDim=std::max(aMaxSize.Width,aMaxSize.Height);
250 awt::Size aTotalSize;
251 aCurrShape=rShape->getChildren().begin();
252 for( sal_Int32 i=0; i<nShapes; ++i, ++aCurrShape )
254 const awt::Size& sz=(*aCurrShape)->getSize();
256 const double r=nShapes*nMaxDim/F_2PI * 360.0/nSpanAngle;
257 const awt::Point aCurrPos(
258 r + r*sin( (double(i)*nSpanAngle/nShapes + nStartAngle)*F_PI180 ),
259 r - r*cos( (double(i)*nSpanAngle/nShapes + nStartAngle)*F_PI180 ) );
260 (*aCurrShape)->setPosition(aCurrPos);
262 aTotalSize.Width = std::max(
263 aTotalSize.Width,
264 aCurrPos.X + sz.Width);
265 aTotalSize.Height = std::max(
266 aTotalSize.Height,
267 aCurrPos.Y + sz.Height);
270 rShape->setSize(aTotalSize);
271 break;
274 case XML_hierChild:
275 case XML_hierRoot:
276 break;
278 case XML_lin:
280 if( rShape->getChildren().empty() )
282 rShape->setSize(awt::Size(50,50));
283 break;
286 const sal_Int32 nDir=maMap.count(XML_linDir) ? maMap.find(XML_linDir)->second : XML_fromL;
287 const sal_Int32 nIncX=nDir==XML_fromL ? 1 : (nDir==XML_fromR ? -1 : 0);
288 const sal_Int32 nIncY=nDir==XML_fromT ? 1 : (nDir==XML_fromB ? -1 : 0);
290 std::vector<ShapePtr>::const_iterator aCurrShape=rShape->getChildren().begin();
291 const std::vector<ShapePtr>::const_iterator aLastShape=rShape->getChildren().end();
292 const awt::Point aStartPos=(*aCurrShape)->getPosition();
293 awt::Point aCurrPos=aStartPos;
294 awt::Size aTotalSize;
295 while( aCurrShape != aLastShape )
297 const awt::Size& sz=(*aCurrShape)->getSize();
298 (*aCurrShape)->setPosition(aCurrPos);
300 aTotalSize.Width = std::max(
301 aTotalSize.Width,
302 aCurrPos.X + sz.Width);
303 aTotalSize.Height = std::max(
304 aTotalSize.Height,
305 aCurrPos.Y + sz.Height);
307 // HACK: the spacing is arbitrary
308 aCurrPos.X += nIncX*(sz.Width+5);
309 aCurrPos.Y += nIncY*(sz.Height+5);
311 ++aCurrShape;
314 rShape->setSize(aTotalSize);
315 break;
318 case XML_pyra:
319 case XML_snake:
320 break;
322 case XML_sp:
323 // HACK. Handled one level higher. Or rather, planned to
324 break;
326 case XML_tx:
328 TextBodyPtr pTextBody=rShape->getTextBody();
329 if( !pTextBody ||
330 pTextBody->getParagraphs().empty() ||
331 pTextBody->getParagraphs().front()->getRuns().empty() )
333 rShape->setSize(awt::Size(5,5));
334 break;
337 // HACK - count chars & paragraphs to come up with *some*
338 // notion of necessary size
339 const sal_Int32 nHackyFontHeight=50;
340 const sal_Int32 nHackyFontWidth=20;
341 awt::Size aTotalSize;
342 for( sal_uInt32 nPara=0; nPara<pTextBody->getParagraphs().size(); ++nPara )
344 aTotalSize.Height += nHackyFontHeight;
346 sal_Int32 nLocalWidth=0;
347 for( sal_uInt32 nRun=0; nRun<pTextBody->getParagraphs().at(nPara)->getRuns().size(); ++nRun )
348 nLocalWidth +=
349 pTextBody->getParagraphs().at(nPara)->getRuns().at(nRun)->getText().getLength()
350 * nHackyFontWidth;
352 aTotalSize.Width = std::max(
353 aTotalSize.Width,
354 nLocalWidth);
357 rShape->setSize(aTotalSize);
360 default:
361 break;
364 SAL_INFO(
365 "oox.drawingml",
366 "Layouting shape " << rName << ": (" << rShape->getPosition().X << ","
367 << rShape->getPosition().Y << "," << rShape->getSize().Width << ","
368 << rShape->getSize().Height << ")");
371 void LayoutNode::accept( LayoutAtomVisitor& rVisitor )
373 rVisitor.visit(*this);
376 bool LayoutNode::setupShape( const ShapePtr& rShape, const Diagram& rDgm, sal_uInt32 nIdx ) const
378 // find the data node to grab text from
379 DiagramData::PointsNameMap::const_iterator aDataNode=rDgm.getData()->getPointsPresNameMap().find(msName);
380 if( aDataNode != rDgm.getData()->getPointsPresNameMap().end() &&
381 aDataNode->second.size() > nIdx )
383 SAL_INFO(
384 "oox.drawingml",
385 "Filling content from " << nIdx << "th layout node named \""
386 << msName << "\", modelId \""
387 << aDataNode->second.at(nIdx)->msModelId << "\"");
389 // got the presentation node - now, need the actual data node:
390 const DiagramData::StringMap::const_iterator aNodeName=rDgm.getData()->getPresOfNameMap().find(
391 aDataNode->second.at(nIdx)->msModelId);
392 if( aNodeName != rDgm.getData()->getPresOfNameMap().end() )
394 DiagramData::StringMap::value_type::second_type::const_iterator aVecIter=aNodeName->second.begin();
395 const DiagramData::StringMap::value_type::second_type::const_iterator aVecEnd=aNodeName->second.end();
396 while( aVecIter != aVecEnd )
398 DiagramData::PointNameMap& rMap = rDgm.getData()->getPointNameMap();
399 DiagramData::PointNameMap::const_iterator aDataNode2 = rMap.find(aVecIter->first);
400 if (aDataNode2 == rMap.end())
402 //busted, skip it
403 ++aVecIter;
404 continue;
407 if( aVecIter->second == 0 )
409 // grab shape attr from topmost element(s)
410 rShape->getShapeProperties() = aDataNode2->second->mpShape->getShapeProperties();
411 rShape->getLineProperties() = aDataNode2->second->mpShape->getLineProperties();
412 rShape->getFillProperties() = aDataNode2->second->mpShape->getFillProperties();
413 rShape->getCustomShapeProperties() = aDataNode2->second->mpShape->getCustomShapeProperties();
414 rShape->setMasterTextListStyle( aDataNode2->second->mpShape->getMasterTextListStyle() );
416 SAL_INFO(
417 "oox.drawingml",
418 "Custom shape with preset type "
419 << (rShape->getCustomShapeProperties()
420 ->getShapePresetType())
421 << " added for layout node named \"" << msName
422 << "\"");
425 // append text with right outline level
426 if( aDataNode2->second->mpShape->getTextBody() &&
427 !aDataNode2->second->mpShape->getTextBody()->getParagraphs().empty() &&
428 !aDataNode2->second->mpShape->getTextBody()->getParagraphs().front()->getRuns().empty() )
430 TextBodyPtr pTextBody=rShape->getTextBody();
431 if( !pTextBody )
433 pTextBody.reset( new TextBody() );
435 // also copy text attrs
436 pTextBody->getTextListStyle() =
437 aDataNode2->second->mpShape->getTextBody()->getTextListStyle();
438 pTextBody->getTextProperties() =
439 aDataNode2->second->mpShape->getTextBody()->getTextProperties();
441 rShape->setTextBody(pTextBody);
444 TextParagraph& rPara=pTextBody->addParagraph();
445 if( aVecIter->second != -1 )
446 rPara.getProperties().setLevel(aVecIter->second);
448 rPara.addRun(
449 aDataNode2->second->mpShape->getTextBody()->getParagraphs().front()->getRuns().front());
450 rPara.getProperties().apply(
451 aDataNode2->second->mpShape->getTextBody()->getParagraphs().front()->getProperties());
454 ++aVecIter;
457 else
459 SAL_INFO(
460 "oox.drawingml",
461 "ShapeCreationVisitor::visit: no data node name found while"
462 " processing shape type "
463 << rShape->getCustomShapeProperties()->getShapePresetType()
464 << " for layout node named \"" << msName << "\"");
467 // TODO(Q1): apply styling & coloring - taking
468 // layout node's styleLbl for both style & color
469 // now, but docs are a bit unclear on this
470 if( !msStyleLabel.isEmpty() )
472 SAL_INFO(
473 "oox.drawingml", "setting style with label " << msStyleLabel);
475 const DiagramQStyleMap::const_iterator aStyle=rDgm.getStyles().find(msStyleLabel);
476 if( aStyle != rDgm.getStyles().end() )
478 rShape->getShapeStyleRefs()[XML_fillRef] = aStyle->second.maFillStyle;
479 SAL_INFO(
480 "oox.drawingml",
481 "added fill style with id "
482 << aStyle->second.maFillStyle.mnThemedIdx);
483 rShape->getShapeStyleRefs()[XML_lnRef] = aStyle->second.maLineStyle;
484 SAL_INFO(
485 "oox.drawingml",
486 "added line style with id "
487 << aStyle->second.maLineStyle.mnThemedIdx);
488 rShape->getShapeStyleRefs()[XML_effectRef] = aStyle->second.maEffectStyle;
489 SAL_INFO(
490 "oox.drawingml",
491 "added effect style with id "
492 << aStyle->second.maEffectStyle.mnThemedIdx);
493 rShape->getShapeStyleRefs()[XML_fontRef] = aStyle->second.maTextStyle;
494 SAL_INFO(
495 "oox.drawingml",
496 "added fontref style with id "
497 << aStyle->second.maTextStyle.mnThemedIdx);
498 Color aColor=aStyle->second.maTextStyle.maPhClr;
499 OSL_TRACE("added fontref color with alpha %d", aColor.getTransparency() );
502 const DiagramColorMap::const_iterator aColor=rDgm.getColors().find(msStyleLabel);
503 if( aColor != rDgm.getColors().end() )
505 const DiagramColor& rColor=aColor->second;
506 if( rColor.maFillColor.isUsed() )
507 rShape->getShapeStyleRefs()[XML_fillRef].maPhClr = rColor.maFillColor;
508 if( rColor.maLineColor.isUsed() )
509 rShape->getShapeStyleRefs()[XML_lnRef].maPhClr = rColor.maLineColor;
510 if( rColor.maEffectColor.isUsed() )
511 rShape->getShapeStyleRefs()[XML_effectRef].maPhClr = rColor.maEffectColor;
512 if( rColor.maTextFillColor.isUsed() )
513 rShape->getShapeStyleRefs()[XML_fontRef].maPhClr = rColor.maTextFillColor;
517 // even if no data node found, successful anyway. it's
518 // contained at the layoutnode
519 return true;
521 else
523 SAL_INFO(
524 "oox.drawingml",
525 "no text found while processing shape type "
526 << rShape->getCustomShapeProperties()->getShapePresetType()
527 << " for layout node named \"" << msName << "\"");
530 return false;
533 // Visitation
535 class ShapeLayoutingVisitor : public LayoutAtomVisitor
537 ShapePtr mpParentShape;
538 const Diagram& mrDgm;
539 OUString maName;
541 virtual void visit(ConstraintAtom& rAtom) SAL_OVERRIDE;
542 virtual void visit(AlgAtom& rAtom) SAL_OVERRIDE;
543 virtual void visit(ForEachAtom& rAtom) SAL_OVERRIDE;
544 virtual void visit(ConditionAtom& rAtom) SAL_OVERRIDE;
545 virtual void visit(ChooseAtom& rAtom) SAL_OVERRIDE;
546 virtual void visit(LayoutNode& rAtom) SAL_OVERRIDE;
548 public:
549 ShapeLayoutingVisitor(const ShapePtr& rParentShape,
550 const Diagram& rDgm,
551 const OUString& rName) :
552 mpParentShape(rParentShape),
553 mrDgm(rDgm),
554 maName(rName)
557 void defaultVisit(LayoutAtom& rAtom);
560 class ShallowPresNameVisitor : public LayoutAtomVisitor
562 const Diagram& mrDgm;
563 size_t mnCnt;
565 void defaultVisit(LayoutAtom& rAtom);
566 virtual void visit(ConstraintAtom& rAtom) SAL_OVERRIDE;
567 virtual void visit(AlgAtom& rAtom) SAL_OVERRIDE;
568 virtual void visit(ForEachAtom& rAtom) SAL_OVERRIDE;
569 virtual void visit(ConditionAtom& rAtom) SAL_OVERRIDE;
570 virtual void visit(ChooseAtom& rAtom) SAL_OVERRIDE;
571 virtual void visit(LayoutNode& rAtom) SAL_OVERRIDE;
573 public:
574 explicit ShallowPresNameVisitor(const Diagram& rDgm) :
575 mrDgm(rDgm),
576 mnCnt(0)
579 size_t getCount() const
580 { return mnCnt; }
583 void ShapeCreationVisitor::defaultVisit(LayoutAtom& rAtom)
585 const std::vector<LayoutAtomPtr>& pChildren=rAtom.getChildren();
586 std::for_each( pChildren.begin(), pChildren.end(),
587 boost::bind( &LayoutAtom::accept,
589 boost::ref(*this)) );
592 void ShapeCreationVisitor::visit(ConstraintAtom& /*rAtom*/)
594 // TODO: eval the constraints
597 void ShapeCreationVisitor::visit(AlgAtom& rAtom)
599 defaultVisit(rAtom);
602 void ShapeCreationVisitor::visit(ForEachAtom& rAtom)
604 const std::vector<LayoutAtomPtr>& pChildren=rAtom.getChildren();
606 sal_Int32 nChildren=1;
607 if( rAtom.iterator().mnPtType == XML_node )
609 // cound child data nodes - check all child Atoms for "name"
610 // attribute that is contained in diagram's
611 // getPointsPresNameMap()
612 ShallowPresNameVisitor aVisitor(mrDgm);
613 std::for_each( pChildren.begin(), pChildren.end(),
614 boost::bind( &LayoutAtom::accept,
616 boost::ref(aVisitor)) );
617 nChildren = aVisitor.getCount();
620 const sal_Int32 nCnt = std::min(
621 nChildren,
622 rAtom.iterator().mnCnt==-1 ? nChildren : rAtom.iterator().mnCnt);
624 const sal_Int32 nOldIdx=mnCurrIdx;
625 const sal_Int32 nStep=rAtom.iterator().mnStep;
626 for( mnCurrIdx=0; mnCurrIdx<nCnt && nStep>0; mnCurrIdx+=nStep )
628 // TODO there is likely some conditions
629 std::for_each( pChildren.begin(), pChildren.end(),
630 boost::bind( &LayoutAtom::accept,
632 boost::ref(*this)) );
635 // and restore idx
636 mnCurrIdx = nOldIdx;
639 void ShapeCreationVisitor::visit(ConditionAtom& rAtom)
641 defaultVisit(rAtom);
644 void ShapeCreationVisitor::visit(ChooseAtom& rAtom)
646 defaultVisit(rAtom);
649 void ShapeCreationVisitor::visit(LayoutNode& rAtom)
651 ShapePtr pCurrParent(mpParentShape);
652 ShapePtr pCurrShape(rAtom.getShape());
653 if( pCurrShape )
655 SAL_INFO(
656 "oox.drawingml",
657 "processing shape type "
658 << (pCurrShape->getCustomShapeProperties()
659 ->getShapePresetType()));
661 // TODO(F3): cloned shape shares all properties by reference,
662 // don't change them!
663 ShapePtr pClonedShape(
664 new Shape( pCurrShape ));
666 if( rAtom.setupShape(pClonedShape, mrDgm, mnCurrIdx) )
668 pCurrParent->addChild(pClonedShape);
669 pCurrParent = pClonedShape;
672 else
674 OSL_TRACE("ShapeCreationVisitor::visit: no shape set while processing layoutnode named %s",
675 OUSTRING_TO_CSTR( rAtom.getName() ) );
678 // set new parent for children
679 ShapePtr pPreviousParent(mpParentShape);
680 mpParentShape=pCurrParent;
682 // process children
683 defaultVisit(rAtom);
685 // restore parent
686 mpParentShape=pPreviousParent;
688 // layout shapes - now all child shapes are created
689 ShapeLayoutingVisitor aLayoutingVisitor(pCurrParent,
690 mrDgm,
691 rAtom.getName());
692 aLayoutingVisitor.defaultVisit(rAtom);
695 void ShapeLayoutingVisitor::defaultVisit(LayoutAtom& rAtom)
697 // visit all children, one of them needs to be the layout algorithm
698 const std::vector<LayoutAtomPtr>& pChildren=rAtom.getChildren();
699 std::for_each( pChildren.begin(), pChildren.end(),
700 boost::bind( &LayoutAtom::accept,
702 boost::ref(*this)) );
705 void ShapeLayoutingVisitor::visit(ConstraintAtom& /*rAtom*/)
707 // stop processing
710 void ShapeLayoutingVisitor::visit(AlgAtom& rAtom)
712 rAtom.layoutShape(mpParentShape,mrDgm,maName);
715 void ShapeLayoutingVisitor::visit(ForEachAtom& /*rAtom*/)
717 // stop processing
720 void ShapeLayoutingVisitor::visit(ConditionAtom& rAtom)
722 defaultVisit(rAtom);
725 void ShapeLayoutingVisitor::visit(ChooseAtom& rAtom)
727 defaultVisit(rAtom);
730 void ShapeLayoutingVisitor::visit(LayoutNode& /*rAtom*/)
732 // stop processing - only traverse Condition/Choose atoms
735 void ShallowPresNameVisitor::defaultVisit(LayoutAtom& rAtom)
737 // visit all children, at least one of them needs to have proper
738 // name set
739 const std::vector<LayoutAtomPtr>& pChildren=rAtom.getChildren();
740 std::for_each( pChildren.begin(), pChildren.end(),
741 boost::bind( &LayoutAtom::accept,
743 boost::ref(*this)) );
746 void ShallowPresNameVisitor::visit(ConstraintAtom& /*rAtom*/)
748 // stop processing
751 void ShallowPresNameVisitor::visit(AlgAtom& /*rAtom*/)
753 // stop processing
756 void ShallowPresNameVisitor::visit(ForEachAtom& rAtom)
758 defaultVisit(rAtom);
761 void ShallowPresNameVisitor::visit(ConditionAtom& rAtom)
763 defaultVisit(rAtom);
766 void ShallowPresNameVisitor::visit(ChooseAtom& rAtom)
768 defaultVisit(rAtom);
771 void ShallowPresNameVisitor::visit(LayoutNode& rAtom)
773 DiagramData::PointsNameMap::const_iterator aDataNode=
774 mrDgm.getData()->getPointsPresNameMap().find(rAtom.getName());
775 if( aDataNode != mrDgm.getData()->getPointsPresNameMap().end() )
776 mnCnt = std::max(mnCnt,
777 aDataNode->second.size());
782 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */