Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/writerperfect/source/writer/exp/XMLFootnoteImportContext.cxx
Line
Count
Source
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
10
#include "XMLFootnoteImportContext.hxx"
11
12
#include "xmlimp.hxx"
13
#include "xmltext.hxx"
14
15
#include <sal/log.hxx>
16
17
using namespace com::sun::star;
18
19
namespace writerperfect::exp
20
{
21
namespace
22
{
23
/// Handler for <text:note-citation>.
24
class XMLTextNoteCitationContext : public XMLImportContext
25
{
26
public:
27
    XMLTextNoteCitationContext(XMLImport& rImport, librevenge::RVNGPropertyList& rProperties);
28
29
    void SAL_CALL characters(const OUString& rCharacters) override;
30
    void SAL_CALL endElement(const OUString& rName) override;
31
32
private:
33
    librevenge::RVNGPropertyList& m_rProperties;
34
    OUString m_aCharacters;
35
};
36
}
37
38
XMLTextNoteCitationContext::XMLTextNoteCitationContext(XMLImport& rImport,
39
                                                       librevenge::RVNGPropertyList& rProperties)
40
0
    : XMLImportContext(rImport)
41
0
    , m_rProperties(rProperties)
42
0
{
43
0
}
44
45
void XMLTextNoteCitationContext::endElement(const OUString& /*rName*/)
46
0
{
47
0
    m_rProperties.insert("librevenge:number", m_aCharacters.toUtf8().getStr());
48
0
}
49
50
void XMLTextNoteCitationContext::characters(const OUString& rCharacters)
51
0
{
52
0
    m_aCharacters += rCharacters;
53
0
}
54
55
namespace
56
{
57
/// Handler for <text:note-body>.
58
class XMLFootnoteBodyImportContext : public XMLImportContext
59
{
60
public:
61
    XMLFootnoteBodyImportContext(XMLImport& rImport,
62
                                 const librevenge::RVNGPropertyList& rProperties);
63
64
    rtl::Reference<XMLImportContext>
65
    CreateChildContext(const OUString& rName,
66
                       const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override;
67
68
    void SAL_CALL
69
    startElement(const OUString& rName,
70
                 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override;
71
    void SAL_CALL endElement(const OUString& rName) override;
72
73
private:
74
    const librevenge::RVNGPropertyList& m_rProperties;
75
};
76
}
77
78
XMLFootnoteBodyImportContext::XMLFootnoteBodyImportContext(
79
    XMLImport& rImport, const librevenge::RVNGPropertyList& rProperties)
80
0
    : XMLImportContext(rImport)
81
0
    , m_rProperties(rProperties)
82
0
{
83
0
}
84
85
rtl::Reference<XMLImportContext> XMLFootnoteBodyImportContext::CreateChildContext(
86
    const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/)
87
0
{
88
0
    return CreateTextChildContext(GetImport(), rName);
89
0
}
90
91
void XMLFootnoteBodyImportContext::startElement(
92
    const OUString& /*rName*/,
93
    const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/)
94
0
{
95
0
    GetImport().GetGenerator().openFootnote(m_rProperties);
96
0
}
97
98
void XMLFootnoteBodyImportContext::endElement(const OUString& /*rName*/)
99
0
{
100
0
    GetImport().GetGenerator().closeFootnote();
101
0
}
102
103
XMLFootnoteImportContext::XMLFootnoteImportContext(XMLImport& rImport)
104
0
    : XMLImportContext(rImport)
105
0
{
106
0
}
107
108
rtl::Reference<XMLImportContext> XMLFootnoteImportContext::CreateChildContext(
109
    const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/)
110
0
{
111
0
    if (rName == "text:note-citation")
112
0
        return new XMLTextNoteCitationContext(GetImport(), m_aProperties);
113
0
    if (rName == "text:note-body")
114
0
        return new XMLFootnoteBodyImportContext(GetImport(), m_aProperties);
115
0
    SAL_WARN("writerperfect", "XMLFootnoteImportContext::CreateChildContext: unhandled " << rName);
116
0
    return nullptr;
117
0
}
118
119
void XMLFootnoteImportContext::startElement(
120
    const OUString& /*rName*/,
121
    const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/)
122
0
{
123
0
}
124
} // namespace writerperfect::exp
125
126
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */