use insert function instead of for loop
[LibreOffice.git] / xmlsecurity / source / framework / buffernode.hxx
blobf59ae2f8168ad46c35cfeedaf04aec965f6a7117
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 #pragma once
22 #include <com/sun/star/uno/Reference.hxx>
24 #include <memory>
25 #include <vector>
27 namespace com::sun::star::xml::wrapper
29 class XXMLElementWrapper;
32 class ElementMark;
33 class ElementCollector;
35 class BufferNode final
36 /****** buffernode.hxx/CLASS BufferNode ***************************************
38 * NAME
39 * BufferNode -- Class to maintain the tree of buffered elements
41 * FUNCTION
42 * One BufferNode object represents a buffered element in the document
43 * wrapper component.
44 * All BufferNode objects construct a tree which has the same structure
45 * of all buffered elements. That is to say, if one buffered element is
46 * an ancestor of another buffered element, then the corresponding
47 * BufferNode objects are also in ancestor/descendant relationship.
48 * This class is used to manipulate the tree of buffered elements.
49 ******************************************************************************/
51 private:
52 /* the parent BufferNode */
53 BufferNode* m_pParent;
55 /* all child BufferNodes */
56 std::vector<std::unique_ptr<BufferNode>> m_vChildren;
58 /* all ElementCollector holding this BufferNode */
59 std::vector<const ElementCollector*> m_vElementCollectors;
62 * the blocker holding this BufferNode, one BufferNode can have one
63 * blocker at most
65 ElementMark* m_pBlocker;
68 * whether the element has completely buffered by the document wrapper
69 * component
71 bool m_bAllReceived;
73 /* the XMLElementWrapper of the buffered element */
74 css::uno::Reference<css::xml::wrapper::XXMLElementWrapper> m_xXMLElement;
76 private:
77 bool isECInSubTreeIncluded(sal_Int32 nIgnoredSecurityId) const;
78 bool isECOfBeforeModifyInAncestorIncluded(sal_Int32 nIgnoredSecurityId) const;
79 bool isBlockerInSubTreeIncluded(sal_Int32 nIgnoredSecurityId) const;
80 const BufferNode* getNextChild(const BufferNode* pChild) const;
82 public:
83 explicit BufferNode(css::uno::Reference<css::xml::wrapper::XXMLElementWrapper> xXMLElement);
85 bool isECOfBeforeModifyIncluded(sal_Int32 nIgnoredSecurityId) const;
86 void setReceivedAll();
87 bool isAllReceived() const { return m_bAllReceived; }
88 void addElementCollector(const ElementCollector* pElementCollector);
89 void removeElementCollector(const ElementCollector* pElementCollector);
90 ElementMark* getBlocker() const { return m_pBlocker; }
91 void setBlocker(const ElementMark* pBlocker);
92 OUString printChildren() const;
93 bool hasAnything() const;
94 bool hasChildren() const;
95 std::vector<std::unique_ptr<BufferNode>> const& getChildren() const;
96 std::vector<std::unique_ptr<BufferNode>> releaseChildren();
97 const BufferNode* getFirstChild() const;
98 void addChild(std::unique_ptr<BufferNode> pChild, sal_Int32 nPosition);
99 void addChild(std::unique_ptr<BufferNode> pChild);
100 void removeChild(const BufferNode* pChild);
101 sal_Int32 indexOfChild(const BufferNode* pChild) const;
102 const BufferNode* getParent() const { return m_pParent; }
103 void setParent(const BufferNode* pParent);
104 const BufferNode* getNextSibling() const;
105 const BufferNode* isAncestor(const BufferNode* pDescendant) const;
106 bool isPrevious(const BufferNode* pFollowing) const;
107 const BufferNode* getNextNodeByTreeOrder() const;
108 const css::uno::Reference<css::xml::wrapper::XXMLElementWrapper>& getXMLElement() const
110 return m_xXMLElement;
112 void
113 setXMLElement(const css::uno::Reference<css::xml::wrapper::XXMLElementWrapper>& xXMLElement);
114 void notifyBranch();
115 void elementCollectorNotify();
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */