LCOV - code coverage report
Current view: top level - framework/source/fwe/xml - statusbarconfiguration.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 34 35.3 %
Date: 2012-08-25 Functions: 2 4 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 16 70 22.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <framework/statusbarconfiguration.hxx>
      31                 :            : #include <xml/statusbardocumenthandler.hxx>
      32                 :            : #include <xml/saxnamespacefilter.hxx>
      33                 :            : #include <services.h>
      34                 :            : 
      35                 :            : #include <com/sun/star/xml/sax/XParser.hpp>
      36                 :            : #include <com/sun/star/io/XActiveDataSource.hpp>
      37                 :            : #include <com/sun/star/io/XInputStream.hpp>
      38                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      39                 :            : 
      40                 :            : #include <comphelper/processfactory.hxx>
      41                 :            : #include <unotools/streamwrap.hxx>
      42                 :            : 
      43                 :            : using namespace ::com::sun::star::uno;
      44                 :            : using namespace ::com::sun::star::xml::sax;
      45                 :            : using namespace ::com::sun::star::lang;
      46                 :            : using namespace ::com::sun::star::io;
      47                 :            : using namespace ::com::sun::star::container;
      48                 :            : 
      49                 :            : 
      50                 :            : namespace framework
      51                 :            : {
      52                 :            : 
      53                 :         90 : static Reference< XParser > GetSaxParser(
      54                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory
      55                 :            :     )
      56                 :            : {
      57 [ +  - ][ +  - ]:         90 :     return Reference< XParser >( xServiceFactory->createInstance( SERVICENAME_SAXPARSER), UNO_QUERY);
      58                 :            : }
      59                 :            : 
      60                 :          0 : static Reference< XDocumentHandler > GetSaxWriter(
      61                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory
      62                 :            :     )
      63                 :            : {
      64 [ #  # ][ #  # ]:          0 :     return Reference< XDocumentHandler >( xServiceFactory->createInstance( SERVICENAME_SAXWRITER), UNO_QUERY) ;
      65                 :            : }
      66                 :            : 
      67                 :         90 : sal_Bool StatusBarConfiguration::LoadStatusBar(
      68                 :            :     const Reference< XMultiServiceFactory >& xServiceFactory,
      69                 :            :     const Reference< XInputStream >& xInputStream,
      70                 :            :     const Reference< XIndexContainer >& rStatusbarConfiguration )
      71                 :            : {
      72         [ +  - ]:         90 :     Reference< XParser > xParser( GetSaxParser( xServiceFactory ) );
      73                 :            : 
      74                 :            :     // connect stream to input stream to the parser
      75         [ +  - ]:         90 :     InputSource aInputSource;
      76         [ +  - ]:         90 :     aInputSource.aInputStream = xInputStream;
      77                 :            : 
      78                 :            :     // create namespace filter and set menudocument handler inside to support xml namespaces
      79 [ +  - ][ +  - ]:         90 :     Reference< XDocumentHandler > xDocHandler( new OReadStatusBarDocumentHandler( rStatusbarConfiguration ));
                 [ +  - ]
      80 [ +  - ][ +  - ]:         90 :     Reference< XDocumentHandler > xFilter( new SaxNamespaceFilter( xDocHandler ));
           [ +  -  #  #  
                   #  # ]
      81                 :            : 
      82                 :            :     // connect parser and filter
      83 [ +  - ][ +  - ]:         90 :     xParser->setDocumentHandler( xFilter );
      84                 :            : 
      85                 :            :     try
      86                 :            :     {
      87 [ +  - ][ +  - ]:         90 :         xParser->parseStream( aInputSource );
      88                 :         90 :         return sal_True;
      89                 :            :     }
      90         [ #  # ]:          0 :     catch ( const RuntimeException& )
      91                 :            :     {
      92                 :          0 :         return sal_False;
      93                 :            :     }
      94         [ #  # ]:          0 :     catch( const SAXException& )
      95                 :            :     {
      96                 :          0 :         return sal_False;
      97                 :            :     }
      98         [ #  # ]:          0 :     catch( const ::com::sun::star::io::IOException& )
      99                 :            :     {
     100                 :          0 :         return sal_False;
     101         [ +  - ]:         90 :     }
     102                 :            : }
     103                 :            : 
     104                 :          0 : sal_Bool StatusBarConfiguration::StoreStatusBar(
     105                 :            :     const Reference< XMultiServiceFactory >& xServiceFactory,
     106                 :            :     const Reference< XOutputStream >& xOutputStream,
     107                 :            :     const Reference< XIndexAccess >& rStatusbarConfiguration )
     108                 :            : {
     109         [ #  # ]:          0 :     Reference< XDocumentHandler > xWriter( GetSaxWriter( xServiceFactory ) );
     110         [ #  # ]:          0 :     Reference< ::com::sun::star::io::XActiveDataSource> xDataSource( xWriter , UNO_QUERY );
     111 [ #  # ][ #  # ]:          0 :     xDataSource->setOutputStream( xOutputStream );
     112                 :            : 
     113                 :            :     try
     114                 :            :     {
     115         [ #  # ]:          0 :         OWriteStatusBarDocumentHandler aWriteStatusBarDocumentHandler( rStatusbarConfiguration, xWriter );
     116         [ #  # ]:          0 :         aWriteStatusBarDocumentHandler.WriteStatusBarDocument();
     117         [ #  # ]:          0 :         return sal_True;
           [ #  #  #  # ]
     118                 :            :     }
     119         [ #  # ]:          0 :     catch ( const RuntimeException& )
     120                 :            :     {
     121                 :          0 :         return sal_False;
     122                 :            :     }
     123         [ #  # ]:          0 :     catch ( const SAXException& )
     124                 :            :     {
     125                 :          0 :         return sal_False;
     126                 :            :     }
     127         [ #  # ]:          0 :     catch ( const ::com::sun::star::io::IOException& )
     128                 :            :     {
     129                 :          0 :         return sal_False;
     130                 :          0 :     }
     131                 :            : }
     132                 :            : }
     133                 :            : 
     134                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10