LCOV - code coverage report
Current view: top level - xmloff/source/core - XMLBase64Export.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 23 0.0 %
Date: 2014-11-03 Functions: 0 4 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 <rtl/ustrbuf.hxx>
      22             : 
      23             : #include <com/sun/star/io/XInputStream.hpp>
      24             : 
      25             : #include <sax/tools/converter.hxx>
      26             : 
      27             : #include <xmloff/xmlexp.hxx>
      28             : #include <xmloff/xmlnmspe.hxx>
      29             : #include "XMLBase64Export.hxx"
      30             : 
      31             : using namespace ::com::sun::star::uno;
      32             : using namespace ::com::sun::star::io;
      33             : 
      34             : #define INPUT_BUFFER_SIZE 54
      35             : #define OUTPUT_BUFFER_SIZE 72
      36             : 
      37           0 : XMLBase64Export::XMLBase64Export( SvXMLExport& rExp ) :
      38           0 :     rExport( rExp ){
      39           0 : }
      40             : 
      41           0 : bool XMLBase64Export::exportXML( const Reference < XInputStream> & rIn )
      42             : {
      43           0 :     bool bRet = true;
      44             :     try
      45             :     {
      46           0 :         Sequence < sal_Int8 > aInBuff( INPUT_BUFFER_SIZE );
      47           0 :         OUStringBuffer aOutBuff( OUTPUT_BUFFER_SIZE );
      48             :         sal_Int32 nRead;
      49           0 :         do
      50             :         {
      51           0 :             nRead = rIn->readBytes( aInBuff, INPUT_BUFFER_SIZE );
      52           0 :             if( nRead > 0 )
      53             :             {
      54           0 :                                 ::sax::Converter::encodeBase64( aOutBuff, aInBuff );
      55           0 :                 GetExport().Characters( aOutBuff.makeStringAndClear() );
      56           0 :                 if( nRead == INPUT_BUFFER_SIZE )
      57           0 :                     GetExport().IgnorableWhitespace();
      58             :             }
      59             :         }
      60           0 :         while( nRead == INPUT_BUFFER_SIZE );
      61             :     }
      62           0 :     catch( ... )
      63             :     {
      64           0 :         bRet = false;
      65             :     }
      66             : 
      67           0 :     return bRet;
      68             : }
      69             : 
      70           0 : bool XMLBase64Export::exportElement(
      71             :             const Reference < XInputStream > & rIn,
      72             :             sal_uInt16 nNamespace,
      73             :             enum ::xmloff::token::XMLTokenEnum eName )
      74             : {
      75           0 :     SvXMLElementExport aElem( GetExport(), nNamespace, eName, true, true );
      76           0 :     return exportXML( rIn );
      77             : }
      78             : 
      79           0 : bool XMLBase64Export::exportOfficeBinaryDataElement(
      80             :             const Reference < XInputStream > & rIn )
      81             : {
      82             :     return exportElement( rIn, XML_NAMESPACE_OFFICE,
      83           0 :                              ::xmloff::token::XML_BINARY_DATA );
      84             : }
      85             : 
      86             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10