1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
13 #include "element.hxx"
17 #include <comphelper/errcode.hxx>
18 #include <xmloff/xmlimp.hxx>
27 class SmMLImportWrapper
29 rtl::Reference
<SmModel
> m_xModel
;
30 SmDocShell
* m_pDocShell
;
31 SmMLImport
* m_pMlImport
;
34 // Use customized entities
37 /** Get the element tree when parsed from text
39 SmMlElement
* getElementTree();
44 explicit SmMLImportWrapper(rtl::Reference
<SmModel
> xRef
)
45 : m_xModel(std::move(xRef
))
46 , m_pDocShell(nullptr)
47 , m_pMlImport(nullptr)
51 /** Imports the mathml
53 ErrCode
Import(SfxMedium
& rMedium
);
55 /** Imports the mathml
57 ErrCode
Import(std::u16string_view aSource
);
59 /** read a component from input stream
62 ReadThroughComponentIS(const css::uno::Reference
<css::io::XInputStream
>& xInputStream
,
63 const css::uno::Reference
<css::lang::XComponent
>& xModelComponent
,
64 css::uno::Reference
<css::uno::XComponentContext
> const& rxContext
,
65 css::uno::Reference
<css::beans::XPropertySet
> const& rPropSet
,
66 const char16_t
* pFilterName
, bool bEncrypted
,
67 int_fast16_t nSyntaxVersion
);
69 /** read a component from storage
71 ErrCode
ReadThroughComponentS(const css::uno::Reference
<css::embed::XStorage
>& xStorage
,
72 const css::uno::Reference
<css::lang::XComponent
>& xModelComponent
,
73 const char16_t
* pStreamName
,
74 css::uno::Reference
<css::uno::XComponentContext
> const& rxContext
,
75 css::uno::Reference
<css::beans::XPropertySet
> const& rPropSet
,
76 const char16_t
* pFilterName
, int_fast16_t nSyntaxVersion
);
78 /** read a component from text
81 ReadThroughComponentMS(std::u16string_view aText
,
82 const css::uno::Reference
<css::lang::XComponent
>& xModelComponent
,
83 css::uno::Reference
<css::uno::XComponentContext
> const& rxContext
,
84 css::uno::Reference
<css::beans::XPropertySet
> const& rPropSet
);
87 class SmMLImport final
: public SvXMLImport
90 SmMlElement
* m_pElementTree
= new SmMlElement(SmMlElementType::NMlEmpty
);
92 size_t m_nSmSyntaxVersion
;
95 /** Gets parsed element tree
97 SmMlElement
* getElementTree() { return m_pElementTree
; }
99 /** Checks out if parse was a success
101 bool getSuccess() const { return m_bSuccess
; }
104 /** Handles an error on the mathml structure
106 void declareMlError();
111 SmMLImport(const css::uno::Reference
<css::uno::XComponentContext
>& rContext
,
112 OUString
const& implementationName
, SvXMLImportFlags nImportFlags
);
116 virtual ~SmMLImport() noexcept override
{ cleanup(); };
121 void SAL_CALL
endDocument() override
;
123 /** Create a fast context
125 SvXMLImportContext
* CreateFastContext(
127 const css::uno::Reference
<css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
129 /** Imports view settings formula
132 SetViewSettings(const css::uno::Sequence
<css::beans::PropertyValue
>& aViewProps
) override
;
134 /** Imports configurations settings formula
136 virtual void SetConfigurationSettings(
137 const css::uno::Sequence
<css::beans::PropertyValue
>& aViewProps
) override
;
139 /** Set syntax version
141 void SetSmSyntaxVersion(sal_Int16 nSmSyntaxVersion
) { m_nSmSyntaxVersion
= nSmSyntaxVersion
; }
143 /** Get syntax version
145 sal_Int16
GetSmSyntaxVersion() const { return m_nSmSyntaxVersion
; }
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */