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

Generated by: LCOV version 1.10