LibreOffice Module starmath (master) 1
import.hxx
Go to the documentation of this file.
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.
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
10#pragma once
11
12// Our mathml
13#include "element.hxx"
14
15// XML tools
16#include <utility>
18#include <xmloff/xmlimp.hxx>
19
20// Extras
21
22class SfxMedium;
23class SmDocShell;
24class SmMLImport;
25class SmModel;
26
28{
32
33private:
34 // Use customized entities
35
36public:
40
41public:
45 : m_xModel(std::move(xRef))
46 , m_pDocShell(nullptr)
47 , m_pMlImport(nullptr)
48 {
49 }
50
53 ErrCode Import(SfxMedium& rMedium);
54
57 ErrCode Import(std::u16string_view aSource);
58
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);
68
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);
77
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);
85};
86
87class SmMLImport final : public SvXMLImport
88{
89private:
93
94public:
98
101 bool getSuccess() const { return m_bSuccess; }
102
103public:
106 void declareMlError();
107
108public:
111 SmMLImport(const css::uno::Reference<css::uno::XComponentContext>& rContext,
112 OUString const& implementationName, SvXMLImportFlags nImportFlags);
113
116 virtual ~SmMLImport() noexcept override { cleanup(); };
117
118public:
121 void SAL_CALL endDocument() override;
122
126 sal_Int32 nElement,
127 const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override;
128
131 virtual void
132 SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
133
136 virtual void SetConfigurationSettings(
137 const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
138
141 void SetSmSyntaxVersion(sal_uInt16 nSmSyntaxVersion) { m_nSmSyntaxVersion = nSmSyntaxVersion; }
142
145 sal_uInt16 GetSmSyntaxVersion() const { return m_nSmSyntaxVersion; }
146};
147
148/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
SmMLImport * m_pMlImport
Definition: import.hxx:31
SmDocShell * m_pDocShell
Definition: import.hxx:30
ErrCode ReadThroughComponentMS(std::u16string_view aText, const css::uno::Reference< css::lang::XComponent > &xModelComponent, css::uno::Reference< css::uno::XComponentContext > const &rxContext, css::uno::Reference< css::beans::XPropertySet > const &rPropSet)
read a component from text
Definition: import.cxx:547
SmMLImportWrapper(rtl::Reference< SmModel > xRef)
Constructor.
Definition: import.hxx:44
ErrCode ReadThroughComponentIS(const css::uno::Reference< css::io::XInputStream > &xInputStream, const css::uno::Reference< css::lang::XComponent > &xModelComponent, css::uno::Reference< css::uno::XComponentContext > const &rxContext, css::uno::Reference< css::beans::XPropertySet > const &rPropSet, const char16_t *pFilterName, bool bEncrypted, int_fast16_t nSyntaxVersion)
read a component from input stream
Definition: import.cxx:354
ErrCode Import(SfxMedium &rMedium)
Imports the mathml.
Definition: import.cxx:76
rtl::Reference< SmModel > m_xModel
Definition: import.hxx:29
SmMlElement * getElementTree()
Get the element tree when parsed from text.
Definition: import.cxx:71
ErrCode ReadThroughComponentS(const css::uno::Reference< css::embed::XStorage > &xStorage, const css::uno::Reference< css::lang::XComponent > &xModelComponent, const char16_t *pStreamName, css::uno::Reference< css::uno::XComponentContext > const &rxContext, css::uno::Reference< css::beans::XPropertySet > const &rPropSet, const char16_t *pFilterName, int_fast16_t nSyntaxVersion)
read a component from storage
Definition: import.cxx:493
SmMlElement * getElementTree()
Gets parsed element tree.
Definition: import.hxx:97
SmMlElement * m_pElementTree
Definition: import.hxx:90
bool m_bSuccess
Definition: import.hxx:91
sal_uInt16 GetSmSyntaxVersion() const
Get syntax version.
Definition: import.hxx:145
SmMLImport(const css::uno::Reference< css::uno::XComponentContext > &rContext, OUString const &implementationName, SvXMLImportFlags nImportFlags)
Constructor.
Definition: import.cxx:1387
virtual void SetViewSettings(const css::uno::Sequence< css::beans::PropertyValue > &aViewProps) override
Imports view settings formula.
Definition: import.cxx:1280
size_t m_nSmSyntaxVersion
Definition: import.hxx:92
bool getSuccess() const
Checks out if parse was a success.
Definition: import.hxx:101
void SAL_CALL endDocument() override
End the document.
Definition: import.cxx:1227
void SetSmSyntaxVersion(sal_uInt16 nSmSyntaxVersion)
Set syntax version.
Definition: import.hxx:141
virtual void SetConfigurationSettings(const css::uno::Sequence< css::beans::PropertyValue > &aViewProps) override
Imports configurations settings formula.
Definition: import.cxx:1338
SvXMLImportContext * CreateFastContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Create a fast context.
Definition: import.cxx:1190
virtual ~SmMLImport() noexcept override
Destructor.
Definition: import.hxx:116
void declareMlError()
Handles an error on the mathml structure.
Definition: import.cxx:1398
tDoubleVectorPair cleanup(const css::uno::Sequence< double > &rXValues, const css::uno::Sequence< double > &rYValues, Pred aPred)
SvXMLImportFlags