Update ooo320-m1
[ooovba.git] / package / source / manifest / ManifestWriter.cxx
blob300dad2df40fe375ee02ff48a330058dae09a4a2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ManifestWriter.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_package.hxx"
33 #include <ManifestWriter.hxx>
34 #include <ManifestExport.hxx>
35 #include <cppuhelper/factory.hxx>
36 #ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP
37 #include <com/sun/star/io/XActiveDataSource.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP
40 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP
43 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
44 #endif
45 #ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP
46 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
47 #endif
48 #ifndef _COM_SUN_STAR_XML_SAX_SAXEXCEPTION_HPP
49 #include <com/sun/star/xml/sax/SAXException.hpp>
50 #endif
52 #include <osl/diagnose.hxx>
54 using namespace ::rtl;
55 using namespace ::com::sun::star;
56 using namespace ::com::sun::star::uno;
57 using namespace ::com::sun::star::beans;
58 using namespace ::com::sun::star::io;
59 using namespace ::com::sun::star::lang;
60 using namespace ::com::sun::star::registry;
61 using namespace ::com::sun::star::packages;
62 using namespace ::com::sun::star::xml::sax;
63 using namespace ::com::sun::star::packages::manifest;
65 ManifestWriter::ManifestWriter( const Reference < XMultiServiceFactory > & xNewFactory )
66 : xFactory ( xNewFactory )
69 ManifestWriter::~ManifestWriter()
73 // XManifestWriter methods
74 void SAL_CALL ManifestWriter::writeManifestSequence( const Reference< XOutputStream >& rStream, const Sequence< Sequence< PropertyValue > >& rSequence )
75 throw (RuntimeException)
77 OUString sSaxWriter ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.xml.sax.Writer" ) );
78 Reference < XActiveDataSource > xSource ( xFactory->createInstance ( sSaxWriter ), UNO_QUERY );
79 if (xSource.is())
81 xSource->setOutputStream ( rStream );
82 Reference < XDocumentHandler > xHandler ( xSource, UNO_QUERY );
83 if (xHandler.is())
84 try {
85 ManifestExport aExporter ( xHandler, rSequence);
87 catch( SAXException& )
89 throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
94 // Component methods
95 Reference < XInterface > SAL_CALL ManifestWriter_createInstance( Reference< XMultiServiceFactory > const & rServiceFactory )
97 return *new ManifestWriter( rServiceFactory );
100 OUString ManifestWriter::static_getImplementationName()
102 return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.packages.manifest.comp.ManifestWriter" ) );
105 sal_Bool SAL_CALL ManifestWriter::static_supportsService(OUString const & rServiceName)
107 return rServiceName == getSupportedServiceNames()[0];
109 Sequence < OUString > ManifestWriter::static_getSupportedServiceNames()
111 Sequence < OUString > aNames(1);
112 aNames[0] = OUString(RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.packages.manifest.ManifestWriter" ) );
113 return aNames;
116 OUString ManifestWriter::getImplementationName()
117 throw (RuntimeException)
119 return static_getImplementationName();
122 sal_Bool SAL_CALL ManifestWriter::supportsService(OUString const & rServiceName)
123 throw (RuntimeException)
125 return static_supportsService ( rServiceName );
127 Sequence < OUString > ManifestWriter::getSupportedServiceNames()
128 throw (RuntimeException)
130 return static_getSupportedServiceNames();
132 Reference < XSingleServiceFactory > ManifestWriter::createServiceFactory( Reference < XMultiServiceFactory > const & rServiceFactory )
134 return cppu::createSingleFactory (rServiceFactory,
135 static_getImplementationName(),
136 ManifestWriter_createInstance,
137 static_getSupportedServiceNames());