cid#1640468 Dereference after null check
[LibreOffice.git] / package / source / manifest / ManifestWriter.cxx
blob1a847953fdf7063395de2f512db0f9c07efa5240
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "ManifestWriter.hxx"
21 #include "ManifestExport.hxx"
22 #include <cppuhelper/exc_hlp.hxx>
23 #include <cppuhelper/factory.hxx>
24 #include <cppuhelper/supportsservice.hxx>
25 #include <com/sun/star/xml/sax/Writer.hpp>
26 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
27 #include <com/sun/star/xml/sax/SAXException.hpp>
29 #include <sal/log.hxx>
31 using namespace ::com::sun::star;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::beans;
34 using namespace ::com::sun::star::io;
35 using namespace ::com::sun::star::lang;
36 using namespace ::com::sun::star::packages;
37 using namespace ::com::sun::star::xml::sax;
39 #if OSL_DEBUG_LEVEL > 0
40 #define THROW_WHERE SAL_WHERE
41 #else
42 #define THROW_WHERE ""
43 #endif
45 ManifestWriter::ManifestWriter( const Reference < XComponentContext > & xContext )
46 : m_xContext ( xContext )
49 ManifestWriter::~ManifestWriter()
53 // XManifestWriter methods
54 void SAL_CALL ManifestWriter::writeManifestSequence( const Reference< XOutputStream >& rStream, const Sequence< Sequence< PropertyValue > >& rSequence )
56 Reference < XWriter > xSource = Writer::create( m_xContext );
57 xSource->setOutputStream ( rStream );
58 try {
59 ManifestExport( xSource, rSequence);
61 catch( SAXException& )
63 css::uno::Any anyEx = cppu::getCaughtException();
64 throw css::lang::WrappedTargetRuntimeException( THROW_WHERE,
65 nullptr, anyEx );
69 OUString ManifestWriter::getImplementationName()
71 return u"com.sun.star.packages.manifest.comp.ManifestWriter"_ustr;
74 sal_Bool SAL_CALL ManifestWriter::supportsService(OUString const & rServiceName)
76 return cppu::supportsService(this, rServiceName);
78 Sequence < OUString > ManifestWriter::getSupportedServiceNames()
80 return { u"com.sun.star.packages.manifest.ManifestWriter"_ustr };
84 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
85 package_ManifestWriter_get_implementation(
86 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
88 return cppu::acquire(new ManifestWriter(context));
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */