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>
30 namespace com
{ namespace sun
{ namespace star
{
36 typedef std::deque
<std::unique_ptr
<SmNode
>> SmNodeStack
;
38 class SmXMLImportWrapper
40 css::uno::Reference
<css::frame::XModel
> xModel
;
43 explicit SmXMLImportWrapper(css::uno::Reference
<css::frame::XModel
> const &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
,
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
;
88 const css::uno::Reference
< css::uno::XComponentContext
>& rContext
,
89 OUString
const & implementationName
, SvXMLImportFlags nImportFlags
);
90 virtual ~SmXMLImport() throw () override
;
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
200 enum SmXMLPresLayoutElemTokenMap
214 XML_TOK_MMULTISCRIPTS
,
224 enum SmXMLPresLayoutAttrTokenMap
236 enum SmXMLFencedAttrTokenMap
243 enum SmXMLPresTableElemTokenMap
249 enum SmXMLPresElemTokenMap
261 enum SmXMLPresScriptEmptyElemTokenMap
267 enum SmXMLOperatorAttrTokenMap
272 enum SmXMLAnnotationAttrTokenMap
277 enum SmXMLActionAttrTokenMap
282 enum SmXMLMspaceAttrTokenMap
289 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */