Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #ifndef _MATHMLIMPORT_HXX_
21 : : #define _MATHMLIMPORT_HXX_
22 : :
23 : : #include <xmloff/xmlimp.hxx>
24 : : #include <xmloff/xmlexp.hxx>
25 : : #include <xmloff/DocumentSettingsContext.hxx>
26 : : #include <xmloff/xmltoken.hxx>
27 : :
28 : : #include <node.hxx>
29 : :
30 : : class SfxMedium;
31 : : namespace com { namespace sun { namespace star {
32 : : namespace io {
33 : : class XIutputStream; }
34 : : namespace beans {
35 : : class XPropertySet; }
36 : : } } }
37 : :
38 : : ////////////////////////////////////////////////////////////
39 : :
40 : 0 : class SmXMLImportWrapper
41 : : {
42 : : com::sun::star::uno::Reference<com::sun::star::frame::XModel> xModel;
43 : :
44 : : public:
45 : 0 : SmXMLImportWrapper(com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rRef)
46 : 0 : : xModel(rRef) {}
47 : :
48 : : sal_uLong Import(SfxMedium &rMedium);
49 : :
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::lang::XMultiServiceFactory > & rFactory,
54 : : ::com::sun::star::uno::Reference<
55 : : ::com::sun::star::beans::XPropertySet > & rPropSet,
56 : : const sal_Char* pFilterName,
57 : : sal_Bool bEncrypted );
58 : :
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::lang::XMultiServiceFactory > & rFactory,
65 : : ::com::sun::star::uno::Reference<
66 : : ::com::sun::star::beans::XPropertySet > & rPropSet,
67 : : const sal_Char* pFilterName );
68 : : };
69 : :
70 : : ////////////////////////////////////////////////////////////
71 : :
72 : : class SmXMLImport : public SvXMLImport
73 : : {
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;
83 : :
84 : : SmNodeStack aNodeStack;
85 : : sal_Bool bSuccess;
86 : : String aText;
87 : :
88 : : public:
89 : : SmXMLImport(
90 : : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
91 : : sal_uInt16 nImportFlags=IMPORT_ALL);
92 : : virtual ~SmXMLImport() throw ();
93 : :
94 : : // XServiceInfo (override parent method)
95 : : ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
96 : :
97 : : // XUnoTunnel
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();
100 : :
101 : : void SAL_CALL endDocument(void)
102 : : throw( ::com::sun::star::xml::sax::SAXException,
103 : : ::com::sun::star::uno::RuntimeException );
104 : :
105 : : SvXMLImportContext *CreateContext(sal_uInt16 nPrefix,
106 : : const rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::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 rtl::OUString &rLocalName,
231 : : const com::sun::star::uno::Reference <
232 : : com::sun::star::xml::sax::XAttributeList> &xAttrList);
233 : :
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();
243 : :
244 : 0 : SmNodeStack & GetNodeStack() { return aNodeStack; }
245 : 0 : SmNode *GetTree()
246 : : {
247 [ # # ]: 0 : if (aNodeStack.empty())
248 : 0 : return 0;
249 : 0 : SmNode* result = aNodeStack.top();
250 : 0 : aNodeStack.pop();
251 : 0 : return result;
252 : : }
253 : :
254 : 0 : sal_Bool GetSuccess() { return bSuccess; }
255 : 0 : String &GetText() { return aText; }
256 : :
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);
259 : : };
260 : :
261 : : ////////////////////////////////////////////////////////////
262 : :
263 : : enum SmXMLMathElemTokenMap
264 : : {
265 : : XML_TOK_MATH
266 : : };
267 : :
268 : : enum SmXMLPresLayoutElemTokenMap
269 : : {
270 : : XML_TOK_SEMANTICS,
271 : : XML_TOK_MSTYLE,
272 : : XML_TOK_MERROR,
273 : : XML_TOK_MPHANTOM,
274 : : XML_TOK_MROW,
275 : : XML_TOK_MFRAC,
276 : : XML_TOK_MSQRT,
277 : : XML_TOK_MROOT,
278 : : XML_TOK_MSUB,
279 : : XML_TOK_MSUP,
280 : : XML_TOK_MSUBSUP,
281 : : XML_TOK_MMULTISCRIPTS,
282 : : XML_TOK_MUNDER,
283 : : XML_TOK_MOVER,
284 : : XML_TOK_MUNDEROVER,
285 : : XML_TOK_MTABLE,
286 : : XML_TOK_MACTION,
287 : : XML_TOK_MFENCED,
288 : : XML_TOK_MPADDED
289 : : };
290 : :
291 : : enum SmXMLPresLayoutAttrTokenMap
292 : : {
293 : : XML_TOK_FONTWEIGHT,
294 : : XML_TOK_FONTSTYLE,
295 : : XML_TOK_FONTSIZE,
296 : : XML_TOK_FONTFAMILY,
297 : : XML_TOK_COLOR
298 : : };
299 : :
300 : :
301 : : enum SmXMLFencedAttrTokenMap
302 : : {
303 : : XML_TOK_OPEN,
304 : : XML_TOK_CLOSE
305 : : };
306 : :
307 : :
308 : : enum SmXMLPresTableElemTokenMap
309 : : {
310 : : XML_TOK_MTR,
311 : : XML_TOK_MTD
312 : : };
313 : :
314 : : enum SmXMLPresElemTokenMap
315 : : {
316 : : XML_TOK_ANNOTATION,
317 : : XML_TOK_MI,
318 : : XML_TOK_MN,
319 : : XML_TOK_MO,
320 : : XML_TOK_MTEXT,
321 : : XML_TOK_MSPACE,
322 : : XML_TOK_MS,
323 : : XML_TOK_MALIGNGROUP
324 : : };
325 : :
326 : : enum SmXMLPresScriptEmptyElemTokenMap
327 : : {
328 : : XML_TOK_MPRESCRIPTS,
329 : : XML_TOK_NONE
330 : : };
331 : :
332 : : enum SmXMLOperatorAttrTokenMap
333 : : {
334 : : XML_TOK_STRETCHY
335 : : };
336 : :
337 : : enum SmXMLAnnotationAttrTokenMap
338 : : {
339 : : XML_TOK_ENCODING
340 : : };
341 : :
342 : : ////////////////////////////////////////////////////////////
343 : :
344 : : #endif
345 : :
346 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|