LCOV - code coverage report
Current view: top level - libreoffice/xmlscript/source/xmllib_imexp - xmllib_export.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 63 0.0 %
Date: 2012-12-27 Functions: 0 2 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 <xmlscript/xmllib_imexp.hxx>
      22             : #include <xmlscript/xml_helper.hxx>
      23             : 
      24             : using namespace com::sun::star::uno;
      25             : using namespace com::sun::star;
      26             : 
      27             : using ::rtl::OUString;
      28             : 
      29             : namespace xmlscript
      30             : {
      31             : 
      32             : const char aTrueStr[] = "true";
      33             : const char aFalseStr[] = "false";
      34             : 
      35             : //##################################################################################################
      36             : 
      37             : 
      38             : //==================================================================================================
      39             : 
      40             : void
      41           0 : SAL_CALL exportLibraryContainer(
      42             :     Reference< xml::sax::XWriter > const & xOut,
      43             :     const LibDescriptorArray* pLibArray )
      44             :         SAL_THROW( (Exception) )
      45             : {
      46           0 :     xOut->startDocument();
      47             : 
      48             :     OUString aDocTypeStr(
      49             :         "<!DOCTYPE library:libraries PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
      50           0 :         " \"libraries.dtd\">" );
      51           0 :     xOut->unknown( aDocTypeStr );
      52           0 :     xOut->ignorableWhitespace( OUString() );
      53             : 
      54             : 
      55           0 :     OUString aLibrariesName( XMLNS_LIBRARY_PREFIX ":libraries" );
      56           0 :     XMLElement* pLibsElement = new XMLElement( aLibrariesName );
      57           0 :     Reference< xml::sax::XAttributeList > xAttributes( pLibsElement );
      58             : 
      59           0 :     pLibsElement->addAttribute( "xmlns:" XMLNS_LIBRARY_PREFIX, XMLNS_LIBRARY_URI );
      60           0 :     pLibsElement->addAttribute( "xmlns:" XMLNS_XLINK_PREFIX, XMLNS_XLINK_URI );
      61             : 
      62             : 
      63           0 :     xOut->ignorableWhitespace( OUString() );
      64           0 :     xOut->startElement( aLibrariesName, xAttributes );
      65             : 
      66           0 :     OUString sTrueStr(aTrueStr);
      67           0 :     OUString sFalseStr(aFalseStr);
      68             : 
      69           0 :     int nLibCount = pLibArray->mnLibCount;
      70           0 :     for( sal_Int32 i = 0 ; i < nLibCount ; i++ )
      71             :     {
      72           0 :         LibDescriptor& rLib = pLibArray->mpLibs[i];
      73             : 
      74           0 :         OUString aLibraryName( XMLNS_LIBRARY_PREFIX ":library" );
      75           0 :         XMLElement* pLibElement = new XMLElement( aLibraryName );
      76           0 :         Reference< xml::sax::XAttributeList > xLibElementAttribs;
      77           0 :         xLibElementAttribs = static_cast< xml::sax::XAttributeList* >( pLibElement );
      78             : 
      79           0 :         pLibElement->addAttribute( XMLNS_LIBRARY_PREFIX ":name", rLib.aName );
      80             : 
      81             : 
      82           0 :         if( !rLib.aStorageURL.isEmpty() )
      83             :         {
      84           0 :             pLibElement->addAttribute( XMLNS_XLINK_PREFIX ":href", rLib.aStorageURL );
      85           0 :             pLibElement->addAttribute( XMLNS_XLINK_PREFIX ":type", "simple" );
      86             :         }
      87             : 
      88           0 :         pLibElement->addAttribute(  XMLNS_LIBRARY_PREFIX ":link", rLib.bLink ? sTrueStr : sFalseStr );
      89             : 
      90           0 :         if( rLib.bLink )
      91             :         {
      92           0 :             pLibElement->addAttribute( XMLNS_LIBRARY_PREFIX ":readonly", rLib.bReadOnly ? sTrueStr : sFalseStr );
      93             :         }
      94             : 
      95           0 :         pLibElement->dump( xOut.get() );
      96           0 :     }
      97             : 
      98           0 :     xOut->ignorableWhitespace( OUString() );
      99           0 :     xOut->endElement( aLibrariesName );
     100             : 
     101           0 :     xOut->endDocument();
     102           0 : }
     103             : 
     104             : //==================================================================================================
     105             : 
     106             : void
     107           0 : SAL_CALL exportLibrary(
     108             :     ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XWriter > const & xOut,
     109             :     const LibDescriptor& rLib )
     110             :         SAL_THROW( (::com::sun::star::uno::Exception) )
     111             : {
     112           0 :     xOut->startDocument();
     113             : 
     114             :     OUString aDocTypeStr(
     115             :         "<!DOCTYPE library:library PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
     116           0 :         " \"library.dtd\">" );
     117           0 :     xOut->unknown( aDocTypeStr );
     118           0 :     xOut->ignorableWhitespace( OUString() );
     119             : 
     120             : 
     121           0 :     OUString aLibraryName( XMLNS_LIBRARY_PREFIX ":library" );
     122           0 :     XMLElement* pLibElement = new XMLElement( aLibraryName );
     123           0 :     Reference< xml::sax::XAttributeList > xAttributes( pLibElement );
     124             : 
     125           0 :     pLibElement->addAttribute( "xmlns:" XMLNS_LIBRARY_PREFIX, XMLNS_LIBRARY_URI );
     126             : 
     127           0 :     pLibElement->addAttribute( XMLNS_LIBRARY_PREFIX ":name", rLib.aName );
     128             : 
     129           0 :     OUString sTrueStr(aTrueStr);
     130           0 :     OUString sFalseStr(aFalseStr);
     131             : 
     132           0 :     pLibElement->addAttribute( XMLNS_LIBRARY_PREFIX ":readonly", rLib.bReadOnly ? sTrueStr : sFalseStr );
     133             : 
     134           0 :     pLibElement->addAttribute( XMLNS_LIBRARY_PREFIX ":passwordprotected", rLib.bPasswordProtected ? sTrueStr : sFalseStr );
     135             : 
     136           0 :     if( rLib.bPreload )
     137           0 :         pLibElement->addAttribute( XMLNS_LIBRARY_PREFIX ":preload", sTrueStr );
     138             : 
     139           0 :     sal_Int32 nElementCount = rLib.aElementNames.getLength();
     140           0 :     if( nElementCount )
     141             :     {
     142           0 :         const OUString* pElementNames = rLib.aElementNames.getConstArray();
     143           0 :         for( sal_Int32 i = 0 ; i < nElementCount ; i++ )
     144             :         {
     145           0 :             XMLElement* pElement = new XMLElement( XMLNS_LIBRARY_PREFIX ":element" );
     146           0 :             Reference< xml::sax::XAttributeList > xElementAttribs;
     147           0 :             xElementAttribs = static_cast< xml::sax::XAttributeList* >( pElement );
     148             : 
     149             :             pElement->addAttribute( OUString( XMLNS_LIBRARY_PREFIX ":name" ),
     150           0 :                                         pElementNames[i] );
     151             : 
     152           0 :             pLibElement->addSubElement( pElement );
     153           0 :         }
     154             :     }
     155             : 
     156           0 :     pLibElement->dump( xOut.get() );
     157             : 
     158           0 :     xOut->endDocument();
     159           0 : }
     160             : 
     161             : }
     162             : 
     163             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10