Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / package / source / manifest / ManifestReader.cxx
blob2a60feff02d405fa54af4173ba31f7849e1c40f9
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 "ManifestReader.hxx"
21 #include "ManifestImport.hxx"
22 #include <comphelper/diagnose_ex.hxx>
23 #include <comphelper/sequence.hxx>
24 #include <cppuhelper/factory.hxx>
25 #include <cppuhelper/supportsservice.hxx>
26 #include <com/sun/star/io/IOException.hpp>
27 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
28 #include <com/sun/star/xml/sax/SAXParseException.hpp>
29 #include <com/sun/star/xml/sax/Parser.hpp>
30 #include <vector>
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::registry;
37 using namespace ::com::sun::star::packages;
38 using namespace ::com::sun::star::xml::sax;
40 ManifestReader::ManifestReader( const Reference < XComponentContext > & xContext )
41 : m_xContext ( xContext )
44 ManifestReader::~ManifestReader()
47 Sequence< Sequence< PropertyValue > > SAL_CALL ManifestReader::readManifestSequence( const Reference< XInputStream >& rStream )
49 Sequence < Sequence < PropertyValue > > aManifestSequence;
50 Reference < XParser > xParser = Parser::create(m_xContext);
51 try
53 std::vector < Sequence < PropertyValue > > aManVector;
54 Reference < XDocumentHandler > xFilter = new ManifestImport( aManVector );
55 InputSource aParserInput;
56 aParserInput.aInputStream = rStream;
57 aParserInput.sSystemId = "META-INF/manifest.xml";
58 xParser->setDocumentHandler ( xFilter );
59 xParser->parseStream( aParserInput );
60 aManifestSequence = comphelper::containerToSequence(aManVector);
62 catch (const SAXParseException&)
64 TOOLS_WARN_EXCEPTION("package", "ignoring");
66 catch (const SAXException&)
68 TOOLS_WARN_EXCEPTION("package", "ignoring");
70 catch (const IOException&)
72 TOOLS_WARN_EXCEPTION("package", "ignoring");
74 xParser->setDocumentHandler ( Reference < XDocumentHandler > () );
75 return aManifestSequence;
77 // Component functions
80 OUString ManifestReader::getImplementationName()
82 return "com.sun.star.packages.manifest.comp.ManifestReader";
85 sal_Bool SAL_CALL ManifestReader::supportsService(OUString const & rServiceName)
87 return cppu::supportsService(this, rServiceName );
90 Sequence < OUString > ManifestReader::getSupportedServiceNames()
92 return { "com.sun.star.packages.manifest.ManifestReader" };
96 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
97 package_ManifestReader_get_implementation(
98 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
100 return cppu::acquire(new ManifestReader(context));
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */