LCOV - code coverage report
Current view: top level - libreoffice/xmlscript/source/xmldlg_imexp - xmldlg_addfunc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 21 0.0 %
Date: 2012-12-27 Functions: 0 6 0.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 <com/sun/star/lang/XMultiServiceFactory.hpp>
      22             : #include <com/sun/star/io/XActiveDataSource.hpp>
      23             : #include <com/sun/star/xml/sax/Parser.hpp>
      24             : #include <com/sun/star/xml/sax/Writer.hpp>
      25             : 
      26             : #include <comphelper/processfactory.hxx>
      27             : #include <cppuhelper/implbase1.hxx>
      28             : #include <xmlscript/xml_helper.hxx>
      29             : #include <xmlscript/xmldlg_imexp.hxx>
      30             : 
      31             : 
      32             : using namespace ::rtl;
      33             : using namespace ::com::sun::star;
      34             : using namespace ::com::sun::star::uno;
      35             : using namespace ::com::sun::star::frame;
      36             : 
      37             : namespace xmlscript
      38             : {
      39             : 
      40             : //==================================================================================================
      41           0 : class InputStreamProvider
      42             :     : public ::cppu::WeakImplHelper1< io::XInputStreamProvider >
      43             : {
      44             :     ByteSequence _bytes;
      45             : 
      46             : public:
      47           0 :     inline InputStreamProvider( ByteSequence const & rBytes )
      48           0 :         : _bytes( rBytes )
      49           0 :         {}
      50             : 
      51             :     // XInputStreamProvider
      52             :     virtual Reference< io::XInputStream > SAL_CALL createInputStream()
      53             :         throw (RuntimeException);
      54             : };
      55             : //__________________________________________________________________________________________________
      56           0 : Reference< io::XInputStream > InputStreamProvider::createInputStream()
      57             :     throw (RuntimeException)
      58             : {
      59           0 :     return ::xmlscript::createInputStream( _bytes );
      60             : }
      61             : 
      62             : //==================================================================================================
      63           0 : Reference< io::XInputStreamProvider > SAL_CALL exportDialogModel(
      64             :     Reference< container::XNameContainer > const & xDialogModel,
      65             :     Reference< XComponentContext > const & xContext,
      66             :     Reference< XModel > const & xDocument )
      67             :     SAL_THROW( (Exception) )
      68             : {
      69           0 :     Reference< xml::sax::XWriter > xWriter = xml::sax::Writer::create(xContext);
      70             : 
      71           0 :     ByteSequence aBytes;
      72           0 :     xWriter->setOutputStream( createOutputStream( &aBytes ) );
      73             : 
      74           0 :     Reference< xml::sax::XExtendedDocumentHandler > xHandler(xWriter, UNO_QUERY_THROW);
      75           0 :     exportDialogModel( xHandler, xDialogModel, xDocument );
      76             : 
      77           0 :     return new InputStreamProvider( aBytes );
      78             : }
      79             : 
      80             : //==================================================================================================
      81           0 : void SAL_CALL importDialogModel(
      82             :     Reference< io::XInputStream > const & xInput,
      83             :     Reference< container::XNameContainer > const & xDialogModel,
      84             :     Reference< XComponentContext > const & xContext,
      85             :     Reference< XModel > const & xDocument )
      86             :     SAL_THROW( (Exception) )
      87             : {
      88           0 :     Reference< xml::sax::XParser > xParser = xml::sax::Parser::create( xContext );
      89             : 
      90             :     // error handler, entity resolver omitted for this helper function
      91           0 :     xParser->setDocumentHandler( importDialogModel( xDialogModel, xContext, xDocument ) );
      92             : 
      93           0 :     xml::sax::InputSource source;
      94           0 :     source.aInputStream = xInput;
      95           0 :     source.sSystemId = "virtual file";
      96             : 
      97           0 :     xParser->parseStream( source );
      98           0 : }
      99             : 
     100             : }
     101             : 
     102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10