2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-12 17:21:24 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2001-05-18 12:33:18 +00:00
|
|
|
|
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
|
|
|
|
2001-05-18 12:33:18 +00:00
|
|
|
#include <rtl/ustrbuf.hxx>
|
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
|
|
|
|
2001-05-18 12:33:18 +00:00
|
|
|
#include <com/sun/star/io/XInputStream.hpp>
|
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
|
|
|
|
|
|
|
#include <sax/tools/converter.hxx>
|
|
|
|
|
2007-06-27 13:55:16 +00:00
|
|
|
#include <xmloff/xmlexp.hxx>
|
2013-11-11 22:30:35 -06:00
|
|
|
#include <xmloff/xmlnmspe.hxx>
|
2001-05-18 12:33:18 +00:00
|
|
|
#include "XMLBase64Export.hxx"
|
|
|
|
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::io;
|
|
|
|
|
|
|
|
#define INPUT_BUFFER_SIZE 54
|
|
|
|
#define OUTPUT_BUFFER_SIZE 72
|
|
|
|
|
|
|
|
XMLBase64Export::XMLBase64Export( SvXMLExport& rExp ) :
|
|
|
|
rExport( rExp ){
|
|
|
|
}
|
|
|
|
|
2014-04-07 16:42:18 +02:00
|
|
|
bool XMLBase64Export::exportXML( const Reference < XInputStream> & rIn )
|
2001-05-18 12:33:18 +00:00
|
|
|
{
|
2014-04-07 16:42:18 +02:00
|
|
|
bool bRet = true;
|
2001-05-18 12:33:18 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Sequence < sal_Int8 > aInBuff( INPUT_BUFFER_SIZE );
|
|
|
|
OUStringBuffer aOutBuff( OUTPUT_BUFFER_SIZE );
|
|
|
|
sal_Int32 nRead;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
nRead = rIn->readBytes( aInBuff, INPUT_BUFFER_SIZE );
|
|
|
|
if( nRead > 0 )
|
|
|
|
{
|
2016-02-09 09:21:53 +11:00
|
|
|
::sax::Converter::encodeBase64( aOutBuff, aInBuff );
|
2001-10-19 17:43:58 +00:00
|
|
|
GetExport().Characters( aOutBuff.makeStringAndClear() );
|
2001-05-18 12:33:18 +00:00
|
|
|
if( nRead == INPUT_BUFFER_SIZE )
|
2001-10-19 17:43:58 +00:00
|
|
|
GetExport().IgnorableWhitespace();
|
2001-05-18 12:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
while( nRead == INPUT_BUFFER_SIZE );
|
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
2014-04-07 16:42:18 +02:00
|
|
|
bRet = false;
|
2001-05-18 12:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2014-04-07 16:42:18 +02:00
|
|
|
bool XMLBase64Export::exportElement(
|
2001-06-19 14:08:23 +00:00
|
|
|
const Reference < XInputStream > & rIn,
|
|
|
|
enum ::xmloff::token::XMLTokenEnum eName )
|
|
|
|
{
|
2016-03-16 10:17:37 +02:00
|
|
|
SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_OFFICE, eName, true, true );
|
2001-06-19 14:08:23 +00:00
|
|
|
return exportXML( rIn );
|
|
|
|
}
|
|
|
|
|
2014-04-07 16:42:18 +02:00
|
|
|
bool XMLBase64Export::exportOfficeBinaryDataElement(
|
2001-06-19 14:08:23 +00:00
|
|
|
const Reference < XInputStream > & rIn )
|
|
|
|
{
|
2016-03-16 10:17:37 +02:00
|
|
|
return exportElement( rIn, ::xmloff::token::XML_BINARY_DATA );
|
2001-06-19 14:08:23 +00:00
|
|
|
}
|
2001-05-18 12:33:18 +00:00
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|