1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include "XMLFootnoteImportContext.hxx"
13 #include "xmltext.hxx"
15 #include <sal/log.hxx>
17 using namespace com::sun::star
;
19 namespace writerperfect::exp
23 /// Handler for <text:note-citation>.
24 class XMLTextNoteCitationContext
: public XMLImportContext
27 XMLTextNoteCitationContext(XMLImport
& rImport
, librevenge::RVNGPropertyList
& rProperties
);
29 void SAL_CALL
characters(const OUString
& rCharacters
) override
;
30 void SAL_CALL
endElement(const OUString
& rName
) override
;
33 librevenge::RVNGPropertyList
& m_rProperties
;
34 OUString m_aCharacters
;
38 XMLTextNoteCitationContext::XMLTextNoteCitationContext(XMLImport
& rImport
,
39 librevenge::RVNGPropertyList
& rProperties
)
40 : XMLImportContext(rImport
)
41 , m_rProperties(rProperties
)
45 void XMLTextNoteCitationContext::endElement(const OUString
& /*rName*/)
47 m_rProperties
.insert("librevenge:number", m_aCharacters
.toUtf8().getStr());
50 void XMLTextNoteCitationContext::characters(const OUString
& rCharacters
)
52 m_aCharacters
+= rCharacters
;
57 /// Handler for <text:note-body>.
58 class XMLFootnoteBodyImportContext
: public XMLImportContext
61 XMLFootnoteBodyImportContext(XMLImport
& rImport
,
62 const librevenge::RVNGPropertyList
& rProperties
);
64 rtl::Reference
<XMLImportContext
>
65 CreateChildContext(const OUString
& rName
,
66 const css::uno::Reference
<css::xml::sax::XAttributeList
>& xAttribs
) override
;
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
;
74 const librevenge::RVNGPropertyList
& m_rProperties
;
78 XMLFootnoteBodyImportContext::XMLFootnoteBodyImportContext(
79 XMLImport
& rImport
, const librevenge::RVNGPropertyList
& rProperties
)
80 : XMLImportContext(rImport
)
81 , m_rProperties(rProperties
)
85 rtl::Reference
<XMLImportContext
> XMLFootnoteBodyImportContext::CreateChildContext(
86 const OUString
& rName
, const css::uno::Reference
<css::xml::sax::XAttributeList
>& /*xAttribs*/)
88 return CreateTextChildContext(GetImport(), rName
);
91 void XMLFootnoteBodyImportContext::startElement(
92 const OUString
& /*rName*/,
93 const css::uno::Reference
<css::xml::sax::XAttributeList
>& /*xAttribs*/)
95 GetImport().GetGenerator().openFootnote(m_rProperties
);
98 void XMLFootnoteBodyImportContext::endElement(const OUString
& /*rName*/)
100 GetImport().GetGenerator().closeFootnote();
103 XMLFootnoteImportContext::XMLFootnoteImportContext(XMLImport
& rImport
)
104 : XMLImportContext(rImport
)
108 rtl::Reference
<XMLImportContext
> XMLFootnoteImportContext::CreateChildContext(
109 const OUString
& rName
, const css::uno::Reference
<css::xml::sax::XAttributeList
>& /*xAttribs*/)
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
);
119 void XMLFootnoteImportContext::startElement(
120 const OUString
& /*rName*/,
121 const css::uno::Reference
<css::xml::sax::XAttributeList
>& /*xAttribs*/)
124 } // namespace writerperfect::exp
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */