LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/framework/source/fwe/xml - statusbarconfiguration.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 11 30 36.7 %
Date: 2013-07-09 Functions: 3 4 75.0 %
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             : 
      21             : #include <framework/statusbarconfiguration.hxx>
      22             : #include <xml/statusbardocumenthandler.hxx>
      23             : #include <xml/saxnamespacefilter.hxx>
      24             : #include <services.h>
      25             : 
      26             : #include <com/sun/star/xml/sax/Parser.hpp>
      27             : #include <com/sun/star/xml/sax/Writer.hpp>
      28             : #include <com/sun/star/io/XActiveDataSource.hpp>
      29             : #include <com/sun/star/io/XInputStream.hpp>
      30             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      31             : 
      32             : #include <comphelper/processfactory.hxx>
      33             : #include <unotools/streamwrap.hxx>
      34             : 
      35             : using namespace ::com::sun::star::uno;
      36             : using namespace ::com::sun::star::xml::sax;
      37             : using namespace ::com::sun::star::lang;
      38             : using namespace ::com::sun::star::io;
      39             : using namespace ::com::sun::star::container;
      40             : 
      41             : 
      42             : namespace framework
      43             : {
      44             : 
      45          45 : sal_Bool StatusBarConfiguration::LoadStatusBar(
      46             :     const Reference< XComponentContext >& rxContext,
      47             :     const Reference< XInputStream >& xInputStream,
      48             :     const Reference< XIndexContainer >& rStatusbarConfiguration )
      49             : {
      50          45 :     Reference< XParser > xParser = Parser::create(rxContext);
      51             : 
      52             :     // connect stream to input stream to the parser
      53          90 :     InputSource aInputSource;
      54          45 :     aInputSource.aInputStream = xInputStream;
      55             : 
      56             :     // create namespace filter and set menudocument handler inside to support xml namespaces
      57          90 :     Reference< XDocumentHandler > xDocHandler( new OReadStatusBarDocumentHandler( rStatusbarConfiguration ));
      58          90 :     Reference< XDocumentHandler > xFilter( new SaxNamespaceFilter( xDocHandler ));
      59             : 
      60             :     // connect parser and filter
      61          45 :     xParser->setDocumentHandler( xFilter );
      62             : 
      63             :     try
      64             :     {
      65          45 :         xParser->parseStream( aInputSource );
      66          45 :         return sal_True;
      67             :     }
      68           0 :     catch ( const RuntimeException& )
      69             :     {
      70           0 :         return sal_False;
      71             :     }
      72           0 :     catch( const SAXException& )
      73             :     {
      74           0 :         return sal_False;
      75             :     }
      76           0 :     catch( const ::com::sun::star::io::IOException& )
      77             :     {
      78           0 :         return sal_False;
      79          45 :     }
      80             : }
      81             : 
      82           0 : sal_Bool StatusBarConfiguration::StoreStatusBar(
      83             :     const Reference< XComponentContext >& rxContext,
      84             :     const Reference< XOutputStream >& xOutputStream,
      85             :     const Reference< XIndexAccess >& rStatusbarConfiguration )
      86             : {
      87           0 :     Reference< XWriter > xWriter = Writer::create( rxContext );
      88           0 :     xWriter->setOutputStream( xOutputStream );
      89             : 
      90             :     try
      91             :     {
      92           0 :         OWriteStatusBarDocumentHandler aWriteStatusBarDocumentHandler( rStatusbarConfiguration, xWriter );
      93           0 :         aWriteStatusBarDocumentHandler.WriteStatusBarDocument();
      94           0 :         return sal_True;
      95             :     }
      96           0 :     catch ( const RuntimeException& )
      97             :     {
      98           0 :         return sal_False;
      99             :     }
     100           0 :     catch ( const SAXException& )
     101             :     {
     102           0 :         return sal_False;
     103             :     }
     104           0 :     catch ( const ::com::sun::star::io::IOException& )
     105             :     {
     106           0 :         return sal_False;
     107           0 :     }
     108             : }
     109         411 : }
     110             : 
     111             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10