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