nss: upgrade to release 3.73
[LibreOffice.git] / test / source / htmltesttools.cxx
blob9f9a1bbddfc630e87fdfda3b9d6769d85dc3d439
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>
12 #include <memory>
14 htmlDocUniquePtr HtmlTestTools::parseHtml(utl::TempFile const & aTempFile)
16 SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ);
17 htmlDocUniquePtr doc = parseHtmlStream(&aFileStream);
18 xmlFree(doc->name);
19 doc->name = reinterpret_cast<char *>(
20 xmlStrdup(
21 reinterpret_cast<xmlChar const *>(
22 OUStringToOString(
23 aTempFile.GetURL(), RTL_TEXTENCODING_UTF8).getStr())));
24 return doc;
27 htmlDocUniquePtr HtmlTestTools::parseHtmlStream(SvStream* pStream)
29 std::size_t nSize = pStream->remainingSize();
30 std::unique_ptr<sal_uInt8[]> pBuffer(new sal_uInt8[nSize + 1]);
31 pStream->ReadBytes(pBuffer.get(), nSize);
32 pBuffer[nSize] = 0;
33 return htmlDocUniquePtr(htmlParseDoc(reinterpret_cast<xmlChar*>(pBuffer.get()), nullptr));
36 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */