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 "oox/mathml/import.hxx"
12 #include <oox/mathml/importutils.hxx>
13 #include <oox/core/contexthandler.hxx>
14 #include <oox/token/namespaces.hxx>
15 #include <oox/token/tokens.hxx>
17 #include <drawingml/textparagraph.hxx>
20 using namespace ::com::sun::star
;
25 FormulaImportBase::FormulaImportBase()
29 namespace formulaimport
{
31 class LazyMathBufferingContext
: public core::ContextHandler
34 XmlStreamBuilder
& m_rBuilder
;
38 LazyMathBufferingContext(core::ContextHandler
const& rParent
,
39 drawingml::TextParagraph
& rPara
);
41 // com.sun.star.xml.sax.XFastContextHandler interface ---------------------
43 virtual void SAL_CALL
startFastElement(::sal_Int32 Element
, const uno::Reference
<xml::sax::XFastAttributeList
>& xAttribs
) throw (xml::sax::SAXException
, uno::RuntimeException
, std::exception
) override
;
44 virtual void SAL_CALL
endFastElement(::sal_Int32 Element
) throw (xml::sax::SAXException
, uno::RuntimeException
, std::exception
) override
;
45 virtual uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(::sal_Int32 Element
, const uno::Reference
<xml::sax::XFastAttributeList
>& xAttribs
) throw (xml::sax::SAXException
, uno::RuntimeException
, std::exception
) override
;
46 virtual void SAL_CALL
characters(const OUString
& rChars
) throw (xml::sax::SAXException
, uno::RuntimeException
, std::exception
) override
;
50 LazyMathBufferingContext::LazyMathBufferingContext(
51 core::ContextHandler
const& rParent
, drawingml::TextParagraph
& rPara
)
52 : core::ContextHandler(rParent
)
53 , m_rBuilder(rPara
.GetMathXml())
58 void SAL_CALL
LazyMathBufferingContext::startFastElement(
59 sal_Int32
const nElement
,
60 uno::Reference
<xml::sax::XFastAttributeList
> const& xAttrs
)
61 throw (xml::sax::SAXException
, uno::RuntimeException
, std::exception
)
63 if (0 < m_Counter
) // ignore a14:m
64 { // ignore outer oMathPara
65 if (1 != m_Counter
|| OOX_TOKEN(officeMath
, oMathPara
) != nElement
)
67 m_rBuilder
.appendOpeningTag(nElement
, xAttrs
);
73 void SAL_CALL
LazyMathBufferingContext::endFastElement(sal_Int32
const nElement
)
74 throw (xml::sax::SAXException
, uno::RuntimeException
, std::exception
)
77 if (0 < m_Counter
) // ignore a14:m
78 { // ignore outer oMathPara
79 if (1 != m_Counter
|| OOX_TOKEN(officeMath
, oMathPara
) != nElement
)
81 m_rBuilder
.appendClosingTag(nElement
);
86 uno::Reference
<xml::sax::XFastContextHandler
> SAL_CALL
87 LazyMathBufferingContext::createFastChildContext(sal_Int32
const,
88 uno::Reference
<xml::sax::XFastAttributeList
> const&)
89 throw (xml::sax::SAXException
, uno::RuntimeException
, std::exception
)
94 void SAL_CALL
LazyMathBufferingContext::characters(OUString
const& rChars
)
95 throw (xml::sax::SAXException
, uno::RuntimeException
, std::exception
)
97 if (0 < m_Counter
) // ignore a14:m
99 m_rBuilder
.appendCharacters(rChars
);
103 } // namespace formulaimport
105 core::ContextHandlerRef
CreateLazyMathBufferingContext(
106 core::ContextHandler
const& rParent
, drawingml::TextParagraph
& rPara
)
108 return new formulaimport::LazyMathBufferingContext(rParent
, rPara
);
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */