Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / starmath / source / mathmlimport.hxx
blobb91a51bea2bd3535744f36420061a53882af6a09
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>
25 #include <node.hxx>
26 #include <deque>
27 #include <memory>
29 class SfxMedium;
30 namespace com { namespace sun { namespace star {
31 namespace beans {
32 class XPropertySet; }
33 } } }
36 typedef std::deque<std::unique_ptr<SmNode>> SmNodeStack;
38 class SmXMLImportWrapper
40 css::uno::Reference<css::frame::XModel> xModel;
42 public:
43 explicit SmXMLImportWrapper(css::uno::Reference<css::frame::XModel> const &rRef)
44 : xModel(rRef) {}
46 ErrCode Import(SfxMedium &rMedium);
48 static ErrCode ReadThroughComponent(
49 const css::uno::Reference< css::io::XInputStream >& xInputStream,
50 const css::uno::Reference< css::lang::XComponent >& xModelComponent,
51 css::uno::Reference< css::uno::XComponentContext > const & rxContext,
52 css::uno::Reference< css::beans::XPropertySet > const & rPropSet,
53 const sal_Char* pFilterName,
54 bool bEncrypted );
56 static ErrCode ReadThroughComponent(
57 const css::uno::Reference< css::embed::XStorage >& xStorage,
58 const css::uno::Reference< css::lang::XComponent >& xModelComponent,
59 const sal_Char* pStreamName,
60 const sal_Char* pCompatibilityStreamName,
61 css::uno::Reference< css::uno::XComponentContext > const & rxContext,
62 css::uno::Reference< css::beans::XPropertySet > const & rPropSet,
63 const sal_Char* pFilterName );
67 class SmXMLImport : public SvXMLImport
69 std::unique_ptr<SvXMLTokenMap> pPresLayoutElemTokenMap;
70 std::unique_ptr<SvXMLTokenMap> pPresLayoutAttrTokenMap;
71 std::unique_ptr<SvXMLTokenMap> pFencedAttrTokenMap;
72 std::unique_ptr<SvXMLTokenMap> pOperatorAttrTokenMap;
73 std::unique_ptr<SvXMLTokenMap> pAnnotationAttrTokenMap;
74 std::unique_ptr<SvXMLTokenMap> pPresElemTokenMap;
75 std::unique_ptr<SvXMLTokenMap> pPresScriptEmptyElemTokenMap;
76 std::unique_ptr<SvXMLTokenMap> pPresTableElemTokenMap;
77 std::unique_ptr<SvXMLTokenMap> pColorTokenMap;
78 std::unique_ptr<SvXMLTokenMap> pActionAttrTokenMap;
79 std::unique_ptr<SvXMLTokenMap> pMspaceAttrTokenMap;
81 SmNodeStack aNodeStack;
82 bool bSuccess;
83 int nParseDepth;
84 OUString aText;
86 public:
87 SmXMLImport(
88 const css::uno::Reference< css::uno::XComponentContext >& rContext,
89 OUString const & implementationName, SvXMLImportFlags nImportFlags);
90 virtual ~SmXMLImport() throw () override;
92 // XUnoTunnel
93 sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override;
94 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
96 void SAL_CALL endDocument() override;
98 SvXMLImportContext *CreateDocumentContext(sal_uInt16 nPrefix,
99 const OUString &rLocalName,
100 const css::uno::Reference <
101 css::xml::sax::XAttributeList> &xAttrList) override;
102 SvXMLImportContext *CreateFastContext( sal_Int32 nElement,
103 const css::uno::Reference<
104 css::xml::sax::XFastAttributeList >& xAttrList ) override;
105 SvXMLImportContext *CreateRowContext(sal_uInt16 nPrefix,
106 const OUString &rLocalName);
107 SvXMLImportContext *CreateEncloseContext(sal_uInt16 nPrefix,
108 const OUString &rLocalName);
109 SvXMLImportContext *CreateFracContext(sal_uInt16 nPrefix,
110 const OUString &rLocalName);
111 SvXMLImportContext *CreateNumberContext(sal_uInt16 nPrefix,
112 const OUString &rLocalName);
113 SvXMLImportContext *CreateTextContext(sal_uInt16 nPrefix,
114 const OUString &rLocalName);
115 SvXMLImportContext *CreateAnnotationContext(sal_uInt16 nPrefix,
116 const OUString &rLocalName);
117 SvXMLImportContext *CreateStringContext(sal_uInt16 nPrefix,
118 const OUString &rLocalName);
119 SvXMLImportContext *CreateIdentifierContext(sal_uInt16 nPrefix,
120 const OUString &rLocalName);
121 SvXMLImportContext *CreateOperatorContext(sal_uInt16 nPrefix,
122 const OUString &rLocalName);
123 SvXMLImportContext *CreateSpaceContext(sal_uInt16 nPrefix,
124 const OUString &rLocalName);
125 SvXMLImportContext *CreateSqrtContext(sal_uInt16 nPrefix,
126 const OUString &rLocalName);
127 SvXMLImportContext *CreateRootContext(sal_uInt16 nPrefix,
128 const OUString &rLocalName);
129 SvXMLImportContext *CreateStyleContext(sal_uInt16 nPrefix,
130 const OUString &rLocalName);
131 SvXMLImportContext *CreatePaddedContext(sal_uInt16 nPrefix,
132 const OUString &rLocalName);
133 SvXMLImportContext *CreatePhantomContext(sal_uInt16 nPrefix,
134 const OUString &rLocalName);
135 SvXMLImportContext *CreateFencedContext(sal_uInt16 nPrefix,
136 const OUString &rLocalName);
137 SvXMLImportContext *CreateErrorContext(sal_uInt16 nPrefix,
138 const OUString &rLocalName);
139 SvXMLImportContext *CreateSubContext(sal_uInt16 nPrefix,
140 const OUString &rLocalName);
141 SvXMLImportContext *CreateSupContext(sal_uInt16 nPrefix,
142 const OUString &rLocalName);
143 SvXMLImportContext *CreateSubSupContext(sal_uInt16 nPrefix,
144 const OUString &rLocalName);
145 SvXMLImportContext *CreateUnderContext(sal_uInt16 nPrefix,
146 const OUString &rLocalName);
147 SvXMLImportContext *CreateOverContext(sal_uInt16 nPrefix,
148 const OUString &rLocalName);
149 SvXMLImportContext *CreateUnderOverContext(sal_uInt16 nPrefix,
150 const OUString &rLocalName);
151 SvXMLImportContext *CreateMultiScriptsContext(sal_uInt16 nPrefix,
152 const OUString &rLocalName);
153 SvXMLImportContext *CreateNoneContext(sal_uInt16 nPrefix,
154 const OUString &rLocalName);
155 SvXMLImportContext *CreatePrescriptsContext(sal_uInt16 nPrefix,
156 const OUString &rLocalName);
157 SvXMLImportContext *CreateTableContext(sal_uInt16 nPrefix,
158 const OUString &rLocalName);
159 SvXMLImportContext *CreateTableRowContext(sal_uInt16 nPrefix,
160 const OUString &rLocalName);
161 SvXMLImportContext *CreateTableCellContext(sal_uInt16 nPrefix,
162 const OUString &rLocalName);
163 SvXMLImportContext *CreateAlignGroupContext(sal_uInt16 nPrefix,
164 const OUString &rLocalName);
165 SvXMLImportContext *CreateActionContext(sal_uInt16 nPrefix,
166 const OUString &rLocalName);
168 const SvXMLTokenMap &GetPresLayoutElemTokenMap();
169 const SvXMLTokenMap &GetPresLayoutAttrTokenMap();
170 const SvXMLTokenMap &GetFencedAttrTokenMap();
171 const SvXMLTokenMap &GetOperatorAttrTokenMap();
172 const SvXMLTokenMap &GetAnnotationAttrTokenMap();
173 const SvXMLTokenMap &GetPresElemTokenMap();
174 const SvXMLTokenMap &GetPresScriptEmptyElemTokenMap();
175 const SvXMLTokenMap &GetPresTableElemTokenMap();
176 const SvXMLTokenMap &GetColorTokenMap();
177 const SvXMLTokenMap &GetActionAttrTokenMap();
178 const SvXMLTokenMap &GetMspaceAttrTokenMap();
180 SmNodeStack & GetNodeStack() { return aNodeStack; }
182 bool GetSuccess() { return bSuccess; }
183 SAL_WARN_UNUSED_RESULT const OUString& GetText() { return aText; }
184 void SetText(const OUString &rStr) { aText = rStr; }
186 virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
187 virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
189 void IncParseDepth() { ++nParseDepth; }
190 bool TooDeep() const { return nParseDepth >= 2048; }
191 void DecParseDepth() { --nParseDepth; }
195 enum SmXMLMathElemTokenMap
197 XML_TOK_MATH
200 enum SmXMLPresLayoutElemTokenMap
202 XML_TOK_SEMANTICS,
203 XML_TOK_MSTYLE,
204 XML_TOK_MERROR,
205 XML_TOK_MPHANTOM,
206 XML_TOK_MROW,
207 XML_TOK_MENCLOSE,
208 XML_TOK_MFRAC,
209 XML_TOK_MSQRT,
210 XML_TOK_MROOT,
211 XML_TOK_MSUB,
212 XML_TOK_MSUP,
213 XML_TOK_MSUBSUP,
214 XML_TOK_MMULTISCRIPTS,
215 XML_TOK_MUNDER,
216 XML_TOK_MOVER,
217 XML_TOK_MUNDEROVER,
218 XML_TOK_MTABLE,
219 XML_TOK_MACTION,
220 XML_TOK_MFENCED,
221 XML_TOK_MPADDED
224 enum SmXMLPresLayoutAttrTokenMap
226 XML_TOK_FONTWEIGHT,
227 XML_TOK_FONTSTYLE,
228 XML_TOK_FONTSIZE,
229 XML_TOK_FONTFAMILY,
230 XML_TOK_COLOR,
231 XML_TOK_MATHCOLOR,
232 XML_TOK_MATHVARIANT
236 enum SmXMLFencedAttrTokenMap
238 XML_TOK_OPEN,
239 XML_TOK_CLOSE
243 enum SmXMLPresTableElemTokenMap
245 XML_TOK_MTR,
246 XML_TOK_MTD
249 enum SmXMLPresElemTokenMap
251 XML_TOK_ANNOTATION,
252 XML_TOK_MI,
253 XML_TOK_MN,
254 XML_TOK_MO,
255 XML_TOK_MTEXT,
256 XML_TOK_MSPACE,
257 XML_TOK_MS,
258 XML_TOK_MALIGNGROUP
261 enum SmXMLPresScriptEmptyElemTokenMap
263 XML_TOK_MPRESCRIPTS,
264 XML_TOK_NONE
267 enum SmXMLOperatorAttrTokenMap
269 XML_TOK_STRETCHY
272 enum SmXMLAnnotationAttrTokenMap
274 XML_TOK_ENCODING
277 enum SmXMLActionAttrTokenMap
279 XML_TOK_SELECTION
282 enum SmXMLMspaceAttrTokenMap
284 XML_TOK_WIDTH
287 #endif
289 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */