1*06b3ce53SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*06b3ce53SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*06b3ce53SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*06b3ce53SAndrew Rist  * distributed with this work for additional information
6*06b3ce53SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*06b3ce53SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*06b3ce53SAndrew Rist  * "License"); you may not use this file except in compliance
9*06b3ce53SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*06b3ce53SAndrew Rist  *
11*06b3ce53SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*06b3ce53SAndrew Rist  *
13*06b3ce53SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*06b3ce53SAndrew Rist  * software distributed under the License is distributed on an
15*06b3ce53SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*06b3ce53SAndrew Rist  * KIND, either express or implied.  See the License for the
17*06b3ce53SAndrew Rist  * specific language governing permissions and limitations
18*06b3ce53SAndrew Rist  * under the License.
19*06b3ce53SAndrew Rist  *
20*06b3ce53SAndrew Rist  *************************************************************/
21*06b3ce53SAndrew Rist 
22*06b3ce53SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmlsecurity.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "xmldocumentwrapper_xmlsecimpl.hxx"
28cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <xmloff/attrlist.hxx>
31cdf0e10cSrcweir #include "xmlelementwrapper_xmlsecimpl.hxx"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir //#include <malloc.h>
34cdf0e10cSrcweir #include <stdio.h>
35cdf0e10cSrcweir #include <stdlib.h>
36cdf0e10cSrcweir #include <string.h>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir /*
39cdf0e10cSrcweir  * Deleted by AF
40cdf0e10cSrcweir #include <memory.h>
41cdf0e10cSrcweir  */
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <sys/types.h>
44cdf0e10cSrcweir #include <sys/stat.h>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #ifndef INCLUDED_VECTOR
47cdf0e10cSrcweir #include <vector>
48cdf0e10cSrcweir #define INCLUDED_VECTOR
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #ifdef UNX
52cdf0e10cSrcweir #define stricmp strcasecmp
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir 
55cdf0e10cSrcweir namespace cssu = com::sun::star::uno;
56cdf0e10cSrcweir namespace cssl = com::sun::star::lang;
57cdf0e10cSrcweir namespace cssxc = com::sun::star::xml::crypto;
58cdf0e10cSrcweir namespace cssxcsax = com::sun::star::xml::csax;
59cdf0e10cSrcweir namespace cssxs = com::sun::star::xml::sax;
60cdf0e10cSrcweir namespace cssxw = com::sun::star::xml::wrapper;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir #define SERVICE_NAME "com.sun.star.xml.wrapper.XMLDocumentWrapper"
63cdf0e10cSrcweir #define IMPLEMENTATION_NAME "com.sun.star.xml.security.bridge.xmlsec.XMLDocumentWrapper_XmlSecImpl"
64cdf0e10cSrcweir 
65cdf0e10cSrcweir #define STRXMLNS "xmlns"
66cdf0e10cSrcweir 
67cdf0e10cSrcweir #define RTL_ASCII_USTRINGPARAM( asciiStr ) asciiStr, strlen( asciiStr ), RTL_TEXTENCODING_ASCII_US
68cdf0e10cSrcweir #define RTL_UTF8_USTRINGPARAM( asciiStr ) asciiStr, strlen( asciiStr ), RTL_TEXTENCODING_UTF8
69cdf0e10cSrcweir 
70cdf0e10cSrcweir /* used by the recursiveDelete method */
71cdf0e10cSrcweir #define NODE_REMOVED    0
72cdf0e10cSrcweir #define NODE_NOTREMOVED 1
73cdf0e10cSrcweir #define NODE_STOPED     2
74cdf0e10cSrcweir 
XMLDocumentWrapper_XmlSecImpl()75cdf0e10cSrcweir XMLDocumentWrapper_XmlSecImpl::XMLDocumentWrapper_XmlSecImpl( )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir 	saxHelper.startDocument();
78cdf0e10cSrcweir 	m_pDocument = saxHelper.getDocument();
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 	/*
81cdf0e10cSrcweir 	 * creates the virtual root element
82cdf0e10cSrcweir 	 */
83cdf0e10cSrcweir 	saxHelper.startElement(rtl::OUString(RTL_UTF8_USTRINGPARAM( "root" )), cssu::Sequence<cssxcsax::XMLAttribute>());
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	m_pRootElement = saxHelper.getCurrentNode();
86cdf0e10cSrcweir 	m_pCurrentElement = m_pRootElement;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
~XMLDocumentWrapper_XmlSecImpl()89cdf0e10cSrcweir XMLDocumentWrapper_XmlSecImpl::~XMLDocumentWrapper_XmlSecImpl()
90cdf0e10cSrcweir {
91cdf0e10cSrcweir 	saxHelper.endDocument();
92cdf0e10cSrcweir 	xmlFreeDoc(m_pDocument);
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
getNextSAXEvent()95cdf0e10cSrcweir void XMLDocumentWrapper_XmlSecImpl::getNextSAXEvent()
96cdf0e10cSrcweir /****** XMLDocumentWrapper_XmlSecImpl/getNextSAXEvent *************************
97cdf0e10cSrcweir  *
98cdf0e10cSrcweir  *   NAME
99cdf0e10cSrcweir  *	getNextSAXEvent -- Prepares the next SAX event to be manipulate
100cdf0e10cSrcweir  *
101cdf0e10cSrcweir  *   SYNOPSIS
102cdf0e10cSrcweir  *	getNextSAXEvent();
103cdf0e10cSrcweir  *
104cdf0e10cSrcweir  *   FUNCTION
105cdf0e10cSrcweir  *	When converting the document into SAX events, this method is used to
106cdf0e10cSrcweir  *	decide the next SAX event to be generated.
107cdf0e10cSrcweir  *	Two member variables are checked to make the decision, the
108cdf0e10cSrcweir  *	m_pCurrentElement and the m_nCurrentPosition.
109cdf0e10cSrcweir  *	The m_pCurrentElement represents the node which have been covered, and
110cdf0e10cSrcweir  *	the m_nCurrentPosition represents the event which have been sent.
111cdf0e10cSrcweir  *	For example, suppose that the m_pCurrentElement
112cdf0e10cSrcweir  *	points to element A, and the m_nCurrentPosition equals to
113cdf0e10cSrcweir  *	NODEPOSITION_STARTELEMENT, then the next SAX event should be the
114cdf0e10cSrcweir  *	endElement for element A if A has no child, or startElement for the
115cdf0e10cSrcweir  *	first child element of element A otherwise.
116cdf0e10cSrcweir  *	The m_nCurrentPosition can be one of following values:
117cdf0e10cSrcweir  *	NODEPOSITION_STARTELEMENT for startElement;
118cdf0e10cSrcweir  *	NODEPOSITION_ENDELEMENT for endElement;
119cdf0e10cSrcweir  *	NODEPOSITION_NORMAL for other SAX events;
120cdf0e10cSrcweir  *
121cdf0e10cSrcweir  *   INPUTS
122cdf0e10cSrcweir  *	empty
123cdf0e10cSrcweir  *
124cdf0e10cSrcweir  *   RESULT
125cdf0e10cSrcweir  *	empty
126cdf0e10cSrcweir  *
127cdf0e10cSrcweir  *   HISTORY
128cdf0e10cSrcweir  *	05.01.2004 -	implemented
129cdf0e10cSrcweir  *
130cdf0e10cSrcweir  *   AUTHOR
131cdf0e10cSrcweir  *	Michael Mi
132cdf0e10cSrcweir  *	Email: michael.mi@sun.com
133cdf0e10cSrcweir  ******************************************************************************/
134cdf0e10cSrcweir {
135cdf0e10cSrcweir 	OSL_ASSERT( m_pCurrentElement != NULL );
136cdf0e10cSrcweir 
137cdf0e10cSrcweir         /*
138cdf0e10cSrcweir          * Get the next event through tree order.
139cdf0e10cSrcweir          *
140cdf0e10cSrcweir          * if the current event is a startElement, then the next
141cdf0e10cSrcweir          * event depends on whether or not the current node has
142cdf0e10cSrcweir          * children.
143cdf0e10cSrcweir          */
144cdf0e10cSrcweir 	if (m_nCurrentPosition == NODEPOSITION_STARTELEMENT)
145cdf0e10cSrcweir 	{
146cdf0e10cSrcweir 	        /*
147cdf0e10cSrcweir 	         * If the current node has children, then its first child
148cdf0e10cSrcweir 	         * should be next current node, and the next event will be
149cdf0e10cSrcweir 	         * startElement or charaters(PI) based on that child's node
150cdf0e10cSrcweir 	         * type. Otherwise, the endElement of current node is the
151cdf0e10cSrcweir 	         * next event.
152cdf0e10cSrcweir 	         */
153cdf0e10cSrcweir 		if (m_pCurrentElement->children != NULL)
154cdf0e10cSrcweir 		{
155cdf0e10cSrcweir 			m_pCurrentElement = m_pCurrentElement->children;
156cdf0e10cSrcweir 			m_nCurrentPosition
157cdf0e10cSrcweir 				= (m_pCurrentElement->type == XML_ELEMENT_NODE)?
158cdf0e10cSrcweir 					NODEPOSITION_STARTELEMENT:NODEPOSITION_NORMAL;
159cdf0e10cSrcweir 		}
160cdf0e10cSrcweir 		else
161cdf0e10cSrcweir 		{
162cdf0e10cSrcweir 			m_nCurrentPosition = NODEPOSITION_ENDELEMENT;
163cdf0e10cSrcweir 		}
164cdf0e10cSrcweir 	}
165cdf0e10cSrcweir         /*
166cdf0e10cSrcweir          * if the current event is a not startElement, then the next
167cdf0e10cSrcweir          * event depends on whether or not the current node has
168cdf0e10cSrcweir          * following sibling.
169cdf0e10cSrcweir          */
170cdf0e10cSrcweir 	else if (m_nCurrentPosition == NODEPOSITION_ENDELEMENT || m_nCurrentPosition == NODEPOSITION_NORMAL)
171cdf0e10cSrcweir 	{
172cdf0e10cSrcweir 		xmlNodePtr pNextSibling = m_pCurrentElement->next;
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 	        /*
175cdf0e10cSrcweir 	         * If the current node has following sibling, that sibling
176cdf0e10cSrcweir 	         * should be next current node, and the next event will be
177cdf0e10cSrcweir 	         * startElement or charaters(PI) based on that sibling's node
178cdf0e10cSrcweir 	         * type. Otherwise, the endElement of current node's parent
179cdf0e10cSrcweir 	         * becomes the next event.
180cdf0e10cSrcweir 	         */
181cdf0e10cSrcweir 		if (pNextSibling != NULL)
182cdf0e10cSrcweir 		{
183cdf0e10cSrcweir 			m_pCurrentElement = pNextSibling;
184cdf0e10cSrcweir 			m_nCurrentPosition
185cdf0e10cSrcweir 				= (m_pCurrentElement->type == XML_ELEMENT_NODE)?
186cdf0e10cSrcweir 					NODEPOSITION_STARTELEMENT:NODEPOSITION_NORMAL;
187cdf0e10cSrcweir 		}
188cdf0e10cSrcweir 		else
189cdf0e10cSrcweir 		{
190cdf0e10cSrcweir 			m_pCurrentElement = m_pCurrentElement->parent;
191cdf0e10cSrcweir 			m_nCurrentPosition = NODEPOSITION_ENDELEMENT;
192cdf0e10cSrcweir 		}
193cdf0e10cSrcweir 	}
194cdf0e10cSrcweir }
195cdf0e10cSrcweir 
sendStartElement(const cssu::Reference<cssxs::XDocumentHandler> & xHandler,const cssu::Reference<cssxs::XDocumentHandler> & xHandler2,const xmlNodePtr pNode) const196cdf0e10cSrcweir void XMLDocumentWrapper_XmlSecImpl::sendStartElement(
197cdf0e10cSrcweir 	const cssu::Reference< cssxs::XDocumentHandler >& xHandler,
198cdf0e10cSrcweir 	const cssu::Reference< cssxs::XDocumentHandler >& xHandler2,
199cdf0e10cSrcweir 	const xmlNodePtr pNode) const
200cdf0e10cSrcweir 	throw (cssxs::SAXException)
201cdf0e10cSrcweir /****** XMLDocumentWrapper_XmlSecImpl/sendStartElement ************************
202cdf0e10cSrcweir  *
203cdf0e10cSrcweir  *   NAME
204cdf0e10cSrcweir  *	sendStartElement -- Constructs a startElement SAX event
205cdf0e10cSrcweir  *
206cdf0e10cSrcweir  *   SYNOPSIS
207cdf0e10cSrcweir  *	sendStartElement(xHandler, xHandler2, pNode);
208cdf0e10cSrcweir  *
209cdf0e10cSrcweir  *   FUNCTION
210cdf0e10cSrcweir  *	Used when converting the document into SAX event stream.
211cdf0e10cSrcweir  *	This method constructs a startElement SAX event for a particular
212cdf0e10cSrcweir  *	element, then calls the startElement methods of the XDocumentHandlers.
213cdf0e10cSrcweir  *
214cdf0e10cSrcweir  *   INPUTS
215cdf0e10cSrcweir  *	xHandler -	the first XDocumentHandler interface to receive the
216cdf0e10cSrcweir  *			startElement SAX event. It can be NULL.
217cdf0e10cSrcweir  *	xHandler2 -	the second XDocumentHandler interface to receive the
218cdf0e10cSrcweir  *			startElement SAX event. It can't be NULL.
219cdf0e10cSrcweir  *	pNode -		the node on which the startElement should be generated.
220cdf0e10cSrcweir  *			This node must be a element type.
221cdf0e10cSrcweir  *
222cdf0e10cSrcweir  *   RESULT
223cdf0e10cSrcweir  *	empty
224cdf0e10cSrcweir  *
225cdf0e10cSrcweir  *   HISTORY
226cdf0e10cSrcweir  *	05.01.2004 -	implemented
227cdf0e10cSrcweir  *
228cdf0e10cSrcweir  *   AUTHOR
229cdf0e10cSrcweir  *	Michael Mi
230cdf0e10cSrcweir  *	Email: michael.mi@sun.com
231cdf0e10cSrcweir  ******************************************************************************/
232cdf0e10cSrcweir {
233cdf0e10cSrcweir 	SvXMLAttributeList* pAttributeList = new SvXMLAttributeList();
234cdf0e10cSrcweir 	cssu::Reference < cssxs::XAttributeList > xAttrList = cssu::Reference< cssxs::XAttributeList > (pAttributeList);
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 	xmlNsPtr pNsDef = pNode->nsDef;
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 	while (pNsDef != NULL)
239cdf0e10cSrcweir 	{
240cdf0e10cSrcweir 		const xmlChar* pNsPrefix = pNsDef->prefix;
241cdf0e10cSrcweir 		const xmlChar* pNsHref = pNsDef->href;
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 		if (pNsDef->prefix == NULL)
244cdf0e10cSrcweir 		{
245cdf0e10cSrcweir 			pAttributeList->AddAttribute(
246cdf0e10cSrcweir 				rtl::OUString(RTL_UTF8_USTRINGPARAM( STRXMLNS )),
247cdf0e10cSrcweir 				rtl::OUString(RTL_UTF8_USTRINGPARAM( (sal_Char*)pNsHref )));
248cdf0e10cSrcweir 		}
249cdf0e10cSrcweir 		else
250cdf0e10cSrcweir 		{
251cdf0e10cSrcweir 			pAttributeList->AddAttribute(
252cdf0e10cSrcweir 				rtl::OUString(RTL_UTF8_USTRINGPARAM( STRXMLNS ))
253cdf0e10cSrcweir 				+rtl::OUString(RTL_UTF8_USTRINGPARAM( ":" ))
254cdf0e10cSrcweir 				+rtl::OUString(RTL_UTF8_USTRINGPARAM( (sal_Char*)pNsPrefix )),
255cdf0e10cSrcweir 				rtl::OUString(RTL_UTF8_USTRINGPARAM( (sal_Char*)pNsHref )));
256cdf0e10cSrcweir 		}
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 		pNsDef = pNsDef->next;
259cdf0e10cSrcweir 	}
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 	xmlAttrPtr pAttr = pNode->properties;
262cdf0e10cSrcweir 
263cdf0e10cSrcweir 	while (pAttr != NULL)
264cdf0e10cSrcweir 	{
265cdf0e10cSrcweir 		const xmlChar* pAttrName = pAttr->name;
266cdf0e10cSrcweir 		xmlNsPtr pAttrNs = pAttr->ns;
267cdf0e10cSrcweir 
268cdf0e10cSrcweir 		rtl::OUString ouAttrName;
269cdf0e10cSrcweir 		if (pAttrNs == NULL)
270cdf0e10cSrcweir 		{
271cdf0e10cSrcweir 			ouAttrName = rtl::OUString(RTL_UTF8_USTRINGPARAM( (sal_Char*)pAttrName ));
272cdf0e10cSrcweir 		}
273cdf0e10cSrcweir 		else
274cdf0e10cSrcweir 		{
275cdf0e10cSrcweir 			ouAttrName = rtl::OUString(RTL_UTF8_USTRINGPARAM( (sal_Char*)pAttrNs->prefix))
276cdf0e10cSrcweir 				+rtl::OUString(RTL_UTF8_USTRINGPARAM( (sal_Char*)":" ))
277cdf0e10cSrcweir 				+rtl::OUString(RTL_UTF8_USTRINGPARAM( (sal_Char*)pAttrName ));
278cdf0e10cSrcweir 		}
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 		pAttributeList->AddAttribute(
281cdf0e10cSrcweir 			ouAttrName,
282cdf0e10cSrcweir 			rtl::OUString(RTL_UTF8_USTRINGPARAM( (sal_Char*)(pAttr->children->content))));
283cdf0e10cSrcweir 		pAttr = pAttr->next;
284cdf0e10cSrcweir 	}
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 	rtl::OString sNodeName = getNodeQName(pNode);
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 	if (xHandler.is())
289cdf0e10cSrcweir 	{
290cdf0e10cSrcweir 		xHandler->startElement(
291cdf0e10cSrcweir 			rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(sNodeName.getStr())) )),
292cdf0e10cSrcweir 			xAttrList);
293cdf0e10cSrcweir 	}
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 	xHandler2->startElement(
296cdf0e10cSrcweir 		rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(sNodeName.getStr())) )),
297cdf0e10cSrcweir 		xAttrList);
298cdf0e10cSrcweir }
299cdf0e10cSrcweir 
sendEndElement(const cssu::Reference<cssxs::XDocumentHandler> & xHandler,const cssu::Reference<cssxs::XDocumentHandler> & xHandler2,const xmlNodePtr pNode) const300cdf0e10cSrcweir void XMLDocumentWrapper_XmlSecImpl::sendEndElement(
301cdf0e10cSrcweir 	const cssu::Reference< cssxs::XDocumentHandler >& xHandler,
302cdf0e10cSrcweir 	const cssu::Reference< cssxs::XDocumentHandler >& xHandler2,
303cdf0e10cSrcweir 	const xmlNodePtr pNode) const
304cdf0e10cSrcweir 	throw (cssxs::SAXException)
305cdf0e10cSrcweir /****** XMLDocumentWrapper_XmlSecImpl/sendEndElement **************************
306cdf0e10cSrcweir  *
307cdf0e10cSrcweir  *   NAME
308cdf0e10cSrcweir  *	sendEndElement -- Constructs a endElement SAX event
309cdf0e10cSrcweir  *
310cdf0e10cSrcweir  *   SYNOPSIS
311cdf0e10cSrcweir  *	sendEndElement(xHandler, xHandler2, pNode);
312cdf0e10cSrcweir  *
313cdf0e10cSrcweir  *   FUNCTION
314cdf0e10cSrcweir  *	Used when converting the document into SAX event stream.
315cdf0e10cSrcweir  *	This method constructs a endElement SAX event for a particular
316cdf0e10cSrcweir  *	element, then calls the endElement methods of the XDocumentHandlers.
317cdf0e10cSrcweir  *
318cdf0e10cSrcweir  *   INPUTS
319cdf0e10cSrcweir  *	xHandler -	the first XDocumentHandler interface to receive the
320cdf0e10cSrcweir  *			endElement SAX event. It can be NULL.
321cdf0e10cSrcweir  *	xHandler2 -	the second XDocumentHandler interface to receive the
322cdf0e10cSrcweir  *			endElement SAX event. It can't be NULL.
323cdf0e10cSrcweir  *	pNode -		the node on which the endElement should be generated.
324cdf0e10cSrcweir  *			This node must be a element type.
325cdf0e10cSrcweir  *
326cdf0e10cSrcweir  *   RESULT
327cdf0e10cSrcweir  *	empty
328cdf0e10cSrcweir  *
329cdf0e10cSrcweir  *   HISTORY
330cdf0e10cSrcweir  *	05.01.2004 -	implemented
331cdf0e10cSrcweir  *
332cdf0e10cSrcweir  *   AUTHOR
333cdf0e10cSrcweir  *	Michael Mi
334cdf0e10cSrcweir  *	Email: michael.mi@sun.com
335cdf0e10cSrcweir  ******************************************************************************/
336cdf0e10cSrcweir {
337cdf0e10cSrcweir 	rtl::OString sNodeName = getNodeQName(pNode);
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 	if (xHandler.is())
340cdf0e10cSrcweir 	{
341cdf0e10cSrcweir 		xHandler->endElement(rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(sNodeName.getStr())) )));
342cdf0e10cSrcweir 	}
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 	xHandler2->endElement(rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(sNodeName.getStr())) )));
345cdf0e10cSrcweir }
346cdf0e10cSrcweir 
sendNode(const cssu::Reference<cssxs::XDocumentHandler> & xHandler,const cssu::Reference<cssxs::XDocumentHandler> & xHandler2,const xmlNodePtr pNode) const347cdf0e10cSrcweir void XMLDocumentWrapper_XmlSecImpl::sendNode(
348cdf0e10cSrcweir 	const cssu::Reference< cssxs::XDocumentHandler >& xHandler,
349cdf0e10cSrcweir 	const cssu::Reference< cssxs::XDocumentHandler >& xHandler2,
350cdf0e10cSrcweir 	const xmlNodePtr pNode) const
351cdf0e10cSrcweir 	throw (cssxs::SAXException)
352cdf0e10cSrcweir /****** XMLDocumentWrapper_XmlSecImpl/sendNode ********************************
353cdf0e10cSrcweir  *
354cdf0e10cSrcweir  *   NAME
355cdf0e10cSrcweir  *	sendNode -- Constructs a characters SAX event or a
356cdf0e10cSrcweir  *	processingInstruction SAX event
357cdf0e10cSrcweir  *
358cdf0e10cSrcweir  *   SYNOPSIS
359cdf0e10cSrcweir  *	sendNode(xHandler, xHandler2, pNode);
360cdf0e10cSrcweir  *
361cdf0e10cSrcweir  *   FUNCTION
362cdf0e10cSrcweir  *	Used when converting the document into SAX event stream.
363cdf0e10cSrcweir  *	This method constructs a characters SAX event or a
364cdf0e10cSrcweir  *	processingInstructionfor SAX event based on the type of a particular
365cdf0e10cSrcweir  *	element, then calls the corresponding methods of the XDocumentHandlers.
366cdf0e10cSrcweir  *
367cdf0e10cSrcweir  *   INPUTS
368cdf0e10cSrcweir  *	xHandler -	the first XDocumentHandler interface to receive the
369cdf0e10cSrcweir  *			SAX event. It can be NULL.
370cdf0e10cSrcweir  *	xHandler2 -	the second XDocumentHandler interface to receive the
371cdf0e10cSrcweir  *			SAX event. It can't be NULL.
372cdf0e10cSrcweir  *	pNode -		the node on which the endElement should be generated.
373cdf0e10cSrcweir  *			If it is a text node, then a characters SAX event is
374cdf0e10cSrcweir  *			generated; if it is a PI node, then a
375cdf0e10cSrcweir  *			processingInstructionfor SAX event is generated.
376cdf0e10cSrcweir  *
377cdf0e10cSrcweir  *   RESULT
378cdf0e10cSrcweir  *	empty
379cdf0e10cSrcweir  *
380cdf0e10cSrcweir  *   HISTORY
381cdf0e10cSrcweir  *	05.01.2004 -	implemented
382cdf0e10cSrcweir  *
383cdf0e10cSrcweir  *   AUTHOR
384cdf0e10cSrcweir  *	Michael Mi
385cdf0e10cSrcweir  *	Email: michael.mi@sun.com
386cdf0e10cSrcweir  ******************************************************************************/
387cdf0e10cSrcweir {
388cdf0e10cSrcweir 	xmlElementType type = pNode->type;
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 	if (type == XML_TEXT_NODE)
391cdf0e10cSrcweir 	{
392cdf0e10cSrcweir 		if (xHandler.is())
393cdf0e10cSrcweir 		{
394cdf0e10cSrcweir 			xHandler->characters(rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(pNode->content)) )));
395cdf0e10cSrcweir 		}
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 		xHandler2->characters(rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(pNode->content)) )));
398cdf0e10cSrcweir 	}
399cdf0e10cSrcweir 	else if (type == XML_PI_NODE)
400cdf0e10cSrcweir 	{
401cdf0e10cSrcweir 		if (xHandler.is())
402cdf0e10cSrcweir 		{
403cdf0e10cSrcweir 			xHandler->processingInstruction(
404cdf0e10cSrcweir 				rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(pNode->name)) )),
405cdf0e10cSrcweir 				rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(pNode->content)) )));
406cdf0e10cSrcweir 		}
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 		xHandler2->processingInstruction(
409cdf0e10cSrcweir 			rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(pNode->name)) )),
410cdf0e10cSrcweir 			rtl::OUString(RTL_UTF8_USTRINGPARAM ( ((sal_Char*)(pNode->content)) )));
411cdf0e10cSrcweir 	}
412cdf0e10cSrcweir }
413cdf0e10cSrcweir 
getNodeQName(const xmlNodePtr pNode) const414cdf0e10cSrcweir rtl::OString XMLDocumentWrapper_XmlSecImpl::getNodeQName(const xmlNodePtr pNode) const
415cdf0e10cSrcweir /****** XMLDocumentWrapper_XmlSecImpl/getNodeQName ****************************
416cdf0e10cSrcweir  *
417cdf0e10cSrcweir  *   NAME
418cdf0e10cSrcweir  *	getNodeQName -- Retrives the qualified name of a node
419cdf0e10cSrcweir  *
420cdf0e10cSrcweir  *   SYNOPSIS
421cdf0e10cSrcweir  *	name = getNodeQName(pNode);
422cdf0e10cSrcweir  *
423cdf0e10cSrcweir  *   FUNCTION
424cdf0e10cSrcweir  *	see NAME
425cdf0e10cSrcweir  *
426cdf0e10cSrcweir  *   INPUTS
427cdf0e10cSrcweir  *	pNode -	the node whose name will be retrived
428cdf0e10cSrcweir  *
429cdf0e10cSrcweir  *   RESULT
430cdf0e10cSrcweir  *	name - the node's qualified name
431cdf0e10cSrcweir  *
432cdf0e10cSrcweir  *   HISTORY
433cdf0e10cSrcweir  *	05.01.2004 -	implemented
434cdf0e10cSrcweir  *
435cdf0e10cSrcweir  *   AUTHOR
436cdf0e10cSrcweir  *	Michael Mi
437cdf0e10cSrcweir  *	Email: michael.mi@sun.com
438cdf0e10cSrcweir  ******************************************************************************/
439cdf0e10cSrcweir {
440cdf0e10cSrcweir 	rtl::OString sNodeName((const sal_Char*)pNode->name);
441cdf0e10cSrcweir 	if (pNode->ns != NULL)
442cdf0e10cSrcweir 	{
443cdf0e10cSrcweir 		xmlNsPtr pNs = pNode->ns;
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 		if (pNs->prefix != NULL)
446cdf0e10cSrcweir 		{
447cdf0e10cSrcweir 			rtl::OString sPrefix((const sal_Char*)pNs->prefix);
448cdf0e10cSrcweir 			sNodeName = sPrefix+rtl::OString(":")+sNodeName;
449cdf0e10cSrcweir 		}
450cdf0e10cSrcweir 	}
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 	return sNodeName;
453cdf0e10cSrcweir }
454cdf0e10cSrcweir 
checkElement(const cssu::Reference<cssxw::XXMLElementWrapper> & xXMLElement) const455cdf0e10cSrcweir xmlNodePtr XMLDocumentWrapper_XmlSecImpl::checkElement( const cssu::Reference< cssxw::XXMLElementWrapper >& xXMLElement) const
456cdf0e10cSrcweir /****** XMLDocumentWrapper_XmlSecImpl/checkElement ****************************
457cdf0e10cSrcweir  *
458cdf0e10cSrcweir  *   NAME
459cdf0e10cSrcweir  *	checkElement -- Retrives the node wrapped by an XXMLElementWrapper
460cdf0e10cSrcweir  *	interface
461cdf0e10cSrcweir  *
462cdf0e10cSrcweir  *   SYNOPSIS
463cdf0e10cSrcweir  *	node = checkElement(xXMLElement);
464cdf0e10cSrcweir  *
465cdf0e10cSrcweir  *   FUNCTION
466cdf0e10cSrcweir  *	see NAME
467cdf0e10cSrcweir  *
468cdf0e10cSrcweir  *   INPUTS
469cdf0e10cSrcweir  *	xXMLElement -	the XXMLElementWrapper interface wraping a node
470cdf0e10cSrcweir  *
471cdf0e10cSrcweir  *   RESULT
472cdf0e10cSrcweir  *	node - the node wrapped in the XXMLElementWrapper interface
473cdf0e10cSrcweir  *
474cdf0e10cSrcweir  *   HISTORY
475cdf0e10cSrcweir  *	05.01.2004 -	implemented
476cdf0e10cSrcweir  *
477cdf0e10cSrcweir  *   AUTHOR
478cdf0e10cSrcweir  *	Michael Mi
479cdf0e10cSrcweir  *	Email: michael.mi@sun.com
480cdf0e10cSrcweir  ******************************************************************************/
481cdf0e10cSrcweir {
482cdf0e10cSrcweir 	xmlNodePtr rc = NULL;
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 	if (xXMLElement.is())
485cdf0e10cSrcweir 	{
486cdf0e10cSrcweir 		cssu::Reference< cssl::XUnoTunnel > xNodTunnel( xXMLElement, cssu::UNO_QUERY ) ;
487cdf0e10cSrcweir 		if( !xNodTunnel.is() )
488cdf0e10cSrcweir 		{
489cdf0e10cSrcweir 			throw cssu::RuntimeException() ;
490cdf0e10cSrcweir 		}
491cdf0e10cSrcweir 
492cdf0e10cSrcweir 		XMLElementWrapper_XmlSecImpl* pElement
493cdf0e10cSrcweir 			= reinterpret_cast<XMLElementWrapper_XmlSecImpl*>(
494cdf0e10cSrcweir                 sal::static_int_cast<sal_uIntPtr>(
495cdf0e10cSrcweir                     xNodTunnel->getSomething(
496cdf0e10cSrcweir                         XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ))) ;
497cdf0e10cSrcweir 
498cdf0e10cSrcweir 		if( pElement == NULL ) {
499cdf0e10cSrcweir 			throw cssu::RuntimeException() ;
500cdf0e10cSrcweir 		}
501cdf0e10cSrcweir 
502cdf0e10cSrcweir 		rc = pElement->getNativeElement();
503cdf0e10cSrcweir 	}
504cdf0e10cSrcweir 
505cdf0e10cSrcweir 	return rc;
506cdf0e10cSrcweir }
507cdf0e10cSrcweir 
recursiveDelete(const xmlNodePtr pNode)508cdf0e10cSrcweir sal_Int32 XMLDocumentWrapper_XmlSecImpl::recursiveDelete(
509cdf0e10cSrcweir 	const xmlNodePtr pNode)
510cdf0e10cSrcweir /****** XMLDocumentWrapper_XmlSecImpl/recursiveDelete *************************
511cdf0e10cSrcweir  *
512cdf0e10cSrcweir  *   NAME
513cdf0e10cSrcweir  *	recursiveDelete -- Deletes a paticular node with its branch.
514cdf0e10cSrcweir  *
515cdf0e10cSrcweir  *   SYNOPSIS
516cdf0e10cSrcweir  *	result = recursiveDelete(pNode);
517cdf0e10cSrcweir  *
518cdf0e10cSrcweir  *   FUNCTION
519cdf0e10cSrcweir  *	Deletes a paticular node with its branch, while reserving the nodes
520cdf0e10cSrcweir  *	(and their brance) listed in the m_aReservedNodes.
521cdf0e10cSrcweir  *	The deletion process is preformed in the tree order, that is, a node
522cdf0e10cSrcweir  *	is deleted after its previous sibling node is deleted, a parent node
523cdf0e10cSrcweir  *	is deleted after its branch is deleted.
524cdf0e10cSrcweir  *	During the deletion process when the m_pStopAtNode is reached, the
525cdf0e10cSrcweir  *	progress is interrupted at once.
526cdf0e10cSrcweir  *
527cdf0e10cSrcweir  *   INPUTS
528cdf0e10cSrcweir  *	pNode -	the node to be deleted
529cdf0e10cSrcweir  *
530cdf0e10cSrcweir  *   RESULT
531cdf0e10cSrcweir  *	result -	the result of the deletion process, can be one of following
532cdf0e10cSrcweir  *			values:
533cdf0e10cSrcweir  *			NODE_STOPED - the process is interrupted by meeting the
534cdf0e10cSrcweir  *				m_pStopAtNode
535cdf0e10cSrcweir  *			NODE_NOTREMOVED - the pNode is not completely removed
536cdf0e10cSrcweir  *				because there is its descendant in the
537cdf0e10cSrcweir  *				m_aReservedNodes list
538cdf0e10cSrcweir  *			NODE_REMOVED - the pNode and its branch are completely
539cdf0e10cSrcweir  *				removed
540cdf0e10cSrcweir  *
541cdf0e10cSrcweir  *   NOTES
542cdf0e10cSrcweir  *	The node in the m_aReservedNodes list must be in the tree order, otherwise
543cdf0e10cSrcweir  *	the result is unpredictable.
544cdf0e10cSrcweir  *
545cdf0e10cSrcweir  *   HISTORY
546cdf0e10cSrcweir  *	05.01.2004 -	implemented
547cdf0e10cSrcweir  *
548cdf0e10cSrcweir  *   AUTHOR
549cdf0e10cSrcweir  *	Michael Mi
550cdf0e10cSrcweir  *	Email: michael.mi@sun.com
551cdf0e10cSrcweir  ******************************************************************************/
552cdf0e10cSrcweir {
553cdf0e10cSrcweir 	if (pNode == m_pStopAtNode)
554cdf0e10cSrcweir 	{
555cdf0e10cSrcweir 		return NODE_STOPED;
556cdf0e10cSrcweir 	}
557cdf0e10cSrcweir 
558cdf0e10cSrcweir 	if (pNode != m_pCurrentReservedNode)
559cdf0e10cSrcweir 	{
560cdf0e10cSrcweir 		xmlNodePtr pChild = pNode->children;
561cdf0e10cSrcweir 
562cdf0e10cSrcweir 		xmlNodePtr pNextSibling;
563cdf0e10cSrcweir 		bool bIsRemoved = true;
564cdf0e10cSrcweir 		sal_Int32 nResult;
565cdf0e10cSrcweir 
566cdf0e10cSrcweir 		while( pChild != NULL )
567cdf0e10cSrcweir 		{
568cdf0e10cSrcweir 			pNextSibling = pChild->next;
569cdf0e10cSrcweir 			nResult = recursiveDelete(pChild);
570cdf0e10cSrcweir 
571cdf0e10cSrcweir 			switch (nResult)
572cdf0e10cSrcweir 			{
573cdf0e10cSrcweir 			case NODE_STOPED:
574cdf0e10cSrcweir 				return NODE_STOPED;
575cdf0e10cSrcweir 			case NODE_NOTREMOVED:
576cdf0e10cSrcweir 				bIsRemoved = false;
577cdf0e10cSrcweir 				break;
578cdf0e10cSrcweir 			case NODE_REMOVED:
579cdf0e10cSrcweir 				removeNode(pChild);
580cdf0e10cSrcweir 				break;
581cdf0e10cSrcweir 			default:
582cdf0e10cSrcweir 				throw cssu::RuntimeException();
583cdf0e10cSrcweir 			}
584cdf0e10cSrcweir 
585cdf0e10cSrcweir 			pChild = pNextSibling;
586cdf0e10cSrcweir 		}
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 		if (pNode == m_pCurrentElement)
589cdf0e10cSrcweir 		{
590cdf0e10cSrcweir 			bIsRemoved = false;
591cdf0e10cSrcweir 		}
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 		return bIsRemoved?NODE_REMOVED:NODE_NOTREMOVED;
594cdf0e10cSrcweir 	}
595cdf0e10cSrcweir 	else
596cdf0e10cSrcweir 	{
597cdf0e10cSrcweir 		getNextReservedNode();
598cdf0e10cSrcweir 		return NODE_NOTREMOVED;
599cdf0e10cSrcweir 	}
600cdf0e10cSrcweir }
601cdf0e10cSrcweir 
getNextReservedNode()602cdf0e10cSrcweir void XMLDocumentWrapper_XmlSecImpl::getNextReservedNode()
603cdf0e10cSrcweir /****** XMLDocumentWrapper_XmlSecImpl/getNextReservedNode *********************
604cdf0e10cSrcweir  *
605cdf0e10cSrcweir  *   NAME
606cdf0e10cSrcweir  *	getNextReservedNode -- Highlights the next reserved node in the
607cdf0e10cSrcweir  *	reserved node list
608cdf0e10cSrcweir  *
609cdf0e10cSrcweir  *   SYNOPSIS
610cdf0e10cSrcweir  *	getNextReservedNode();
611cdf0e10cSrcweir  *
612cdf0e10cSrcweir  *   FUNCTION
613cdf0e10cSrcweir  *	The m_aReservedNodes array holds a node list, while the
614cdf0e10cSrcweir  *	m_pCurrentReservedNode points to the one currently highlighted.
615cdf0e10cSrcweir  *	This method is used to highlight the next node in the node list.
616cdf0e10cSrcweir  *	This method is called at the time when the current highlighted node
617cdf0e10cSrcweir  *	has been already processed, and the next node should be ready.
618cdf0e10cSrcweir  *
619cdf0e10cSrcweir  *   INPUTS
620cdf0e10cSrcweir  *	empty
621cdf0e10cSrcweir  *
622cdf0e10cSrcweir  *   RESULT
623cdf0e10cSrcweir  *	empty
624cdf0e10cSrcweir  *
625cdf0e10cSrcweir  *   HISTORY
626cdf0e10cSrcweir  *	05.01.2004 -	implemented
627cdf0e10cSrcweir  *
628cdf0e10cSrcweir  *   AUTHOR
629cdf0e10cSrcweir  *	Michael Mi
630cdf0e10cSrcweir  *	Email: michael.mi@sun.com
631cdf0e10cSrcweir  ******************************************************************************/
632cdf0e10cSrcweir {
633cdf0e10cSrcweir 	if (m_nReservedNodeIndex < m_aReservedNodes.getLength())
634cdf0e10cSrcweir 	{
635cdf0e10cSrcweir 		m_pCurrentReservedNode = checkElement( m_aReservedNodes[m_nReservedNodeIndex] );
636cdf0e10cSrcweir 		m_nReservedNodeIndex ++;
637cdf0e10cSrcweir 	}
638cdf0e10cSrcweir 	else
639cdf0e10cSrcweir 	{
640cdf0e10cSrcweir 		m_pCurrentReservedNode = NULL;
641cdf0e10cSrcweir 	}
642cdf0e10cSrcweir }
643cdf0e10cSrcweir 
removeNode(const xmlNodePtr pNode) const644cdf0e10cSrcweir void XMLDocumentWrapper_XmlSecImpl::removeNode(const xmlNodePtr pNode) const
645cdf0e10cSrcweir /****** XMLDocumentWrapper_XmlSecImpl/removeNode ******************************
646cdf0e10cSrcweir  *
647cdf0e10cSrcweir  *   NAME
648cdf0e10cSrcweir  *	removeNode -- Deletes a node with its branch unconditionaly
649cdf0e10cSrcweir  *
650cdf0e10cSrcweir  *   SYNOPSIS
651cdf0e10cSrcweir  *	removeNode( pNode );
652cdf0e10cSrcweir  *
653cdf0e10cSrcweir  *   FUNCTION
654cdf0e10cSrcweir  *	Delete the node along with its branch from the document.
655cdf0e10cSrcweir  *
656cdf0e10cSrcweir  *   INPUTS
657cdf0e10cSrcweir  *	pNode -	the node to be deleted
658cdf0e10cSrcweir  *
659cdf0e10cSrcweir  *   RESULT
660cdf0e10cSrcweir  *	empty
661cdf0e10cSrcweir  *
662cdf0e10cSrcweir  *   HISTORY
663cdf0e10cSrcweir  *	05.01.2004 -	implemented
664cdf0e10cSrcweir  *
665cdf0e10cSrcweir  *   AUTHOR
666cdf0e10cSrcweir  *	Michael Mi
667cdf0e10cSrcweir  *	Email: michael.mi@sun.com
668cdf0e10cSrcweir  ******************************************************************************/
669cdf0e10cSrcweir {
670cdf0e10cSrcweir 	/* you can't remove the current node */
671cdf0e10cSrcweir 	OSL_ASSERT( m_pCurrentElement != pNode );
672cdf0e10cSrcweir 
673cdf0e10cSrcweir 	xmlAttrPtr pAttr = pNode->properties;
674cdf0e10cSrcweir 
675cdf0e10cSrcweir 	while (pAttr != NULL)
676cdf0e10cSrcweir 	{
677cdf0e10cSrcweir 		if (!stricmp((sal_Char*)pAttr->name,"id"))
678cdf0e10cSrcweir 		{
679cdf0e10cSrcweir 			xmlRemoveID(m_pDocument, pAttr);
680cdf0e10cSrcweir 		}
681cdf0e10cSrcweir 
682cdf0e10cSrcweir 		pAttr = pAttr->next;
683cdf0e10cSrcweir 	}
684cdf0e10cSrcweir 
685cdf0e10cSrcweir 	xmlUnlinkNode(pNode);
686cdf0e10cSrcweir 	xmlFreeNode(pNode);
687cdf0e10cSrcweir }
688cdf0e10cSrcweir 
buildIDAttr(xmlNodePtr pNode) const689cdf0e10cSrcweir void XMLDocumentWrapper_XmlSecImpl::buildIDAttr(xmlNodePtr pNode) const
690cdf0e10cSrcweir /****** XMLDocumentWrapper_XmlSecImpl/buildIDAttr *****************************
691cdf0e10cSrcweir  *
692cdf0e10cSrcweir  *   NAME
693cdf0e10cSrcweir  *	buildIDAttr -- build the ID attribute of a node
694cdf0e10cSrcweir  *
695cdf0e10cSrcweir  *   SYNOPSIS
696cdf0e10cSrcweir  *	buildIDAttr( pNode );
697cdf0e10cSrcweir  *
698cdf0e10cSrcweir  *   FUNCTION
699cdf0e10cSrcweir  *	see NAME
700cdf0e10cSrcweir  *
701cdf0e10cSrcweir  *   INPUTS
702cdf0e10cSrcweir  *	pNode -	the node whose id attribute will be built
703cdf0e10cSrcweir  *
704cdf0e10cSrcweir  *   RESULT
705cdf0e10cSrcweir  *	empty
706cdf0e10cSrcweir  *
707cdf0e10cSrcweir  *   HISTORY
708cdf0e10cSrcweir  *	14.06.2004 -	implemented
709cdf0e10cSrcweir  *
710cdf0e10cSrcweir  *   AUTHOR
711cdf0e10cSrcweir  *	Michael Mi
712cdf0e10cSrcweir  *	Email: michael.mi@sun.com
713cdf0e10cSrcweir  ******************************************************************************/
714cdf0e10cSrcweir {
715cdf0e10cSrcweir 	xmlAttrPtr idAttr = xmlHasProp( pNode, (const unsigned char *)"id" );
716cdf0e10cSrcweir 	if (idAttr == NULL)
717cdf0e10cSrcweir 	{
718cdf0e10cSrcweir 		idAttr = xmlHasProp( pNode, (const unsigned char *)"Id" );
719cdf0e10cSrcweir 	}
720cdf0e10cSrcweir 
721cdf0e10cSrcweir 	if (idAttr != NULL)
722cdf0e10cSrcweir 	{
723cdf0e10cSrcweir 		xmlChar* idValue = xmlNodeListGetString( m_pDocument, idAttr->children, 1 ) ;
724cdf0e10cSrcweir 		xmlAddID( NULL, m_pDocument, idValue, idAttr );
725cdf0e10cSrcweir 	}
726cdf0e10cSrcweir }
727cdf0e10cSrcweir 
rebuildIDLink(xmlNodePtr pNode) const728cdf0e10cSrcweir void XMLDocumentWrapper_XmlSecImpl::rebuildIDLink(xmlNodePtr pNode) const
729cdf0e10cSrcweir /****** XMLDocumentWrapper_XmlSecImpl/rebuildIDLink ***************************
730cdf0e10cSrcweir  *
731cdf0e10cSrcweir  *   NAME
732cdf0e10cSrcweir  *	rebuildIDLink -- rebuild the ID link for the branch
733cdf0e10cSrcweir  *
734cdf0e10cSrcweir  *   SYNOPSIS
735cdf0e10cSrcweir  *	rebuildIDLink( pNode );
736cdf0e10cSrcweir  *
737cdf0e10cSrcweir  *   FUNCTION
738cdf0e10cSrcweir  *	see NAME
739cdf0e10cSrcweir  *
740cdf0e10cSrcweir  *   INPUTS
741cdf0e10cSrcweir  *	pNode -	the node, from which the branch will be rebuilt
742cdf0e10cSrcweir  *
743cdf0e10cSrcweir  *   RESULT
744cdf0e10cSrcweir  *	empty
745cdf0e10cSrcweir  *
746cdf0e10cSrcweir  *   HISTORY
747cdf0e10cSrcweir  *	14.06.2004 -	implemented
748cdf0e10cSrcweir  *
749cdf0e10cSrcweir  *   AUTHOR
750cdf0e10cSrcweir  *	Michael Mi
751cdf0e10cSrcweir  *	Email: michael.mi@sun.com
752cdf0e10cSrcweir  ******************************************************************************/
753cdf0e10cSrcweir {
754cdf0e10cSrcweir 	if (pNode != NULL && pNode->type == XML_ELEMENT_NODE)
755cdf0e10cSrcweir 	{
756cdf0e10cSrcweir 		buildIDAttr( pNode );
757cdf0e10cSrcweir 
758cdf0e10cSrcweir 		xmlNodePtr child = pNode->children;
759cdf0e10cSrcweir 		while (child != NULL)
760cdf0e10cSrcweir 		{
761cdf0e10cSrcweir 			rebuildIDLink(child);
762cdf0e10cSrcweir 			child = child->next;
763cdf0e10cSrcweir 		}
764cdf0e10cSrcweir 	}
765cdf0e10cSrcweir }
766cdf0e10cSrcweir 
767cdf0e10cSrcweir /* XXMLDocumentWrapper */
getCurrentElement()768cdf0e10cSrcweir cssu::Reference< cssxw::XXMLElementWrapper > SAL_CALL XMLDocumentWrapper_XmlSecImpl::getCurrentElement(  )
769cdf0e10cSrcweir 	throw (cssu::RuntimeException)
770cdf0e10cSrcweir {
771cdf0e10cSrcweir 	XMLElementWrapper_XmlSecImpl* pElement = new XMLElementWrapper_XmlSecImpl(m_pCurrentElement);
772cdf0e10cSrcweir 	return (cssu::Reference< cssxw::XXMLElementWrapper >)pElement;
773cdf0e10cSrcweir }
774cdf0e10cSrcweir 
setCurrentElement(const cssu::Reference<cssxw::XXMLElementWrapper> & element)775cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::setCurrentElement( const cssu::Reference< cssxw::XXMLElementWrapper >& element )
776cdf0e10cSrcweir 	throw (cssu::RuntimeException)
777cdf0e10cSrcweir {
778cdf0e10cSrcweir 	m_pCurrentElement = checkElement( element );
779cdf0e10cSrcweir 	saxHelper.setCurrentNode( m_pCurrentElement );
780cdf0e10cSrcweir }
781cdf0e10cSrcweir 
removeCurrentElement()782cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::removeCurrentElement(  )
783cdf0e10cSrcweir 	throw (cssu::RuntimeException)
784cdf0e10cSrcweir {
785cdf0e10cSrcweir 	OSL_ASSERT( m_pCurrentElement != NULL );
786cdf0e10cSrcweir 
787cdf0e10cSrcweir 	xmlNodePtr pOldCurrentElement = m_pCurrentElement;
788cdf0e10cSrcweir 
789cdf0e10cSrcweir 	/*
790cdf0e10cSrcweir 	 * pop the top node in the parser context's
791cdf0e10cSrcweir 	 * nodeTab stack, then the parent of that node will
792cdf0e10cSrcweir 	 * automatically become the new stack top, and
793cdf0e10cSrcweir 	 * the current node as well.
794cdf0e10cSrcweir 	 */
795cdf0e10cSrcweir 	saxHelper.endElement(
796cdf0e10cSrcweir 		rtl::OUString(
797cdf0e10cSrcweir 			RTL_UTF8_USTRINGPARAM (
798cdf0e10cSrcweir 				(sal_Char*)(pOldCurrentElement->name)
799cdf0e10cSrcweir 			)));
800cdf0e10cSrcweir 	m_pCurrentElement = saxHelper.getCurrentNode();
801cdf0e10cSrcweir 
802cdf0e10cSrcweir 	/*
803cdf0e10cSrcweir 	 * remove the node
804cdf0e10cSrcweir 	 */
805cdf0e10cSrcweir 	removeNode(pOldCurrentElement);
806cdf0e10cSrcweir }
807cdf0e10cSrcweir 
isCurrent(const cssu::Reference<cssxw::XXMLElementWrapper> & node)808cdf0e10cSrcweir sal_Bool SAL_CALL XMLDocumentWrapper_XmlSecImpl::isCurrent( const cssu::Reference< cssxw::XXMLElementWrapper >& node )
809cdf0e10cSrcweir 	throw (cssu::RuntimeException)
810cdf0e10cSrcweir {
811cdf0e10cSrcweir 	xmlNodePtr pNode = checkElement(node);
812cdf0e10cSrcweir 	return (pNode == m_pCurrentElement);
813cdf0e10cSrcweir }
814cdf0e10cSrcweir 
isCurrentElementEmpty()815cdf0e10cSrcweir sal_Bool SAL_CALL XMLDocumentWrapper_XmlSecImpl::isCurrentElementEmpty(  )
816cdf0e10cSrcweir 	throw (cssu::RuntimeException)
817cdf0e10cSrcweir {
818cdf0e10cSrcweir 	sal_Bool rc = sal_False;
819cdf0e10cSrcweir 
820cdf0e10cSrcweir 	if (m_pCurrentElement->children == NULL)
821cdf0e10cSrcweir 	{
822cdf0e10cSrcweir 		rc = sal_True;
823cdf0e10cSrcweir 	}
824cdf0e10cSrcweir 
825cdf0e10cSrcweir 	return rc;
826cdf0e10cSrcweir }
827cdf0e10cSrcweir 
getNodeName(const cssu::Reference<cssxw::XXMLElementWrapper> & node)828cdf0e10cSrcweir rtl::OUString SAL_CALL XMLDocumentWrapper_XmlSecImpl::getNodeName( const cssu::Reference< cssxw::XXMLElementWrapper >& node )
829cdf0e10cSrcweir 	throw (cssu::RuntimeException)
830cdf0e10cSrcweir {
831cdf0e10cSrcweir 	xmlNodePtr pNode = checkElement(node);
832cdf0e10cSrcweir 	return rtl::OUString(RTL_UTF8_USTRINGPARAM ( (sal_Char*)pNode->name ));
833cdf0e10cSrcweir }
834cdf0e10cSrcweir 
clearUselessData(const cssu::Reference<cssxw::XXMLElementWrapper> & node,const cssu::Sequence<cssu::Reference<cssxw::XXMLElementWrapper>> & reservedDescendants,const cssu::Reference<cssxw::XXMLElementWrapper> & stopAtNode)835cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::clearUselessData(
836cdf0e10cSrcweir 	const cssu::Reference< cssxw::XXMLElementWrapper >& node,
837cdf0e10cSrcweir 	const cssu::Sequence< cssu::Reference< cssxw::XXMLElementWrapper > >& reservedDescendants,
838cdf0e10cSrcweir 	const cssu::Reference< cssxw::XXMLElementWrapper >& stopAtNode )
839cdf0e10cSrcweir 	throw (cssu::RuntimeException)
840cdf0e10cSrcweir {
841cdf0e10cSrcweir 	xmlNodePtr pTargetNode = checkElement(node);
842cdf0e10cSrcweir 
843cdf0e10cSrcweir 	m_pStopAtNode = checkElement(stopAtNode);
844cdf0e10cSrcweir 	m_aReservedNodes = reservedDescendants;
845cdf0e10cSrcweir 	m_nReservedNodeIndex = 0;
846cdf0e10cSrcweir 
847cdf0e10cSrcweir 	getNextReservedNode();
848cdf0e10cSrcweir 
849cdf0e10cSrcweir 	recursiveDelete(pTargetNode);
850cdf0e10cSrcweir }
851cdf0e10cSrcweir 
collapse(const cssu::Reference<cssxw::XXMLElementWrapper> & node)852cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::collapse( const cssu::Reference< cssxw::XXMLElementWrapper >& node )
853cdf0e10cSrcweir 	throw (cssu::RuntimeException)
854cdf0e10cSrcweir {
855cdf0e10cSrcweir 	xmlNodePtr pTargetNode = checkElement(node);
856cdf0e10cSrcweir 	xmlNodePtr pParent;
857cdf0e10cSrcweir 
858cdf0e10cSrcweir 	while (pTargetNode != NULL)
859cdf0e10cSrcweir 	{
860cdf0e10cSrcweir 		if (pTargetNode->children != NULL || pTargetNode == m_pCurrentElement)
861cdf0e10cSrcweir 		{
862cdf0e10cSrcweir 			break;
863cdf0e10cSrcweir 		}
864cdf0e10cSrcweir 
865cdf0e10cSrcweir 		pParent = pTargetNode->parent;
866cdf0e10cSrcweir 		removeNode(pTargetNode);
867cdf0e10cSrcweir 		pTargetNode = pParent;
868cdf0e10cSrcweir 	}
869cdf0e10cSrcweir }
870cdf0e10cSrcweir 
getTree(const cssu::Reference<cssxs::XDocumentHandler> & handler)871cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::getTree( const cssu::Reference< cssxs::XDocumentHandler >& handler )
872cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
873cdf0e10cSrcweir {
874cdf0e10cSrcweir 	if (m_pRootElement != NULL)
875cdf0e10cSrcweir 	{
876cdf0e10cSrcweir 		xmlNodePtr pTempCurrentElement = m_pCurrentElement;
877cdf0e10cSrcweir 		sal_Int32 nTempCurrentPosition = m_nCurrentPosition;
878cdf0e10cSrcweir 
879cdf0e10cSrcweir 		m_pCurrentElement = m_pRootElement;
880cdf0e10cSrcweir 
881cdf0e10cSrcweir 		m_nCurrentPosition = NODEPOSITION_STARTELEMENT;
882cdf0e10cSrcweir 		cssu::Reference< cssxs::XDocumentHandler > xHandler = handler;
883cdf0e10cSrcweir 
884cdf0e10cSrcweir 		while(true)
885cdf0e10cSrcweir 		{
886cdf0e10cSrcweir 			switch (m_nCurrentPosition)
887cdf0e10cSrcweir 			{
888cdf0e10cSrcweir 			case NODEPOSITION_STARTELEMENT:
889cdf0e10cSrcweir 				sendStartElement(NULL, xHandler, m_pCurrentElement);
890cdf0e10cSrcweir 				break;
891cdf0e10cSrcweir 			case NODEPOSITION_ENDELEMENT:
892cdf0e10cSrcweir 				sendEndElement(NULL, xHandler, m_pCurrentElement);
893cdf0e10cSrcweir 				break;
894cdf0e10cSrcweir 			case NODEPOSITION_NORMAL:
895cdf0e10cSrcweir 				sendNode(NULL, xHandler, m_pCurrentElement);
896cdf0e10cSrcweir 				break;
897cdf0e10cSrcweir 			}
898cdf0e10cSrcweir 
899cdf0e10cSrcweir 			if ( (m_pCurrentElement == m_pRootElement) && (m_nCurrentPosition == NODEPOSITION_ENDELEMENT ))
900cdf0e10cSrcweir 			{
901cdf0e10cSrcweir 				break;
902cdf0e10cSrcweir 			}
903cdf0e10cSrcweir 
904cdf0e10cSrcweir 			getNextSAXEvent();
905cdf0e10cSrcweir 		}
906cdf0e10cSrcweir 
907cdf0e10cSrcweir 		m_pCurrentElement = pTempCurrentElement;
908cdf0e10cSrcweir 		m_nCurrentPosition = nTempCurrentPosition;
909cdf0e10cSrcweir 	}
910cdf0e10cSrcweir }
911cdf0e10cSrcweir 
generateSAXEvents(const cssu::Reference<cssxs::XDocumentHandler> & handler,const cssu::Reference<cssxs::XDocumentHandler> & xEventKeeperHandler,const cssu::Reference<cssxw::XXMLElementWrapper> & startNode,const cssu::Reference<cssxw::XXMLElementWrapper> & endNode)912cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::generateSAXEvents(
913cdf0e10cSrcweir 	const cssu::Reference< cssxs::XDocumentHandler >& handler,
914cdf0e10cSrcweir 	const cssu::Reference< cssxs::XDocumentHandler >& xEventKeeperHandler,
915cdf0e10cSrcweir 	const cssu::Reference< cssxw::XXMLElementWrapper >& startNode,
916cdf0e10cSrcweir 	const cssu::Reference< cssxw::XXMLElementWrapper >& endNode )
917cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
918cdf0e10cSrcweir {
919cdf0e10cSrcweir         /*
920cdf0e10cSrcweir          * The first SAX event is the startElement of the startNode
921cdf0e10cSrcweir          * element.
922cdf0e10cSrcweir          */
923cdf0e10cSrcweir 	bool bHasCurrentElementChild = (m_pCurrentElement->children != NULL);
924cdf0e10cSrcweir 
925cdf0e10cSrcweir 	xmlNodePtr pTempCurrentElement = m_pCurrentElement;
926cdf0e10cSrcweir 
927cdf0e10cSrcweir 	m_pCurrentElement = checkElement(startNode);
928cdf0e10cSrcweir 
929cdf0e10cSrcweir 	if (m_pCurrentElement->type == XML_ELEMENT_NODE)
930cdf0e10cSrcweir 	{
931cdf0e10cSrcweir 		m_nCurrentPosition = NODEPOSITION_STARTELEMENT;
932cdf0e10cSrcweir 	}
933cdf0e10cSrcweir 	else
934cdf0e10cSrcweir 	{
935cdf0e10cSrcweir 		m_nCurrentPosition = NODEPOSITION_NORMAL;
936cdf0e10cSrcweir 	}
937cdf0e10cSrcweir 
938cdf0e10cSrcweir 	xmlNodePtr pEndNode = checkElement(endNode);
939cdf0e10cSrcweir 
940cdf0e10cSrcweir 	cssu::Reference < cssxc::sax::XSAXEventKeeper > xSAXEventKeeper( xEventKeeperHandler, cssu::UNO_QUERY );
941cdf0e10cSrcweir 
942cdf0e10cSrcweir 	cssu::Reference< cssxs::XDocumentHandler > xHandler = handler;
943cdf0e10cSrcweir 
944cdf0e10cSrcweir 	while(true)
945cdf0e10cSrcweir 	{
946cdf0e10cSrcweir 		switch (m_nCurrentPosition)
947cdf0e10cSrcweir 		{
948cdf0e10cSrcweir 		case NODEPOSITION_STARTELEMENT:
949cdf0e10cSrcweir 			sendStartElement(xHandler, xEventKeeperHandler, m_pCurrentElement);
950cdf0e10cSrcweir 			break;
951cdf0e10cSrcweir 		case NODEPOSITION_ENDELEMENT:
952cdf0e10cSrcweir 			sendEndElement(xHandler, xEventKeeperHandler, m_pCurrentElement);
953cdf0e10cSrcweir 			break;
954cdf0e10cSrcweir 		case NODEPOSITION_NORMAL:
955cdf0e10cSrcweir 			sendNode(xHandler, xEventKeeperHandler, m_pCurrentElement);
956cdf0e10cSrcweir 			break;
957cdf0e10cSrcweir 		default:
958cdf0e10cSrcweir 			throw cssu::RuntimeException();
959cdf0e10cSrcweir 		}
960cdf0e10cSrcweir 
961cdf0e10cSrcweir 		if (xSAXEventKeeper->isBlocking())
962cdf0e10cSrcweir 		{
963cdf0e10cSrcweir 			xHandler = NULL;
964cdf0e10cSrcweir 		}
965cdf0e10cSrcweir 
966cdf0e10cSrcweir 		if (pEndNode == NULL &&
967cdf0e10cSrcweir 			((bHasCurrentElementChild && m_pCurrentElement == xmlGetLastChild(pTempCurrentElement) && m_nCurrentPosition != NODEPOSITION_STARTELEMENT) ||
968cdf0e10cSrcweir 			 (!bHasCurrentElementChild && m_pCurrentElement == pTempCurrentElement && m_nCurrentPosition == NODEPOSITION_STARTELEMENT)))
969cdf0e10cSrcweir 		{
970cdf0e10cSrcweir 			break;
971cdf0e10cSrcweir 		}
972cdf0e10cSrcweir 
973cdf0e10cSrcweir 		getNextSAXEvent();
974cdf0e10cSrcweir 
975cdf0e10cSrcweir 	        /*
976cdf0e10cSrcweir 	         * If there is an end point specified, then check whether
977cdf0e10cSrcweir 	         * the current node equals to the end point. If so, stop
978cdf0e10cSrcweir 	         * generating.
979cdf0e10cSrcweir 	         */
980cdf0e10cSrcweir 		if (pEndNode != NULL && m_pCurrentElement == pEndNode)
981cdf0e10cSrcweir 		{
982cdf0e10cSrcweir 			break;
983cdf0e10cSrcweir 		}
984cdf0e10cSrcweir 	}
985cdf0e10cSrcweir 
986cdf0e10cSrcweir 	m_pCurrentElement = pTempCurrentElement;
987cdf0e10cSrcweir }
988cdf0e10cSrcweir 
rebuildIDLink(const com::sun::star::uno::Reference<com::sun::star::xml::wrapper::XXMLElementWrapper> & node)989cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::rebuildIDLink(
990cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::wrapper::XXMLElementWrapper >& node )
991cdf0e10cSrcweir 	throw (com::sun::star::uno::RuntimeException)
992cdf0e10cSrcweir {
993cdf0e10cSrcweir 	xmlNodePtr pNode = checkElement( node );
994cdf0e10cSrcweir 	rebuildIDLink(pNode);
995cdf0e10cSrcweir }
996cdf0e10cSrcweir 
997cdf0e10cSrcweir 
998cdf0e10cSrcweir /* cssxs::XDocumentHandler */
startDocument()999cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::startDocument(  )
1000cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
1001cdf0e10cSrcweir {
1002cdf0e10cSrcweir }
1003cdf0e10cSrcweir 
endDocument()1004cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::endDocument(  )
1005cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
1006cdf0e10cSrcweir {
1007cdf0e10cSrcweir }
1008cdf0e10cSrcweir 
startElement(const rtl::OUString & aName,const cssu::Reference<cssxs::XAttributeList> & xAttribs)1009cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::startElement( const rtl::OUString& aName, const cssu::Reference< cssxs::XAttributeList >& xAttribs )
1010cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
1011cdf0e10cSrcweir {
1012cdf0e10cSrcweir 	sal_Int32 nLength = xAttribs->getLength();
1013cdf0e10cSrcweir 	cssu::Sequence< cssxcsax::XMLAttribute > aAttributes (nLength);
1014cdf0e10cSrcweir 
1015cdf0e10cSrcweir 	for (int i = 0; i < nLength; ++i)
1016cdf0e10cSrcweir 	{
1017cdf0e10cSrcweir 		aAttributes[i].sName = xAttribs->getNameByIndex((short)i);
1018cdf0e10cSrcweir 		aAttributes[i].sValue =xAttribs->getValueByIndex((short)i);
1019cdf0e10cSrcweir 	}
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir 	_startElement(aName, aAttributes);
1022cdf0e10cSrcweir }
1023cdf0e10cSrcweir 
endElement(const rtl::OUString & aName)1024cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::endElement( const rtl::OUString& aName )
1025cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
1026cdf0e10cSrcweir {
1027cdf0e10cSrcweir 	saxHelper.endElement(aName);
1028cdf0e10cSrcweir 	m_pCurrentElement = saxHelper.getCurrentNode();
1029cdf0e10cSrcweir }
1030cdf0e10cSrcweir 
characters(const rtl::OUString & aChars)1031cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::characters( const rtl::OUString& aChars )
1032cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
1033cdf0e10cSrcweir {
1034cdf0e10cSrcweir 	saxHelper.characters(aChars);
1035cdf0e10cSrcweir }
1036cdf0e10cSrcweir 
ignorableWhitespace(const rtl::OUString & aWhitespaces)1037cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::ignorableWhitespace( const rtl::OUString& aWhitespaces )
1038cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
1039cdf0e10cSrcweir {
1040cdf0e10cSrcweir 	saxHelper.ignorableWhitespace(aWhitespaces);
1041cdf0e10cSrcweir }
1042cdf0e10cSrcweir 
processingInstruction(const rtl::OUString & aTarget,const rtl::OUString & aData)1043cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::processingInstruction( const rtl::OUString& aTarget, const rtl::OUString& aData )
1044cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
1045cdf0e10cSrcweir {
1046cdf0e10cSrcweir 	saxHelper.processingInstruction(aTarget, aData);
1047cdf0e10cSrcweir }
1048cdf0e10cSrcweir 
setDocumentLocator(const cssu::Reference<cssxs::XLocator> & xLocator)1049cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::setDocumentLocator( const cssu::Reference< cssxs::XLocator >& xLocator )
1050cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
1051cdf0e10cSrcweir {
1052cdf0e10cSrcweir 	saxHelper.setDocumentLocator(xLocator);
1053cdf0e10cSrcweir }
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir /* XCompressedDocumentHandler */
_startDocument()1056cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::_startDocument(  )
1057cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
1058cdf0e10cSrcweir {
1059cdf0e10cSrcweir }
1060cdf0e10cSrcweir 
_endDocument()1061cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::_endDocument(  )
1062cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
1063cdf0e10cSrcweir {
1064cdf0e10cSrcweir }
1065cdf0e10cSrcweir 
_startElement(const rtl::OUString & aName,const cssu::Sequence<cssxcsax::XMLAttribute> & aAttributes)1066cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::_startElement( const rtl::OUString& aName, const cssu::Sequence< cssxcsax::XMLAttribute >& aAttributes )
1067cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir 	saxHelper.startElement(aName, aAttributes);
1070cdf0e10cSrcweir 	m_pCurrentElement = saxHelper.getCurrentNode();
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir 	buildIDAttr( m_pCurrentElement );
1073cdf0e10cSrcweir }
1074cdf0e10cSrcweir 
_endElement(const rtl::OUString & aName)1075cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::_endElement( const rtl::OUString& aName )
1076cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
1077cdf0e10cSrcweir {
1078cdf0e10cSrcweir 	endElement( aName );
1079cdf0e10cSrcweir }
1080cdf0e10cSrcweir 
_characters(const rtl::OUString & aChars)1081cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::_characters( const rtl::OUString& aChars )
1082cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
1083cdf0e10cSrcweir {
1084cdf0e10cSrcweir 	characters( aChars );
1085cdf0e10cSrcweir }
1086cdf0e10cSrcweir 
_ignorableWhitespace(const rtl::OUString & aWhitespaces)1087cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::_ignorableWhitespace( const rtl::OUString& aWhitespaces )
1088cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
1089cdf0e10cSrcweir {
1090cdf0e10cSrcweir 	ignorableWhitespace( aWhitespaces );
1091cdf0e10cSrcweir }
1092cdf0e10cSrcweir 
_processingInstruction(const rtl::OUString & aTarget,const rtl::OUString & aData)1093cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::_processingInstruction( const rtl::OUString& aTarget, const rtl::OUString& aData )
1094cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
1095cdf0e10cSrcweir {
1096cdf0e10cSrcweir 	processingInstruction( aTarget, aData );
1097cdf0e10cSrcweir }
1098cdf0e10cSrcweir 
_setDocumentLocator(sal_Int32,sal_Int32,const rtl::OUString &,const rtl::OUString &)1099cdf0e10cSrcweir void SAL_CALL XMLDocumentWrapper_XmlSecImpl::_setDocumentLocator( sal_Int32 /*columnNumber*/, sal_Int32 /*lineNumber*/, const rtl::OUString& /*publicId*/, const rtl::OUString& /*systemId*/ )
1100cdf0e10cSrcweir 	throw (cssxs::SAXException, cssu::RuntimeException)
1101cdf0e10cSrcweir {
1102cdf0e10cSrcweir }
1103cdf0e10cSrcweir 
XMLDocumentWrapper_XmlSecImpl_getImplementationName()1104cdf0e10cSrcweir rtl::OUString XMLDocumentWrapper_XmlSecImpl_getImplementationName ()
1105cdf0e10cSrcweir 	throw (cssu::RuntimeException)
1106cdf0e10cSrcweir {
1107cdf0e10cSrcweir 	return rtl::OUString ( RTL_ASCII_USTRINGPARAM ( IMPLEMENTATION_NAME ) );
1108cdf0e10cSrcweir }
1109cdf0e10cSrcweir 
XMLDocumentWrapper_XmlSecImpl_supportsService(const rtl::OUString & ServiceName)1110cdf0e10cSrcweir sal_Bool SAL_CALL XMLDocumentWrapper_XmlSecImpl_supportsService( const rtl::OUString& ServiceName )
1111cdf0e10cSrcweir 	throw (cssu::RuntimeException)
1112cdf0e10cSrcweir {
1113cdf0e10cSrcweir 	return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ));
1114cdf0e10cSrcweir }
1115cdf0e10cSrcweir 
XMLDocumentWrapper_XmlSecImpl_getSupportedServiceNames()1116cdf0e10cSrcweir cssu::Sequence< rtl::OUString > SAL_CALL XMLDocumentWrapper_XmlSecImpl_getSupportedServiceNames(  )
1117cdf0e10cSrcweir 	throw (cssu::RuntimeException)
1118cdf0e10cSrcweir {
1119cdf0e10cSrcweir 	cssu::Sequence < rtl::OUString > aRet(1);
1120cdf0e10cSrcweir 	rtl::OUString* pArray = aRet.getArray();
1121cdf0e10cSrcweir 	pArray[0] =  rtl::OUString ( RTL_ASCII_USTRINGPARAM ( SERVICE_NAME ) );
1122cdf0e10cSrcweir 	return aRet;
1123cdf0e10cSrcweir }
1124cdf0e10cSrcweir #undef SERVICE_NAME
1125cdf0e10cSrcweir 
XMLDocumentWrapper_XmlSecImpl_createInstance(const cssu::Reference<cssl::XMultiServiceFactory> &)1126cdf0e10cSrcweir cssu::Reference< cssu::XInterface > SAL_CALL XMLDocumentWrapper_XmlSecImpl_createInstance(
1127cdf0e10cSrcweir 	const cssu::Reference< cssl::XMultiServiceFactory > &)
1128cdf0e10cSrcweir 	throw( cssu::Exception )
1129cdf0e10cSrcweir {
1130cdf0e10cSrcweir 	return (cppu::OWeakObject*) new XMLDocumentWrapper_XmlSecImpl( );
1131cdf0e10cSrcweir }
1132cdf0e10cSrcweir 
1133cdf0e10cSrcweir /* XServiceInfo */
getImplementationName()1134cdf0e10cSrcweir rtl::OUString SAL_CALL XMLDocumentWrapper_XmlSecImpl::getImplementationName(  )
1135cdf0e10cSrcweir 	throw (cssu::RuntimeException)
1136cdf0e10cSrcweir {
1137cdf0e10cSrcweir 	return XMLDocumentWrapper_XmlSecImpl_getImplementationName();
1138cdf0e10cSrcweir }
supportsService(const rtl::OUString & rServiceName)1139cdf0e10cSrcweir sal_Bool SAL_CALL XMLDocumentWrapper_XmlSecImpl::supportsService( const rtl::OUString& rServiceName )
1140cdf0e10cSrcweir 	throw (cssu::RuntimeException)
1141cdf0e10cSrcweir {
1142cdf0e10cSrcweir 	return XMLDocumentWrapper_XmlSecImpl_supportsService( rServiceName );
1143cdf0e10cSrcweir }
getSupportedServiceNames()1144cdf0e10cSrcweir cssu::Sequence< rtl::OUString > SAL_CALL XMLDocumentWrapper_XmlSecImpl::getSupportedServiceNames(  )
1145cdf0e10cSrcweir 	throw (cssu::RuntimeException)
1146cdf0e10cSrcweir {
1147cdf0e10cSrcweir 	return XMLDocumentWrapper_XmlSecImpl_getSupportedServiceNames();
1148cdf0e10cSrcweir }
1149cdf0e10cSrcweir 
1150