LibreOffice Module writerperfect (master) 1
XMLBase64ImportContext.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
11
12#include <comphelper/base64.hxx>
13
14using namespace com::sun::star;
15
16namespace writerperfect::exp
17{
19 : XMLImportContext(rImport)
20{
21}
22
24 const OUString& /*rName*/,
25 const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/)
26{
27}
28
29void XMLBase64ImportContext::endElement(const OUString& /*rName*/)
30{
31 m_aBinaryData.append(static_cast<const unsigned char*>(m_aStream.GetData()),
33}
34
35void XMLBase64ImportContext::characters(const OUString& rChars)
36{
37 OUString aTrimmedChars(rChars.trim());
38
39 if (aTrimmedChars.isEmpty())
40 return;
41
42 OUString aChars;
43 if (!m_aBase64CharsLeft.isEmpty())
44 {
45 aChars = m_aBase64CharsLeft + aTrimmedChars;
46 m_aBase64CharsLeft.clear();
47 }
48 else
49 aChars = aTrimmedChars;
50
51 uno::Sequence<sal_Int8> aBuffer((aChars.getLength() / 4) * 3);
52 const sal_Int32 nCharsDecoded = comphelper::Base64::decodeSomeChars(aBuffer, aChars);
53 m_aStream.WriteBytes(aBuffer.getArray(), aBuffer.getLength());
54 if (nCharsDecoded != aChars.getLength())
55 m_aBase64CharsLeft = aChars.copy(nCharsDecoded);
56}
57
58const librevenge::RVNGBinaryData& XMLBase64ImportContext::getBinaryData() const
59{
60 return m_aBinaryData;
61}
62
63} // namespace writerperfect::exp
64
65/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const void * GetData()
sal_uInt64 GetSize()
std::size_t WriteBytes(const void *pData, std::size_t nSize)
static std::size_t decodeSomeChars(css::uno::Sequence< sal_Int8 > &aPass, std::u16string_view sBuffer)
void SAL_CALL endElement(const OUString &rName) override
const librevenge::RVNGBinaryData & getBinaryData() const
void SAL_CALL startElement(const OUString &rName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override
void SAL_CALL characters(const OUString &rChars) override
Base class for a handler of a single XML element during ODF -> librevenge conversion.
Definition: xmlictxt.hxx:23
ODT export feeds this class to make librevenge calls.
Definition: xmlimp.hxx:69
std::unique_ptr< char[]> aBuffer