Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <com/sun/star/embed/ElementModes.hpp>
30 : : #include <tools/debug.hxx>
31 : : #include <unotools/streamwrap.hxx>
32 : : #include <xmlversion.hxx>
33 : : #include <xmloff/xmlmetae.hxx>
34 : :
35 : : #include <xmloff/xmltoken.hxx>
36 : : #include <comphelper/processfactory.hxx>
37 : : #include <com/sun/star/io/XActiveDataSource.hpp>
38 : : #include <com/sun/star/io/XOutputStream.hpp>
39 : : #include <com/sun/star/util/DateTime.hpp>
40 : : #include <com/sun/star/util/MeasureUnit.hpp>
41 : : #include <com/sun/star/xml/sax/InputSource.hpp>
42 : : #include <com/sun/star/xml/sax/XParser.hpp>
43 : :
44 : : using namespace ::com::sun::star::xml::sax;
45 : : using namespace ::com::sun::star::uno;
46 : : using namespace ::com::sun::star;
47 : : using ::rtl::OUString;
48 : :
49 : : // ------------------------------------------------------------------------
50 : :
51 : : const char XMLN_VERSIONSLIST[] = "VersionList.xml";
52 : :
53 : : // ------------------------------------------------------------------------
54 : : // #110897#
55 : 0 : XMLVersionListExport::XMLVersionListExport(
56 : : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
57 : : const com::sun::star::uno::Sequence < com::sun::star::util::RevisionTag >& rVersions,
58 : : const OUString &rFileName,
59 : : Reference< XDocumentHandler > &rHandler )
60 : : : SvXMLExport( xServiceFactory, rFileName, util::MeasureUnit::CM, rHandler ),
61 : 0 : maVersions( rVersions )
62 : : {
63 [ # # ]: 0 : _GetNamespaceMap().AddAtIndex( XML_NAMESPACE_DC_IDX, xmloff::token::GetXMLToken(xmloff::token::XML_NP_DC),
64 [ # # # # ]: 0 : xmloff::token::GetXMLToken(xmloff::token::XML_N_DC), XML_NAMESPACE_DC );
65 [ # # ]: 0 : _GetNamespaceMap().AddAtIndex( XML_NAMESPACE_FRAMEWORK_IDX, xmloff::token::GetXMLToken(xmloff::token::XML_NP_VERSIONS_LIST),
66 [ # # # # ]: 0 : xmloff::token::GetXMLToken(xmloff::token::XML_N_VERSIONS_LIST), XML_NAMESPACE_FRAMEWORK );
67 : 0 : }
68 : :
69 : : // ------------------------------------------------------------------------
70 : 0 : sal_uInt32 XMLVersionListExport::exportDoc( enum ::xmloff::token::XMLTokenEnum )
71 : : {
72 : 0 : GetDocHandler()->startDocument();
73 : :
74 : 0 : addChaffWhenEncryptedStorage();
75 : :
76 : 0 : sal_uInt16 nPos = _GetNamespaceMap().GetIndexByKey( XML_NAMESPACE_DC );
77 : :
78 : 0 : AddAttribute( XML_NAMESPACE_NONE, _GetNamespaceMap().GetAttrNameByIndex( nPos ),
79 [ # # ]: 0 : _GetNamespaceMap().GetNameByIndex ( nPos ) );
80 : :
81 : 0 : nPos = _GetNamespaceMap().GetIndexByKey( XML_NAMESPACE_FRAMEWORK );
82 : 0 : AddAttribute( XML_NAMESPACE_NONE, _GetNamespaceMap().GetAttrNameByIndex( nPos ),
83 [ # # ]: 0 : _GetNamespaceMap().GetNameByIndex ( nPos ) );
84 : :
85 : : {
86 : : // the following object will write all collected attributes in its dtor
87 [ # # ]: 0 : SvXMLElementExport aRoot( *this, XML_NAMESPACE_FRAMEWORK, xmloff::token::XML_VERSION_LIST, sal_True, sal_True );
88 : :
89 [ # # ]: 0 : for ( sal_Int32 n=0; n<maVersions.getLength(); n++ )
90 : : {
91 : 0 : const util::RevisionTag& rInfo = maVersions[n];
92 : : AddAttribute( XML_NAMESPACE_FRAMEWORK,
93 : : xmloff::token::XML_TITLE,
94 [ # # ]: 0 : OUString( rInfo.Identifier ) );
95 : : AddAttribute( XML_NAMESPACE_FRAMEWORK,
96 : : xmloff::token::XML_COMMENT,
97 [ # # ]: 0 : OUString( rInfo.Comment ) );
98 : : AddAttribute( XML_NAMESPACE_FRAMEWORK,
99 : : xmloff::token::XML_CREATOR,
100 [ # # ]: 0 : OUString( rInfo.Author ) );
101 : :
102 : : OUString aDateStr =
103 [ # # ]: 0 : SvXMLMetaExport::GetISODateTimeString( rInfo.TimeStamp );
104 : :
105 [ # # ]: 0 : AddAttribute( XML_NAMESPACE_DC, xmloff::token::XML_DATE_TIME, aDateStr );
106 : :
107 : : // the following object will write all collected attributes in its dtor
108 [ # # ]: 0 : SvXMLElementExport aEntry( *this, XML_NAMESPACE_FRAMEWORK, xmloff::token::XML_VERSION_ENTRY, sal_True, sal_True );
109 [ # # ][ # # ]: 0 : }
110 : : }
111 : 0 : GetDocHandler()->endDocument();
112 : 0 : return 0;
113 : : }
114 : :
115 : : // ------------------------------------------------------------------------
116 : : // #110897#
117 : 0 : XMLVersionListImport::XMLVersionListImport(
118 : : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
119 : : com::sun::star::uno::Sequence < com::sun::star::util::RevisionTag >& rVersions )
120 : : : SvXMLImport(xServiceFactory),
121 : 0 : maVersions( rVersions )
122 : : {
123 [ # # ]: 0 : GetNamespaceMap().AddAtIndex( XML_NAMESPACE_FRAMEWORK_IDX, xmloff::token::GetXMLToken(xmloff::token::XML_NP_VERSIONS_LIST),
124 [ # # # # ]: 0 : xmloff::token::GetXMLToken(xmloff::token::XML_N_VERSIONS_LIST), XML_NAMESPACE_FRAMEWORK );
125 : 0 : }
126 : :
127 : : // ------------------------------------------------------------------------
128 : 0 : XMLVersionListImport::~XMLVersionListImport( void ) throw()
129 [ # # ]: 0 : {}
130 : :
131 : : // ------------------------------------------------------------------------
132 : 0 : SvXMLImportContext *XMLVersionListImport::CreateContext(
133 : : sal_uInt16 nPrefix,
134 : : const OUString& rLocalName,
135 : : const Reference< XAttributeList > & xAttrList )
136 : : {
137 : 0 : SvXMLImportContext *pContext = 0;
138 : :
139 [ # # # # ]: 0 : if ( XML_NAMESPACE_FRAMEWORK == nPrefix &&
[ # # ]
140 : 0 : rLocalName == xmloff::token::GetXMLToken(xmloff::token::XML_VERSION_LIST) )
141 : : {
142 [ # # ]: 0 : pContext = new XMLVersionListContext( *this, nPrefix, rLocalName, xAttrList );
143 : : }
144 : : else
145 : : {
146 : 0 : pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
147 : : }
148 : :
149 : 0 : return pContext;
150 : : }
151 : :
152 : :
153 : : // ------------------------------------------------------------------------
154 : 0 : XMLVersionListContext::XMLVersionListContext( XMLVersionListImport& rImport,
155 : : sal_uInt16 nPrefix,
156 : : const OUString& rLocalName,
157 : : const Reference< XAttributeList > & )
158 : : : SvXMLImportContext( rImport, nPrefix, rLocalName )
159 : 0 : , rLocalRef( rImport )
160 : : {
161 : 0 : }
162 : :
163 : : // ------------------------------------------------------------------------
164 : 0 : XMLVersionListContext::~XMLVersionListContext( void )
165 [ # # ]: 0 : {}
166 : :
167 : : // ------------------------------------------------------------------------
168 : 0 : SvXMLImportContext *XMLVersionListContext::CreateChildContext( sal_uInt16 nPrefix,
169 : : const OUString& rLocalName,
170 : : const Reference< XAttributeList > & xAttrList )
171 : : {
172 : 0 : SvXMLImportContext *pContext = 0;
173 : :
174 [ # # # # ]: 0 : if ( nPrefix == XML_NAMESPACE_FRAMEWORK &&
[ # # ]
175 : 0 : rLocalName == xmloff::token::GetXMLToken(xmloff::token::XML_VERSION_ENTRY) )
176 : : {
177 [ # # ]: 0 : pContext = new XMLVersionContext( rLocalRef, nPrefix, rLocalName, xAttrList );
178 : : }
179 : : else
180 : : {
181 [ # # ]: 0 : pContext = new SvXMLImportContext( rLocalRef, nPrefix, rLocalName );
182 : : }
183 : :
184 : 0 : return pContext;
185 : : }
186 : :
187 : : // ------------------------------------------------------------------------
188 : 0 : XMLVersionContext::XMLVersionContext( XMLVersionListImport& rImport,
189 : : sal_uInt16 nPref,
190 : : const OUString& rLocalName,
191 : : const Reference< XAttributeList > & xAttrList )
192 : : : SvXMLImportContext( rImport, nPref, rLocalName )
193 : 0 : , rLocalRef( rImport )
194 : : {
195 [ # # ][ # # ]: 0 : sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
[ # # ]
196 : :
197 [ # # ]: 0 : if ( !nAttrCount )
198 : 0 : return;
199 : :
200 : 0 : util::RevisionTag aInfo;
201 [ # # ]: 0 : for ( sal_Int16 i=0; i < nAttrCount; i++ )
202 : : {
203 : 0 : OUString aLocalName;
204 [ # # ][ # # ]: 0 : const OUString& rAttrName = xAttrList->getNameByIndex( i );
205 [ # # ]: 0 : sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName );
206 : :
207 [ # # ]: 0 : if ( XML_NAMESPACE_FRAMEWORK == nPrefix )
208 : : {
209 [ # # ][ # # ]: 0 : if ( aLocalName == xmloff::token::GetXMLToken(xmloff::token::XML_TITLE) )
210 : : {
211 [ # # ][ # # ]: 0 : const OUString& rAttrValue = xAttrList->getValueByIndex( i );
212 : 0 : aInfo.Identifier = rAttrValue;
213 : : }
214 [ # # ][ # # ]: 0 : else if ( aLocalName == xmloff::token::GetXMLToken(xmloff::token::XML_COMMENT) )
215 : : {
216 [ # # ][ # # ]: 0 : const OUString& rAttrValue = xAttrList->getValueByIndex( i );
217 : 0 : aInfo.Comment = rAttrValue;
218 : : }
219 [ # # ][ # # ]: 0 : else if ( aLocalName == xmloff::token::GetXMLToken(xmloff::token::XML_CREATOR) )
220 : : {
221 [ # # ][ # # ]: 0 : const OUString& rAttrValue = xAttrList->getValueByIndex( i );
222 : 0 : aInfo.Author = rAttrValue;
223 : : }
224 : : }
225 [ # # # # ]: 0 : else if ( ( XML_NAMESPACE_DC == nPrefix ) &&
[ # # ]
226 [ # # ]: 0 : ( aLocalName == xmloff::token::GetXMLToken(xmloff::token::XML_DATE_TIME) ) )
227 : : {
228 [ # # ][ # # ]: 0 : const OUString& rAttrValue = xAttrList->getValueByIndex( i );
229 : 0 : util::DateTime aTime;
230 [ # # ][ # # ]: 0 : if ( ParseISODateTimeString( rAttrValue, aTime ) )
231 : 0 : aInfo.TimeStamp = aTime;
232 : : }
233 : 0 : }
234 : :
235 : 0 : uno::Sequence < util::RevisionTag >& aList = rLocalRef.GetList();
236 : 0 : sal_Int32 nLength = aList.getLength();
237 [ # # ]: 0 : aList.realloc( nLength+1 );
238 [ # # ]: 0 : aList[nLength] = aInfo;
239 : : }
240 : :
241 : :
242 : : // ------------------------------------------------------------------------
243 : 0 : XMLVersionContext::~XMLVersionContext( void )
244 [ # # ]: 0 : {}
245 : :
246 : : // ------------------------------------------------------------------------
247 : 0 : sal_Bool XMLVersionContext::ParseISODateTimeString(
248 : : const rtl::OUString& rString,
249 : : util::DateTime& rDateTime )
250 : : {
251 : 0 : sal_Bool bSuccess = sal_True;
252 : :
253 : 0 : OUString aDateStr, aTimeStr;
254 : 0 : sal_Int32 nPos = rString.indexOf( (sal_Unicode) 'T' );
255 [ # # ]: 0 : if ( nPos >= 0 )
256 : : {
257 : 0 : aDateStr = rString.copy( 0, nPos );
258 : 0 : aTimeStr = rString.copy( nPos + 1 );
259 : : }
260 : : else
261 : 0 : aDateStr = rString; // no separator: only date part
262 : :
263 : 0 : sal_Int32 nYear = 0;
264 : 0 : sal_Int32 nMonth = 1;
265 : 0 : sal_Int32 nDay = 1;
266 : 0 : sal_Int32 nHour = 0;
267 : 0 : sal_Int32 nMin = 0;
268 : 0 : sal_Int32 nSec = 0;
269 : :
270 : 0 : const sal_Unicode* pStr = aDateStr.getStr();
271 : 0 : sal_Int32 nDateTokens = 1;
272 [ # # ]: 0 : while ( *pStr )
273 : : {
274 [ # # ]: 0 : if ( *pStr == '-' )
275 : 0 : nDateTokens++;
276 : 0 : pStr++;
277 : : }
278 [ # # ][ # # ]: 0 : if ( nDateTokens > 3 || aDateStr.isEmpty() )
[ # # ]
279 : 0 : bSuccess = sal_False;
280 : : else
281 : : {
282 : 0 : sal_Int32 n = 0;
283 : 0 : nYear = aDateStr.getToken( 0, '-', n ).toInt32();
284 [ # # ]: 0 : if ( nYear > 9999 )
285 : 0 : bSuccess = sal_False;
286 [ # # ]: 0 : else if ( nDateTokens >= 2 )
287 : : {
288 : 0 : nMonth = aDateStr.getToken( 0, '-', n ).toInt32();
289 [ # # ]: 0 : if ( nMonth > 12 )
290 : 0 : bSuccess = sal_False;
291 [ # # ]: 0 : else if ( nDateTokens >= 3 )
292 : : {
293 : 0 : nDay = aDateStr.getToken( 0, '-', n ).toInt32();
294 [ # # ]: 0 : if ( nDay > 31 )
295 : 0 : bSuccess = sal_False;
296 : : }
297 : : }
298 : : }
299 : :
300 [ # # ][ # # ]: 0 : if ( bSuccess && !aTimeStr.isEmpty() ) // time is optional
[ # # ]
301 : : {
302 : 0 : pStr = aTimeStr.getStr();
303 : 0 : sal_Int32 nTimeTokens = 1;
304 [ # # ]: 0 : while ( *pStr )
305 : : {
306 [ # # ]: 0 : if ( *pStr == ':' )
307 : 0 : nTimeTokens++;
308 : 0 : pStr++;
309 : : }
310 [ # # ]: 0 : if ( nTimeTokens > 3 )
311 : 0 : bSuccess = sal_False;
312 : : else
313 : : {
314 : 0 : sal_Int32 n = 0;
315 : 0 : nHour = aTimeStr.getToken( 0, ':', n ).toInt32();
316 [ # # ]: 0 : if ( nHour > 23 )
317 : 0 : bSuccess = sal_False;
318 [ # # ]: 0 : else if ( nTimeTokens >= 2 )
319 : : {
320 : 0 : nMin = aTimeStr.getToken( 0, ':', n ).toInt32();
321 [ # # ]: 0 : if ( nMin > 59 )
322 : 0 : bSuccess = sal_False;
323 [ # # ]: 0 : else if ( nTimeTokens >= 3 )
324 : : {
325 : 0 : nSec = aTimeStr.getToken( 0, ':', n ).toInt32();
326 [ # # ]: 0 : if ( nSec > 59 )
327 : 0 : bSuccess = sal_False;
328 : : }
329 : : }
330 : : }
331 : : }
332 : :
333 [ # # ]: 0 : if ( bSuccess )
334 : : {
335 : 0 : rDateTime.Day = sal::static_int_cast< sal_uInt16 >(nDay);
336 : 0 : rDateTime.Month = sal::static_int_cast< sal_uInt16 >(nMonth);
337 : 0 : rDateTime.Year = sal::static_int_cast< sal_uInt16 >(nYear);
338 : 0 : rDateTime.Hours = sal::static_int_cast< sal_uInt16 >(nHour);
339 : 0 : rDateTime.Minutes = sal::static_int_cast< sal_uInt16 >(nMin);
340 : 0 : rDateTime.Seconds = sal::static_int_cast< sal_uInt16 >(nSec);
341 : : }
342 : :
343 : 0 : return bSuccess;
344 : : }
345 : :
346 : :
347 : : // ------------------------------------------------------------------------
348 : 0 : void SAL_CALL XMLVersionListPersistence::store( const uno::Reference< embed::XStorage >& xRoot, const uno::Sequence< util::RevisionTag >& rVersions )
349 : : throw (::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
350 : : {
351 : : // no storage, no version list!
352 [ # # ]: 0 : if ( xRoot.is() )
353 : : {
354 : : // get the services needed for writing the xml data
355 : : Reference< lang::XMultiServiceFactory > xServiceFactory =
356 [ # # ]: 0 : comphelper::getProcessServiceFactory();
357 : : DBG_ASSERT( xServiceFactory.is(), "XMLReader::Read: got no service manager" );
358 : :
359 [ # # ]: 0 : Reference< XInterface > xWriter (xServiceFactory->createInstance(
360 [ # # ]: 0 : OUString("com.sun.star.xml.sax.Writer")));
361 : : DBG_ASSERT( xWriter.is(), "com.sun.star.xml.sax.Writer service missing" );
362 : :
363 : : // check whether there's already a sub storage with the version info
364 : : // and delete it
365 : 0 : OUString sVerName( XMLN_VERSIONSLIST );
366 : :
367 : : try {
368 : : // open (create) the sub storage with the version info
369 [ # # ]: 0 : uno::Reference< io::XStream > xVerStream = xRoot->openStreamElement(
370 : : sVerName,
371 [ # # ]: 0 : embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
372 [ # # ]: 0 : if ( !xVerStream.is() )
373 [ # # ]: 0 : throw uno::RuntimeException();
374 : :
375 [ # # ][ # # ]: 0 : Reference< io::XOutputStream > xOut = xVerStream->getOutputStream();
376 [ # # ]: 0 : if ( !xOut.is() )
377 [ # # ]: 0 : throw uno::RuntimeException(); // the stream was successfuly opened for writing already
378 : :
379 [ # # ]: 0 : Reference< io::XActiveDataSource > xSrc( xWriter, uno::UNO_QUERY );
380 [ # # ][ # # ]: 0 : xSrc->setOutputStream(xOut);
381 : :
382 [ # # ]: 0 : Reference< XDocumentHandler > xHandler( xWriter, uno::UNO_QUERY );
383 : :
384 [ # # ]: 0 : XMLVersionListExport aExp( xServiceFactory, rVersions, sVerName, xHandler );
385 : :
386 [ # # ]: 0 : aExp.exportDoc( ::xmloff::token::XML_VERSION );
387 : :
388 [ # # ][ # # ]: 0 : xVerStream = uno::Reference< io::XStream >(); // use refcounting for now to dispose
[ # # ]
389 : : }
390 [ # # ]: 0 : catch( uno::Exception& )
391 : : {
392 : : // TODO: error handling
393 : 0 : }
394 : : }
395 : 0 : }
396 : :
397 : : // ------------------------------------------------------------------------
398 : 259 : uno::Sequence< util::RevisionTag > SAL_CALL XMLVersionListPersistence::load( const uno::Reference< embed::XStorage >& xRoot )
399 : : throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
400 : : {
401 [ + - ]: 259 : com::sun::star::uno::Sequence < com::sun::star::util::RevisionTag > aVersions;
402 : :
403 : 259 : const OUString sDocName( XMLN_VERSIONSLIST );
404 [ + - ]: 259 : uno::Reference< container::XNameAccess > xRootNames( xRoot, uno::UNO_QUERY );
405 : :
406 : : try {
407 [ + - ][ + - ]: 259 : if ( xRootNames.is() && xRootNames->hasByName( sDocName ) && xRoot->isStreamElement( sDocName ) )
[ + + ][ - + ]
[ # # ][ # # ]
[ # # ][ - + ]
408 : : {
409 : : Reference< lang::XMultiServiceFactory > xServiceFactory =
410 [ # # ]: 0 : comphelper::getProcessServiceFactory();
411 : : DBG_ASSERT( xServiceFactory.is(), "XMLReader::Read: got no service manager" );
412 : :
413 [ # # ]: 0 : InputSource aParserInput;
414 : :
415 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps( xRoot, uno::UNO_QUERY );
416 : : OSL_ENSURE( xProps.is(), "Storage must implement XPropertySet!\n" );
417 [ # # ]: 0 : if ( xProps.is() )
418 : : {
419 : : try {
420 [ # # ][ # # ]: 0 : xProps->getPropertyValue( ::rtl::OUString("URL") ) >>= aParserInput.sSystemId;
[ # # ]
421 : : }
422 [ # # ]: 0 : catch( uno::Exception& )
423 : : {}
424 : : }
425 : :
426 [ # # ]: 0 : uno::Reference< io::XStream > xDocStream = xRoot->openStreamElement(
427 : : sDocName,
428 [ # # ]: 0 : embed::ElementModes::READ );
429 [ # # ]: 0 : if ( !xDocStream.is() )
430 [ # # ]: 0 : throw uno::RuntimeException();
431 : :
432 [ # # ][ # # ]: 0 : aParserInput.aInputStream = xDocStream->getInputStream();
[ # # ]
433 : : OSL_ENSURE( aParserInput.aInputStream.is(),
434 : : "The stream was successfuly opened for reading, the input part must be accessible!\n" );
435 [ # # ]: 0 : if ( !aParserInput.aInputStream.is() )
436 [ # # ]: 0 : throw uno::RuntimeException();
437 : :
438 : : // get parser
439 [ # # ]: 0 : Reference< XInterface > xXMLParser = xServiceFactory->createInstance(
440 [ # # ]: 0 : OUString("com.sun.star.xml.sax.Parser") );
441 : : DBG_ASSERT( xXMLParser.is(),
442 : : "XMLReader::Read: com.sun.star.xml.sax.Parser service missing" );
443 : :
444 : : // get filter
445 [ # # ][ # # ]: 0 : Reference< XDocumentHandler > xFilter = new XMLVersionListImport( xServiceFactory, aVersions );
[ # # # # ]
[ # # ]
446 : :
447 : : // connect parser and filter
448 [ # # ]: 0 : Reference< XParser > xParser( xXMLParser, UNO_QUERY );
449 [ # # ][ # # ]: 0 : xParser->setDocumentHandler( xFilter );
450 : :
451 : : // parse
452 : : try
453 : : {
454 [ # # ][ # # ]: 0 : xParser->parseStream( aParserInput );
455 : : }
456 [ # # ]: 0 : catch( SAXParseException& ) {}
457 [ # # ]: 0 : catch( SAXException& ) {}
458 [ # # ][ # # ]: 14 : catch( io::IOException& ) {}
[ - + ]
459 : : }
460 : : }
461 [ + - ]: 14 : catch( uno::Exception& )
462 : : {
463 : : // TODO: error handling
464 : : }
465 : :
466 : 259 : return aVersions;
467 : : }
468 : :
469 : 30 : uno::Sequence< rtl::OUString > SAL_CALL XMLVersionListPersistence_getSupportedServiceNames()
470 : : throw()
471 : : {
472 : : const rtl::OUString aServiceName(
473 : 30 : "com.sun.star.document.DocumentRevisionListPersistence" );
474 [ + - ]: 30 : const uno::Sequence< rtl::OUString > aSeq( &aServiceName, 1 );
475 : 30 : return aSeq;
476 : : }
477 : :
478 : 60 : rtl::OUString SAL_CALL XMLVersionListPersistence_getImplementationName() throw()
479 : : {
480 : 60 : return rtl::OUString( "XMLVersionListPersistence" );
481 : : }
482 : :
483 : 259 : uno::Reference< uno::XInterface > SAL_CALL XMLVersionListPersistence_createInstance(
484 : : const uno::Reference< lang::XMultiServiceFactory > &)
485 : : throw( uno::Exception )
486 : : {
487 [ + - ]: 259 : return (cppu::OWeakObject*)new XMLVersionListPersistence;
488 : : }
489 : :
490 : 0 : uno::Sequence< rtl::OUString > SAL_CALL XMLVersionImExportOOO_getSupportedServiceNames()
491 : : throw()
492 : : {
493 : : const rtl::OUString aServiceName(
494 : 0 : "com.sun.star.document.DocumentRevisionListPersistence" );
495 [ # # ]: 0 : const uno::Sequence< rtl::OUString > aSeq( &aServiceName, 1 );
496 : 0 : return aSeq;
497 : : }
498 : :
499 : 0 : rtl::OUString SAL_CALL XMLVersionImExportOOO_getImplementationName() throw()
500 : : {
501 : 0 : return rtl::OUString( "XMLVersionImExportOOo" );
502 : : }
503 : :
504 : 0 : uno::Reference< uno::XInterface > SAL_CALL XMLVersionImExportOOO_createInstance(
505 : : const uno::Reference< lang::XMultiServiceFactory > &)
506 : : throw( uno::Exception )
507 : : {
508 [ # # ]: 0 : return (cppu::OWeakObject*)new XMLVersionListPersistence;
509 : : }
510 : :
511 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|