xref: /aoo42x/main/extensions/test/sax/testwriter.cxx (revision 2a97ec55)
1*2a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2a97ec55SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2a97ec55SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2a97ec55SAndrew Rist  * distributed with this work for additional information
6*2a97ec55SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2a97ec55SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2a97ec55SAndrew Rist  * "License"); you may not use this file except in compliance
9*2a97ec55SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2a97ec55SAndrew Rist  *
11*2a97ec55SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2a97ec55SAndrew Rist  *
13*2a97ec55SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2a97ec55SAndrew Rist  * software distributed under the License is distributed on an
15*2a97ec55SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2a97ec55SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2a97ec55SAndrew Rist  * specific language governing permissions and limitations
18*2a97ec55SAndrew Rist  * under the License.
19*2a97ec55SAndrew Rist  *
20*2a97ec55SAndrew Rist  *************************************************************/
21*2a97ec55SAndrew Rist 
22*2a97ec55SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_extensions.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //#include <tools/presys.h>
28cdf0e10cSrcweir #include <vector>
29cdf0e10cSrcweir //#include <tools/postsys.h>
30cdf0e10cSrcweir #include <smart/com/sun/star/test/XSimpleTest.hxx>
31cdf0e10cSrcweir #include <smart/com/sun/star/lang/XMultiServiceFactory.hxx>  // for the multiservice-factories
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <stdio.h>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <smart/com/sun/star/io/XActiveDataSource.hxx>
36cdf0e10cSrcweir #include <smart/com/sun/star/io/XOutputStream.hxx>
37cdf0e10cSrcweir #include <smart/com/sun/star/xml/sax/SAXParseException.hxx>
38cdf0e10cSrcweir #include <smart/com/sun/star/xml/sax/XParser.hxx>
39cdf0e10cSrcweir #include <smart/com/sun/star/xml/sax/XExtendedDocumentHandler.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include <rtl/wstring.hxx>
42cdf0e10cSrcweir #include <osl/time.h>
43cdf0e10cSrcweir #include <usr/weak.hxx>
44cdf0e10cSrcweir #include <tools/string.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #include <usr/factoryhlp.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include <usr/reflserv.hxx>  // for EXTERN_SERVICE_CALLTYPE
49cdf0e10cSrcweir 
50cdf0e10cSrcweir using namespace std;
51cdf0e10cSrcweir using namespace rtl;
52cdf0e10cSrcweir using namespace vos;
53cdf0e10cSrcweir using namespace usr;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #define BUILD_ERROR(expr, Message)\
56cdf0e10cSrcweir 		{\
57cdf0e10cSrcweir 			m_seqErrors.realloc( m_seqErrors.getLen() + 1 ); \
58cdf0e10cSrcweir 		m_seqExceptions.realloc(  m_seqExceptions.getLen() + 1 ); \
59cdf0e10cSrcweir 		String str; \
60cdf0e10cSrcweir 		str += __FILE__;\
61cdf0e10cSrcweir 		str += " "; \
62cdf0e10cSrcweir 		str += "(" ; \
63cdf0e10cSrcweir 		str += __LINE__ ;\
64cdf0e10cSrcweir 		str += ")\n";\
65cdf0e10cSrcweir 		str += "[ " ; \
66cdf0e10cSrcweir 		str += #expr; \
67cdf0e10cSrcweir 		str += " ] : " ; \
68cdf0e10cSrcweir 		str += Message; \
69cdf0e10cSrcweir 		m_seqErrors.getArray()[ m_seqErrors.getLen()-1] = StringToUString( str , CHARSET_SYSTEM ); \
70cdf0e10cSrcweir 		}\
71cdf0e10cSrcweir 		((void)0)
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 
74cdf0e10cSrcweir #define WARNING_ASSERT(expr, Message) \
75cdf0e10cSrcweir 		if( ! (expr) ) { \
76cdf0e10cSrcweir 			m_seqWarnings.realloc( m_seqErrors.getLen() +1 ); \
77cdf0e10cSrcweir 			String str;\
78cdf0e10cSrcweir 			str += __FILE__;\
79cdf0e10cSrcweir 			str += " "; \
80cdf0e10cSrcweir 			str += "(" ; \
81cdf0e10cSrcweir 			str += __LINE__ ;\
82cdf0e10cSrcweir 			str += ")\n";\
83cdf0e10cSrcweir 			str += "[ " ; \
84cdf0e10cSrcweir 			str += #expr; \
85cdf0e10cSrcweir 			str += " ] : " ; \
86cdf0e10cSrcweir 			str += Message; \
87cdf0e10cSrcweir 			m_seqWarnings.getArray()[ m_seqWarnings.getLen()-1] = StringToUString( str , CHARSET_SYSTEM ); \
88cdf0e10cSrcweir 			return; \
89cdf0e10cSrcweir 		}\
90cdf0e10cSrcweir 		((void)0)
91cdf0e10cSrcweir 
92cdf0e10cSrcweir #define ERROR_ASSERT(expr, Message) \
93cdf0e10cSrcweir 		if( ! (expr) ) { \
94cdf0e10cSrcweir 			BUILD_ERROR(expr, Message );\
95cdf0e10cSrcweir 			return; \
96cdf0e10cSrcweir 		}\
97cdf0e10cSrcweir 		((void)0)
98cdf0e10cSrcweir 
99cdf0e10cSrcweir #define ERROR_EXCEPTION_ASSERT(expr, Message, Exception) \
100cdf0e10cSrcweir 	if( !(expr)) { \
101cdf0e10cSrcweir 		BUILD_ERROR(expr,Message);\
102cdf0e10cSrcweir 		m_seqExceptions.getArray()[ m_seqExceptions.getLen()-1] = UsrAny( Exception );\
103cdf0e10cSrcweir 		return; \
104cdf0e10cSrcweir 	} \
105cdf0e10cSrcweir 	((void)0)
106cdf0e10cSrcweir 
107cdf0e10cSrcweir /****
108cdf0e10cSrcweir * test szenarios :
109cdf0e10cSrcweir *
110cdf0e10cSrcweir *
111cdf0e10cSrcweir *
112cdf0e10cSrcweir ****/
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 
115cdf0e10cSrcweir class OFileWriter :
116cdf0e10cSrcweir 		public XOutputStream,
117cdf0e10cSrcweir 		public OWeakObject
118cdf0e10cSrcweir {
119cdf0e10cSrcweir public:
OFileWriter(char * pcFile)120cdf0e10cSrcweir 	OFileWriter( char *pcFile ) { strcpy( m_pcFile , pcFile ); m_f = 0; }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 
123cdf0e10cSrcweir public: // refcounting
queryInterface(Uik aUik,XInterfaceRef & rOut)124cdf0e10cSrcweir 	BOOL						queryInterface( Uik aUik, XInterfaceRef & rOut )
125cdf0e10cSrcweir 	{
126cdf0e10cSrcweir 		if( XOutputStream::getSmartUik() == aUik ) {
127cdf0e10cSrcweir 			rOut = (XOutputStream *) this;
128cdf0e10cSrcweir 		}
129cdf0e10cSrcweir 		else return OWeakObject::queryInterface( aUik , rOut );
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 		return TRUE;
132cdf0e10cSrcweir 	}
acquire()133cdf0e10cSrcweir 	void 						acquire() 						 { OWeakObject::acquire(); }
release()134cdf0e10cSrcweir 	void 						release() 						 { OWeakObject::release(); }
getImplementation(Reflection * p)135cdf0e10cSrcweir 	void* 						getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir public:
138cdf0e10cSrcweir     virtual void writeBytes(const Sequence< BYTE >& aData)
139cdf0e10cSrcweir     					THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) );
140cdf0e10cSrcweir     virtual void flush(void)
141cdf0e10cSrcweir     					THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) );
142cdf0e10cSrcweir     virtual void closeOutput(void)
143cdf0e10cSrcweir     					THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) );
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 
146cdf0e10cSrcweir private:
147cdf0e10cSrcweir 	char m_pcFile[256];
148cdf0e10cSrcweir 	FILE *m_f;
149cdf0e10cSrcweir };
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 
writeBytes(const Sequence<BYTE> & aData)152cdf0e10cSrcweir void OFileWriter::writeBytes(const Sequence< BYTE >& aData)
153cdf0e10cSrcweir 			THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir 	if( ! m_f ) {
156cdf0e10cSrcweir 		m_f = fopen( m_pcFile , "w" );
157cdf0e10cSrcweir 	}
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 	fwrite( aData.getConstArray() , 1 , aData.getLen() , m_f );
160cdf0e10cSrcweir 
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 
flush(void)164cdf0e10cSrcweir void OFileWriter::flush(void)
165cdf0e10cSrcweir 			THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir 	fflush( m_f );
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
closeOutput(void)170cdf0e10cSrcweir void OFileWriter::closeOutput(void)
171cdf0e10cSrcweir     					THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) )
172cdf0e10cSrcweir {
173cdf0e10cSrcweir 	fclose( m_f );
174cdf0e10cSrcweir 	m_f = 0;
175cdf0e10cSrcweir }
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 
178cdf0e10cSrcweir class OSaxWriterTest :
179cdf0e10cSrcweir 		public XSimpleTest,
180cdf0e10cSrcweir         public OWeakObject
181cdf0e10cSrcweir {
182cdf0e10cSrcweir public:
OSaxWriterTest(const XMultiServiceFactoryRef & rFactory)183cdf0e10cSrcweir 	OSaxWriterTest( const XMultiServiceFactoryRef & rFactory ) : m_rFactory( rFactory )
184cdf0e10cSrcweir 	{
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 	}
~OSaxWriterTest()187cdf0e10cSrcweir 	~OSaxWriterTest() {}
188cdf0e10cSrcweir 
189cdf0e10cSrcweir public: // refcounting
190cdf0e10cSrcweir 	BOOL						queryInterface( Uik aUik, XInterfaceRef & rOut );
acquire()191cdf0e10cSrcweir 	void 						acquire() 						 { OWeakObject::acquire(); }
release()192cdf0e10cSrcweir 	void 						release() 						 { OWeakObject::release(); }
getImplementation(Reflection * p)193cdf0e10cSrcweir 	void* 						getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir public:
196cdf0e10cSrcweir     virtual void testInvariant(const UString& TestName, const XInterfaceRef& TestObject)
197cdf0e10cSrcweir     															THROWS( (	IllegalArgumentException,
198cdf0e10cSrcweir     																		UsrSystemException) );
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     virtual INT32 test(	const UString& TestName,
201cdf0e10cSrcweir     					const XInterfaceRef& TestObject,
202cdf0e10cSrcweir     					INT32 hTestHandle) 						THROWS( (	IllegalArgumentException,
203cdf0e10cSrcweir     																		UsrSystemException) );
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     virtual BOOL testPassed(void) 								THROWS( (	UsrSystemException) );
206cdf0e10cSrcweir     virtual Sequence< UString > getErrors(void) 				THROWS( (UsrSystemException) );
207cdf0e10cSrcweir     virtual Sequence< UsrAny > getErrorExceptions(void) 		THROWS( (UsrSystemException) );
208cdf0e10cSrcweir     virtual Sequence< UString > getWarnings(void) 				THROWS( (UsrSystemException) );
209cdf0e10cSrcweir 
210cdf0e10cSrcweir private:
211cdf0e10cSrcweir 	void testSimple( const XExtendedDocumentHandlerRef &r );
212cdf0e10cSrcweir 	void testExceptions( const XExtendedDocumentHandlerRef &r );
213cdf0e10cSrcweir 	void testDTD( const XExtendedDocumentHandlerRef &r );
214cdf0e10cSrcweir 	void testPerformance( const XExtendedDocumentHandlerRef &r );
215cdf0e10cSrcweir 	void writeParagraph( const XExtendedDocumentHandlerRef &r , const UString & s);
216cdf0e10cSrcweir 
217cdf0e10cSrcweir private:
218cdf0e10cSrcweir 	Sequence<UsrAny>  		m_seqExceptions;
219cdf0e10cSrcweir 	Sequence<UString> 		m_seqErrors;
220cdf0e10cSrcweir 	Sequence<UString> 		m_seqWarnings;
221cdf0e10cSrcweir 	XMultiServiceFactoryRef m_rFactory;
222cdf0e10cSrcweir 
223cdf0e10cSrcweir };
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 
227cdf0e10cSrcweir /*----------------------------------------
228cdf0e10cSrcweir *
229cdf0e10cSrcweir * 	Attributlist implementation
230cdf0e10cSrcweir *
231cdf0e10cSrcweir *----------------------------------------*/
232cdf0e10cSrcweir struct AttributeListImpl_impl;
233cdf0e10cSrcweir class AttributeListImpl :
234cdf0e10cSrcweir 		public XAttributeList,
235cdf0e10cSrcweir 		public OWeakObject
236cdf0e10cSrcweir {
237cdf0e10cSrcweir public:
238cdf0e10cSrcweir 	AttributeListImpl();
239cdf0e10cSrcweir 	AttributeListImpl( const AttributeListImpl & );
240cdf0e10cSrcweir 	~AttributeListImpl();
241cdf0e10cSrcweir 
242cdf0e10cSrcweir public:
243cdf0e10cSrcweir 	BOOL					queryInterface( Uik aUik, XInterfaceRef & rOut );
acquire()244cdf0e10cSrcweir 	void 					acquire() 						 { OWeakObject::acquire(); }
release()245cdf0e10cSrcweir 	void 					release() 						 { OWeakObject::release(); }
getImplementation(Reflection * p)246cdf0e10cSrcweir 	void* 					getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir public:
249cdf0e10cSrcweir     virtual INT16 getLength(void) THROWS( (UsrSystemException) );
250cdf0e10cSrcweir     virtual UString getNameByIndex(INT16 i) THROWS( (UsrSystemException) );
251cdf0e10cSrcweir     virtual UString getTypeByIndex(INT16 i) THROWS( (UsrSystemException) );
252cdf0e10cSrcweir     virtual UString getTypeByName(const UString& aName) THROWS( (UsrSystemException) );
253cdf0e10cSrcweir     virtual UString getValueByIndex(INT16 i) THROWS( (UsrSystemException) );
254cdf0e10cSrcweir     virtual UString getValueByName(const UString& aName) THROWS( (UsrSystemException) );
255cdf0e10cSrcweir 
256cdf0e10cSrcweir public:
257cdf0e10cSrcweir 	void addAttribute( const UString &sName , const UString &sType , const UString &sValue );
258cdf0e10cSrcweir 	void clear();
259cdf0e10cSrcweir 
260cdf0e10cSrcweir private:
261cdf0e10cSrcweir 	struct AttributeListImpl_impl *m_pImpl;
262cdf0e10cSrcweir };
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 
265cdf0e10cSrcweir struct TagAttribute
266cdf0e10cSrcweir {
TagAttributeTagAttribute267cdf0e10cSrcweir 	TagAttribute(){}
TagAttributeTagAttribute268cdf0e10cSrcweir 	TagAttribute( const UString &sName, const UString &sType , const UString &sValue )
269cdf0e10cSrcweir 	{
270cdf0e10cSrcweir 		this->sName 	= sName;
271cdf0e10cSrcweir 		this->sType 	= sType;
272cdf0e10cSrcweir 		this->sValue 	= sValue;
273cdf0e10cSrcweir 	}
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 	UString sName;
276cdf0e10cSrcweir 	UString sType;
277cdf0e10cSrcweir 	UString sValue;
278cdf0e10cSrcweir };
279cdf0e10cSrcweir 
280cdf0e10cSrcweir struct AttributeListImpl_impl
281cdf0e10cSrcweir {
AttributeListImpl_implAttributeListImpl_impl282cdf0e10cSrcweir 	AttributeListImpl_impl()
283cdf0e10cSrcweir 	{
284cdf0e10cSrcweir 		// performance improvement during adding
285cdf0e10cSrcweir 		vecAttribute.reserve(20);
286cdf0e10cSrcweir 	}
287cdf0e10cSrcweir 	vector<struct TagAttribute> vecAttribute;
288cdf0e10cSrcweir };
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 
291cdf0e10cSrcweir 
getLength(void)292cdf0e10cSrcweir INT16 AttributeListImpl::getLength(void) THROWS( (UsrSystemException) )
293cdf0e10cSrcweir {
294cdf0e10cSrcweir 	return m_pImpl->vecAttribute.size();
295cdf0e10cSrcweir }
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 
AttributeListImpl(const AttributeListImpl & r)298cdf0e10cSrcweir AttributeListImpl::AttributeListImpl( const AttributeListImpl &r )
299cdf0e10cSrcweir {
300cdf0e10cSrcweir 	m_pImpl = new AttributeListImpl_impl;
301cdf0e10cSrcweir 	*m_pImpl = *(r.m_pImpl);
302cdf0e10cSrcweir }
303cdf0e10cSrcweir 
getNameByIndex(INT16 i)304cdf0e10cSrcweir UString AttributeListImpl::getNameByIndex(INT16 i) THROWS( (UsrSystemException) )
305cdf0e10cSrcweir {
306cdf0e10cSrcweir 	if( i < m_pImpl->vecAttribute.size() ) {
307cdf0e10cSrcweir 		return m_pImpl->vecAttribute[i].sName;
308cdf0e10cSrcweir 	}
309cdf0e10cSrcweir 	return UString();
310cdf0e10cSrcweir }
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 
getTypeByIndex(INT16 i)313cdf0e10cSrcweir UString AttributeListImpl::getTypeByIndex(INT16 i) THROWS( (UsrSystemException) )
314cdf0e10cSrcweir {
315cdf0e10cSrcweir 	if( i < m_pImpl->vecAttribute.size() ) {
316cdf0e10cSrcweir 		return m_pImpl->vecAttribute[i].sType;
317cdf0e10cSrcweir 	}
318cdf0e10cSrcweir 	return UString();
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
getValueByIndex(INT16 i)321cdf0e10cSrcweir UString AttributeListImpl::getValueByIndex(INT16 i) THROWS( (UsrSystemException) )
322cdf0e10cSrcweir {
323cdf0e10cSrcweir 	if( i < m_pImpl->vecAttribute.size() ) {
324cdf0e10cSrcweir 		return m_pImpl->vecAttribute[i].sValue;
325cdf0e10cSrcweir 	}
326cdf0e10cSrcweir 	return UString();
327cdf0e10cSrcweir 
328cdf0e10cSrcweir }
329cdf0e10cSrcweir 
getTypeByName(const UString & sName)330cdf0e10cSrcweir UString AttributeListImpl::getTypeByName( const UString& sName ) THROWS( (UsrSystemException) )
331cdf0e10cSrcweir {
332cdf0e10cSrcweir 	vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
333cdf0e10cSrcweir 
334cdf0e10cSrcweir 	for( ; ii != m_pImpl->vecAttribute.end() ; ii ++ ) {
335cdf0e10cSrcweir 		if( (*ii).sName == sName ) {
336cdf0e10cSrcweir 			return (*ii).sType;
337cdf0e10cSrcweir 		}
338cdf0e10cSrcweir 	}
339cdf0e10cSrcweir 	return UString();
340cdf0e10cSrcweir }
341cdf0e10cSrcweir 
getValueByName(const UString & sName)342cdf0e10cSrcweir UString AttributeListImpl::getValueByName(const UString& sName) THROWS( (UsrSystemException) )
343cdf0e10cSrcweir {
344cdf0e10cSrcweir 	vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
345cdf0e10cSrcweir 
346cdf0e10cSrcweir 	for( ; ii != m_pImpl->vecAttribute.end() ; ii ++ ) {
347cdf0e10cSrcweir 		if( (*ii).sName == sName ) {
348cdf0e10cSrcweir 			return (*ii).sValue;
349cdf0e10cSrcweir 		}
350cdf0e10cSrcweir 	}
351cdf0e10cSrcweir 	return UString();
352cdf0e10cSrcweir }
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 
queryInterface(Uik aUik,XInterfaceRef & rOut)355cdf0e10cSrcweir BOOL AttributeListImpl::queryInterface( Uik aUik, XInterfaceRef & rOut )
356cdf0e10cSrcweir {
357cdf0e10cSrcweir 	if( aUik == XAttributeList::getSmartUik() ) {
358cdf0e10cSrcweir 		rOut = (XAttributeList * )this;
359cdf0e10cSrcweir 	}
360cdf0e10cSrcweir 	else {
361cdf0e10cSrcweir 		return OWeakObject::queryInterface( aUik , rOut );
362cdf0e10cSrcweir 	}
363cdf0e10cSrcweir 	return TRUE;
364cdf0e10cSrcweir }
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 
AttributeListImpl()367cdf0e10cSrcweir AttributeListImpl::AttributeListImpl()
368cdf0e10cSrcweir {
369cdf0e10cSrcweir 	m_pImpl = new AttributeListImpl_impl;
370cdf0e10cSrcweir }
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 
~AttributeListImpl()374cdf0e10cSrcweir AttributeListImpl::~AttributeListImpl()
375cdf0e10cSrcweir {
376cdf0e10cSrcweir 	delete m_pImpl;
377cdf0e10cSrcweir }
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 
addAttribute(const UString & sName,const UString & sType,const UString & sValue)380cdf0e10cSrcweir void AttributeListImpl::addAttribute( 	const UString &sName ,
381cdf0e10cSrcweir 										const UString &sType ,
382cdf0e10cSrcweir 										const UString &sValue )
383cdf0e10cSrcweir {
384cdf0e10cSrcweir 	m_pImpl->vecAttribute.push_back( TagAttribute( sName , sType , sValue ) );
385cdf0e10cSrcweir }
386cdf0e10cSrcweir 
clear()387cdf0e10cSrcweir void AttributeListImpl::clear()
388cdf0e10cSrcweir {
389cdf0e10cSrcweir 	vector<struct TagAttribute> dummy;
390cdf0e10cSrcweir 	m_pImpl->vecAttribute.swap( dummy );
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 	OSL_ASSERT( ! getLength() );
393cdf0e10cSrcweir }
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 
405cdf0e10cSrcweir /**
406cdf0e10cSrcweir * for external binding
407cdf0e10cSrcweir *
408cdf0e10cSrcweir *
409cdf0e10cSrcweir **/
OSaxWriterTest_CreateInstance(const XMultiServiceFactoryRef & rSMgr)410cdf0e10cSrcweir XInterfaceRef OSaxWriterTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception))
411cdf0e10cSrcweir {
412cdf0e10cSrcweir 	OSaxWriterTest *p = new OSaxWriterTest( rSMgr );
413cdf0e10cSrcweir 	XInterfaceRef xService = *p;
414cdf0e10cSrcweir 	return xService;
415cdf0e10cSrcweir }
416cdf0e10cSrcweir 
OSaxWriterTest_getServiceName()417cdf0e10cSrcweir UString     OSaxWriterTest_getServiceName( ) THROWS( () )
418cdf0e10cSrcweir {
419cdf0e10cSrcweir 	return L"test.com.sun.star.xml.sax.Writer";
420cdf0e10cSrcweir }
421cdf0e10cSrcweir 
OSaxWriterTest_getImplementationName()422cdf0e10cSrcweir UString 	OSaxWriterTest_getImplementationName( ) THROWS( () )
423cdf0e10cSrcweir {
424cdf0e10cSrcweir 	return L"test.extensions.xml.sax.Writer";
425cdf0e10cSrcweir }
426cdf0e10cSrcweir 
OSaxWriterTest_getSupportedServiceNames()427cdf0e10cSrcweir Sequence<UString> OSaxWriterTest_getSupportedServiceNames( ) THROWS( () )
428cdf0e10cSrcweir {
429cdf0e10cSrcweir 	Sequence<UString> aRet(1);
430cdf0e10cSrcweir 
431cdf0e10cSrcweir 	aRet.getArray()[0] = OSaxWriterTest_getImplementationName( );
432cdf0e10cSrcweir 
433cdf0e10cSrcweir 	return aRet;
434cdf0e10cSrcweir }
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 
queryInterface(Uik uik,XInterfaceRef & rOut)437cdf0e10cSrcweir BOOL OSaxWriterTest::queryInterface( Uik uik , XInterfaceRef &rOut )
438cdf0e10cSrcweir {
439cdf0e10cSrcweir 	if( XSimpleTest::getSmartUik() == uik ) {
440cdf0e10cSrcweir 		rOut = (XSimpleTest *) this;
441cdf0e10cSrcweir 	}
442cdf0e10cSrcweir 	else {
443cdf0e10cSrcweir 		return OWeakObject::queryInterface( uik , rOut );
444cdf0e10cSrcweir 	}
445cdf0e10cSrcweir 	return TRUE;
446cdf0e10cSrcweir }
447cdf0e10cSrcweir 
448cdf0e10cSrcweir 
testInvariant(const UString & TestName,const XInterfaceRef & TestObject)449cdf0e10cSrcweir void OSaxWriterTest::testInvariant( const UString& TestName, const XInterfaceRef& TestObject )
450cdf0e10cSrcweir     															THROWS( (	IllegalArgumentException,
451cdf0e10cSrcweir     																		UsrSystemException) )
452cdf0e10cSrcweir {
453cdf0e10cSrcweir 	if( L"com.sun.star.xml.sax.Writer" == TestName ) {
454cdf0e10cSrcweir 		XDocumentHandlerRef doc( TestObject , USR_QUERY );
455cdf0e10cSrcweir 		XExtendedDocumentHandlerRef ext( TestObject , USR_QUERY );
456cdf0e10cSrcweir 		XActiveDataSourceRef source( TestObject , USR_QUERY );
457cdf0e10cSrcweir 
458cdf0e10cSrcweir 		ERROR_ASSERT( doc.is() , "XDocumentHandler cannot be queried" );
459cdf0e10cSrcweir 		ERROR_ASSERT( ext.is() , "XExtendedDocumentHandler cannot be queried" );
460cdf0e10cSrcweir 		ERROR_ASSERT( source.is() , "XActiveDataSource cannot be queried" );
461cdf0e10cSrcweir 	}
462cdf0e10cSrcweir 	else {
463cdf0e10cSrcweir 		BUILD_ERROR( 0 , "wrong test" );
464cdf0e10cSrcweir 	}
465cdf0e10cSrcweir }
466cdf0e10cSrcweir 
467cdf0e10cSrcweir 
test(const UString & TestName,const XInterfaceRef & TestObject,INT32 hTestHandle)468cdf0e10cSrcweir INT32 OSaxWriterTest::test(	const UString& TestName,
469cdf0e10cSrcweir     					const XInterfaceRef& TestObject,
470cdf0e10cSrcweir     					INT32 hTestHandle) 						THROWS( (	IllegalArgumentException,
471cdf0e10cSrcweir     																		UsrSystemException) )
472cdf0e10cSrcweir {
473cdf0e10cSrcweir 	if( L"com.sun.star.xml.sax.Writer" == TestName )  {
474cdf0e10cSrcweir 		try {
475cdf0e10cSrcweir 			if( 0 == hTestHandle ) {
476cdf0e10cSrcweir 				testInvariant( TestName , TestObject );
477cdf0e10cSrcweir 			}
478cdf0e10cSrcweir 			else {
479cdf0e10cSrcweir 
480cdf0e10cSrcweir 				XExtendedDocumentHandlerRef writer( TestObject , USR_QUERY );
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 				if( 1 == hTestHandle ) {
483cdf0e10cSrcweir 					testSimple( writer );
484cdf0e10cSrcweir 				}
485cdf0e10cSrcweir 				else if( 2 == hTestHandle ) {
486cdf0e10cSrcweir 					testExceptions( writer );
487cdf0e10cSrcweir 				}
488cdf0e10cSrcweir 				else if( 3 == hTestHandle ) {
489cdf0e10cSrcweir 					testDTD( writer );
490cdf0e10cSrcweir 				}
491cdf0e10cSrcweir 				else if( 4 == hTestHandle ) {
492cdf0e10cSrcweir 					testPerformance( writer );
493cdf0e10cSrcweir 				}
494cdf0e10cSrcweir 			}
495cdf0e10cSrcweir 		}
496cdf0e10cSrcweir 		catch( Exception& e )  {
497cdf0e10cSrcweir 			BUILD_ERROR( 0 , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() );
498cdf0e10cSrcweir 		}
499cdf0e10cSrcweir 		catch(...) {
500cdf0e10cSrcweir 			BUILD_ERROR( 0 , "unknown exception (Exception is  not base class)" );
501cdf0e10cSrcweir 		}
502cdf0e10cSrcweir 
503cdf0e10cSrcweir 		hTestHandle ++;
504cdf0e10cSrcweir 
505cdf0e10cSrcweir 		if( hTestHandle >= 5) {
506cdf0e10cSrcweir 			// all tests finished.
507cdf0e10cSrcweir 			hTestHandle = -1;
508cdf0e10cSrcweir 		}
509cdf0e10cSrcweir 	}
510cdf0e10cSrcweir 	else {
511cdf0e10cSrcweir 		BUILD_ERROR( 0 , "service not supported by test." );
512cdf0e10cSrcweir 	}
513cdf0e10cSrcweir 	return hTestHandle;
514cdf0e10cSrcweir }
515cdf0e10cSrcweir 
516cdf0e10cSrcweir 
517cdf0e10cSrcweir 
testPassed(void)518cdf0e10cSrcweir BOOL OSaxWriterTest::testPassed(void) 										THROWS( (UsrSystemException) )
519cdf0e10cSrcweir {
520cdf0e10cSrcweir 	return m_seqErrors.getLen() == 0;
521cdf0e10cSrcweir }
522cdf0e10cSrcweir 
523cdf0e10cSrcweir 
getErrors(void)524cdf0e10cSrcweir Sequence< UString > OSaxWriterTest::getErrors(void) 							THROWS( (UsrSystemException) )
525cdf0e10cSrcweir {
526cdf0e10cSrcweir 	return m_seqErrors;
527cdf0e10cSrcweir }
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 
getErrorExceptions(void)530cdf0e10cSrcweir Sequence< UsrAny > OSaxWriterTest::getErrorExceptions(void) 					THROWS( (UsrSystemException) )
531cdf0e10cSrcweir {
532cdf0e10cSrcweir 	return m_seqExceptions;
533cdf0e10cSrcweir }
534cdf0e10cSrcweir 
535cdf0e10cSrcweir 
getWarnings(void)536cdf0e10cSrcweir Sequence< UString > OSaxWriterTest::getWarnings(void) 						THROWS( (UsrSystemException) )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir 	return m_seqWarnings;
539cdf0e10cSrcweir }
540cdf0e10cSrcweir 
writeParagraph(const XExtendedDocumentHandlerRef & r,const UString & s)541cdf0e10cSrcweir void OSaxWriterTest::writeParagraph( const XExtendedDocumentHandlerRef &r , const UString & s)
542cdf0e10cSrcweir {
543cdf0e10cSrcweir 	int nMax = s.len();
544cdf0e10cSrcweir 	int nStart = 0;
545cdf0e10cSrcweir 
546cdf0e10cSrcweir 	Sequence<UINT16> seq( s.len() );
547cdf0e10cSrcweir 	memcpy( seq.getArray() , s.getStr() , s.len() * sizeof( UINT16 ) );
548cdf0e10cSrcweir 
549cdf0e10cSrcweir 	for( int n = 1 ; n < nMax ; n++ ){
550cdf0e10cSrcweir 		if( 32 == seq.getArray()[n] ) {
551cdf0e10cSrcweir 			r->allowLineBreak();
552cdf0e10cSrcweir 			r->characters( s.copy( nStart , n - nStart ) );
553cdf0e10cSrcweir 			nStart = n;
554cdf0e10cSrcweir 		}
555cdf0e10cSrcweir 	}
556cdf0e10cSrcweir 	r->allowLineBreak();
557cdf0e10cSrcweir 	r->characters( s.copy( nStart , n - nStart ) );
558cdf0e10cSrcweir 
559cdf0e10cSrcweir 
560cdf0e10cSrcweir }
561cdf0e10cSrcweir 
562cdf0e10cSrcweir 
563cdf0e10cSrcweir 
testSimple(const XExtendedDocumentHandlerRef & r)564cdf0e10cSrcweir void OSaxWriterTest::testSimple( const XExtendedDocumentHandlerRef &r )
565cdf0e10cSrcweir {
566cdf0e10cSrcweir 	UString testParagraph = L"Dies ist ein bloeder Test um zu uberpruefen, ob der SAXWriter "
567cdf0e10cSrcweir 	                        L"wohl Zeilenumbrueche halbwegs richtig macht oder ob er die Zeile "
568cdf0e10cSrcweir 	                        L"bis zum bitteren Ende schreibt.";
569cdf0e10cSrcweir 
570cdf0e10cSrcweir 	OFileWriter *pw = new OFileWriter("output.xml");
571cdf0e10cSrcweir 	AttributeListImpl *pList = new AttributeListImpl;
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 	XAttributeListRef rList( (XAttributeList *) pList , USR_QUERY );
574cdf0e10cSrcweir 	XOutputStreamRef ref( ( XOutputStream * ) pw , USR_QUERY );
575cdf0e10cSrcweir 
576cdf0e10cSrcweir 	XActiveDataSourceRef source( r , USR_QUERY );
577cdf0e10cSrcweir 
578cdf0e10cSrcweir 	ERROR_ASSERT( ref.is() , "no output stream" );
579cdf0e10cSrcweir 	ERROR_ASSERT( source.is() , "no active data source" );
580cdf0e10cSrcweir 
581cdf0e10cSrcweir 	source->setOutputStream( ref );
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 	r->startDocument();
584cdf0e10cSrcweir 
585cdf0e10cSrcweir 	pList->addAttribute( L"Arg1" , L"CDATA" , L"bla\n	u" );
586cdf0e10cSrcweir 	pList->addAttribute( L"Arg2" , L"CDATA" , L"blub" );
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 	r->startElement( L"tag1"  , rList );
589cdf0e10cSrcweir 	r->ignorableWhitespace( L"" );
590cdf0e10cSrcweir 
591cdf0e10cSrcweir 	r->characters( L"huhu" );
592cdf0e10cSrcweir 	r->ignorableWhitespace( L"" );
593cdf0e10cSrcweir 
594cdf0e10cSrcweir 	r->startElement( L"hi" , rList );
595cdf0e10cSrcweir 	r->ignorableWhitespace( L"" );
596cdf0e10cSrcweir 
597cdf0e10cSrcweir 	// the enpassant must be converted & -> &amp;
598cdf0e10cSrcweir 	r->characters( L"&#252;" );
599cdf0e10cSrcweir 
600cdf0e10cSrcweir 	// Test added for mib. Tests if errors during conversions occurs
601cdf0e10cSrcweir 	r->ignorableWhitespace( UString() );
602cdf0e10cSrcweir 	sal_Char array[256];
603cdf0e10cSrcweir 	for( sal_Int32 n = 32 ; n < 254 ; n ++ ) {
604cdf0e10cSrcweir 		array[n-32] = n;
605cdf0e10cSrcweir 	}
606cdf0e10cSrcweir 	array[254-32] = 0;
607cdf0e10cSrcweir 	r->characters(
608cdf0e10cSrcweir 		StringToUString( array , RTL_TEXTENCODING_SYMBOL )
609cdf0e10cSrcweir 		);
610cdf0e10cSrcweir 	r->ignorableWhitespace( UString() );
611cdf0e10cSrcweir 
612cdf0e10cSrcweir 	// '>' must not be converted
613cdf0e10cSrcweir 	r->startCDATA();
614cdf0e10cSrcweir 	r->characters( L">fsfsdf<" );
615cdf0e10cSrcweir 	r->endCDATA();
616cdf0e10cSrcweir 	r->ignorableWhitespace( UString() );
617cdf0e10cSrcweir 
618cdf0e10cSrcweir 	writeParagraph( r , testParagraph );
619cdf0e10cSrcweir 
620cdf0e10cSrcweir 
621cdf0e10cSrcweir 	r->ignorableWhitespace( UString() );
622cdf0e10cSrcweir 	r->comment( L"Dies ist ein Kommentar !" );
623cdf0e10cSrcweir 	r->ignorableWhitespace( UString() );
624cdf0e10cSrcweir 
625cdf0e10cSrcweir 	r->startElement( L"emptytagtest"  , rList );
626cdf0e10cSrcweir 	r->endElement( L"emptytagtest" );
627cdf0e10cSrcweir 
628cdf0e10cSrcweir 	r->endElement( L"hi" );
629cdf0e10cSrcweir 	r->ignorableWhitespace( L"" );
630cdf0e10cSrcweir 
631cdf0e10cSrcweir 	r->endElement( L"tag1" );
632cdf0e10cSrcweir 	r->endDocument();
633cdf0e10cSrcweir 
634cdf0e10cSrcweir }
635cdf0e10cSrcweir 
testExceptions(const XExtendedDocumentHandlerRef & r)636cdf0e10cSrcweir void OSaxWriterTest::testExceptions( const XExtendedDocumentHandlerRef & r )
637cdf0e10cSrcweir {
638cdf0e10cSrcweir 
639cdf0e10cSrcweir 	OFileWriter *pw = new OFileWriter("output2.xml");
640cdf0e10cSrcweir 	AttributeListImpl *pList = new AttributeListImpl;
641cdf0e10cSrcweir 
642cdf0e10cSrcweir 	XAttributeListRef rList( (XAttributeList *) pList , USR_QUERY );
643cdf0e10cSrcweir 	XOutputStreamRef ref( ( XOutputStream * ) pw , USR_QUERY );
644cdf0e10cSrcweir 
645cdf0e10cSrcweir 	XActiveDataSourceRef source( r , USR_QUERY );
646cdf0e10cSrcweir 
647cdf0e10cSrcweir 	ERROR_ASSERT( ref.is() , "no output stream" );
648cdf0e10cSrcweir 	ERROR_ASSERT( source.is() , "no active data source" );
649cdf0e10cSrcweir 
650cdf0e10cSrcweir 	source->setOutputStream( ref );
651cdf0e10cSrcweir 
652cdf0e10cSrcweir 	{ // startDocument must be called before start element
653cdf0e10cSrcweir 		BOOL bException = TRUE;
654cdf0e10cSrcweir 		try {
655cdf0e10cSrcweir 			r->startElement( L"huhu" , rList );
656cdf0e10cSrcweir 			bException = FALSE;
657cdf0e10cSrcweir 		}
658cdf0e10cSrcweir 		catch( SAXException& e ) {
659cdf0e10cSrcweir 
660cdf0e10cSrcweir 		}
661cdf0e10cSrcweir 		ERROR_ASSERT( bException , "expected exception not thrown !" );
662cdf0e10cSrcweir 	}
663cdf0e10cSrcweir 
664cdf0e10cSrcweir 	r->startDocument();
665cdf0e10cSrcweir 
666cdf0e10cSrcweir 	r->startElement( L"huhu" , rList );
667cdf0e10cSrcweir 	r->startCDATA();
668cdf0e10cSrcweir 
669cdf0e10cSrcweir 	{
670cdf0e10cSrcweir 		BOOL bException = TRUE;
671cdf0e10cSrcweir 		try {
672cdf0e10cSrcweir 			r->startElement( L"huhu" , rList );
673cdf0e10cSrcweir 			bException = FALSE;
674cdf0e10cSrcweir 		}
675cdf0e10cSrcweir 		catch( SAXException& e ) {
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 		}
678cdf0e10cSrcweir 		ERROR_ASSERT( bException , "expected exception not thrown !" );
679cdf0e10cSrcweir 	}
680cdf0e10cSrcweir 
681cdf0e10cSrcweir 	r->endCDATA();
682cdf0e10cSrcweir 	r->endElement( L"hi" );
683cdf0e10cSrcweir 
684cdf0e10cSrcweir 	r->endDocument();
685cdf0e10cSrcweir }
686cdf0e10cSrcweir 
687cdf0e10cSrcweir 
testDTD(const XExtendedDocumentHandlerRef & r)688cdf0e10cSrcweir void OSaxWriterTest::testDTD(const  XExtendedDocumentHandlerRef &r )
689cdf0e10cSrcweir {
690cdf0e10cSrcweir 	OFileWriter *pw = new OFileWriter("outputDTD.xml");
691cdf0e10cSrcweir 	AttributeListImpl *pList = new AttributeListImpl;
692cdf0e10cSrcweir 
693cdf0e10cSrcweir 	XAttributeListRef rList( (XAttributeList *) pList , USR_QUERY );
694cdf0e10cSrcweir 	XOutputStreamRef ref( ( XOutputStream * ) pw , USR_QUERY );
695cdf0e10cSrcweir 
696cdf0e10cSrcweir 	XActiveDataSourceRef source( r , USR_QUERY );
697cdf0e10cSrcweir 
698cdf0e10cSrcweir 	ERROR_ASSERT( ref.is() , "no output stream" );
699cdf0e10cSrcweir 	ERROR_ASSERT( source.is() , "no active data source" );
700cdf0e10cSrcweir 
701cdf0e10cSrcweir 	source->setOutputStream( ref );
702cdf0e10cSrcweir 
703cdf0e10cSrcweir 
704cdf0e10cSrcweir 	r->startDocument();
705cdf0e10cSrcweir 	r->unknown( L"<!DOCTYPE iCalendar >\n" );
706cdf0e10cSrcweir 	r->startElement( L"huhu" , rList );
707cdf0e10cSrcweir 
708cdf0e10cSrcweir 	r->endElement( L"huhu" );
709cdf0e10cSrcweir 	r->endDocument();
710cdf0e10cSrcweir }
711cdf0e10cSrcweir 
testPerformance(const XExtendedDocumentHandlerRef & r)712cdf0e10cSrcweir void OSaxWriterTest::testPerformance(const  XExtendedDocumentHandlerRef &r )
713cdf0e10cSrcweir {
714cdf0e10cSrcweir 	OFileWriter *pw = new OFileWriter("testPerformance.xml");
715cdf0e10cSrcweir 	AttributeListImpl *pList = new AttributeListImpl;
716cdf0e10cSrcweir 
717cdf0e10cSrcweir 	UString testParagraph = L"Dies ist ein bloeder Test um zu uberpruefen, ob der SAXWriter "
718cdf0e10cSrcweir 	                        L"wohl > Zeilenumbrueche halbwegs richtig macht oder ob er die Zeile "
719cdf0e10cSrcweir 	                        L"bis zum bitteren Ende schreibt.";
720cdf0e10cSrcweir 
721cdf0e10cSrcweir 
722cdf0e10cSrcweir 	XAttributeListRef rList( (XAttributeList *) pList , USR_QUERY );
723cdf0e10cSrcweir 	XOutputStreamRef ref( ( XOutputStream * ) pw , USR_QUERY );
724cdf0e10cSrcweir 
725cdf0e10cSrcweir 	XActiveDataSourceRef source( r , USR_QUERY );
726cdf0e10cSrcweir 
727cdf0e10cSrcweir 	ERROR_ASSERT( ref.is() , "no output stream" );
728cdf0e10cSrcweir 	ERROR_ASSERT( source.is() , "no active data source" );
729cdf0e10cSrcweir 
730cdf0e10cSrcweir 	source->setOutputStream( ref );
731cdf0e10cSrcweir 
732cdf0e10cSrcweir 	TimeValue aStartTime, aEndTime;
733cdf0e10cSrcweir 	osl_getSystemTime( &aStartTime );
734cdf0e10cSrcweir 
735cdf0e10cSrcweir 
736cdf0e10cSrcweir 	r->startDocument();
737cdf0e10cSrcweir 	// just write a bunch of xml tags !
738cdf0e10cSrcweir 	// for performance testing
739cdf0e10cSrcweir 	sal_Int32 i2;
740cdf0e10cSrcweir 	for( i2 = 0 ; i2 < 15 ; i2 ++ )
741cdf0e10cSrcweir 	{
742cdf0e10cSrcweir 		r->startElement( UString( L"tag" ) + UString::valueOf( i2 ), rList );
743cdf0e10cSrcweir 		for( sal_Int32 i = 0 ; i < 450 ; i ++ )
744cdf0e10cSrcweir 		{
745cdf0e10cSrcweir 			r->ignorableWhitespace( L"");
746cdf0e10cSrcweir 			r->startElement( L"huhu" , rList );
747cdf0e10cSrcweir 			r->characters( testParagraph );
748cdf0e10cSrcweir //			writeParagraph( r , testParagraph );
749cdf0e10cSrcweir 
750cdf0e10cSrcweir 			r->ignorableWhitespace( L"");
751cdf0e10cSrcweir 			r->endElement( L"huhu" );
752cdf0e10cSrcweir 		}
753cdf0e10cSrcweir 	}
754cdf0e10cSrcweir 	for( i2 = 14 ; i2 >= 0  ; i2-- )
755cdf0e10cSrcweir 	{
756cdf0e10cSrcweir 		r->ignorableWhitespace( L"");
757cdf0e10cSrcweir 		r->endElement( UString( L"tag" ) + UString::valueOf( i2 ) );
758cdf0e10cSrcweir 	}
759cdf0e10cSrcweir 
760cdf0e10cSrcweir 	r->endDocument();
761cdf0e10cSrcweir 
762cdf0e10cSrcweir 	osl_getSystemTime( &aEndTime );
763cdf0e10cSrcweir 
764cdf0e10cSrcweir 	double fStart = (double)aStartTime.Seconds + ((double)aStartTime.Nanosec / 1000000000.0);
765cdf0e10cSrcweir 	double fEnd = (double)aEndTime.Seconds + ((double)aEndTime.Nanosec / 1000000000.0);
766cdf0e10cSrcweir 
767cdf0e10cSrcweir 	printf( "Performance writing : %g s\n" , fEnd - fStart );
768cdf0e10cSrcweir }
769