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 <cppuhelper/supportsservice.hxx>
25 : #include <com/sun/star/io/XActiveDataSource.hpp>
26 : #include <com/sun/star/xml/sax/Writer.hpp>
27 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28 : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
29 : #include <com/sun/star/xml/sax/SAXException.hpp>
30 :
31 : #include <osl/diagnose.hxx>
32 :
33 : using namespace ::rtl;
34 : using namespace ::com::sun::star;
35 : using namespace ::com::sun::star::uno;
36 : using namespace ::com::sun::star::beans;
37 : using namespace ::com::sun::star::io;
38 : using namespace ::com::sun::star::lang;
39 : using namespace ::com::sun::star::registry;
40 : using namespace ::com::sun::star::packages;
41 : using namespace ::com::sun::star::xml::sax;
42 : using namespace ::com::sun::star::packages::manifest;
43 :
44 : #if OSL_DEBUG_LEVEL > 0
45 : #define THROW_WHERE SAL_WHERE
46 : #else
47 : #define THROW_WHERE ""
48 : #endif
49 :
50 0 : ManifestWriter::ManifestWriter( const Reference < XComponentContext > & xContext )
51 0 : : m_xContext ( xContext )
52 : {
53 0 : }
54 0 : ManifestWriter::~ManifestWriter()
55 : {
56 0 : }
57 :
58 : // XManifestWriter methods
59 0 : void SAL_CALL ManifestWriter::writeManifestSequence( const Reference< XOutputStream >& rStream, const Sequence< Sequence< PropertyValue > >& rSequence )
60 : throw (RuntimeException, std::exception)
61 : {
62 0 : Reference < XWriter > xSource = Writer::create( m_xContext );
63 0 : xSource->setOutputStream ( rStream );
64 : try {
65 0 : ManifestExport( xSource, rSequence);
66 : }
67 0 : catch( SAXException& )
68 : {
69 0 : throw RuntimeException( THROW_WHERE, uno::Reference< uno::XInterface >() );
70 0 : }
71 0 : }
72 :
73 : // Component methods
74 0 : Reference < XInterface > SAL_CALL ManifestWriter_createInstance( Reference< XMultiServiceFactory > const & rServiceFactory )
75 : {
76 0 : return *new ManifestWriter( comphelper::getComponentContext(rServiceFactory) );
77 : }
78 :
79 0 : OUString ManifestWriter::static_getImplementationName()
80 : {
81 0 : return OUString ( "com.sun.star.packages.manifest.comp.ManifestWriter" );
82 : }
83 :
84 0 : Sequence < OUString > ManifestWriter::static_getSupportedServiceNames()
85 : {
86 0 : Sequence < OUString > aNames(1);
87 0 : aNames[0] = "com.sun.star.packages.manifest.ManifestWriter";
88 0 : return aNames;
89 : }
90 :
91 0 : OUString ManifestWriter::getImplementationName()
92 : throw (RuntimeException, std::exception)
93 : {
94 0 : return static_getImplementationName();
95 : }
96 :
97 0 : sal_Bool SAL_CALL ManifestWriter::supportsService(OUString const & rServiceName)
98 : throw (RuntimeException, std::exception)
99 : {
100 0 : return cppu::supportsService(this, rServiceName);
101 : }
102 0 : Sequence < OUString > ManifestWriter::getSupportedServiceNames()
103 : throw (RuntimeException, std::exception)
104 : {
105 0 : return static_getSupportedServiceNames();
106 : }
107 0 : Reference < XSingleServiceFactory > ManifestWriter::createServiceFactory( Reference < XMultiServiceFactory > const & rServiceFactory )
108 : {
109 : return cppu::createSingleFactory (rServiceFactory,
110 : static_getImplementationName(),
111 : ManifestWriter_createInstance,
112 0 : static_getSupportedServiceNames());
113 : }
114 :
115 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|