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