1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _BUFFERNODE_HXX 29 #define _BUFFERNODE_HXX 30 31 #include <com/sun/star/lang/XServiceInfo.hpp> 32 #include <com/sun/star/xml/wrapper/XXMLElementWrapper.hpp> 33 34 #ifndef INCLUDED_VECTOR 35 #include <vector> 36 #define INCLUDED_VECTOR 37 #endif 38 39 class ElementMark; 40 class ElementCollector; 41 42 class BufferNode 43 /****** buffernode.hxx/CLASS BufferNode *************************************** 44 * 45 * NAME 46 * BufferNode -- Class to maintain the tree of bufferred elements 47 * 48 * FUNCTION 49 * One BufferNode object represents a bufferred element in the document 50 * wrapper component. 51 * All BufferNode objects construct a tree which has the same structure 52 * of all bufferred elements. That is to say, if one bufferred element is 53 * an ancestor of another bufferred element, then the corresponding 54 * BufferNode objects are also in ancestor/descendant relationship. 55 * This class is used to manipulate the tree of bufferred elements. 56 * 57 * HISTORY 58 * 05.01.2004 - implemented 59 * 60 * AUTHOR 61 * Michael Mi 62 * Email: michael.mi@sun.com 63 ******************************************************************************/ 64 { 65 private: 66 /* the parent BufferNode */ 67 BufferNode* m_pParent; 68 69 /* all child BufferNodes */ 70 std::vector< const BufferNode* > m_vChildren; 71 72 /* all ElementCollector holding this BufferNode */ 73 std::vector< const ElementCollector* > m_vElementCollectors; 74 75 /* 76 * the blocker holding this BufferNode, one BufferNode can have one 77 * blocker at most 78 */ 79 ElementMark* m_pBlocker; 80 81 /* 82 * whether the element has completely bufferred by the document wrapper 83 * component 84 */ 85 bool m_bAllReceived; 86 87 /* the XMLElementWrapper of the bufferred element */ 88 com::sun::star::uno::Reference< 89 com::sun::star::xml::wrapper::XXMLElementWrapper > m_xXMLElement; 90 91 private: 92 bool isECInSubTreeIncluded(sal_Int32 nIgnoredSecurityId) const; 93 bool isECOfBeforeModifyInAncestorIncluded(sal_Int32 nIgnoredSecurityId) const; 94 bool isBlockerInSubTreeIncluded(sal_Int32 nIgnoredSecurityId) const; 95 const BufferNode* getNextChild(const BufferNode* pChild) const; 96 97 public: 98 explicit BufferNode( 99 const com::sun::star::uno::Reference< 100 com::sun::star::xml::wrapper::XXMLElementWrapper >& xXMLElement); 101 virtual ~BufferNode() {}; 102 103 bool isECOfBeforeModifyIncluded(sal_Int32 nIgnoredSecurityId) const; 104 void setReceivedAll(); 105 bool isAllReceived() const; 106 void addElementCollector(const ElementCollector* pElementCollector); 107 void removeElementCollector(const ElementCollector* pElementCollector); 108 ElementMark* getBlocker() const; 109 void setBlocker(const ElementMark* pBlocker); 110 rtl::OUString printChildren() const; 111 bool hasAnything() const; 112 bool hasChildren() const; 113 std::vector< const BufferNode* >* getChildren() const; 114 const BufferNode* getFirstChild() const; 115 void addChild(const BufferNode* pChild, sal_Int32 nPosition); 116 void addChild(const BufferNode* pChild); 117 void removeChild(const BufferNode* pChild); 118 sal_Int32 indexOfChild(const BufferNode* pChild) const; 119 const BufferNode* childAt(sal_Int32 nIndex) const; 120 const BufferNode* getParent() const; 121 void setParent(const BufferNode* pParent); 122 const BufferNode* getNextSibling() const; 123 const BufferNode* isAncestor(const BufferNode* pDescendant) const; 124 bool isPrevious(const BufferNode* pFollowing) const; 125 const BufferNode* getNextNodeByTreeOrder() const; 126 com::sun::star::uno::Reference< 127 com::sun::star::xml::wrapper::XXMLElementWrapper > getXMLElement() const; 128 void setXMLElement(const com::sun::star::uno::Reference< 129 com::sun::star::xml::wrapper::XXMLElementWrapper >& xXMLElement); 130 void notifyBranch(); 131 void notifyAncestor(); 132 void elementCollectorNotify(); 133 void freeAllChildren(); 134 }; 135 136 #endif 137 138