Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <rtl/ustrbuf.hxx>
31 : :
32 : : #include <com/sun/star/io/XInputStream.hpp>
33 : :
34 : : #include <sax/tools/converter.hxx>
35 : :
36 : : #include <xmloff/xmlexp.hxx>
37 : : #include "xmloff/xmlnmspe.hxx"
38 : : #include "XMLBase64Export.hxx"
39 : :
40 : : using namespace ::com::sun::star::uno;
41 : : using namespace ::com::sun::star::io;
42 : : using ::rtl::OUString;
43 : : using ::rtl::OUStringBuffer;
44 : :
45 : : #define INPUT_BUFFER_SIZE 54
46 : : #define OUTPUT_BUFFER_SIZE 72
47 : :
48 : 0 : XMLBase64Export::XMLBase64Export( SvXMLExport& rExp ) :
49 : 0 : rExport( rExp ){
50 : 0 : }
51 : :
52 : 0 : sal_Bool XMLBase64Export::exportXML( const Reference < XInputStream> & rIn )
53 : : {
54 : 0 : sal_Bool bRet = sal_True;
55 : : try
56 : : {
57 [ # # ]: 0 : Sequence < sal_Int8 > aInBuff( INPUT_BUFFER_SIZE );
58 : 0 : OUStringBuffer aOutBuff( OUTPUT_BUFFER_SIZE );
59 : : sal_Int32 nRead;
60 [ # # ]: 0 : do
61 : : {
62 [ # # ][ # # ]: 0 : nRead = rIn->readBytes( aInBuff, INPUT_BUFFER_SIZE );
63 [ # # ]: 0 : if( nRead > 0 )
64 : : {
65 [ # # ]: 0 : ::sax::Converter::encodeBase64( aOutBuff, aInBuff );
66 [ # # ][ # # ]: 0 : GetExport().Characters( aOutBuff.makeStringAndClear() );
67 [ # # ]: 0 : if( nRead == INPUT_BUFFER_SIZE )
68 [ # # ]: 0 : GetExport().IgnorableWhitespace();
69 : : }
70 : : }
71 [ # # ]: 0 : while( nRead == INPUT_BUFFER_SIZE );
72 : : }
73 : 0 : catch( ... )
74 : : {
75 : 0 : bRet = sal_False;
76 : : }
77 : :
78 : 0 : return bRet;
79 : : }
80 : :
81 : 0 : sal_Bool XMLBase64Export::exportElement(
82 : : const Reference < XInputStream > & rIn,
83 : : sal_uInt16 nNamespace,
84 : : enum ::xmloff::token::XMLTokenEnum eName )
85 : : {
86 : 0 : SvXMLElementExport aElem( GetExport(), nNamespace, eName, sal_True,
87 [ # # ]: 0 : sal_True );
88 [ # # ][ # # ]: 0 : return exportXML( rIn );
89 : : }
90 : :
91 : 0 : sal_Bool XMLBase64Export::exportOfficeBinaryDataElement(
92 : : const Reference < XInputStream > & rIn )
93 : : {
94 : : return exportElement( rIn, XML_NAMESPACE_OFFICE,
95 : 0 : ::xmloff::token::XML_BINARY_DATA );
96 : : }
97 : :
98 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|