LCOV - code coverage report
Current view: top level - package/source/manifest - ManifestWriter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 26 36 72.2 %
Date: 2012-08-25 Functions: 8 12 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 16 40 40.0 %

           Branch data     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 <ManifestWriter.hxx>
      21                 :            : #include <ManifestExport.hxx>
      22                 :            : #include <cppuhelper/factory.hxx>
      23                 :            : #include <com/sun/star/io/XActiveDataSource.hpp>
      24                 :            : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
      25                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      26                 :            : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      27                 :            : #include <com/sun/star/xml/sax/SAXException.hpp>
      28                 :            : 
      29                 :            : #include <osl/diagnose.hxx>
      30                 :            : 
      31                 :            : using namespace ::rtl;
      32                 :            : using namespace ::com::sun::star;
      33                 :            : using namespace ::com::sun::star::uno;
      34                 :            : using namespace ::com::sun::star::beans;
      35                 :            : using namespace ::com::sun::star::io;
      36                 :            : using namespace ::com::sun::star::lang;
      37                 :            : using namespace ::com::sun::star::registry;
      38                 :            : using namespace ::com::sun::star::packages;
      39                 :            : using namespace ::com::sun::star::xml::sax;
      40                 :            : using namespace ::com::sun::star::packages::manifest;
      41                 :            : 
      42                 :        281 : ManifestWriter::ManifestWriter( const Reference < XMultiServiceFactory > & xNewFactory )
      43                 :        281 : : xFactory ( xNewFactory )
      44                 :            : {
      45                 :        281 : }
      46                 :        281 : ManifestWriter::~ManifestWriter()
      47                 :            : {
      48         [ -  + ]:        562 : }
      49                 :            : 
      50                 :            : // XManifestWriter methods
      51                 :        281 : void SAL_CALL ManifestWriter::writeManifestSequence( const Reference< XOutputStream >& rStream, const Sequence< Sequence< PropertyValue > >& rSequence )
      52                 :            :         throw (RuntimeException)
      53                 :            : {
      54         [ +  - ]:        281 :     OUString sSaxWriter ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.xml.sax.Writer" ) );
      55 [ +  - ][ +  - ]:        281 :     Reference < XActiveDataSource > xSource ( xFactory->createInstance ( sSaxWriter ), UNO_QUERY );
                 [ +  - ]
      56         [ +  - ]:        281 :     if (xSource.is())
      57                 :            :     {
      58 [ +  - ][ +  - ]:        281 :         xSource->setOutputStream ( rStream );
      59         [ +  - ]:        281 :         Reference < XDocumentHandler > xHandler ( xSource, UNO_QUERY );
      60         [ +  - ]:        281 :         if (xHandler.is())
      61                 :            :             try {
      62         [ +  - ]:        281 :                 ManifestExport( xHandler, rSequence);
      63                 :            :             }
      64         [ #  # ]:          0 :             catch( SAXException& )
      65                 :            :             {
      66   [ #  #  #  # ]:          0 :                 throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
      67                 :        281 :             }
      68                 :        281 :     }
      69                 :        281 : }
      70                 :            : 
      71                 :            : // Component methods
      72                 :        281 : Reference < XInterface > SAL_CALL ManifestWriter_createInstance( Reference< XMultiServiceFactory > const & rServiceFactory )
      73                 :            : {
      74         [ +  - ]:        281 :     return *new ManifestWriter( rServiceFactory );
      75                 :            : }
      76                 :            : 
      77                 :        365 : OUString ManifestWriter::static_getImplementationName()
      78                 :            : {
      79                 :        365 :     return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.packages.manifest.comp.ManifestWriter" ) );
      80                 :            : }
      81                 :            : 
      82                 :          0 : sal_Bool SAL_CALL ManifestWriter::static_supportsService(OUString const & rServiceName)
      83                 :            : {
      84         [ #  # ]:          0 :     return rServiceName == getSupportedServiceNames()[0];
      85                 :            : }
      86                 :         31 : Sequence < OUString > ManifestWriter::static_getSupportedServiceNames()
      87                 :            : {
      88                 :         31 :     Sequence < OUString > aNames(1);
      89 [ +  - ][ +  - ]:         31 :     aNames[0] = OUString(RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.packages.manifest.ManifestWriter" ) );
      90                 :         31 :     return aNames;
      91                 :            : }
      92                 :            : 
      93                 :          0 : OUString ManifestWriter::getImplementationName()
      94                 :            :     throw (RuntimeException)
      95                 :            : {
      96                 :          0 :     return static_getImplementationName();
      97                 :            : }
      98                 :            : 
      99                 :          0 : sal_Bool SAL_CALL ManifestWriter::supportsService(OUString const & rServiceName)
     100                 :            :     throw (RuntimeException)
     101                 :            : {
     102                 :          0 :     return static_supportsService ( rServiceName );
     103                 :            : }
     104                 :          0 : Sequence < OUString > ManifestWriter::getSupportedServiceNames()
     105                 :            :     throw (RuntimeException)
     106                 :            : {
     107                 :          0 :     return static_getSupportedServiceNames();
     108                 :            : }
     109                 :         31 : Reference < XSingleServiceFactory > ManifestWriter::createServiceFactory( Reference < XMultiServiceFactory > const & rServiceFactory )
     110                 :            : {
     111                 :            :     return cppu::createSingleFactory (rServiceFactory,
     112                 :            :                                            static_getImplementationName(),
     113                 :            :                                            ManifestWriter_createInstance,
     114 [ +  - ][ +  - ]:         31 :                                            static_getSupportedServiceNames());
     115                 :            : }
     116                 :            : 
     117                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10