xref: /AOO41X/main/xmlsecurity/source/framework/buffernode.hxx (revision ec61c6ed669d81c7df08233ccc38d0040f129ece)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _BUFFERNODE_HXX
25 #define _BUFFERNODE_HXX
26 
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
29 
30 #ifndef INCLUDED_VECTOR
31 #include <vector>
32 #define INCLUDED_VECTOR
33 #endif
34 
35 class ElementMark;
36 class ElementCollector;
37 
38 class BufferNode
39 /****** buffernode.hxx/CLASS BufferNode ***************************************
40  *
41  *   NAME
42  *  BufferNode -- Class to maintain the tree of bufferred elements
43  *
44  *   FUNCTION
45  *  One BufferNode object represents a bufferred element in the document
46  *  wrapper component.
47  *  All BufferNode objects construct a tree which has the same structure
48  *  of all bufferred elements. That is to say, if one bufferred element is
49  *  an ancestor of another bufferred element, then the corresponding
50  *  BufferNode objects are also in ancestor/descendant relationship.
51  *  This class is used to manipulate the tree of bufferred elements.
52  *
53  *   HISTORY
54  *  05.01.2004 -    implemented
55  *
56  *   AUTHOR
57  *  Michael Mi
58  *  Email: michael.mi@sun.com
59  ******************************************************************************/
60 {
61 private:
62     /* the parent BufferNode */
63     BufferNode* m_pParent;
64 
65     /* all child BufferNodes */
66     std::vector< const BufferNode* > m_vChildren;
67 
68     /* all ElementCollector holding this BufferNode */
69     std::vector< const ElementCollector* > m_vElementCollectors;
70 
71     /*
72      * the blocker holding this BufferNode, one BufferNode can have one
73      * blocker at most
74      */
75     ElementMark* m_pBlocker;
76 
77     /*
78      * whether the element has completely bufferred by the document wrapper
79      * component
80      */
81     bool m_bAllReceived;
82 
83     /* the XMLElementWrapper of the bufferred element */
84     com::sun::star::uno::Reference<
85         com::sun::star::xml::wrapper::XXMLElementWrapper > m_xXMLElement;
86 
87 private:
88     bool isECInSubTreeIncluded(sal_Int32 nIgnoredSecurityId) const;
89     bool isECOfBeforeModifyInAncestorIncluded(sal_Int32 nIgnoredSecurityId) const;
90     bool isBlockerInSubTreeIncluded(sal_Int32 nIgnoredSecurityId) const;
91     const BufferNode* getNextChild(const BufferNode* pChild) const;
92 
93 public:
94     explicit BufferNode(
95         const com::sun::star::uno::Reference<
96             com::sun::star::xml::wrapper::XXMLElementWrapper >& xXMLElement);
~BufferNode()97     virtual ~BufferNode() {};
98 
99     bool isECOfBeforeModifyIncluded(sal_Int32 nIgnoredSecurityId) const;
100         void setReceivedAll();
101         bool isAllReceived() const;
102     void addElementCollector(const ElementCollector* pElementCollector);
103     void removeElementCollector(const ElementCollector* pElementCollector);
104     ElementMark* getBlocker() const;
105     void setBlocker(const ElementMark* pBlocker);
106     rtl::OUString printChildren() const;
107     bool hasAnything() const;
108     bool hasChildren() const;
109     std::vector< const BufferNode* >* getChildren() const;
110     const BufferNode* getFirstChild() const;
111     void addChild(const BufferNode* pChild, sal_Int32 nPosition);
112     void addChild(const BufferNode* pChild);
113     void removeChild(const BufferNode* pChild);
114     sal_Int32 indexOfChild(const BufferNode* pChild) const;
115     const BufferNode* childAt(sal_Int32 nIndex) const;
116     const BufferNode* getParent() const;
117     void setParent(const BufferNode* pParent);
118     const BufferNode* getNextSibling() const;
119     const BufferNode* isAncestor(const BufferNode* pDescendant) const;
120     bool isPrevious(const BufferNode* pFollowing) const;
121     const BufferNode* getNextNodeByTreeOrder() const;
122     com::sun::star::uno::Reference<
123         com::sun::star::xml::wrapper::XXMLElementWrapper > getXMLElement() const;
124     void setXMLElement(const com::sun::star::uno::Reference<
125         com::sun::star::xml::wrapper::XXMLElementWrapper >& xXMLElement);
126     void notifyBranch();
127     void notifyAncestor();
128     void elementCollectorNotify();
129     void freeAllChildren();
130 };
131 
132 #endif
133 
134