LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/xmloff/source/core - XMLBase64ImportContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 25 0.0 %
Date: 2013-07-09 Functions: 0 10 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/io/XOutputStream.hpp>
      22             : 
      23             : #include <sax/tools/converter.hxx>
      24             : 
      25             : #include <xmloff/xmlimp.hxx>
      26             : #include <xmloff/XMLBase64ImportContext.hxx>
      27             : 
      28             : 
      29             : using namespace ::com::sun::star::uno;
      30             : using namespace ::com::sun::star::xml::sax;
      31             : using namespace ::com::sun::star::io;
      32             : 
      33             : //-----------------------------------------------------------------------------
      34             : 
      35           0 : TYPEINIT1( XMLBase64ImportContext, SvXMLImportContext );
      36             : 
      37             : 
      38           0 : XMLBase64ImportContext::XMLBase64ImportContext(
      39             :         SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
      40             :         const Reference< XAttributeList >&,
      41             :         const Reference< XOutputStream >& rOut ) :
      42             :     SvXMLImportContext( rImport, nPrfx, rLName ),
      43           0 :     xOut( rOut )
      44             : {
      45           0 : }
      46             : 
      47           0 : XMLBase64ImportContext::~XMLBase64ImportContext()
      48             : {
      49           0 : }
      50             : 
      51             : 
      52           0 : void XMLBase64ImportContext::EndElement()
      53             : {
      54           0 :     xOut->closeOutput();
      55           0 : }
      56             : 
      57           0 : void XMLBase64ImportContext::Characters( const OUString& rChars )
      58             : {
      59           0 :     OUString sTrimmedChars( rChars. trim() );
      60           0 :     if( !sTrimmedChars.isEmpty() )
      61             :     {
      62           0 :         OUString sChars;
      63           0 :         if( !sBase64CharsLeft.isEmpty() )
      64             :         {
      65           0 :             sChars = sBase64CharsLeft;
      66           0 :             sChars += sTrimmedChars;
      67           0 :             sBase64CharsLeft = OUString();
      68             :         }
      69             :         else
      70             :         {
      71           0 :             sChars = sTrimmedChars;
      72             :         }
      73           0 :         Sequence< sal_Int8 > aBuffer( (sChars.getLength() / 4) * 3 );
      74             :                 sal_Int32 const nCharsDecoded =
      75           0 :                                 ::sax::Converter::decodeBase64SomeChars( aBuffer, sChars );
      76           0 :         xOut->writeBytes( aBuffer );
      77           0 :         if( nCharsDecoded != sChars.getLength() )
      78           0 :             sBase64CharsLeft = sChars.copy( nCharsDecoded );
      79           0 :     }
      80           0 : }
      81             : 
      82             : 
      83             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10