Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _BUFFERNODE_HXX
21 : #define _BUFFERNODE_HXX
22 :
23 : #include <com/sun/star/lang/XServiceInfo.hpp>
24 : #include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp>
25 :
26 : #include <vector>
27 :
28 : class ElementMark;
29 : class ElementCollector;
30 :
31 : class BufferNode
32 : /****** buffernode.hxx/CLASS BufferNode ***************************************
33 : *
34 : * NAME
35 : * BufferNode -- Class to maintain the tree of bufferred elements
36 : *
37 : * FUNCTION
38 : * One BufferNode object represents a bufferred element in the document
39 : * wrapper component.
40 : * All BufferNode objects construct a tree which has the same structure
41 : * of all bufferred elements. That is to say, if one bufferred element is
42 : * an ancestor of another bufferred element, then the corresponding
43 : * BufferNode objects are also in ancestor/descendant relationship.
44 : * This class is used to manipulate the tree of bufferred elements.
45 : *
46 : * AUTHOR
47 : * Michael Mi
48 : * Email: michael.mi@sun.com
49 : ******************************************************************************/
50 : {
51 : private:
52 : /* the parent BufferNode */
53 : BufferNode* m_pParent;
54 :
55 : /* all child BufferNodes */
56 : std::vector< const BufferNode* > m_vChildren;
57 :
58 : /* all ElementCollector holding this BufferNode */
59 : std::vector< const ElementCollector* > m_vElementCollectors;
60 :
61 : /*
62 : * the blocker holding this BufferNode, one BufferNode can have one
63 : * blocker at most
64 : */
65 : ElementMark* m_pBlocker;
66 :
67 : /*
68 : * whether the element has completely bufferred by the document wrapper
69 : * component
70 : */
71 : bool m_bAllReceived;
72 :
73 : /* the XMLElementWrapper of the bufferred element */
74 : com::sun::star::uno::Reference<
75 : com::sun::star::xml::wrapper::XXMLElementWrapper > m_xXMLElement;
76 :
77 : private:
78 : bool isECInSubTreeIncluded(sal_Int32 nIgnoredSecurityId) const;
79 : bool isECOfBeforeModifyInAncestorIncluded(sal_Int32 nIgnoredSecurityId) const;
80 : bool isBlockerInSubTreeIncluded(sal_Int32 nIgnoredSecurityId) const;
81 : const BufferNode* getNextChild(const BufferNode* pChild) const;
82 :
83 : public:
84 : explicit BufferNode(
85 : const com::sun::star::uno::Reference<
86 : com::sun::star::xml::wrapper::XXMLElementWrapper >& xXMLElement);
87 0 : virtual ~BufferNode() {};
88 :
89 : bool isECOfBeforeModifyIncluded(sal_Int32 nIgnoredSecurityId) const;
90 : void setReceivedAll();
91 : bool isAllReceived() const;
92 : void addElementCollector(const ElementCollector* pElementCollector);
93 : void removeElementCollector(const ElementCollector* pElementCollector);
94 : ElementMark* getBlocker() const;
95 : void setBlocker(const ElementMark* pBlocker);
96 : OUString printChildren() const;
97 : bool hasAnything() const;
98 : bool hasChildren() const;
99 : std::vector< const BufferNode* >* getChildren() const;
100 : const BufferNode* getFirstChild() const;
101 : void addChild(const BufferNode* pChild, sal_Int32 nPosition);
102 : void addChild(const BufferNode* pChild);
103 : void removeChild(const BufferNode* pChild);
104 : sal_Int32 indexOfChild(const BufferNode* pChild) const;
105 : const BufferNode* getParent() const;
106 : void setParent(const BufferNode* pParent);
107 : const BufferNode* getNextSibling() const;
108 : const BufferNode* isAncestor(const BufferNode* pDescendant) const;
109 : bool isPrevious(const BufferNode* pFollowing) const;
110 : const BufferNode* getNextNodeByTreeOrder() const;
111 : com::sun::star::uno::Reference<
112 : com::sun::star::xml::wrapper::XXMLElementWrapper > getXMLElement() const;
113 : void setXMLElement(const com::sun::star::uno::Reference<
114 : com::sun::star::xml::wrapper::XXMLElementWrapper >& xXMLElement);
115 : void notifyBranch();
116 : void elementCollectorNotify();
117 : void freeAllChildren();
118 : };
119 :
120 : #endif
121 :
122 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|