Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <ManifestWriter.hxx>
21 : #include <ManifestExport.hxx>
22 : #include <comphelper/processfactory.hxx>
23 : #include <cppuhelper/factory.hxx>
24 : #include <com/sun/star/io/XActiveDataSource.hpp>
25 : #include <com/sun/star/xml/sax/Writer.hpp>
26 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
28 : #include <com/sun/star/xml/sax/SAXException.hpp>
29 :
30 : #include <osl/diagnose.hxx>
31 :
32 : using namespace ::rtl;
33 : using namespace ::com::sun::star;
34 : using namespace ::com::sun::star::uno;
35 : using namespace ::com::sun::star::beans;
36 : using namespace ::com::sun::star::io;
37 : using namespace ::com::sun::star::lang;
38 : using namespace ::com::sun::star::registry;
39 : using namespace ::com::sun::star::packages;
40 : using namespace ::com::sun::star::xml::sax;
41 : using namespace ::com::sun::star::packages::manifest;
42 :
43 175 : ManifestWriter::ManifestWriter( const Reference < XComponentContext > & xContext )
44 175 : : m_xContext ( xContext )
45 : {
46 175 : }
47 350 : ManifestWriter::~ManifestWriter()
48 : {
49 350 : }
50 :
51 : // XManifestWriter methods
52 175 : void SAL_CALL ManifestWriter::writeManifestSequence( const Reference< XOutputStream >& rStream, const Sequence< Sequence< PropertyValue > >& rSequence )
53 : throw (RuntimeException)
54 : {
55 175 : Reference < XWriter > xSource = Writer::create( m_xContext );
56 175 : xSource->setOutputStream ( rStream );
57 : try {
58 175 : ManifestExport( xSource, rSequence);
59 : }
60 0 : catch( SAXException& )
61 : {
62 0 : throw RuntimeException( OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
63 175 : }
64 175 : }
65 :
66 : // Component methods
67 175 : Reference < XInterface > SAL_CALL ManifestWriter_createInstance( Reference< XMultiServiceFactory > const & rServiceFactory )
68 : {
69 175 : return *new ManifestWriter( comphelper::getComponentContext(rServiceFactory) );
70 : }
71 :
72 164 : OUString ManifestWriter::static_getImplementationName()
73 : {
74 164 : return OUString ( "com.sun.star.packages.manifest.comp.ManifestWriter" );
75 : }
76 :
77 0 : sal_Bool SAL_CALL ManifestWriter::static_supportsService(OUString const & rServiceName)
78 : {
79 0 : return rServiceName == getSupportedServiceNames()[0];
80 : }
81 17 : Sequence < OUString > ManifestWriter::static_getSupportedServiceNames()
82 : {
83 17 : Sequence < OUString > aNames(1);
84 17 : aNames[0] = "com.sun.star.packages.manifest.ManifestWriter";
85 17 : return aNames;
86 : }
87 :
88 0 : OUString ManifestWriter::getImplementationName()
89 : throw (RuntimeException)
90 : {
91 0 : return static_getImplementationName();
92 : }
93 :
94 0 : sal_Bool SAL_CALL ManifestWriter::supportsService(OUString const & rServiceName)
95 : throw (RuntimeException)
96 : {
97 0 : return static_supportsService ( rServiceName );
98 : }
99 0 : Sequence < OUString > ManifestWriter::getSupportedServiceNames()
100 : throw (RuntimeException)
101 : {
102 0 : return static_getSupportedServiceNames();
103 : }
104 17 : Reference < XSingleServiceFactory > ManifestWriter::createServiceFactory( Reference < XMultiServiceFactory > const & rServiceFactory )
105 : {
106 : return cppu::createSingleFactory (rServiceFactory,
107 : static_getImplementationName(),
108 : ManifestWriter_createInstance,
109 17 : static_getSupportedServiceNames());
110 : }
111 :
112 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|