Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / oox / source / drawingml / diagram / layoutatomvisitorbase.hxx
blobff12f82e2f9684ddf11153ba341b2451307dbfb9
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 #ifndef INCLUDED_OOX_SOURCE_DRAWINGML_DIAGRAM_LAYOUTATOMVISITORBASE_HXX
21 #define INCLUDED_OOX_SOURCE_DRAWINGML_DIAGRAM_LAYOUTATOMVISITORBASE_HXX
23 #include <memory>
25 #include <oox/drawingml/shape.hxx>
26 #include "diagram.hxx"
27 #include "diagramlayoutatoms.hxx"
29 namespace oox { namespace drawingml {
31 struct LayoutAtomVisitor
33 virtual ~LayoutAtomVisitor() {}
34 virtual void visit(ConstraintAtom& rAtom) = 0;
35 virtual void visit(AlgAtom& rAtom) = 0;
36 virtual void visit(ForEachAtom& rAtom) = 0;
37 virtual void visit(ConditionAtom& rAtom) = 0;
38 virtual void visit(ChooseAtom& rAtom) = 0;
39 virtual void visit(LayoutNode& rAtom) = 0;
40 virtual void visit(ShapeAtom& rAtom) = 0;
43 // basic visitor implementation that follows if/else and for-each nodes
44 // and keeps track of current position in data tree
45 class LayoutAtomVisitorBase : public LayoutAtomVisitor
47 public:
48 LayoutAtomVisitorBase(const Diagram& rDgm, const dgm::Point* pRootPoint) :
49 mrDgm(rDgm),
50 mpCurrentNode(pRootPoint),
51 mnCurrIdx(0),
52 mnCurrStep(0),
53 mnCurrCnt(0),
54 meLookFor(LAYOUT_NODE)
57 void defaultVisit(LayoutAtom const& rAtom);
59 using LayoutAtomVisitor::visit;
60 virtual void visit(ForEachAtom& rAtom) override;
61 virtual void visit(ConditionAtom& rAtom) override;
62 virtual void visit(ChooseAtom& rAtom) override;
63 virtual void visit(LayoutNode& rAtom) override;
65 protected:
66 const Diagram& mrDgm;
67 const dgm::Point* mpCurrentNode;
68 sal_Int32 mnCurrIdx;
69 sal_Int32 mnCurrStep;
70 sal_Int32 mnCurrCnt;
71 enum {LAYOUT_NODE, CONSTRAINT, ALGORITHM} meLookFor;
74 class ShallowPresNameVisitor : public LayoutAtomVisitorBase
76 public:
77 explicit ShallowPresNameVisitor(const Diagram& rDgm, const dgm::Point* pRootPoint) :
78 LayoutAtomVisitorBase(rDgm, pRootPoint),
79 mnCnt(0)
82 using LayoutAtomVisitorBase::visit;
83 virtual void visit(ConstraintAtom& rAtom) override;
84 virtual void visit(AlgAtom& rAtom) override;
85 virtual void visit(ForEachAtom& rAtom) override;
86 virtual void visit(LayoutNode& rAtom) override;
87 virtual void visit(ShapeAtom& rAtom) override;
89 size_t getCount() const { return mnCnt; }
91 private:
92 size_t mnCnt;
95 } }
97 #endif
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */