1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ManifestWriter.cxx,v $
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>
39 #ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP
40 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
42 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP
43 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
45 #ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP
46 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
48 #ifndef _COM_SUN_STAR_XML_SAX_SAXEXCEPTION_HPP
49 #include <com/sun/star/xml/sax/SAXException.hpp>
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
);
81 xSource
->setOutputStream ( rStream
);
82 Reference
< XDocumentHandler
> xHandler ( xSource
, UNO_QUERY
);
85 ManifestExport
aExporter ( xHandler
, rSequence
);
87 catch( SAXException
& )
89 throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX
) ), uno::Reference
< uno::XInterface
>() );
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" ) );
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());