tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / package / source / manifest / ManifestReader.cxx
blob1e6a6ed848c739ce4923c448c278b3919f94dfed
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::packages;
37 using namespace ::com::sun::star::xml::sax;
39 ManifestReader::ManifestReader( const Reference < XComponentContext > & xContext )
40 : m_xContext ( xContext )
43 ManifestReader::~ManifestReader()
46 Sequence< Sequence< PropertyValue > > SAL_CALL ManifestReader::readManifestSequence( const Reference< XInputStream >& rStream )
48 Sequence < Sequence < PropertyValue > > aManifestSequence;
49 Reference < XParser > xParser = Parser::create(m_xContext);
50 try
52 std::vector < Sequence < PropertyValue > > aManVector;
53 Reference < XDocumentHandler > xFilter = new ManifestImport( aManVector );
54 InputSource aParserInput;
55 aParserInput.aInputStream = rStream;
56 aParserInput.sSystemId = "META-INF/manifest.xml";
57 xParser->setDocumentHandler ( xFilter );
58 xParser->parseStream( aParserInput );
59 aManifestSequence = comphelper::containerToSequence(aManVector);
61 catch (const SAXParseException&)
63 TOOLS_WARN_EXCEPTION("package", "ignoring");
65 catch (const SAXException&)
67 TOOLS_WARN_EXCEPTION("package", "ignoring");
69 catch (const IOException&)
71 TOOLS_WARN_EXCEPTION("package", "ignoring");
73 xParser->setDocumentHandler ( Reference < XDocumentHandler > () );
74 return aManifestSequence;
76 // Component functions
79 OUString ManifestReader::getImplementationName()
81 return u"com.sun.star.packages.manifest.comp.ManifestReader"_ustr;
84 sal_Bool SAL_CALL ManifestReader::supportsService(OUString const & rServiceName)
86 return cppu::supportsService(this, rServiceName );
89 Sequence < OUString > ManifestReader::getSupportedServiceNames()
91 return { u"com.sun.star.packages.manifest.ManifestReader"_ustr };
95 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
96 package_ManifestReader_get_implementation(
97 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
99 return cppu::acquire(new ManifestReader(context));
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */