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 _MATHMLIMPORT_HXX_
21 #define _MATHMLIMPORT_HXX_
23 #include <xmloff/xmlimp.hxx>
24 #include <xmloff/xmlexp.hxx>
25 #include <xmloff/DocumentSettingsContext.hxx>
26 #include <xmloff/xmltoken.hxx>
31 namespace com
{ namespace sun
{ namespace star
{
33 class XIutputStream
; }
38 ////////////////////////////////////////////////////////////
40 class SmXMLImportWrapper
42 com::sun::star::uno::Reference
<com::sun::star::frame::XModel
> xModel
;
45 SmXMLImportWrapper(com::sun::star::uno::Reference
<com::sun::star::frame::XModel
> &rRef
)
48 sal_uLong
Import(SfxMedium
&rMedium
);
50 sal_uLong
ReadThroughComponent(
51 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XInputStream
> xInputStream
,
52 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
> xModelComponent
,
53 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> & rxContext
,
54 ::com::sun::star::uno::Reference
<
55 ::com::sun::star::beans::XPropertySet
> & rPropSet
,
56 const sal_Char
* pFilterName
,
57 sal_Bool bEncrypted
);
59 sal_uLong
ReadThroughComponent(
60 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& xStorage
,
61 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
> xModelComponent
,
62 const sal_Char
* pStreamName
,
63 const sal_Char
* pCompatibilityStreamName
,
64 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> & rxContext
,
65 ::com::sun::star::uno::Reference
<
66 ::com::sun::star::beans::XPropertySet
> & rPropSet
,
67 const sal_Char
* pFilterName
);
70 ////////////////////////////////////////////////////////////
72 class SmXMLImport
: public SvXMLImport
74 SvXMLTokenMap
*pPresLayoutElemTokenMap
;
75 SvXMLTokenMap
*pPresLayoutAttrTokenMap
;
76 SvXMLTokenMap
*pFencedAttrTokenMap
;
77 SvXMLTokenMap
*pOperatorAttrTokenMap
;
78 SvXMLTokenMap
*pAnnotationAttrTokenMap
;
79 SvXMLTokenMap
*pPresElemTokenMap
;
80 SvXMLTokenMap
*pPresScriptEmptyElemTokenMap
;
81 SvXMLTokenMap
*pPresTableElemTokenMap
;
82 SvXMLTokenMap
*pColorTokenMap
;
84 SmNodeStack aNodeStack
;
90 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> xContext
,
91 sal_uInt16 nImportFlags
=IMPORT_ALL
);
92 virtual ~SmXMLImport() throw ();
94 // XServiceInfo (override parent method)
95 OUString SAL_CALL
getImplementationName() throw( ::com::sun::star::uno::RuntimeException
);
98 sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& rId
) throw(::com::sun::star::uno::RuntimeException
);
99 static const ::com::sun::star::uno::Sequence
< sal_Int8
> & getUnoTunnelId() throw();
101 void SAL_CALL
endDocument(void)
102 throw( ::com::sun::star::xml::sax::SAXException
,
103 ::com::sun::star::uno::RuntimeException
);
105 SvXMLImportContext
*CreateContext(sal_uInt16 nPrefix
,
106 const OUString
&rLocalName
,
107 const com::sun::star::uno::Reference
<
108 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
109 SvXMLImportContext
*CreateMathContext(sal_uInt16 nPrefix
,
110 const OUString
&rLocalName
,
111 const com::sun::star::uno::Reference
<
112 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
113 SvXMLImportContext
*CreateRowContext(sal_uInt16 nPrefix
,
114 const OUString
&rLocalName
,
115 const com::sun::star::uno::Reference
<
116 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
117 SvXMLImportContext
*CreateFracContext(sal_uInt16 nPrefix
,
118 const OUString
&rLocalName
,
119 const com::sun::star::uno::Reference
<
120 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
121 SvXMLImportContext
*CreateNumberContext(sal_uInt16 nPrefix
,
122 const OUString
&rLocalName
,
123 const com::sun::star::uno::Reference
<
124 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
125 SvXMLImportContext
*CreateTextContext(sal_uInt16 nPrefix
,
126 const OUString
&rLocalName
,
127 const com::sun::star::uno::Reference
<
128 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
129 SvXMLImportContext
*CreateAnnotationContext(sal_uInt16 nPrefix
,
130 const OUString
&rLocalName
,
131 const com::sun::star::uno::Reference
<
132 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
133 SvXMLImportContext
*CreateStringContext(sal_uInt16 nPrefix
,
134 const OUString
&rLocalName
,
135 const com::sun::star::uno::Reference
<
136 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
137 SvXMLImportContext
*CreateIdentifierContext(sal_uInt16 nPrefix
,
138 const OUString
&rLocalName
,
139 const com::sun::star::uno::Reference
<
140 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
141 SvXMLImportContext
*CreateOperatorContext(sal_uInt16 nPrefix
,
142 const OUString
&rLocalName
,
143 const com::sun::star::uno::Reference
<
144 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
145 SvXMLImportContext
*CreateSpaceContext(sal_uInt16 nPrefix
,
146 const OUString
&rLocalName
,
147 const com::sun::star::uno::Reference
<
148 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
149 SvXMLImportContext
*CreateSqrtContext(sal_uInt16 nPrefix
,
150 const OUString
&rLocalName
,
151 const com::sun::star::uno::Reference
<
152 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
153 SvXMLImportContext
*CreateRootContext(sal_uInt16 nPrefix
,
154 const OUString
&rLocalName
,
155 const com::sun::star::uno::Reference
<
156 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
157 SvXMLImportContext
*CreateStyleContext(sal_uInt16 nPrefix
,
158 const OUString
&rLocalName
,
159 const com::sun::star::uno::Reference
<
160 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
161 SvXMLImportContext
*CreatePaddedContext(sal_uInt16 nPrefix
,
162 const OUString
&rLocalName
,
163 const com::sun::star::uno::Reference
<
164 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
165 SvXMLImportContext
*CreatePhantomContext(sal_uInt16 nPrefix
,
166 const OUString
&rLocalName
,
167 const com::sun::star::uno::Reference
<
168 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
169 SvXMLImportContext
*CreateFencedContext(sal_uInt16 nPrefix
,
170 const OUString
&rLocalName
,
171 const com::sun::star::uno::Reference
<
172 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
173 SvXMLImportContext
*CreateErrorContext(sal_uInt16 nPrefix
,
174 const OUString
&rLocalName
,
175 const com::sun::star::uno::Reference
<
176 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
177 SvXMLImportContext
*CreateSubContext(sal_uInt16 nPrefix
,
178 const OUString
&rLocalName
,
179 const com::sun::star::uno::Reference
<
180 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
181 SvXMLImportContext
*CreateSupContext(sal_uInt16 nPrefix
,
182 const OUString
&rLocalName
,
183 const com::sun::star::uno::Reference
<
184 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
185 SvXMLImportContext
*CreateSubSupContext(sal_uInt16 nPrefix
,
186 const OUString
&rLocalName
,
187 const com::sun::star::uno::Reference
<
188 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
189 SvXMLImportContext
*CreateUnderContext(sal_uInt16 nPrefix
,
190 const OUString
&rLocalName
,
191 const com::sun::star::uno::Reference
<
192 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
193 SvXMLImportContext
*CreateOverContext(sal_uInt16 nPrefix
,
194 const OUString
&rLocalName
,
195 const com::sun::star::uno::Reference
<
196 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
197 SvXMLImportContext
*CreateUnderOverContext(sal_uInt16 nPrefix
,
198 const OUString
&rLocalName
,
199 const com::sun::star::uno::Reference
<
200 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
201 SvXMLImportContext
*CreateMultiScriptsContext(sal_uInt16 nPrefix
,
202 const OUString
&rLocalName
,
203 const com::sun::star::uno::Reference
<
204 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
205 SvXMLImportContext
*CreateNoneContext(sal_uInt16 nPrefix
,
206 const OUString
&rLocalName
,
207 const com::sun::star::uno::Reference
<
208 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
209 SvXMLImportContext
*CreatePrescriptsContext(sal_uInt16 nPrefix
,
210 const OUString
&rLocalName
,
211 const com::sun::star::uno::Reference
<
212 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
213 SvXMLImportContext
*CreateTableContext(sal_uInt16 nPrefix
,
214 const OUString
&rLocalName
,
215 const com::sun::star::uno::Reference
<
216 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
217 SvXMLImportContext
*CreateTableRowContext(sal_uInt16 nPrefix
,
218 const OUString
&rLocalName
,
219 const com::sun::star::uno::Reference
<
220 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
221 SvXMLImportContext
*CreateTableCellContext(sal_uInt16 nPrefix
,
222 const OUString
&rLocalName
,
223 const com::sun::star::uno::Reference
<
224 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
225 SvXMLImportContext
*CreateAlignGroupContext(sal_uInt16 nPrefix
,
226 const OUString
&rLocalName
,
227 const com::sun::star::uno::Reference
<
228 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
229 SvXMLImportContext
*CreateActionContext(sal_uInt16 nPrefix
,
230 const OUString
&rLocalName
,
231 const com::sun::star::uno::Reference
<
232 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
234 const SvXMLTokenMap
&GetPresLayoutElemTokenMap();
235 const SvXMLTokenMap
&GetPresLayoutAttrTokenMap();
236 const SvXMLTokenMap
&GetFencedAttrTokenMap();
237 const SvXMLTokenMap
&GetOperatorAttrTokenMap();
238 const SvXMLTokenMap
&GetAnnotationAttrTokenMap();
239 const SvXMLTokenMap
&GetPresElemTokenMap();
240 const SvXMLTokenMap
&GetPresScriptEmptyElemTokenMap();
241 const SvXMLTokenMap
&GetPresTableElemTokenMap();
242 const SvXMLTokenMap
&GetColorTokenMap();
244 SmNodeStack
& GetNodeStack() { return aNodeStack
; }
247 if (aNodeStack
.empty())
249 SmNode
* result
= aNodeStack
.top();
254 sal_Bool
GetSuccess() { return bSuccess
; }
255 String
&GetText() { return aText
; }
257 virtual void SetViewSettings(const com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
>& aViewProps
);
258 virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
>& aViewProps
);
261 ////////////////////////////////////////////////////////////
263 enum SmXMLMathElemTokenMap
268 enum SmXMLPresLayoutElemTokenMap
281 XML_TOK_MMULTISCRIPTS
,
291 enum SmXMLPresLayoutAttrTokenMap
301 enum SmXMLFencedAttrTokenMap
308 enum SmXMLPresTableElemTokenMap
314 enum SmXMLPresElemTokenMap
326 enum SmXMLPresScriptEmptyElemTokenMap
332 enum SmXMLOperatorAttrTokenMap
337 enum SmXMLAnnotationAttrTokenMap
342 ////////////////////////////////////////////////////////////
346 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */