LCOV - code coverage report
Current view: top level - libreoffice/package/source/manifest - ManifestReader.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 33 44 75.0 %
Date: 2012-12-27 Functions: 8 12 66.7 %
Legend: Lines: hit not hit

          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 <ManifestReader.hxx>
      21             : #include <ManifestImport.hxx>
      22             : #include <comphelper/processfactory.hxx>
      23             : #include <cppuhelper/factory.hxx>
      24             : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
      25             : #include <com/sun/star/xml/sax/SAXParseException.hpp>
      26             : #include <com/sun/star/xml/sax/Parser.hpp>
      27             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      28             : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      29             : #include <vector>
      30             : 
      31             : using namespace ::std;
      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;
      39             : using namespace ::com::sun::star::packages::manifest;
      40             : using ::rtl::OUString;
      41             : 
      42          63 : ManifestReader::ManifestReader( const Reference < XMultiServiceFactory > & xNewFactory )
      43          63 : : xFactory ( xNewFactory )
      44             : {
      45          63 : }
      46         126 : ManifestReader::~ManifestReader()
      47             : {
      48         126 : }
      49          63 : Sequence< Sequence< PropertyValue > > SAL_CALL ManifestReader::readManifestSequence( const Reference< XInputStream >& rStream )
      50             :     throw (::com::sun::star::uno::RuntimeException)
      51             : {
      52          63 :     Sequence < Sequence < PropertyValue > > aManifestSequence;
      53          63 :     Reference < XParser > xParser  = Parser::create(comphelper::getComponentContext(xFactory));
      54             :     try
      55             :     {
      56          63 :         vector < Sequence < PropertyValue > > aManVector;
      57          63 :         Reference < XDocumentHandler > xFilter = new ManifestImport( aManVector );
      58          63 :         InputSource aParserInput;
      59          63 :         aParserInput.aInputStream = rStream;
      60          63 :         aParserInput.sSystemId = "META-INF/manifest.xml";
      61          63 :         xParser->setDocumentHandler ( xFilter );
      62          63 :         xParser->parseStream( aParserInput );
      63          63 :         aManifestSequence.realloc ( aManVector.size() );
      64          63 :         Sequence < PropertyValue > * pSequence = aManifestSequence.getArray();
      65          63 :         ::std::vector < Sequence < PropertyValue > >::const_iterator aIter = aManVector.begin();
      66          63 :         ::std::vector < Sequence < PropertyValue > >::const_iterator aEnd = aManVector.end();
      67         832 :         while( aIter != aEnd )
      68         769 :             *pSequence++ = (*aIter++);
      69             :     }
      70           0 :     catch (SAXParseException& )
      71             :     {
      72             :     }
      73           0 :     catch (SAXException& )
      74             :     {
      75             :     }
      76           0 :     catch (IOException& )
      77             :     {
      78             :     }
      79          63 :     xParser->setDocumentHandler ( Reference < XDocumentHandler > () );
      80          63 :     return aManifestSequence;
      81             : }
      82             : // Component functions
      83             : 
      84          63 : Reference < XInterface > SAL_CALL ManifestReader_createInstance( Reference< XMultiServiceFactory > const & rServiceFactory )
      85             : {
      86          63 :     return *new ManifestReader( rServiceFactory );
      87             : }
      88          52 : OUString ManifestReader::static_getImplementationName()
      89             : {
      90          52 :     return OUString( "com.sun.star.packages.manifest.comp.ManifestReader" );
      91             : }
      92             : 
      93           0 : sal_Bool SAL_CALL ManifestReader::static_supportsService(OUString const & rServiceName)
      94             : {
      95           0 :     return rServiceName == getSupportedServiceNames()[0];
      96             : }
      97             : 
      98          11 : Sequence < OUString > ManifestReader::static_getSupportedServiceNames()
      99             : {
     100          11 :     Sequence < OUString > aNames(1);
     101          11 :     aNames[0] = "com.sun.star.packages.manifest.ManifestReader";
     102          11 :     return aNames;
     103             : }
     104             : 
     105           0 : OUString ManifestReader::getImplementationName()
     106             :     throw (RuntimeException)
     107             : {
     108           0 :     return static_getImplementationName();
     109             : }
     110             : 
     111           0 : sal_Bool SAL_CALL ManifestReader::supportsService(OUString const & rServiceName)
     112             :     throw (RuntimeException)
     113             : {
     114           0 :     return static_supportsService ( rServiceName );
     115             : }
     116             : 
     117           0 : Sequence < OUString > ManifestReader::getSupportedServiceNames()
     118             :     throw (RuntimeException)
     119             : {
     120           0 :     return static_getSupportedServiceNames();
     121             : }
     122          11 : Reference < XSingleServiceFactory > ManifestReader::createServiceFactory( Reference < XMultiServiceFactory > const & rServiceFactory )
     123             : {
     124             :     return cppu::createSingleFactory (rServiceFactory,
     125             :                                            static_getImplementationName(),
     126             :                                            ManifestReader_createInstance,
     127          11 :                                            static_getSupportedServiceNames());
     128             : }
     129             : 
     130             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10