Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / test / source / htmltesttools.cxx
blobdedda5f982253ebe745bec0705803aac7e2307a7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include <test/htmltesttools.hxx>
11 #include <sal/log.hxx>
13 #include <memory>
15 htmlDocUniquePtr HtmlTestTools::parseHtml(utl::TempFileNamed const & aTempFile)
17 SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ);
18 htmlDocUniquePtr doc = parseHtmlStream(&aFileStream);
19 xmlFree(doc->name);
20 doc->name = reinterpret_cast<char *>(
21 xmlStrdup(
22 reinterpret_cast<xmlChar const *>(
23 OUStringToOString(
24 aTempFile.GetURL(), RTL_TEXTENCODING_UTF8).getStr())));
25 return doc;
28 htmlDocUniquePtr HtmlTestTools::parseHtmlStream(SvStream* pStream)
30 std::size_t nSize = pStream->remainingSize();
31 std::unique_ptr<sal_uInt8[]> pBuffer(new sal_uInt8[nSize + 1]);
32 pStream->ReadBytes(pBuffer.get(), nSize);
33 pBuffer[nSize] = 0;
34 auto pCharBuffer = reinterpret_cast<xmlChar*>(pBuffer.get());
35 SAL_INFO("test", "HtmlTestTools::parseXmlStream: pBuffer is '" << pCharBuffer << "'");
36 return htmlDocUniquePtr(htmlParseDoc(pCharBuffer, nullptr));
39 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */