Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/package/source/manifest/ManifestReader.cxx
Line
Count
Source
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 "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>
31
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;
38
39
ManifestReader::ManifestReader( const Reference < XComponentContext > & xContext )
40
0
: m_xContext ( xContext )
41
0
{
42
0
}
43
ManifestReader::~ManifestReader()
44
0
{
45
0
}
46
Sequence< Sequence< PropertyValue > > SAL_CALL ManifestReader::readManifestSequence( const Reference< XInputStream >& rStream )
47
0
{
48
0
    Sequence < Sequence < PropertyValue > > aManifestSequence;
49
0
    Reference < XParser > xParser  = Parser::create(m_xContext);
50
0
    try
51
0
    {
52
0
        std::vector < Sequence < PropertyValue > > aManVector;
53
0
        Reference < XDocumentHandler > xFilter = new ManifestImport( aManVector );
54
0
        InputSource aParserInput;
55
0
        aParserInput.aInputStream = rStream;
56
0
        aParserInput.sSystemId = "META-INF/manifest.xml";
57
0
        xParser->setDocumentHandler ( xFilter );
58
0
        xParser->parseStream( aParserInput );
59
0
        aManifestSequence = comphelper::containerToSequence(aManVector);
60
0
    }
61
0
    catch (const SAXParseException&)
62
0
    {
63
0
        TOOLS_WARN_EXCEPTION("package", "ignoring");
64
0
    }
65
0
    catch (const SAXException&)
66
0
    {
67
0
        TOOLS_WARN_EXCEPTION("package", "ignoring");
68
0
    }
69
0
    catch (const IOException&)
70
0
    {
71
0
        TOOLS_WARN_EXCEPTION("package", "ignoring");
72
0
    }
73
0
    xParser->setDocumentHandler ( Reference < XDocumentHandler > () );
74
0
    return aManifestSequence;
75
0
}
76
// Component functions
77
78
79
OUString ManifestReader::getImplementationName()
80
0
{
81
0
    return u"com.sun.star.packages.manifest.comp.ManifestReader"_ustr;
82
0
}
83
84
sal_Bool SAL_CALL ManifestReader::supportsService(OUString const & rServiceName)
85
0
{
86
0
    return cppu::supportsService(this, rServiceName );
87
0
}
88
89
Sequence < OUString > ManifestReader::getSupportedServiceNames()
90
0
{
91
0
    return { u"com.sun.star.packages.manifest.ManifestReader"_ustr };
92
0
}
93
94
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&)
98
0
{
99
0
    return cppu::acquire(new ManifestReader(context));
100
0
}
101
102
103
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */