xref: /AOO41X/main/xmlsecurity/source/framework/buffernode.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_xmlsecurity.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "elementmark.hxx"
32*cdf0e10cSrcweir #include "elementcollector.hxx"
33*cdf0e10cSrcweir #include "buffernode.hxx"
34*cdf0e10cSrcweir #include <com/sun/star/xml/crypto/sax/ConstOfSecurityId.hpp>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir namespace cssu = com::sun::star::uno;
37*cdf0e10cSrcweir namespace cssxw = com::sun::star::xml::wrapper;
38*cdf0e10cSrcweir namespace cssxc = com::sun::star::xml::crypto;
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir BufferNode::BufferNode( const cssu::Reference< cssxw::XXMLElementWrapper >& xXMLElement )
41*cdf0e10cSrcweir 	:m_pParent(NULL),
42*cdf0e10cSrcweir 	 m_pBlocker(NULL),
43*cdf0e10cSrcweir 	 m_bAllReceived(false),
44*cdf0e10cSrcweir      m_xXMLElement(xXMLElement)
45*cdf0e10cSrcweir {
46*cdf0e10cSrcweir }
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir bool BufferNode::isECOfBeforeModifyIncluded(sal_Int32 nIgnoredSecurityId) const
49*cdf0e10cSrcweir /****** BufferNode/isECOfBeforeModifyIncluded ********************************
50*cdf0e10cSrcweir  *
51*cdf0e10cSrcweir  *   NAME
52*cdf0e10cSrcweir  *	isECOfBeforeModifyIncluded -- checks whether there is some
53*cdf0e10cSrcweir  *	ElementCollector on this BufferNode, that has BEFORE-MODIFY priority.
54*cdf0e10cSrcweir  *
55*cdf0e10cSrcweir  *   SYNOPSIS
56*cdf0e10cSrcweir  *	bExist = isECOfBeforeModifyIncluded(nIgnoredSecurityId);
57*cdf0e10cSrcweir  *
58*cdf0e10cSrcweir  *   FUNCTION
59*cdf0e10cSrcweir  *	checks each ElementCollector on this BufferNode, if all following
60*cdf0e10cSrcweir  *	conditions are satisfied, then returns true:
61*cdf0e10cSrcweir  *	1. the ElementCollector's priority is BEFOREMODIFY;
62*cdf0e10cSrcweir  *	2. the ElementCollector's securityId can't be ignored.
63*cdf0e10cSrcweir  *	otherwise, returns false.
64*cdf0e10cSrcweir  *
65*cdf0e10cSrcweir  *   INPUTS
66*cdf0e10cSrcweir  *	nIgnoredSecurityId -	the security Id to be ignored. If it equals
67*cdf0e10cSrcweir  *	                        to UNDEFINEDSECURITYID, then no security Id
68*cdf0e10cSrcweir  *	                    	will be ignored.
69*cdf0e10cSrcweir  *
70*cdf0e10cSrcweir  *   RESULT
71*cdf0e10cSrcweir  *	bExist - true if a match found, false otherwise
72*cdf0e10cSrcweir  *
73*cdf0e10cSrcweir  *   HISTORY
74*cdf0e10cSrcweir  *	05.01.2004 -	implemented
75*cdf0e10cSrcweir  *
76*cdf0e10cSrcweir  *   AUTHOR
77*cdf0e10cSrcweir  *	Michael Mi
78*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
79*cdf0e10cSrcweir  ******************************************************************************/
80*cdf0e10cSrcweir {
81*cdf0e10cSrcweir 	bool rc = false;
82*cdf0e10cSrcweir 	std::vector< const ElementCollector* >::const_iterator ii = m_vElementCollectors.begin();
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 	for( ; ii != m_vElementCollectors.end() ; ++ii )
85*cdf0e10cSrcweir 	{
86*cdf0e10cSrcweir 		ElementCollector* pElementCollector = (ElementCollector*)*ii;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 		if ((nIgnoredSecurityId == cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID ||
89*cdf0e10cSrcweir 		 	pElementCollector->getSecurityId() != nIgnoredSecurityId) &&
90*cdf0e10cSrcweir 		    (pElementCollector->getPriority() == cssxc::sax::ElementMarkPriority_BEFOREMODIFY))
91*cdf0e10cSrcweir 		{
92*cdf0e10cSrcweir 			rc = true;
93*cdf0e10cSrcweir 			break;
94*cdf0e10cSrcweir 		}
95*cdf0e10cSrcweir 	}
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 	return rc;
98*cdf0e10cSrcweir }
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir void BufferNode::setReceivedAll()
101*cdf0e10cSrcweir /****** BufferNode/setReceiveAll *********************************************
102*cdf0e10cSrcweir  *
103*cdf0e10cSrcweir  *   NAME
104*cdf0e10cSrcweir  *	setReceivedAll -- indicates that the element in this BufferNode has
105*cdf0e10cSrcweir  *	been compeletely bufferred.
106*cdf0e10cSrcweir  *
107*cdf0e10cSrcweir  *   SYNOPSIS
108*cdf0e10cSrcweir  *	setReceivedAll();
109*cdf0e10cSrcweir  *
110*cdf0e10cSrcweir  *   FUNCTION
111*cdf0e10cSrcweir  *	sets the all-received flag and launches ElementCollector's notify
112*cdf0e10cSrcweir  *	process.
113*cdf0e10cSrcweir  *
114*cdf0e10cSrcweir  *   INPUTS
115*cdf0e10cSrcweir  *	empty
116*cdf0e10cSrcweir  *
117*cdf0e10cSrcweir  *   RESULT
118*cdf0e10cSrcweir  *	empty
119*cdf0e10cSrcweir  *
120*cdf0e10cSrcweir  *   HISTORY
121*cdf0e10cSrcweir  *	05.01.2004 -	implemented
122*cdf0e10cSrcweir  *
123*cdf0e10cSrcweir  *   AUTHOR
124*cdf0e10cSrcweir  *	Michael Mi
125*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
126*cdf0e10cSrcweir  ******************************************************************************/
127*cdf0e10cSrcweir {
128*cdf0e10cSrcweir 	m_bAllReceived = true;
129*cdf0e10cSrcweir 	elementCollectorNotify();
130*cdf0e10cSrcweir }
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir bool BufferNode::isAllReceived() const
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir 	return m_bAllReceived;
135*cdf0e10cSrcweir }
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir void BufferNode::addElementCollector(const ElementCollector* pElementCollector)
138*cdf0e10cSrcweir /****** BufferNode/addElementCollector ***************************************
139*cdf0e10cSrcweir  *
140*cdf0e10cSrcweir  *   NAME
141*cdf0e10cSrcweir  *	addElementCollector -- adds a new ElementCollector to this BufferNode.
142*cdf0e10cSrcweir  *
143*cdf0e10cSrcweir  *   SYNOPSIS
144*cdf0e10cSrcweir  *	addElementCollector(pElementCollector);
145*cdf0e10cSrcweir  *
146*cdf0e10cSrcweir  *   FUNCTION
147*cdf0e10cSrcweir  *	see NAME
148*cdf0e10cSrcweir  *
149*cdf0e10cSrcweir  *   INPUTS
150*cdf0e10cSrcweir  *	pElementCollector - the ElementCollector to be added
151*cdf0e10cSrcweir  *
152*cdf0e10cSrcweir  *   RESULT
153*cdf0e10cSrcweir  *	empty
154*cdf0e10cSrcweir  *
155*cdf0e10cSrcweir  *   HISTORY
156*cdf0e10cSrcweir  *	05.01.2004 -	implemented
157*cdf0e10cSrcweir  *
158*cdf0e10cSrcweir  *   AUTHOR
159*cdf0e10cSrcweir  *	Michael Mi
160*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
161*cdf0e10cSrcweir  ******************************************************************************/
162*cdf0e10cSrcweir {
163*cdf0e10cSrcweir 	m_vElementCollectors.push_back( pElementCollector );
164*cdf0e10cSrcweir 	((ElementCollector*)pElementCollector)->setBufferNode(this);
165*cdf0e10cSrcweir }
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir void BufferNode::removeElementCollector(const ElementCollector* pElementCollector)
168*cdf0e10cSrcweir /****** BufferNode/removeElementCollector ************************************
169*cdf0e10cSrcweir  *
170*cdf0e10cSrcweir  *   NAME
171*cdf0e10cSrcweir  *	removeElementCollector -- removes an ElementCollector from this
172*cdf0e10cSrcweir  *	BufferNode.
173*cdf0e10cSrcweir  *
174*cdf0e10cSrcweir  *   SYNOPSIS
175*cdf0e10cSrcweir  *	removeElementCollector(pElementCollector);
176*cdf0e10cSrcweir  *
177*cdf0e10cSrcweir  *   FUNCTION
178*cdf0e10cSrcweir  *	see NAME
179*cdf0e10cSrcweir  *
180*cdf0e10cSrcweir  *   INPUTS
181*cdf0e10cSrcweir  *	pElementCollector - the ElementCollector to be removed
182*cdf0e10cSrcweir  *
183*cdf0e10cSrcweir  *   RESULT
184*cdf0e10cSrcweir  *	empty
185*cdf0e10cSrcweir  *
186*cdf0e10cSrcweir  *   HISTORY
187*cdf0e10cSrcweir  *	05.01.2004 -	implemented
188*cdf0e10cSrcweir  *
189*cdf0e10cSrcweir  *   AUTHOR
190*cdf0e10cSrcweir  *	Michael Mi
191*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
192*cdf0e10cSrcweir  ******************************************************************************/
193*cdf0e10cSrcweir {
194*cdf0e10cSrcweir 	std::vector< const ElementCollector* >::iterator ii = m_vElementCollectors.begin();
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 	for( ; ii != m_vElementCollectors.end() ; ++ii )
197*cdf0e10cSrcweir 	{
198*cdf0e10cSrcweir 		if( *ii == pElementCollector )
199*cdf0e10cSrcweir 		{
200*cdf0e10cSrcweir 			m_vElementCollectors.erase( ii );
201*cdf0e10cSrcweir 			((ElementCollector*)pElementCollector)->setBufferNode(NULL);
202*cdf0e10cSrcweir 			break;
203*cdf0e10cSrcweir 		}
204*cdf0e10cSrcweir 	}
205*cdf0e10cSrcweir }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir ElementMark* BufferNode::getBlocker() const
208*cdf0e10cSrcweir {
209*cdf0e10cSrcweir 	return m_pBlocker;
210*cdf0e10cSrcweir }
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir void BufferNode::setBlocker(const ElementMark* pBlocker)
213*cdf0e10cSrcweir /****** BufferNode/setBlocker ************************************************
214*cdf0e10cSrcweir  *
215*cdf0e10cSrcweir  *   NAME
216*cdf0e10cSrcweir  *	setBlocker -- adds a blocker to this BufferNode.
217*cdf0e10cSrcweir  *
218*cdf0e10cSrcweir  *   SYNOPSIS
219*cdf0e10cSrcweir  *	setBlocker(pBlocker);
220*cdf0e10cSrcweir  *
221*cdf0e10cSrcweir  *   FUNCTION
222*cdf0e10cSrcweir  *	see NAME
223*cdf0e10cSrcweir  *
224*cdf0e10cSrcweir  *   INPUTS
225*cdf0e10cSrcweir  *	pBlocker - the new blocker to be attached
226*cdf0e10cSrcweir  *
227*cdf0e10cSrcweir  *   RESULT
228*cdf0e10cSrcweir  *	empty
229*cdf0e10cSrcweir  *
230*cdf0e10cSrcweir  *   NOTES
231*cdf0e10cSrcweir  *	Because there is only one blocker permited for a BufferNode, so the
232*cdf0e10cSrcweir  *	old blocker on this BufferNode, if there is one, will be overcasted.
233*cdf0e10cSrcweir  *
234*cdf0e10cSrcweir  *   HISTORY
235*cdf0e10cSrcweir  *	05.01.2004 -	implemented
236*cdf0e10cSrcweir  *
237*cdf0e10cSrcweir  *   AUTHOR
238*cdf0e10cSrcweir  *	Michael Mi
239*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
240*cdf0e10cSrcweir  ******************************************************************************/
241*cdf0e10cSrcweir {
242*cdf0e10cSrcweir 	OSL_ASSERT(!(m_pBlocker != NULL && pBlocker != NULL));
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 	m_pBlocker = (ElementMark*)pBlocker;
245*cdf0e10cSrcweir 	if (m_pBlocker != NULL)
246*cdf0e10cSrcweir 	{
247*cdf0e10cSrcweir 		m_pBlocker->setBufferNode(this);
248*cdf0e10cSrcweir 	}
249*cdf0e10cSrcweir }
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir rtl::OUString BufferNode::printChildren() const
252*cdf0e10cSrcweir /****** BufferNode/printChildren *********************************************
253*cdf0e10cSrcweir  *
254*cdf0e10cSrcweir  *   NAME
255*cdf0e10cSrcweir  *	printChildren -- prints children information into a string.
256*cdf0e10cSrcweir  *
257*cdf0e10cSrcweir  *   SYNOPSIS
258*cdf0e10cSrcweir  *	result = printChildren();
259*cdf0e10cSrcweir  *
260*cdf0e10cSrcweir  *   FUNCTION
261*cdf0e10cSrcweir  *	see NAME
262*cdf0e10cSrcweir  *
263*cdf0e10cSrcweir  *   INPUTS
264*cdf0e10cSrcweir  *	empty
265*cdf0e10cSrcweir  *
266*cdf0e10cSrcweir  *   RESULT
267*cdf0e10cSrcweir  *	result - the information string
268*cdf0e10cSrcweir  *
269*cdf0e10cSrcweir  *   HISTORY
270*cdf0e10cSrcweir  *	05.01.2004 -	implemented
271*cdf0e10cSrcweir  *
272*cdf0e10cSrcweir  *   AUTHOR
273*cdf0e10cSrcweir  *	Michael Mi
274*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
275*cdf0e10cSrcweir  ******************************************************************************/
276*cdf0e10cSrcweir {
277*cdf0e10cSrcweir 	rtl::OUString rc;
278*cdf0e10cSrcweir 	std::vector< const ElementCollector* >::const_iterator ii = m_vElementCollectors.begin();
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir 	for( ; ii != m_vElementCollectors.end() ; ++ii )
281*cdf0e10cSrcweir 	{
282*cdf0e10cSrcweir 		rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BufID=" ));
283*cdf0e10cSrcweir 		rc += rtl::OUString::valueOf((*ii)->getBufferId());
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir 		if (((ElementCollector*)(*ii))->getModify())
286*cdf0e10cSrcweir 		{
287*cdf0e10cSrcweir 			rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "[M]" ));
288*cdf0e10cSrcweir 		}
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir 		rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ",Pri=" ));
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir 		switch (((ElementCollector*)(*ii))->getPriority())
293*cdf0e10cSrcweir 		{
294*cdf0e10cSrcweir 			case cssxc::sax::ElementMarkPriority_BEFOREMODIFY:
295*cdf0e10cSrcweir 				rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BEFOREMODIFY" ));
296*cdf0e10cSrcweir 				break;
297*cdf0e10cSrcweir 			case cssxc::sax::ElementMarkPriority_AFTERMODIFY:
298*cdf0e10cSrcweir 				rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AFTERMODIFY" ));
299*cdf0e10cSrcweir 				break;
300*cdf0e10cSrcweir 			default:
301*cdf0e10cSrcweir 				rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UNKNOWN" ));
302*cdf0e10cSrcweir 				break;
303*cdf0e10cSrcweir 		}
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir 		rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "(" ));
306*cdf0e10cSrcweir 		/*
307*cdf0e10cSrcweir 		if (((ElementCollector*)(*ii))->isInternalNotificationSuppressed())
308*cdf0e10cSrcweir 		{
309*cdf0e10cSrcweir 			rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*IN-Suppressed* " ));
310*cdf0e10cSrcweir 		}
311*cdf0e10cSrcweir 		*/
312*cdf0e10cSrcweir 		rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SecID=" ));
313*cdf0e10cSrcweir 		rc += rtl::OUString::valueOf(((ElementCollector*)(*ii))->getSecurityId());
314*cdf0e10cSrcweir 		rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" ));
315*cdf0e10cSrcweir 		rc += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " " ));
316*cdf0e10cSrcweir 	}
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir 	return rc;
319*cdf0e10cSrcweir }
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir bool BufferNode::hasAnything() const
322*cdf0e10cSrcweir /****** BufferNode/hasAnything ***********************************************
323*cdf0e10cSrcweir  *
324*cdf0e10cSrcweir  *   NAME
325*cdf0e10cSrcweir  *	hasAnything -- checks whether there is any ElementCollector or blocker
326*cdf0e10cSrcweir  *	on this BufferNode.
327*cdf0e10cSrcweir  *
328*cdf0e10cSrcweir  *   SYNOPSIS
329*cdf0e10cSrcweir  *	bExist = hasAnything();
330*cdf0e10cSrcweir  *
331*cdf0e10cSrcweir  *   FUNCTION
332*cdf0e10cSrcweir  *	see NAME
333*cdf0e10cSrcweir  *
334*cdf0e10cSrcweir  *   INPUTS
335*cdf0e10cSrcweir  *	empty
336*cdf0e10cSrcweir  *
337*cdf0e10cSrcweir  *   RESULT
338*cdf0e10cSrcweir  *	bExist - true if there is, false otherwise.
339*cdf0e10cSrcweir  *
340*cdf0e10cSrcweir  *   HISTORY
341*cdf0e10cSrcweir  *	05.01.2004 -	implemented
342*cdf0e10cSrcweir  *
343*cdf0e10cSrcweir  *   AUTHOR
344*cdf0e10cSrcweir  *	Michael Mi
345*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
346*cdf0e10cSrcweir  ******************************************************************************/
347*cdf0e10cSrcweir {
348*cdf0e10cSrcweir 	return (m_pBlocker != NULL || m_vElementCollectors.size() > 0);
349*cdf0e10cSrcweir }
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir bool BufferNode::hasChildren() const
352*cdf0e10cSrcweir /****** BufferNode/hasChildren ***********************************************
353*cdf0e10cSrcweir  *
354*cdf0e10cSrcweir  *   NAME
355*cdf0e10cSrcweir  *	hasChildren -- checks whether this BufferNode has any child
356*cdf0e10cSrcweir  *	BufferNode.
357*cdf0e10cSrcweir  *
358*cdf0e10cSrcweir  *   SYNOPSIS
359*cdf0e10cSrcweir  *	bExist = hasChildren();
360*cdf0e10cSrcweir  *
361*cdf0e10cSrcweir  *   FUNCTION
362*cdf0e10cSrcweir  *	see NAME
363*cdf0e10cSrcweir  *
364*cdf0e10cSrcweir  *   INPUTS
365*cdf0e10cSrcweir  *	empty
366*cdf0e10cSrcweir  *
367*cdf0e10cSrcweir  *   RESULT
368*cdf0e10cSrcweir  *	bExist - true if there is, false otherwise.
369*cdf0e10cSrcweir  *
370*cdf0e10cSrcweir  *   HISTORY
371*cdf0e10cSrcweir  *	05.01.2004 -	implemented
372*cdf0e10cSrcweir  *
373*cdf0e10cSrcweir  *   AUTHOR
374*cdf0e10cSrcweir  *	Michael Mi
375*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
376*cdf0e10cSrcweir  ******************************************************************************/
377*cdf0e10cSrcweir {
378*cdf0e10cSrcweir 	return (m_vChildren.size() > 0);
379*cdf0e10cSrcweir }
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir std::vector< const BufferNode* >* BufferNode::getChildren() const
382*cdf0e10cSrcweir {
383*cdf0e10cSrcweir 	return new std::vector< const BufferNode* >( m_vChildren );
384*cdf0e10cSrcweir }
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir const BufferNode* BufferNode::getFirstChild() const
387*cdf0e10cSrcweir /****** BufferNode/getFirstChild *********************************************
388*cdf0e10cSrcweir  *
389*cdf0e10cSrcweir  *   NAME
390*cdf0e10cSrcweir  *	getFirstChild -- retrieves the first child BufferNode.
391*cdf0e10cSrcweir  *
392*cdf0e10cSrcweir  *   SYNOPSIS
393*cdf0e10cSrcweir  *	child = getFirstChild();
394*cdf0e10cSrcweir  *
395*cdf0e10cSrcweir  *   FUNCTION
396*cdf0e10cSrcweir  *	see NAME
397*cdf0e10cSrcweir  *
398*cdf0e10cSrcweir  *   INPUTS
399*cdf0e10cSrcweir  *	empty
400*cdf0e10cSrcweir  *
401*cdf0e10cSrcweir  *   RESULT
402*cdf0e10cSrcweir  *	child -	the first child BufferNode, or NULL if there is no child
403*cdf0e10cSrcweir  *	       	BufferNode.
404*cdf0e10cSrcweir  *
405*cdf0e10cSrcweir  *   HISTORY
406*cdf0e10cSrcweir  *	05.01.2004 -	implemented
407*cdf0e10cSrcweir  *
408*cdf0e10cSrcweir  *   AUTHOR
409*cdf0e10cSrcweir  *	Michael Mi
410*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
411*cdf0e10cSrcweir  ******************************************************************************/
412*cdf0e10cSrcweir {
413*cdf0e10cSrcweir 	BufferNode* rc = NULL;
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir 	if (m_vChildren.size() > 0)
416*cdf0e10cSrcweir 	{
417*cdf0e10cSrcweir 		rc = (BufferNode*)m_vChildren.front();
418*cdf0e10cSrcweir 	}
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir 	return (const BufferNode*)rc;
421*cdf0e10cSrcweir }
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir void BufferNode::addChild(const BufferNode* pChild, sal_Int32 nPosition)
424*cdf0e10cSrcweir /****** BufferNode/addChild(pChild,nPosition) ********************************
425*cdf0e10cSrcweir  *
426*cdf0e10cSrcweir  *   NAME
427*cdf0e10cSrcweir  *	addChild -- inserts a child BufferNode at specific position.
428*cdf0e10cSrcweir  *
429*cdf0e10cSrcweir  *   SYNOPSIS
430*cdf0e10cSrcweir  *	addChild(pChild, nPosition);
431*cdf0e10cSrcweir  *
432*cdf0e10cSrcweir  *   FUNCTION
433*cdf0e10cSrcweir  *	see NAME
434*cdf0e10cSrcweir  *
435*cdf0e10cSrcweir  *   INPUTS
436*cdf0e10cSrcweir  *	pChild - 	the child BufferNode to be added.
437*cdf0e10cSrcweir  *	nPosition -	the position where the new child locates.
438*cdf0e10cSrcweir  *
439*cdf0e10cSrcweir  *   RESULT
440*cdf0e10cSrcweir  *	empty
441*cdf0e10cSrcweir  *
442*cdf0e10cSrcweir  *   NOTES
443*cdf0e10cSrcweir  *	If the nPosition is -1, then the new child BufferNode is appended
444*cdf0e10cSrcweir  *	at the end.
445*cdf0e10cSrcweir  *
446*cdf0e10cSrcweir  *   HISTORY
447*cdf0e10cSrcweir  *	05.01.2004 -	implemented
448*cdf0e10cSrcweir  *
449*cdf0e10cSrcweir  *   AUTHOR
450*cdf0e10cSrcweir  *	Michael Mi
451*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
452*cdf0e10cSrcweir  ******************************************************************************/
453*cdf0e10cSrcweir {
454*cdf0e10cSrcweir 	if (nPosition == -1)
455*cdf0e10cSrcweir 	{
456*cdf0e10cSrcweir 		m_vChildren.push_back( pChild );
457*cdf0e10cSrcweir 	}
458*cdf0e10cSrcweir 	else
459*cdf0e10cSrcweir 	{
460*cdf0e10cSrcweir 		std::vector< const BufferNode* >::iterator ii = m_vChildren.begin();
461*cdf0e10cSrcweir 		ii += nPosition;
462*cdf0e10cSrcweir 		m_vChildren.insert(ii, pChild);
463*cdf0e10cSrcweir 	}
464*cdf0e10cSrcweir }
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir void BufferNode::addChild(const BufferNode* pChild)
467*cdf0e10cSrcweir /****** BufferNode/addChild() ************************************************
468*cdf0e10cSrcweir  *
469*cdf0e10cSrcweir  *   NAME
470*cdf0e10cSrcweir  *	addChild -- add a new child BufferNode.
471*cdf0e10cSrcweir  *
472*cdf0e10cSrcweir  *   SYNOPSIS
473*cdf0e10cSrcweir  *	addChild(pChild);
474*cdf0e10cSrcweir  *
475*cdf0e10cSrcweir  *   FUNCTION
476*cdf0e10cSrcweir  *	see NAME
477*cdf0e10cSrcweir  *
478*cdf0e10cSrcweir  *   INPUTS
479*cdf0e10cSrcweir  *	pChild - 	the child BufferNode to be added.
480*cdf0e10cSrcweir  *
481*cdf0e10cSrcweir  *   RESULT
482*cdf0e10cSrcweir  *	empty
483*cdf0e10cSrcweir  *
484*cdf0e10cSrcweir  *   NOTES
485*cdf0e10cSrcweir  *	The new child BufferNode is appended at the end.
486*cdf0e10cSrcweir  *
487*cdf0e10cSrcweir  *   HISTORY
488*cdf0e10cSrcweir  *	05.01.2004 -	implemented
489*cdf0e10cSrcweir  *
490*cdf0e10cSrcweir  *   AUTHOR
491*cdf0e10cSrcweir  *	Michael Mi
492*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
493*cdf0e10cSrcweir  ******************************************************************************/
494*cdf0e10cSrcweir {
495*cdf0e10cSrcweir 	addChild(pChild, -1);
496*cdf0e10cSrcweir }
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir void BufferNode::removeChild(const BufferNode* pChild)
499*cdf0e10cSrcweir /****** BufferNode/removeChild ***********************************************
500*cdf0e10cSrcweir  *
501*cdf0e10cSrcweir  *   NAME
502*cdf0e10cSrcweir  *	removeChild -- removes a child BufferNode from the children list.
503*cdf0e10cSrcweir  *
504*cdf0e10cSrcweir  *   SYNOPSIS
505*cdf0e10cSrcweir  *	removeChild(pChild);
506*cdf0e10cSrcweir  *
507*cdf0e10cSrcweir  *   FUNCTION
508*cdf0e10cSrcweir  *	see NAME
509*cdf0e10cSrcweir  *
510*cdf0e10cSrcweir  *   INPUTS
511*cdf0e10cSrcweir  *	pChild - the child BufferNode to be removed
512*cdf0e10cSrcweir  *
513*cdf0e10cSrcweir  *   RESULT
514*cdf0e10cSrcweir  *	empty
515*cdf0e10cSrcweir  *
516*cdf0e10cSrcweir  *   HISTORY
517*cdf0e10cSrcweir  *	05.01.2004 -	implemented
518*cdf0e10cSrcweir  *
519*cdf0e10cSrcweir  *   AUTHOR
520*cdf0e10cSrcweir  *	Michael Mi
521*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
522*cdf0e10cSrcweir  ******************************************************************************/
523*cdf0e10cSrcweir {
524*cdf0e10cSrcweir 	std::vector< const BufferNode* >::iterator ii = m_vChildren.begin();
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir 	for( ; ii != m_vChildren.end() ; ++ii )
527*cdf0e10cSrcweir 	{
528*cdf0e10cSrcweir 		if( *ii == pChild )
529*cdf0e10cSrcweir 		{
530*cdf0e10cSrcweir 			m_vChildren.erase( ii );
531*cdf0e10cSrcweir 			break;
532*cdf0e10cSrcweir 		}
533*cdf0e10cSrcweir 	}
534*cdf0e10cSrcweir }
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir sal_Int32 BufferNode::indexOfChild(const BufferNode* pChild) const
537*cdf0e10cSrcweir /****** BufferNode/indexOfChild **********************************************
538*cdf0e10cSrcweir  *
539*cdf0e10cSrcweir  *   NAME
540*cdf0e10cSrcweir  *	indexOfChild -- gets the index of a child BufferNode.
541*cdf0e10cSrcweir  *
542*cdf0e10cSrcweir  *   SYNOPSIS
543*cdf0e10cSrcweir  *	index = indexOfChild(pChild);
544*cdf0e10cSrcweir  *
545*cdf0e10cSrcweir  *   FUNCTION
546*cdf0e10cSrcweir  *	see NAME
547*cdf0e10cSrcweir  *
548*cdf0e10cSrcweir  *   INPUTS
549*cdf0e10cSrcweir  *	pChild - the child BufferNode whose index to be gotten
550*cdf0e10cSrcweir  *
551*cdf0e10cSrcweir  *   RESULT
552*cdf0e10cSrcweir  *	index -	the index of that child BufferNode. If that child BufferNode
553*cdf0e10cSrcweir  *	       	is not found, -1 is returned.
554*cdf0e10cSrcweir  *
555*cdf0e10cSrcweir  *   HISTORY
556*cdf0e10cSrcweir  *	05.01.2004 -	implemented
557*cdf0e10cSrcweir  *
558*cdf0e10cSrcweir  *   AUTHOR
559*cdf0e10cSrcweir  *	Michael Mi
560*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
561*cdf0e10cSrcweir  ******************************************************************************/
562*cdf0e10cSrcweir {
563*cdf0e10cSrcweir 	sal_Int32 nIndex = 0;
564*cdf0e10cSrcweir 	bool bFound = false;
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir 	std::vector< const BufferNode * >::const_iterator ii = m_vChildren.begin();
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir 	for( ; ii != m_vChildren.end() ; ++ii )
569*cdf0e10cSrcweir 	{
570*cdf0e10cSrcweir 		if( *ii == pChild )
571*cdf0e10cSrcweir 		{
572*cdf0e10cSrcweir 			bFound = true;
573*cdf0e10cSrcweir 			break;
574*cdf0e10cSrcweir 		}
575*cdf0e10cSrcweir 		nIndex++;
576*cdf0e10cSrcweir 	}
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir 	if (!bFound )
579*cdf0e10cSrcweir 	{
580*cdf0e10cSrcweir 		nIndex = -1;
581*cdf0e10cSrcweir 	}
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir 	return nIndex;
584*cdf0e10cSrcweir }
585*cdf0e10cSrcweir 
586*cdf0e10cSrcweir const BufferNode* BufferNode::childAt(sal_Int32 nIndex) const
587*cdf0e10cSrcweir /****** BufferNode/childAt ***************************************************
588*cdf0e10cSrcweir  *
589*cdf0e10cSrcweir  *   NAME
590*cdf0e10cSrcweir  *	childAt -- retrieves the child BufferNode at specific possition.
591*cdf0e10cSrcweir  *
592*cdf0e10cSrcweir  *   SYNOPSIS
593*cdf0e10cSrcweir  *	child = childAt(nIndex);
594*cdf0e10cSrcweir  *
595*cdf0e10cSrcweir  *   FUNCTION
596*cdf0e10cSrcweir  *	see NAME
597*cdf0e10cSrcweir  *
598*cdf0e10cSrcweir  *   INPUTS
599*cdf0e10cSrcweir  *	nIndex - the index of the child BufferNode to be retrieved
600*cdf0e10cSrcweir  *
601*cdf0e10cSrcweir  *   RESULT
602*cdf0e10cSrcweir  *	child -	the child BufferNode at index position, or NULL if the index
603*cdf0e10cSrcweir  *	       	is out of the range of children.
604*cdf0e10cSrcweir  *
605*cdf0e10cSrcweir  *   HISTORY
606*cdf0e10cSrcweir  *	05.01.2004 -	implemented
607*cdf0e10cSrcweir  *
608*cdf0e10cSrcweir  *   AUTHOR
609*cdf0e10cSrcweir  *	Michael Mi
610*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
611*cdf0e10cSrcweir  ******************************************************************************/
612*cdf0e10cSrcweir {
613*cdf0e10cSrcweir 	BufferNode* rc = NULL;
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir 	if (nIndex < ((sal_Int32)m_vChildren.size()) && nIndex >= 0)
616*cdf0e10cSrcweir 	{
617*cdf0e10cSrcweir 		rc = (BufferNode*)m_vChildren[nIndex];
618*cdf0e10cSrcweir 	}
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir 	return (const BufferNode*)rc;
621*cdf0e10cSrcweir }
622*cdf0e10cSrcweir 
623*cdf0e10cSrcweir const BufferNode* BufferNode::getParent() const
624*cdf0e10cSrcweir {
625*cdf0e10cSrcweir 	return m_pParent;
626*cdf0e10cSrcweir }
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir void BufferNode::setParent(const BufferNode* pParent)
629*cdf0e10cSrcweir {
630*cdf0e10cSrcweir 	m_pParent = (BufferNode*)pParent;
631*cdf0e10cSrcweir }
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir const BufferNode* BufferNode::getNextSibling() const
634*cdf0e10cSrcweir /****** BufferNode/getNextSibling ********************************************
635*cdf0e10cSrcweir  *
636*cdf0e10cSrcweir  *   NAME
637*cdf0e10cSrcweir  *	getNextSibling -- retrieves the next sibling BufferNode.
638*cdf0e10cSrcweir  *
639*cdf0e10cSrcweir  *   SYNOPSIS
640*cdf0e10cSrcweir  *	sibling = getNextSibling();
641*cdf0e10cSrcweir  *
642*cdf0e10cSrcweir  *   FUNCTION
643*cdf0e10cSrcweir  *	see NAME
644*cdf0e10cSrcweir  *
645*cdf0e10cSrcweir  *   INPUTS
646*cdf0e10cSrcweir  *	empty
647*cdf0e10cSrcweir  *
648*cdf0e10cSrcweir  *   RESULT
649*cdf0e10cSrcweir  *	sibling - the next sibling BufferNode, or NULL if there is none.
650*cdf0e10cSrcweir  *
651*cdf0e10cSrcweir  *   HISTORY
652*cdf0e10cSrcweir  *	05.01.2004 -	implemented
653*cdf0e10cSrcweir  *
654*cdf0e10cSrcweir  *   AUTHOR
655*cdf0e10cSrcweir  *	Michael Mi
656*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
657*cdf0e10cSrcweir  ******************************************************************************/
658*cdf0e10cSrcweir {
659*cdf0e10cSrcweir 	BufferNode* rc = NULL;
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir 	if (m_pParent != NULL)
662*cdf0e10cSrcweir 	{
663*cdf0e10cSrcweir 		rc = (BufferNode*)m_pParent->getNextChild(this);
664*cdf0e10cSrcweir 	}
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir 	return (const BufferNode*)rc;
667*cdf0e10cSrcweir }
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir const BufferNode* BufferNode::isAncestor(const BufferNode* pDescendant) const
670*cdf0e10cSrcweir /****** BufferNode/isAncestor ************************************************
671*cdf0e10cSrcweir  *
672*cdf0e10cSrcweir  *   NAME
673*cdf0e10cSrcweir  *	isAncestor -- checks whether this BufferNode is an ancestor of another
674*cdf0e10cSrcweir  *	BufferNode.
675*cdf0e10cSrcweir  *
676*cdf0e10cSrcweir  *   SYNOPSIS
677*cdf0e10cSrcweir  *	bIs = isAncestor(pDescendant);
678*cdf0e10cSrcweir  *
679*cdf0e10cSrcweir  *   FUNCTION
680*cdf0e10cSrcweir  *	see NAME
681*cdf0e10cSrcweir  *
682*cdf0e10cSrcweir  *   INPUTS
683*cdf0e10cSrcweir  *	pDescendant -	the BufferNode to be checked as a descendant
684*cdf0e10cSrcweir  *
685*cdf0e10cSrcweir  *   RESULT
686*cdf0e10cSrcweir  *	bIs -	true if this BufferNode is an ancestor of the pDescendant,
687*cdf0e10cSrcweir  *	     	false otherwise.
688*cdf0e10cSrcweir  *
689*cdf0e10cSrcweir  *   HISTORY
690*cdf0e10cSrcweir  *	05.01.2004 -	implemented
691*cdf0e10cSrcweir  *
692*cdf0e10cSrcweir  *   AUTHOR
693*cdf0e10cSrcweir  *	Michael Mi
694*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
695*cdf0e10cSrcweir  ******************************************************************************/
696*cdf0e10cSrcweir {
697*cdf0e10cSrcweir 	BufferNode* rc = NULL;
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir 	if (pDescendant != NULL)
700*cdf0e10cSrcweir 	{
701*cdf0e10cSrcweir 		std::vector< const BufferNode* >::const_iterator ii = m_vChildren.begin();
702*cdf0e10cSrcweir 
703*cdf0e10cSrcweir 		for( ; ii != m_vChildren.end() ; ++ii )
704*cdf0e10cSrcweir 		{
705*cdf0e10cSrcweir 			BufferNode* pChild = (BufferNode*)*ii;
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir 			if (pChild == pDescendant)
708*cdf0e10cSrcweir 			{
709*cdf0e10cSrcweir 				rc = pChild;
710*cdf0e10cSrcweir 				break;
711*cdf0e10cSrcweir 			}
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir 			if (pChild->isAncestor(pDescendant) != NULL)
714*cdf0e10cSrcweir 			{
715*cdf0e10cSrcweir 				rc = pChild;
716*cdf0e10cSrcweir 				break;
717*cdf0e10cSrcweir 			}
718*cdf0e10cSrcweir 		}
719*cdf0e10cSrcweir 	}
720*cdf0e10cSrcweir 
721*cdf0e10cSrcweir 	return (const BufferNode*)rc;
722*cdf0e10cSrcweir }
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir bool BufferNode::isPrevious(const BufferNode* pFollowing) const
725*cdf0e10cSrcweir /****** BufferNode/isPrevious ************************************************
726*cdf0e10cSrcweir  *
727*cdf0e10cSrcweir  *   NAME
728*cdf0e10cSrcweir  *	isPrevious -- checks whether this BufferNode is ahead of another
729*cdf0e10cSrcweir  *	BufferNode in the tree order.
730*cdf0e10cSrcweir  *
731*cdf0e10cSrcweir  *   SYNOPSIS
732*cdf0e10cSrcweir  *	bIs = isPrevious(pFollowing);
733*cdf0e10cSrcweir  *
734*cdf0e10cSrcweir  *   FUNCTION
735*cdf0e10cSrcweir  *	see NAME
736*cdf0e10cSrcweir  *
737*cdf0e10cSrcweir  *   INPUTS
738*cdf0e10cSrcweir  *	pFollowing -	the BufferNode to be checked as a following
739*cdf0e10cSrcweir  *
740*cdf0e10cSrcweir  *   RESULT
741*cdf0e10cSrcweir  *	bIs -	true if this BufferNode is ahead in the tree order, false
742*cdf0e10cSrcweir  *	     	otherwise.
743*cdf0e10cSrcweir  *
744*cdf0e10cSrcweir  *   HISTORY
745*cdf0e10cSrcweir  *	05.01.2004 -	implemented
746*cdf0e10cSrcweir  *
747*cdf0e10cSrcweir  *   AUTHOR
748*cdf0e10cSrcweir  *	Michael Mi
749*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
750*cdf0e10cSrcweir  ******************************************************************************/
751*cdf0e10cSrcweir {
752*cdf0e10cSrcweir 	bool rc = false;
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir 	BufferNode* pNextBufferNode = (BufferNode*)getNextNodeByTreeOrder();
755*cdf0e10cSrcweir 	while (pNextBufferNode != NULL)
756*cdf0e10cSrcweir 	{
757*cdf0e10cSrcweir 		if (pNextBufferNode == pFollowing)
758*cdf0e10cSrcweir 		{
759*cdf0e10cSrcweir 			rc = true;
760*cdf0e10cSrcweir 			break;
761*cdf0e10cSrcweir 		}
762*cdf0e10cSrcweir 
763*cdf0e10cSrcweir 		pNextBufferNode = (BufferNode*)(pNextBufferNode->getNextNodeByTreeOrder());
764*cdf0e10cSrcweir 	}
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir 	return rc;
767*cdf0e10cSrcweir }
768*cdf0e10cSrcweir 
769*cdf0e10cSrcweir const BufferNode* BufferNode::getNextNodeByTreeOrder() const
770*cdf0e10cSrcweir /****** BufferNode/getNextNodeByTreeOrder ************************************
771*cdf0e10cSrcweir  *
772*cdf0e10cSrcweir  *   NAME
773*cdf0e10cSrcweir  *	getNextNodeByTreeOrder -- retrieves the next BufferNode in the tree
774*cdf0e10cSrcweir  *	order.
775*cdf0e10cSrcweir  *
776*cdf0e10cSrcweir  *   SYNOPSIS
777*cdf0e10cSrcweir  *	next = getNextNodeByTreeOrder();
778*cdf0e10cSrcweir  *
779*cdf0e10cSrcweir  *   FUNCTION
780*cdf0e10cSrcweir  *	see NAME
781*cdf0e10cSrcweir  *
782*cdf0e10cSrcweir  *   INPUTS
783*cdf0e10cSrcweir  *	empty
784*cdf0e10cSrcweir  *
785*cdf0e10cSrcweir  *   RESULT
786*cdf0e10cSrcweir  *	next -	the BufferNode following this BufferNode in the tree order,
787*cdf0e10cSrcweir  *	      	or NULL if there is none.
788*cdf0e10cSrcweir  *
789*cdf0e10cSrcweir  *   NOTES
790*cdf0e10cSrcweir  *	The "next" node in tree order is defined as:
791*cdf0e10cSrcweir  *	1. If a node has children, then the first child is;
792*cdf0e10cSrcweir  *	2. otherwise, if it has a following sibling, then this sibling node is;
793*cdf0e10cSrcweir  *	3. otherwise, if it has a parent node, the the parent's next sibling
794*cdf0e10cSrcweir  *	   node is;
795*cdf0e10cSrcweir  *	4. otherwise, no "next" node exists.
796*cdf0e10cSrcweir  *
797*cdf0e10cSrcweir  *   HISTORY
798*cdf0e10cSrcweir  *	05.01.2004 -	implemented
799*cdf0e10cSrcweir  *
800*cdf0e10cSrcweir  *   AUTHOR
801*cdf0e10cSrcweir  *	Michael Mi
802*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
803*cdf0e10cSrcweir  ******************************************************************************/
804*cdf0e10cSrcweir {
805*cdf0e10cSrcweir         /*
806*cdf0e10cSrcweir          * If this buffer node has m_vChildren, then return the first
807*cdf0e10cSrcweir          * child.
808*cdf0e10cSrcweir          */
809*cdf0e10cSrcweir 	if (hasChildren())
810*cdf0e10cSrcweir 	{
811*cdf0e10cSrcweir 		return getFirstChild();
812*cdf0e10cSrcweir 	}
813*cdf0e10cSrcweir 
814*cdf0e10cSrcweir         /*
815*cdf0e10cSrcweir          * Otherwise, it this buffer node has a following sibling,
816*cdf0e10cSrcweir          * then return that sibling.
817*cdf0e10cSrcweir          */
818*cdf0e10cSrcweir 	BufferNode* pNextSibling = (BufferNode*)getNextSibling();
819*cdf0e10cSrcweir 	if (pNextSibling != NULL)
820*cdf0e10cSrcweir 	{
821*cdf0e10cSrcweir 		return pNextSibling;
822*cdf0e10cSrcweir 	}
823*cdf0e10cSrcweir 
824*cdf0e10cSrcweir         /*
825*cdf0e10cSrcweir          * Otherwise, it this buffer node has parent, then return
826*cdf0e10cSrcweir          * its parent's following sibling.
827*cdf0e10cSrcweir          */
828*cdf0e10cSrcweir         BufferNode* pNode = (BufferNode*)this;
829*cdf0e10cSrcweir 	BufferNode* pParent;
830*cdf0e10cSrcweir 	BufferNode* pNextSiblingParent = NULL;
831*cdf0e10cSrcweir 
832*cdf0e10cSrcweir 	do
833*cdf0e10cSrcweir 	{
834*cdf0e10cSrcweir 		if (pNode == NULL)
835*cdf0e10cSrcweir 		{
836*cdf0e10cSrcweir 			break;
837*cdf0e10cSrcweir 		}
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir 		pParent = (BufferNode*)pNode->getParent();
840*cdf0e10cSrcweir 		if (pParent != NULL)
841*cdf0e10cSrcweir 		{
842*cdf0e10cSrcweir 			pNextSiblingParent = (BufferNode*)pParent->getNextSibling();
843*cdf0e10cSrcweir 		}
844*cdf0e10cSrcweir 		pNode = pParent;
845*cdf0e10cSrcweir 
846*cdf0e10cSrcweir 	}while (pNextSiblingParent == NULL);
847*cdf0e10cSrcweir 
848*cdf0e10cSrcweir 	return pNextSiblingParent;
849*cdf0e10cSrcweir }
850*cdf0e10cSrcweir 
851*cdf0e10cSrcweir cssu::Reference< cssxw::XXMLElementWrapper > BufferNode::getXMLElement() const
852*cdf0e10cSrcweir {
853*cdf0e10cSrcweir 	return m_xXMLElement;
854*cdf0e10cSrcweir }
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir void BufferNode::setXMLElement( const cssu::Reference< cssxw::XXMLElementWrapper >& xXMLElement )
857*cdf0e10cSrcweir {
858*cdf0e10cSrcweir 	m_xXMLElement = xXMLElement;
859*cdf0e10cSrcweir }
860*cdf0e10cSrcweir 
861*cdf0e10cSrcweir void BufferNode::notifyBranch()
862*cdf0e10cSrcweir /****** BufferNode/notifyBranch **********************************************
863*cdf0e10cSrcweir  *
864*cdf0e10cSrcweir  *   NAME
865*cdf0e10cSrcweir  *	notifyBranch -- notifies each BufferNode in the branch of this
866*cdf0e10cSrcweir  *	BufferNode in the tree order.
867*cdf0e10cSrcweir  *
868*cdf0e10cSrcweir  *   SYNOPSIS
869*cdf0e10cSrcweir  *	notifyBranch();
870*cdf0e10cSrcweir  *
871*cdf0e10cSrcweir  *   FUNCTION
872*cdf0e10cSrcweir  *	see NAME
873*cdf0e10cSrcweir  *
874*cdf0e10cSrcweir  *   INPUTS
875*cdf0e10cSrcweir  *	empty
876*cdf0e10cSrcweir  *
877*cdf0e10cSrcweir  *   RESULT
878*cdf0e10cSrcweir  *	empty
879*cdf0e10cSrcweir  *
880*cdf0e10cSrcweir  *   HISTORY
881*cdf0e10cSrcweir  *	05.01.2004 -	implemented
882*cdf0e10cSrcweir  *
883*cdf0e10cSrcweir  *   AUTHOR
884*cdf0e10cSrcweir  *	Michael Mi
885*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
886*cdf0e10cSrcweir  ******************************************************************************/
887*cdf0e10cSrcweir {
888*cdf0e10cSrcweir 	std::vector< const BufferNode* >::const_iterator ii = m_vChildren.begin();
889*cdf0e10cSrcweir 
890*cdf0e10cSrcweir 	for( ; ii != m_vChildren.end() ; ++ii )
891*cdf0e10cSrcweir 	{
892*cdf0e10cSrcweir 		BufferNode* pBufferNode = (BufferNode*)*ii;
893*cdf0e10cSrcweir 		pBufferNode->elementCollectorNotify();
894*cdf0e10cSrcweir 		pBufferNode->notifyBranch();
895*cdf0e10cSrcweir 	}
896*cdf0e10cSrcweir }
897*cdf0e10cSrcweir 
898*cdf0e10cSrcweir void BufferNode::notifyAncestor()
899*cdf0e10cSrcweir /****** BufferNode/notifyAncestor ********************************************
900*cdf0e10cSrcweir  *
901*cdf0e10cSrcweir  *   NAME
902*cdf0e10cSrcweir  *	notifyAncestor -- notifies each ancestor BufferNode through the parent
903*cdf0e10cSrcweir  *	link.
904*cdf0e10cSrcweir  *
905*cdf0e10cSrcweir  *   SYNOPSIS
906*cdf0e10cSrcweir  *	notifyAncestor();
907*cdf0e10cSrcweir  *
908*cdf0e10cSrcweir  *   FUNCTION
909*cdf0e10cSrcweir  *	see NAME
910*cdf0e10cSrcweir  *
911*cdf0e10cSrcweir  *   INPUTS
912*cdf0e10cSrcweir  *	empty
913*cdf0e10cSrcweir  *
914*cdf0e10cSrcweir  *   RESULT
915*cdf0e10cSrcweir  *	empty
916*cdf0e10cSrcweir  *
917*cdf0e10cSrcweir  *   HISTORY
918*cdf0e10cSrcweir  *	05.01.2004 -	implemented
919*cdf0e10cSrcweir  *
920*cdf0e10cSrcweir  *   AUTHOR
921*cdf0e10cSrcweir  *	Michael Mi
922*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
923*cdf0e10cSrcweir  ******************************************************************************/
924*cdf0e10cSrcweir {
925*cdf0e10cSrcweir 	BufferNode* pParent = m_pParent;
926*cdf0e10cSrcweir 	while (pParent != NULL)
927*cdf0e10cSrcweir 	{
928*cdf0e10cSrcweir 		pParent->notifyAncestor();
929*cdf0e10cSrcweir 		pParent = (BufferNode*)pParent->getParent();
930*cdf0e10cSrcweir 	}
931*cdf0e10cSrcweir }
932*cdf0e10cSrcweir 
933*cdf0e10cSrcweir void BufferNode::elementCollectorNotify()
934*cdf0e10cSrcweir /****** BufferNode/elementCollectorNotify ************************************
935*cdf0e10cSrcweir  *
936*cdf0e10cSrcweir  *   NAME
937*cdf0e10cSrcweir  *	elementCollectorNotify -- notifies this BufferNode.
938*cdf0e10cSrcweir  *
939*cdf0e10cSrcweir  *   SYNOPSIS
940*cdf0e10cSrcweir  *	elementCollectorNotify();
941*cdf0e10cSrcweir  *
942*cdf0e10cSrcweir  *   FUNCTION
943*cdf0e10cSrcweir  *	Notifies this BufferNode if the notification is not suppressed.
944*cdf0e10cSrcweir  *
945*cdf0e10cSrcweir  *   INPUTS
946*cdf0e10cSrcweir  *	empty
947*cdf0e10cSrcweir  *
948*cdf0e10cSrcweir  *   RESULT
949*cdf0e10cSrcweir  *	child -	the first child BufferNode, or NULL if there is no child
950*cdf0e10cSrcweir  *	       	BufferNode.
951*cdf0e10cSrcweir  *
952*cdf0e10cSrcweir  *   HISTORY
953*cdf0e10cSrcweir  *	05.01.2004 -	implemented
954*cdf0e10cSrcweir  *
955*cdf0e10cSrcweir  *   AUTHOR
956*cdf0e10cSrcweir  *	Michael Mi
957*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
958*cdf0e10cSrcweir  ******************************************************************************/
959*cdf0e10cSrcweir {
960*cdf0e10cSrcweir 	if (m_vElementCollectors.size()>0)
961*cdf0e10cSrcweir 	{
962*cdf0e10cSrcweir 		cssxc::sax::ElementMarkPriority nMaxPriority = cssxc::sax::ElementMarkPriority_MINIMUM;
963*cdf0e10cSrcweir 		cssxc::sax::ElementMarkPriority nPriority;
964*cdf0e10cSrcweir 
965*cdf0e10cSrcweir 		/*
966*cdf0e10cSrcweir 		 * get the max priority among ElementCollectors on this BufferNode
967*cdf0e10cSrcweir 		 */
968*cdf0e10cSrcweir 		std::vector< const ElementCollector* >::const_iterator ii = m_vElementCollectors.begin();
969*cdf0e10cSrcweir 		for( ; ii != m_vElementCollectors.end() ; ++ii )
970*cdf0e10cSrcweir 		{
971*cdf0e10cSrcweir 			ElementCollector* pElementCollector = (ElementCollector*)*ii;
972*cdf0e10cSrcweir 			nPriority = pElementCollector->getPriority();
973*cdf0e10cSrcweir 			if (nPriority > nMaxPriority)
974*cdf0e10cSrcweir 			{
975*cdf0e10cSrcweir 				nMaxPriority = nPriority;
976*cdf0e10cSrcweir 			}
977*cdf0e10cSrcweir 		}
978*cdf0e10cSrcweir 
979*cdf0e10cSrcweir 		std::vector< const ElementCollector* > vElementCollectors( m_vElementCollectors );
980*cdf0e10cSrcweir 		ii = vElementCollectors.begin();
981*cdf0e10cSrcweir 
982*cdf0e10cSrcweir 		for( ; ii != vElementCollectors.end() ; ++ii )
983*cdf0e10cSrcweir 		{
984*cdf0e10cSrcweir 			ElementCollector* pElementCollector = (ElementCollector*)*ii;
985*cdf0e10cSrcweir 			nPriority = pElementCollector->getPriority();
986*cdf0e10cSrcweir 			bool bToModify = pElementCollector->getModify();
987*cdf0e10cSrcweir 
988*cdf0e10cSrcweir 			/*
989*cdf0e10cSrcweir 			 * Only ElementCollector with the max priority can
990*cdf0e10cSrcweir 			 * perform notify operation.
991*cdf0e10cSrcweir 			 * Moreover, if any blocker exists in the subtree of
992*cdf0e10cSrcweir 			 * this BufferNode, this ElementCollector can't do notify
993*cdf0e10cSrcweir 			 * unless its priority is BEFOREMODIFY.
994*cdf0e10cSrcweir 			 */
995*cdf0e10cSrcweir 			if (nPriority == nMaxPriority &&
996*cdf0e10cSrcweir 				(nPriority == cssxc::sax::ElementMarkPriority_BEFOREMODIFY ||
997*cdf0e10cSrcweir 				 !isBlockerInSubTreeIncluded(pElementCollector->getSecurityId())))
998*cdf0e10cSrcweir 			{
999*cdf0e10cSrcweir 				/*
1000*cdf0e10cSrcweir 				 * If this ElementCollector will modify the bufferred element, then
1001*cdf0e10cSrcweir 				 * special attention must be paid.
1002*cdf0e10cSrcweir 				 *
1003*cdf0e10cSrcweir 				 * If there is any ElementCollector in the subtree or any ancestor
1004*cdf0e10cSrcweir 				 * ElementCollector with PRI_BEFPREMODIFY priority, this
1005*cdf0e10cSrcweir 				 * ElementCollector can't perform notify operation, otherwise, it
1006*cdf0e10cSrcweir 				 * will destroy the bufferred element, in turn, ElementCollectors
1007*cdf0e10cSrcweir 				 * mentioned above can't perform their mission.
1008*cdf0e10cSrcweir 				 */
1009*cdf0e10cSrcweir 				//if (!(nMaxPriority == cssxc::sax::ElementMarkPriority_PRI_MODIFY &&
1010*cdf0e10cSrcweir 				if (!(bToModify &&
1011*cdf0e10cSrcweir 				     (isECInSubTreeIncluded(pElementCollector->getSecurityId()) ||
1012*cdf0e10cSrcweir 				      isECOfBeforeModifyInAncestorIncluded(pElementCollector->getSecurityId()))
1013*cdf0e10cSrcweir 				   ))
1014*cdf0e10cSrcweir 				{
1015*cdf0e10cSrcweir 					pElementCollector->notifyListener();
1016*cdf0e10cSrcweir 				}
1017*cdf0e10cSrcweir 			}
1018*cdf0e10cSrcweir 		}
1019*cdf0e10cSrcweir 	}
1020*cdf0e10cSrcweir }
1021*cdf0e10cSrcweir 
1022*cdf0e10cSrcweir bool BufferNode::isECInSubTreeIncluded(sal_Int32 nIgnoredSecurityId) const
1023*cdf0e10cSrcweir /****** BufferNode/isECInSubTreeIncluded *************************************
1024*cdf0e10cSrcweir  *
1025*cdf0e10cSrcweir  *   NAME
1026*cdf0e10cSrcweir  *	isECInSubTreeIncluded -- checks whether there is any ElementCollector
1027*cdf0e10cSrcweir  *	in the branch of this BufferNode.
1028*cdf0e10cSrcweir  *
1029*cdf0e10cSrcweir  *   SYNOPSIS
1030*cdf0e10cSrcweir  *	bExist = isECInSubTreeIncluded(nIgnoredSecurityId);
1031*cdf0e10cSrcweir  *
1032*cdf0e10cSrcweir  *   FUNCTION
1033*cdf0e10cSrcweir  *	checks each BufferNode in the branch of this BufferNode, if there is
1034*cdf0e10cSrcweir  *	an ElementCollector whose signatureId is not ignored, then return
1035*cdf0e10cSrcweir  *	true, otherwise, false returned.
1036*cdf0e10cSrcweir  *
1037*cdf0e10cSrcweir  *   INPUTS
1038*cdf0e10cSrcweir  *	nIgnoredSecurityId -	the security Id to be ignored. If it equals
1039*cdf0e10cSrcweir  *	                        to UNDEFINEDSECURITYID, then no security Id
1040*cdf0e10cSrcweir  *	                    	will be ignored.
1041*cdf0e10cSrcweir  *
1042*cdf0e10cSrcweir  *   RESULT
1043*cdf0e10cSrcweir  *	bExist - true if a match found, false otherwise.
1044*cdf0e10cSrcweir  *
1045*cdf0e10cSrcweir  *   HISTORY
1046*cdf0e10cSrcweir  *	05.01.2004 -	implemented
1047*cdf0e10cSrcweir  *
1048*cdf0e10cSrcweir  *   AUTHOR
1049*cdf0e10cSrcweir  *	Michael Mi
1050*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
1051*cdf0e10cSrcweir  ******************************************************************************/
1052*cdf0e10cSrcweir {
1053*cdf0e10cSrcweir 	bool rc = false;
1054*cdf0e10cSrcweir 
1055*cdf0e10cSrcweir 	std::vector< const ElementCollector* >::const_iterator jj = m_vElementCollectors.begin();
1056*cdf0e10cSrcweir 
1057*cdf0e10cSrcweir 	for( ; jj != m_vElementCollectors.end() ; ++jj )
1058*cdf0e10cSrcweir 	{
1059*cdf0e10cSrcweir 		ElementCollector* pElementCollector = (ElementCollector*)*jj;
1060*cdf0e10cSrcweir 		if (nIgnoredSecurityId == cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID ||
1061*cdf0e10cSrcweir 		 	pElementCollector->getSecurityId() != nIgnoredSecurityId)
1062*cdf0e10cSrcweir 		{
1063*cdf0e10cSrcweir 			rc = true;
1064*cdf0e10cSrcweir 			break;
1065*cdf0e10cSrcweir 		}
1066*cdf0e10cSrcweir 	}
1067*cdf0e10cSrcweir 
1068*cdf0e10cSrcweir 	if ( !rc )
1069*cdf0e10cSrcweir 	{
1070*cdf0e10cSrcweir 		std::vector< const BufferNode* >::const_iterator ii = m_vChildren.begin();
1071*cdf0e10cSrcweir 
1072*cdf0e10cSrcweir 		for( ; ii != m_vChildren.end() ; ++ii )
1073*cdf0e10cSrcweir 		{
1074*cdf0e10cSrcweir 			BufferNode* pBufferNode = (BufferNode*)*ii;
1075*cdf0e10cSrcweir 
1076*cdf0e10cSrcweir 			if ( pBufferNode->isECInSubTreeIncluded(nIgnoredSecurityId))
1077*cdf0e10cSrcweir 			{
1078*cdf0e10cSrcweir 				rc = true;
1079*cdf0e10cSrcweir 				break;
1080*cdf0e10cSrcweir 			}
1081*cdf0e10cSrcweir 		}
1082*cdf0e10cSrcweir 	}
1083*cdf0e10cSrcweir 
1084*cdf0e10cSrcweir 	return rc;
1085*cdf0e10cSrcweir }
1086*cdf0e10cSrcweir 
1087*cdf0e10cSrcweir bool BufferNode::isECOfBeforeModifyInAncestorIncluded(sal_Int32 nIgnoredSecurityId) const
1088*cdf0e10cSrcweir /****** BufferNode/isECOfBeforeModifyInAncestorIncluded **********************
1089*cdf0e10cSrcweir  *
1090*cdf0e10cSrcweir  *   NAME
1091*cdf0e10cSrcweir  *	isECOfBeforeModifyInAncestorIncluded -- checks whether there is some
1092*cdf0e10cSrcweir  *	ancestor BufferNode which has ElementCollector with PRI_BEFPREMODIFY
1093*cdf0e10cSrcweir  *	priority.
1094*cdf0e10cSrcweir  *
1095*cdf0e10cSrcweir  *   SYNOPSIS
1096*cdf0e10cSrcweir  *	bExist = isECOfBeforeModifyInAncestorIncluded(nIgnoredSecurityId);
1097*cdf0e10cSrcweir  *
1098*cdf0e10cSrcweir  *   FUNCTION
1099*cdf0e10cSrcweir  *	checks each ancestor BufferNode through the parent link, if there is
1100*cdf0e10cSrcweir  *	an ElementCollector with PRI_BEFPREMODIFY priority and its
1101*cdf0e10cSrcweir  *	signatureId is not ignored, then return true, otherwise, false
1102*cdf0e10cSrcweir  *	returned.
1103*cdf0e10cSrcweir  *
1104*cdf0e10cSrcweir  *   INPUTS
1105*cdf0e10cSrcweir  *	nIgnoredSecurityId -	the security Id to be ignored. If it equals
1106*cdf0e10cSrcweir  *	                        to UNDEFINEDSECURITYID, then no security Id
1107*cdf0e10cSrcweir  *	                    	will be ignored.
1108*cdf0e10cSrcweir  *
1109*cdf0e10cSrcweir  *   RESULT
1110*cdf0e10cSrcweir  *	bExist - true if a match found, false otherwise.
1111*cdf0e10cSrcweir  *
1112*cdf0e10cSrcweir  *   HISTORY
1113*cdf0e10cSrcweir  *	05.01.2004 -	implemented
1114*cdf0e10cSrcweir  *
1115*cdf0e10cSrcweir  *   AUTHOR
1116*cdf0e10cSrcweir  *	Michael Mi
1117*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
1118*cdf0e10cSrcweir  ******************************************************************************/
1119*cdf0e10cSrcweir {
1120*cdf0e10cSrcweir 	bool rc = false;
1121*cdf0e10cSrcweir 
1122*cdf0e10cSrcweir 	BufferNode* pParentNode = m_pParent;
1123*cdf0e10cSrcweir 	while (pParentNode != NULL)
1124*cdf0e10cSrcweir 	{
1125*cdf0e10cSrcweir 		if (pParentNode->isECOfBeforeModifyIncluded(nIgnoredSecurityId))
1126*cdf0e10cSrcweir 		{
1127*cdf0e10cSrcweir 			rc = true;
1128*cdf0e10cSrcweir 			break;
1129*cdf0e10cSrcweir 		}
1130*cdf0e10cSrcweir 
1131*cdf0e10cSrcweir 		pParentNode = (BufferNode*)pParentNode->getParent();
1132*cdf0e10cSrcweir 	}
1133*cdf0e10cSrcweir 
1134*cdf0e10cSrcweir 	return rc;
1135*cdf0e10cSrcweir }
1136*cdf0e10cSrcweir 
1137*cdf0e10cSrcweir bool BufferNode::isBlockerInSubTreeIncluded(sal_Int32 nIgnoredSecurityId) const
1138*cdf0e10cSrcweir /****** BufferNode/isBlockerInSubTreeIncluded ********************************
1139*cdf0e10cSrcweir  *
1140*cdf0e10cSrcweir  *   NAME
1141*cdf0e10cSrcweir  *	isBlockerInSubTreeIncluded -- checks whether there is some BufferNode
1142*cdf0e10cSrcweir  *	which has blocker on it
1143*cdf0e10cSrcweir  *
1144*cdf0e10cSrcweir  *   SYNOPSIS
1145*cdf0e10cSrcweir  *	bExist = isBlockerInSubTreeIncluded(nIgnoredSecurityId);
1146*cdf0e10cSrcweir  *
1147*cdf0e10cSrcweir  *   FUNCTION
1148*cdf0e10cSrcweir  *	checks each BufferNode in the branch of this BufferNode, if one has
1149*cdf0e10cSrcweir  *	a blocker on it, and the blocker's securityId is not ignored, then
1150*cdf0e10cSrcweir  *	returns true; otherwise, false returns.
1151*cdf0e10cSrcweir  *
1152*cdf0e10cSrcweir  *   INPUTS
1153*cdf0e10cSrcweir  *	nIgnoredSecurityId -	the security Id to be ignored. If it equals
1154*cdf0e10cSrcweir  *	                        to UNDEFINEDSECURITYID, then no security Id
1155*cdf0e10cSrcweir  *	                    	will be ignored.
1156*cdf0e10cSrcweir  *
1157*cdf0e10cSrcweir  *   RESULT
1158*cdf0e10cSrcweir  *	bExist - true if a match found, false otherwise.
1159*cdf0e10cSrcweir  *
1160*cdf0e10cSrcweir  *   HISTORY
1161*cdf0e10cSrcweir  *	05.01.2004 -	implemented
1162*cdf0e10cSrcweir  *
1163*cdf0e10cSrcweir  *   AUTHOR
1164*cdf0e10cSrcweir  *	Michael Mi
1165*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
1166*cdf0e10cSrcweir  ******************************************************************************/
1167*cdf0e10cSrcweir {
1168*cdf0e10cSrcweir 	bool rc = false;
1169*cdf0e10cSrcweir 
1170*cdf0e10cSrcweir 	std::vector< const BufferNode* >::const_iterator ii = m_vChildren.begin();
1171*cdf0e10cSrcweir 
1172*cdf0e10cSrcweir 	for( ; ii != m_vChildren.end() ; ++ii )
1173*cdf0e10cSrcweir 	{
1174*cdf0e10cSrcweir 		BufferNode* pBufferNode = (BufferNode*)*ii;
1175*cdf0e10cSrcweir 		ElementMark* pBlocker = pBufferNode->getBlocker();
1176*cdf0e10cSrcweir 
1177*cdf0e10cSrcweir 		if (pBlocker != NULL &&
1178*cdf0e10cSrcweir 			(nIgnoredSecurityId == cssxc::sax::ConstOfSecurityId::UNDEFINEDSECURITYID ||
1179*cdf0e10cSrcweir 			pBlocker->getSecurityId() != nIgnoredSecurityId ))
1180*cdf0e10cSrcweir 		{
1181*cdf0e10cSrcweir 			rc = true;
1182*cdf0e10cSrcweir 			break;
1183*cdf0e10cSrcweir 		}
1184*cdf0e10cSrcweir 
1185*cdf0e10cSrcweir 		if (rc || pBufferNode->isBlockerInSubTreeIncluded(nIgnoredSecurityId))
1186*cdf0e10cSrcweir 		{
1187*cdf0e10cSrcweir 			rc = true;
1188*cdf0e10cSrcweir 			break;
1189*cdf0e10cSrcweir 		}
1190*cdf0e10cSrcweir 	}
1191*cdf0e10cSrcweir 
1192*cdf0e10cSrcweir 	return rc;
1193*cdf0e10cSrcweir }
1194*cdf0e10cSrcweir 
1195*cdf0e10cSrcweir const BufferNode* BufferNode::getNextChild(const BufferNode* pChild) const
1196*cdf0e10cSrcweir /****** BufferNode/getNextChild **********************************************
1197*cdf0e10cSrcweir  *
1198*cdf0e10cSrcweir  *   NAME
1199*cdf0e10cSrcweir  *	getNextChild -- get the next child BufferNode.
1200*cdf0e10cSrcweir  *
1201*cdf0e10cSrcweir  *   SYNOPSIS
1202*cdf0e10cSrcweir  *	nextChild = getNextChild();
1203*cdf0e10cSrcweir  *
1204*cdf0e10cSrcweir  *   FUNCTION
1205*cdf0e10cSrcweir  *	see NAME
1206*cdf0e10cSrcweir  *
1207*cdf0e10cSrcweir  *   INPUTS
1208*cdf0e10cSrcweir  *	pChild - the child BufferNode whose next node is retrieved.
1209*cdf0e10cSrcweir  *
1210*cdf0e10cSrcweir  *   RESULT
1211*cdf0e10cSrcweir  *	nextChild -	the next child BufferNode after the pChild, or NULL if
1212*cdf0e10cSrcweir  *	there is none.
1213*cdf0e10cSrcweir  *
1214*cdf0e10cSrcweir  *   HISTORY
1215*cdf0e10cSrcweir  *	05.01.2004 -	implemented
1216*cdf0e10cSrcweir  *
1217*cdf0e10cSrcweir  *   AUTHOR
1218*cdf0e10cSrcweir  *	Michael Mi
1219*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
1220*cdf0e10cSrcweir  ******************************************************************************/
1221*cdf0e10cSrcweir {
1222*cdf0e10cSrcweir 	BufferNode* rc = NULL;
1223*cdf0e10cSrcweir 	bool bChildFound = false;
1224*cdf0e10cSrcweir 
1225*cdf0e10cSrcweir 	std::vector< const BufferNode* >::const_iterator ii = m_vChildren.begin();
1226*cdf0e10cSrcweir 	for( ; ii != m_vChildren.end() ; ++ii )
1227*cdf0e10cSrcweir 	{
1228*cdf0e10cSrcweir 		if (bChildFound)
1229*cdf0e10cSrcweir 		{
1230*cdf0e10cSrcweir 			rc = (BufferNode*)*ii;
1231*cdf0e10cSrcweir 			break;
1232*cdf0e10cSrcweir 		}
1233*cdf0e10cSrcweir 
1234*cdf0e10cSrcweir 		if( *ii == pChild )
1235*cdf0e10cSrcweir 		{
1236*cdf0e10cSrcweir 			bChildFound = true;
1237*cdf0e10cSrcweir 		}
1238*cdf0e10cSrcweir 	}
1239*cdf0e10cSrcweir 
1240*cdf0e10cSrcweir 	return (const BufferNode*)rc;
1241*cdf0e10cSrcweir }
1242*cdf0e10cSrcweir 
1243*cdf0e10cSrcweir 
1244*cdf0e10cSrcweir void BufferNode::freeAllChildren()
1245*cdf0e10cSrcweir /****** BufferNode/freeAllChildren *******************************************
1246*cdf0e10cSrcweir  *
1247*cdf0e10cSrcweir  *   NAME
1248*cdf0e10cSrcweir  *	freeAllChildren -- free all his child BufferNode.
1249*cdf0e10cSrcweir  *
1250*cdf0e10cSrcweir  *   SYNOPSIS
1251*cdf0e10cSrcweir  *	freeAllChildren();
1252*cdf0e10cSrcweir  *
1253*cdf0e10cSrcweir  *   FUNCTION
1254*cdf0e10cSrcweir  *	see NAME
1255*cdf0e10cSrcweir  *
1256*cdf0e10cSrcweir  *   INPUTS
1257*cdf0e10cSrcweir  *	empty
1258*cdf0e10cSrcweir  *
1259*cdf0e10cSrcweir  *   RESULT
1260*cdf0e10cSrcweir  *	empty
1261*cdf0e10cSrcweir  *
1262*cdf0e10cSrcweir  *   HISTORY
1263*cdf0e10cSrcweir  *	30.03.2004 -	the correct the memory leak bug
1264*cdf0e10cSrcweir  *
1265*cdf0e10cSrcweir  *   AUTHOR
1266*cdf0e10cSrcweir  *	Michael Mi
1267*cdf0e10cSrcweir  *	Email: michael.mi@sun.com
1268*cdf0e10cSrcweir  ******************************************************************************/
1269*cdf0e10cSrcweir {
1270*cdf0e10cSrcweir 	std::vector< const BufferNode* >::const_iterator ii = m_vChildren.begin();
1271*cdf0e10cSrcweir 	for( ; ii != m_vChildren.end() ; ++ii )
1272*cdf0e10cSrcweir 	{
1273*cdf0e10cSrcweir 		BufferNode *pChild = (BufferNode *)(*ii);
1274*cdf0e10cSrcweir 		pChild->freeAllChildren();
1275*cdf0e10cSrcweir 		delete pChild;
1276*cdf0e10cSrcweir 	}
1277*cdf0e10cSrcweir 
1278*cdf0e10cSrcweir 	m_vChildren.clear();
1279*cdf0e10cSrcweir }
1280