Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / starmath / source / mathmlimport.hxx
blob2357c9f09bf996bdb561e3e9fd123fed832f0f7c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_STARMATH_SOURCE_MATHMLIMPORT_HXX
21 #define INCLUDED_STARMATH_SOURCE_MATHMLIMPORT_HXX
23 #include <xmloff/xmlimp.hxx>
24 #include <vcl/errcode.hxx>
26 #include <deque>
27 #include <memory>
29 class SmNode;
30 class SfxMedium;
31 namespace com { namespace sun { namespace star {
32 namespace beans {
33 class XPropertySet; }
34 } } }
37 typedef std::deque<std::unique_ptr<SmNode>> SmNodeStack;
39 class SmXMLImportWrapper
41 css::uno::Reference<css::frame::XModel> xModel;
43 public:
44 explicit SmXMLImportWrapper(css::uno::Reference<css::frame::XModel> const &rRef)
45 : xModel(rRef) {}
47 ErrCode Import(SfxMedium &rMedium);
49 static ErrCode ReadThroughComponent(
50 const css::uno::Reference< css::io::XInputStream >& xInputStream,
51 const css::uno::Reference< css::lang::XComponent >& xModelComponent,
52 css::uno::Reference< css::uno::XComponentContext > const & rxContext,
53 css::uno::Reference< css::beans::XPropertySet > const & rPropSet,
54 const sal_Char* pFilterName,
55 bool bEncrypted );
57 static ErrCode ReadThroughComponent(
58 const css::uno::Reference< css::embed::XStorage >& xStorage,
59 const css::uno::Reference< css::lang::XComponent >& xModelComponent,
60 const sal_Char* pStreamName,
61 const sal_Char* pCompatibilityStreamName,
62 css::uno::Reference< css::uno::XComponentContext > const & rxContext,
63 css::uno::Reference< css::beans::XPropertySet > const & rPropSet,
64 const sal_Char* pFilterName );
68 class SmXMLImport : public SvXMLImport
70 std::unique_ptr<SvXMLTokenMap> pPresLayoutElemTokenMap;
71 std::unique_ptr<SvXMLTokenMap> pPresLayoutAttrTokenMap;
72 std::unique_ptr<SvXMLTokenMap> pFencedAttrTokenMap;
73 std::unique_ptr<SvXMLTokenMap> pOperatorAttrTokenMap;
74 std::unique_ptr<SvXMLTokenMap> pAnnotationAttrTokenMap;
75 std::unique_ptr<SvXMLTokenMap> pPresElemTokenMap;
76 std::unique_ptr<SvXMLTokenMap> pPresScriptEmptyElemTokenMap;
77 std::unique_ptr<SvXMLTokenMap> pPresTableElemTokenMap;
78 std::unique_ptr<SvXMLTokenMap> pColorTokenMap;
79 std::unique_ptr<SvXMLTokenMap> pActionAttrTokenMap;
80 std::unique_ptr<SvXMLTokenMap> pMspaceAttrTokenMap;
82 SmNodeStack aNodeStack;
83 bool bSuccess;
84 int nParseDepth;
85 OUString aText;
87 public:
88 SmXMLImport(
89 const css::uno::Reference< css::uno::XComponentContext >& rContext,
90 OUString const & implementationName, SvXMLImportFlags nImportFlags);
91 virtual ~SmXMLImport() throw () override;
93 // XUnoTunnel
94 sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override;
95 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
97 void SAL_CALL endDocument() override;
99 SvXMLImportContext *CreateDocumentContext(sal_uInt16 nPrefix,
100 const OUString &rLocalName,
101 const css::uno::Reference <
102 css::xml::sax::XAttributeList> &xAttrList) override;
103 SvXMLImportContext *CreateFastContext( sal_Int32 nElement,
104 const css::uno::Reference<
105 css::xml::sax::XFastAttributeList >& xAttrList ) override;
106 SvXMLImportContext *CreateRowContext(sal_uInt16 nPrefix,
107 const OUString &rLocalName);
108 SvXMLImportContext *CreateEncloseContext(sal_uInt16 nPrefix,
109 const OUString &rLocalName);
110 SvXMLImportContext *CreateFracContext(sal_uInt16 nPrefix,
111 const OUString &rLocalName);
112 SvXMLImportContext *CreateNumberContext(sal_uInt16 nPrefix,
113 const OUString &rLocalName);
114 SvXMLImportContext *CreateTextContext(sal_uInt16 nPrefix,
115 const OUString &rLocalName);
116 SvXMLImportContext *CreateAnnotationContext(sal_uInt16 nPrefix,
117 const OUString &rLocalName);
118 SvXMLImportContext *CreateStringContext(sal_uInt16 nPrefix,
119 const OUString &rLocalName);
120 SvXMLImportContext *CreateIdentifierContext(sal_uInt16 nPrefix,
121 const OUString &rLocalName);
122 SvXMLImportContext *CreateOperatorContext(sal_uInt16 nPrefix,
123 const OUString &rLocalName);
124 SvXMLImportContext *CreateSpaceContext(sal_uInt16 nPrefix,
125 const OUString &rLocalName);
126 SvXMLImportContext *CreateSqrtContext(sal_uInt16 nPrefix,
127 const OUString &rLocalName);
128 SvXMLImportContext *CreateRootContext(sal_uInt16 nPrefix,
129 const OUString &rLocalName);
130 SvXMLImportContext *CreateStyleContext(sal_uInt16 nPrefix,
131 const OUString &rLocalName);
132 SvXMLImportContext *CreatePaddedContext(sal_uInt16 nPrefix,
133 const OUString &rLocalName);
134 SvXMLImportContext *CreatePhantomContext(sal_uInt16 nPrefix,
135 const OUString &rLocalName);
136 SvXMLImportContext *CreateFencedContext(sal_uInt16 nPrefix,
137 const OUString &rLocalName);
138 SvXMLImportContext *CreateErrorContext(sal_uInt16 nPrefix,
139 const OUString &rLocalName);
140 SvXMLImportContext *CreateSubContext(sal_uInt16 nPrefix,
141 const OUString &rLocalName);
142 SvXMLImportContext *CreateSupContext(sal_uInt16 nPrefix,
143 const OUString &rLocalName);
144 SvXMLImportContext *CreateSubSupContext(sal_uInt16 nPrefix,
145 const OUString &rLocalName);
146 SvXMLImportContext *CreateUnderContext(sal_uInt16 nPrefix,
147 const OUString &rLocalName);
148 SvXMLImportContext *CreateOverContext(sal_uInt16 nPrefix,
149 const OUString &rLocalName);
150 SvXMLImportContext *CreateUnderOverContext(sal_uInt16 nPrefix,
151 const OUString &rLocalName);
152 SvXMLImportContext *CreateMultiScriptsContext(sal_uInt16 nPrefix,
153 const OUString &rLocalName);
154 SvXMLImportContext *CreateNoneContext(sal_uInt16 nPrefix,
155 const OUString &rLocalName);
156 SvXMLImportContext *CreatePrescriptsContext(sal_uInt16 nPrefix,
157 const OUString &rLocalName);
158 SvXMLImportContext *CreateTableContext(sal_uInt16 nPrefix,
159 const OUString &rLocalName);
160 SvXMLImportContext *CreateTableRowContext(sal_uInt16 nPrefix,
161 const OUString &rLocalName);
162 SvXMLImportContext *CreateTableCellContext(sal_uInt16 nPrefix,
163 const OUString &rLocalName);
164 SvXMLImportContext *CreateAlignGroupContext(sal_uInt16 nPrefix,
165 const OUString &rLocalName);
166 SvXMLImportContext *CreateActionContext(sal_uInt16 nPrefix,
167 const OUString &rLocalName);
169 const SvXMLTokenMap &GetPresLayoutElemTokenMap();
170 const SvXMLTokenMap &GetPresLayoutAttrTokenMap();
171 const SvXMLTokenMap &GetFencedAttrTokenMap();
172 const SvXMLTokenMap &GetOperatorAttrTokenMap();
173 const SvXMLTokenMap &GetAnnotationAttrTokenMap();
174 const SvXMLTokenMap &GetPresElemTokenMap();
175 const SvXMLTokenMap &GetPresScriptEmptyElemTokenMap();
176 const SvXMLTokenMap &GetPresTableElemTokenMap();
177 const SvXMLTokenMap &GetColorTokenMap();
178 const SvXMLTokenMap &GetActionAttrTokenMap();
179 const SvXMLTokenMap &GetMspaceAttrTokenMap();
181 SmNodeStack & GetNodeStack() { return aNodeStack; }
183 bool GetSuccess() const { return bSuccess; }
184 [[nodiscard]] const OUString& GetText() const { return aText; }
185 void SetText(const OUString &rStr) { aText = rStr; }
187 virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
188 virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
190 void IncParseDepth() { ++nParseDepth; }
191 bool TooDeep() const { return nParseDepth >= 2048; }
192 void DecParseDepth() { --nParseDepth; }
196 enum SmXMLMathElemTokenMap
198 XML_TOK_MATH
201 enum SmXMLPresLayoutElemTokenMap
203 XML_TOK_SEMANTICS,
204 XML_TOK_MSTYLE,
205 XML_TOK_MERROR,
206 XML_TOK_MPHANTOM,
207 XML_TOK_MROW,
208 XML_TOK_MENCLOSE,
209 XML_TOK_MFRAC,
210 XML_TOK_MSQRT,
211 XML_TOK_MROOT,
212 XML_TOK_MSUB,
213 XML_TOK_MSUP,
214 XML_TOK_MSUBSUP,
215 XML_TOK_MMULTISCRIPTS,
216 XML_TOK_MUNDER,
217 XML_TOK_MOVER,
218 XML_TOK_MUNDEROVER,
219 XML_TOK_MTABLE,
220 XML_TOK_MACTION,
221 XML_TOK_MFENCED,
222 XML_TOK_MPADDED
225 enum SmXMLPresLayoutAttrTokenMap
227 XML_TOK_FONTWEIGHT,
228 XML_TOK_FONTSTYLE,
229 XML_TOK_FONTSIZE,
230 XML_TOK_FONTFAMILY,
231 XML_TOK_COLOR,
232 XML_TOK_MATHCOLOR,
233 XML_TOK_MATHVARIANT
237 enum SmXMLFencedAttrTokenMap
239 XML_TOK_OPEN,
240 XML_TOK_CLOSE
244 enum SmXMLPresTableElemTokenMap
246 XML_TOK_MTR,
247 XML_TOK_MTD
250 enum SmXMLPresElemTokenMap
252 XML_TOK_ANNOTATION,
253 XML_TOK_MI,
254 XML_TOK_MN,
255 XML_TOK_MO,
256 XML_TOK_MTEXT,
257 XML_TOK_MSPACE,
258 XML_TOK_MS,
259 XML_TOK_MALIGNGROUP
262 enum SmXMLPresScriptEmptyElemTokenMap
264 XML_TOK_MPRESCRIPTS,
265 XML_TOK_NONE
268 enum SmXMLOperatorAttrTokenMap
270 XML_TOK_STRETCHY
273 enum SmXMLAnnotationAttrTokenMap
275 XML_TOK_ENCODING
278 enum SmXMLActionAttrTokenMap
280 XML_TOK_SELECTION
283 enum SmXMLMspaceAttrTokenMap
285 XML_TOK_WIDTH
288 #endif
290 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */