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

Generated by: LCOV version 1.10