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

Generated by: LCOV version 1.11