1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
31 namespace com
{ namespace sun
{ namespace star
{
37 typedef std::deque
<std::unique_ptr
<SmNode
>> SmNodeStack
;
39 class SmXMLImportWrapper
41 css::uno::Reference
<css::frame::XModel
> xModel
;
44 explicit SmXMLImportWrapper(css::uno::Reference
<css::frame::XModel
> const &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
,
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
;
89 const css::uno::Reference
< css::uno::XComponentContext
>& rContext
,
90 OUString
const & implementationName
, SvXMLImportFlags nImportFlags
);
91 virtual ~SmXMLImport() throw () override
;
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
201 enum SmXMLPresLayoutElemTokenMap
215 XML_TOK_MMULTISCRIPTS
,
225 enum SmXMLPresLayoutAttrTokenMap
237 enum SmXMLFencedAttrTokenMap
244 enum SmXMLPresTableElemTokenMap
250 enum SmXMLPresElemTokenMap
262 enum SmXMLPresScriptEmptyElemTokenMap
268 enum SmXMLOperatorAttrTokenMap
273 enum SmXMLAnnotationAttrTokenMap
278 enum SmXMLActionAttrTokenMap
283 enum SmXMLMspaceAttrTokenMap
290 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */