Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/comphelper/dumpxmltostring.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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
10
#pragma once
11
12
#include <sal/config.h>
13
14
#include <rtl/ustring.hxx>
15
16
#include <libxml/parser.h>
17
#include <libxml/xmlwriter.h>
18
19
#include <new>
20
21
namespace comphelper
22
{
23
template <typename F> OUString dumpXmlToString(F f)
24
0
{
25
0
    auto const buf = xmlBufferCreate();
26
0
    if (buf == nullptr)
27
0
    {
28
0
        throw std::bad_alloc();
29
0
    }
30
0
    auto const writer = xmlNewTextWriterMemory(buf, 0);
31
0
    if (writer == nullptr)
32
0
    {
33
0
        throw std::bad_alloc();
34
0
    }
35
0
    f(writer);
36
0
    xmlFreeTextWriter(writer);
37
0
    std::string_view s(reinterpret_cast<char const*>(xmlBufferContent(buf)), xmlBufferLength(buf));
38
0
    OUString rv = OStringToOUString(s, RTL_TEXTENCODING_ISO_8859_1); //TODO
39
0
    xmlBufferFree(buf);
40
0
    return rv;
41
0
}
Unexecuted instantiation: ChartView.cxx:rtl::OUString comphelper::dumpXmlToString<chart::ChartView::dump(rtl::OUString const&)::$_0>(chart::ChartView::dump(rtl::OUString const&)::$_0)
Unexecuted instantiation: ChartModel.cxx:rtl::OUString comphelper::dumpXmlToString<chart::ChartModel::dump(rtl::OUString const&)::$_0>(chart::ChartModel::dump(rtl::OUString const&)::$_0)
Unexecuted instantiation: unotxvw.cxx:rtl::OUString comphelper::dumpXmlToString<SwXTextView::dump(rtl::OUString const&)::$_0>(SwXTextView::dump(rtl::OUString const&)::$_0)
42
}
43
44
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */