sw: clean up Start/EndAction in SwViewShell hierarchy
[LibreOffice.git] / starmath / inc / mathml / import.hxx
blob764d5451c652768a14f200f19d0e67a718b5ab3b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
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/.
8 */
10 #pragma once
12 // Our mathml
13 #include "element.hxx"
15 // XML tools
16 #include <utility>
17 #include <comphelper/errcode.hxx>
18 #include <xmloff/xmlimp.hxx>
20 // Extras
22 class SfxMedium;
23 class SmDocShell;
24 class SmMLImport;
25 class SmModel;
27 class SmMLImportWrapper
29 rtl::Reference<SmModel> m_xModel;
30 SmDocShell* m_pDocShell;
31 SmMLImport* m_pMlImport;
33 private:
34 // Use customized entities
36 public:
37 /** Get the element tree when parsed from text
39 SmMlElement* getElementTree();
41 public:
42 /** Constructor
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
61 ErrCode
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
80 ErrCode
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
89 private:
90 SmMlElement* m_pElementTree = new SmMlElement(SmMlElementType::NMlEmpty);
91 bool m_bSuccess;
92 size_t m_nSmSyntaxVersion;
94 public:
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; }
103 public:
104 /** Handles an error on the mathml structure
106 void declareMlError();
108 public:
109 /** Constructor
111 SmMLImport(const css::uno::Reference<css::uno::XComponentContext>& rContext,
112 OUString const& implementationName, SvXMLImportFlags nImportFlags);
114 /** Destructor
116 virtual ~SmMLImport() noexcept override { cleanup(); };
118 public:
119 /** End the document
121 void SAL_CALL endDocument() override;
123 /** Create a fast context
125 SvXMLImportContext* CreateFastContext(
126 sal_Int32 nElement,
127 const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override;
129 /** Imports view settings formula
131 virtual void
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: */