LibreOffice Module xmloff (master) 1
XMLBase64Export.cxx
Go to the documentation of this file.
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 <comphelper/base64.hxx>
26
27#include <xmloff/xmlexp.hxx>
29#include <XMLBase64Export.hxx>
30
31using namespace ::com::sun::star::uno;
32using namespace ::com::sun::star::io;
33
34#define INPUT_BUFFER_SIZE 54
35#define OUTPUT_BUFFER_SIZE 72
36
38 rExport( rExp ){
39}
40
41bool XMLBase64Export::exportXML( const Reference < XInputStream> & rIn )
42{
43 bool bRet = true;
44 try
45 {
46 Sequence < sal_Int8 > aInBuff( INPUT_BUFFER_SIZE );
47 OUStringBuffer aOutBuff( OUTPUT_BUFFER_SIZE );
48 sal_Int32 nRead;
49 do
50 {
51 nRead = rIn->readBytes( aInBuff, INPUT_BUFFER_SIZE );
52 if( nRead > 0 )
53 {
54 ::comphelper::Base64::encode( aOutBuff, aInBuff );
55 GetExport().Characters( aOutBuff.makeStringAndClear() );
56 if( nRead == INPUT_BUFFER_SIZE )
58 }
59 }
60 while( nRead == INPUT_BUFFER_SIZE );
61 }
62 catch( ... )
63 {
64 bRet = false;
65 }
66
67 return bRet;
68}
69
71 const Reference < XInputStream > & rIn,
73{
74 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_OFFICE, eName, true, true );
75 return exportXML( rIn );
76}
77
79 const Reference < XInputStream > & rIn )
80{
82}
83
84/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define OUTPUT_BUFFER_SIZE
#define INPUT_BUFFER_SIZE
void Characters(const OUString &rChars)
Definition: xmlexp.cxx:2133
void IgnorableWhitespace()
Definition: xmlexp.cxx:2194
SvXMLExport & GetExport()
bool exportElement(const css::uno::Reference< css::io::XInputStream > &rIn, enum ::xmloff::token::XMLTokenEnum eName)
XMLBase64Export(SvXMLExport &rExport)
bool exportXML(const css::uno::Reference< css::io::XInputStream > &rIn)
bool exportOfficeBinaryDataElement(const css::uno::Reference< css::io::XInputStream > &rIn)
static void encode(OUStringBuffer &aStrBuffer, const css::uno::Sequence< sal_Int8 > &aPass)
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:50
constexpr sal_uInt16 XML_NAMESPACE_OFFICE