LibreOffice Module writerperfect (master) 1
XMLFootnoteImportContext.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 "xmlimp.hxx"
13#include "xmltext.hxx"
14
15#include <sal/log.hxx>
16
17using namespace com::sun::star;
18
19namespace writerperfect::exp
20{
21namespace
22{
24class XMLTextNoteCitationContext : public XMLImportContext
25{
26public:
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
32private:
33 librevenge::RVNGPropertyList& m_rProperties;
34 OUString m_aCharacters;
35};
36}
37
38XMLTextNoteCitationContext::XMLTextNoteCitationContext(XMLImport& rImport,
39 librevenge::RVNGPropertyList& rProperties)
40 : XMLImportContext(rImport)
41 , m_rProperties(rProperties)
42{
43}
44
45void XMLTextNoteCitationContext::endElement(const OUString& /*rName*/)
46{
47 m_rProperties.insert("librevenge:number", m_aCharacters.toUtf8().getStr());
48}
49
50void XMLTextNoteCitationContext::characters(const OUString& rCharacters)
51{
52 m_aCharacters += rCharacters;
53}
54
55namespace
56{
58class XMLFootnoteBodyImportContext : public XMLImportContext
59{
60public:
61 XMLFootnoteBodyImportContext(XMLImport& rImport,
62 const librevenge::RVNGPropertyList& rProperties);
63
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
73private:
74 const librevenge::RVNGPropertyList& m_rProperties;
75};
76}
77
79 XMLImport& rImport, const librevenge::RVNGPropertyList& rProperties)
80 : XMLImportContext(rImport)
81 , m_rProperties(rProperties)
82{
83}
84
85rtl::Reference<XMLImportContext> XMLFootnoteBodyImportContext::CreateChildContext(
86 const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/)
87{
88 return CreateTextChildContext(GetImport(), rName);
89}
90
91void XMLFootnoteBodyImportContext::startElement(
92 const OUString& /*rName*/,
93 const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/)
94{
95 GetImport().GetGenerator().openFootnote(m_rProperties);
96}
97
98void XMLFootnoteBodyImportContext::endElement(const OUString& /*rName*/)
99{
100 GetImport().GetGenerator().closeFootnote();
101}
102
104 : XMLImportContext(rImport)
105{
106}
107
109 const OUString& rName, const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/)
110{
111 if (rName == "text:note-citation")
112 return new XMLTextNoteCitationContext(GetImport(), m_aProperties);
113 if (rName == "text:note-body")
114 return new XMLFootnoteBodyImportContext(GetImport(), m_aProperties);
115 SAL_WARN("writerperfect", "XMLFootnoteImportContext::CreateChildContext: unhandled " << rName);
116 return nullptr;
117}
118
120 const OUString& /*rName*/,
121 const css::uno::Reference<css::xml::sax::XAttributeList>& /*xAttribs*/)
122{
123}
124} // namespace writerperfect::exp
125
126/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString m_aCharacters
librevenge::RVNGPropertyList & m_rProperties
SvXMLImport & GetImport()
XMLFootnoteBodyImportContext(SvXMLImport &rImport)
XMLFootnoteImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp)
void SAL_CALL startElement(const OUString &rName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override
rtl::Reference< XMLImportContext > CreateChildContext(const OUString &rName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) 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
#define SAL_WARN(area, stream)
rtl::Reference< XMLImportContext > CreateTextChildContext(XMLImport &rImport, std::u16string_view rName, bool bTopLevel)
Context factory for body text, section, table cell, etc.
Definition: xmltext.cxx:39