Update ooo320-m1
[ooovba.git] / binfilter / bf_starmath / source / mathml.hxx
blobeb5ea4413140563dbcf043b0d6f97a449335d7af
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: mathml.hxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef MATHML_HXX
31 #define MATHML_HXX
32 #ifndef _SDXMLIMP_HXX
33 #include <bf_xmloff/xmlimp.hxx>
34 #endif
35 #ifndef _SDXMLEXP_HXX
36 #include <bf_xmloff/xmlexp.hxx>
37 #endif
38 #ifndef _XMLOFF_DOCUMENTSETTINGSCONTEXT_HXX
39 #include <bf_xmloff/DocumentSettingsContext.hxx>
40 #endif
41 #ifndef _XMLOFF_XMLTOKEN_HXX
42 #include <bf_xmloff/xmltoken.hxx>
43 #endif
45 #ifndef NODE_HXX
46 #include <node.hxx>
47 #endif
48 namespace com { namespace sun { namespace star {
49 namespace io {
50 class XInputStream;
51 class XOutputStream; }
52 namespace beans {
53 class XPropertySet; }
54 } } }
55 namespace binfilter {
57 class SvStorage;
58 class SfxMedium;
60 //STRIP008 namespace com { namespace sun { namespace star {
61 //STRIP008 namespace io {
62 //STRIP008 class XInputStream;
63 //STRIP008 class XOutputStream; }
64 //STRIP008 namespace beans { XPropertySet; }
65 //STRIP008 } } }
68 class SmXMLWrapper
70 public:
71 SmXMLWrapper(::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel> &rRef)
72 : xModel(rRef), bFlat(sal_True) {}
73 ULONG Import(SfxMedium &rMedium);
74 sal_Bool Export(SfxMedium &rMedium);
75 void SetFlat(sal_Bool bIn) {bFlat = bIn;}
76 private:
77 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel> xModel;
78 sal_Bool bFlat; //set true for export to flat .mml, set false for
79 //export to a .sxm (or whatever) package
81 ULONG ReadThroughComponent(
82 ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xInputStream,
83 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModelComponent,
84 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
85 const sal_Char* pFilterName,
86 sal_Bool bEncrypted );
88 ULONG ReadThroughComponent(
89 SvStorage* pStorage,
90 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModelComponent,
91 const sal_Char* pStreamName,
92 const sal_Char* pCompatibilityStreamName,
93 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
94 const sal_Char* pFilterName );
96 sal_Bool WriteThroughComponent(
97 ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
98 xOutputStream,
99 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
100 xComponent,
101 ::com::sun::star::uno::Reference<
102 ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
103 ::com::sun::star::uno::Reference<
104 ::com::sun::star::beans::XPropertySet > & rPropSet,
105 const sal_Char* pComponentName );
106 sal_Bool WriteThroughComponent(
107 SvStorage* pStorage,
108 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
109 xComponent,
110 const sal_Char* pStreamName,
111 ::com::sun::star::uno::Reference<
112 ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
113 ::com::sun::star::uno::Reference<
114 ::com::sun::star::beans::XPropertySet > & rPropSet,
115 const sal_Char* pComponentName,
116 sal_Bool bCompress=sal_True );
120 class SmXMLImport : public SvXMLImport
122 public:
123 // #110680#
124 SmXMLImport(
125 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
126 sal_uInt16 nImportFlags=IMPORT_ALL);
128 // XServiceInfo (override parent method)
129 ::rtl::OUString SAL_CALL getImplementationName()
130 throw( ::com::sun::star::uno::RuntimeException );
132 void SAL_CALL endDocument(void)
133 throw( ::com::sun::star::xml::sax::SAXException,
134 ::com::sun::star::uno::RuntimeException );
135 sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
136 sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException);
137 static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId()
138 throw();
139 SvXMLImportContext *CreateContext(sal_uInt16 nPrefix,
140 const ::rtl::OUString &rLocalName,
141 const ::com::sun::star::uno::Reference <
142 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
143 SvXMLImportContext *CreateMathContext(sal_uInt16 nPrefix,
144 const ::rtl::OUString &rLocalName,
145 const ::com::sun::star::uno::Reference <
146 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
147 SvXMLImportContext *CreateRowContext(sal_uInt16 nPrefix,
148 const ::rtl::OUString &rLocalName,
149 const ::com::sun::star::uno::Reference <
150 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
151 SvXMLImportContext *CreateFracContext(sal_uInt16 nPrefix,
152 const ::rtl::OUString &rLocalName,
153 const ::com::sun::star::uno::Reference <
154 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
155 SvXMLImportContext *CreateNumberContext(sal_uInt16 nPrefix,
156 const ::rtl::OUString &rLocalName,
157 const ::com::sun::star::uno::Reference <
158 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
159 SvXMLImportContext *CreateTextContext(sal_uInt16 nPrefix,
160 const ::rtl::OUString &rLocalName,
161 const ::com::sun::star::uno::Reference <
162 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
163 SvXMLImportContext *CreateAnnotationContext(sal_uInt16 nPrefix,
164 const ::rtl::OUString &rLocalName,
165 const ::com::sun::star::uno::Reference <
166 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
167 SvXMLImportContext *CreateStringContext(sal_uInt16 nPrefix,
168 const ::rtl::OUString &rLocalName,
169 const ::com::sun::star::uno::Reference <
170 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
171 SvXMLImportContext *CreateIdentifierContext(sal_uInt16 nPrefix,
172 const ::rtl::OUString &rLocalName,
173 const ::com::sun::star::uno::Reference <
174 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
175 SvXMLImportContext *CreateOperatorContext(sal_uInt16 nPrefix,
176 const ::rtl::OUString &rLocalName,
177 const ::com::sun::star::uno::Reference <
178 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
179 SvXMLImportContext *CreateSpaceContext(sal_uInt16 nPrefix,
180 const ::rtl::OUString &rLocalName,
181 const ::com::sun::star::uno::Reference <
182 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
183 SvXMLImportContext *CreateSqrtContext(sal_uInt16 nPrefix,
184 const ::rtl::OUString &rLocalName,
185 const ::com::sun::star::uno::Reference <
186 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
187 SvXMLImportContext *CreateRootContext(sal_uInt16 nPrefix,
188 const ::rtl::OUString &rLocalName,
189 const ::com::sun::star::uno::Reference <
190 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
191 SvXMLImportContext *CreateStyleContext(sal_uInt16 nPrefix,
192 const ::rtl::OUString &rLocalName,
193 const ::com::sun::star::uno::Reference <
194 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
195 SvXMLImportContext *CreatePaddedContext(sal_uInt16 nPrefix,
196 const ::rtl::OUString &rLocalName,
197 const ::com::sun::star::uno::Reference <
198 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
199 SvXMLImportContext *CreatePhantomContext(sal_uInt16 nPrefix,
200 const ::rtl::OUString &rLocalName,
201 const ::com::sun::star::uno::Reference <
202 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
203 SvXMLImportContext *CreateFencedContext(sal_uInt16 nPrefix,
204 const ::rtl::OUString &rLocalName,
205 const ::com::sun::star::uno::Reference <
206 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
207 SvXMLImportContext *CreateErrorContext(sal_uInt16 nPrefix,
208 const ::rtl::OUString &rLocalName,
209 const ::com::sun::star::uno::Reference <
210 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
211 SvXMLImportContext *CreateSubContext(sal_uInt16 nPrefix,
212 const ::rtl::OUString &rLocalName,
213 const ::com::sun::star::uno::Reference <
214 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
215 SvXMLImportContext *CreateSupContext(sal_uInt16 nPrefix,
216 const ::rtl::OUString &rLocalName,
217 const ::com::sun::star::uno::Reference <
218 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
219 SvXMLImportContext *CreateSubSupContext(sal_uInt16 nPrefix,
220 const ::rtl::OUString &rLocalName,
221 const ::com::sun::star::uno::Reference <
222 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
223 SvXMLImportContext *CreateUnderContext(sal_uInt16 nPrefix,
224 const ::rtl::OUString &rLocalName,
225 const ::com::sun::star::uno::Reference <
226 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
227 SvXMLImportContext *CreateOverContext(sal_uInt16 nPrefix,
228 const ::rtl::OUString &rLocalName,
229 const ::com::sun::star::uno::Reference <
230 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
231 SvXMLImportContext *CreateUnderOverContext(sal_uInt16 nPrefix,
232 const ::rtl::OUString &rLocalName,
233 const ::com::sun::star::uno::Reference <
234 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
235 SvXMLImportContext *CreateMultiScriptsContext(sal_uInt16 nPrefix,
236 const ::rtl::OUString &rLocalName,
237 const ::com::sun::star::uno::Reference <
238 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
239 SvXMLImportContext *CreateNoneContext(sal_uInt16 nPrefix,
240 const ::rtl::OUString &rLocalName,
241 const ::com::sun::star::uno::Reference <
242 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
243 SvXMLImportContext *CreatePrescriptsContext(sal_uInt16 nPrefix,
244 const ::rtl::OUString &rLocalName,
245 const ::com::sun::star::uno::Reference <
246 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
247 SvXMLImportContext *CreateTableContext(sal_uInt16 nPrefix,
248 const ::rtl::OUString &rLocalName,
249 const ::com::sun::star::uno::Reference <
250 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
251 SvXMLImportContext *CreateTableRowContext(sal_uInt16 nPrefix,
252 const ::rtl::OUString &rLocalName,
253 const ::com::sun::star::uno::Reference <
254 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
255 SvXMLImportContext *CreateTableCellContext(sal_uInt16 nPrefix,
256 const ::rtl::OUString &rLocalName,
257 const ::com::sun::star::uno::Reference <
258 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
259 SvXMLImportContext *CreateAlignGroupContext(sal_uInt16 nPrefix,
260 const ::rtl::OUString &rLocalName,
261 const ::com::sun::star::uno::Reference <
262 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
263 SvXMLImportContext *CreateActionContext(sal_uInt16 nPrefix,
264 const ::rtl::OUString &rLocalName,
265 const ::com::sun::star::uno::Reference <
266 ::com::sun::star::xml::sax::XAttributeList> &xAttrList);
267 // const SvXMLTokenMap &GetMathElemTokenMap();
268 const SvXMLTokenMap &GetPresLayoutElemTokenMap();
269 const SvXMLTokenMap &GetPresLayoutAttrTokenMap();
270 const SvXMLTokenMap &GetFencedAttrTokenMap();
271 const SvXMLTokenMap &GetOperatorAttrTokenMap();
272 const SvXMLTokenMap &GetAnnotationAttrTokenMap();
273 const SvXMLTokenMap &GetPresElemTokenMap();
274 const SvXMLTokenMap &GetPresScriptEmptyElemTokenMap();
275 const SvXMLTokenMap &GetPresTableElemTokenMap();
276 const SvXMLTokenMap &GetColorTokenMap();
277 virtual ~SmXMLImport() throw ();
278 SmNodeStack & GetNodeStack() {return aNodeStack;}
279 SmNode *GetTree() { return aNodeStack.Pop();}
280 sal_Bool GetSuccess() { return bSuccess; }
281 String &GetText() { return aText;}
283 virtual void SetViewSettings(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aViewProps);
284 virtual void SetConfigurationSettings(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aViewProps);
286 private:
287 SvXMLTokenMap *pMathElemTokenMap;
288 SvXMLTokenMap *pPresLayoutElemTokenMap;
289 SvXMLTokenMap *pPresLayoutAttrTokenMap;
290 SvXMLTokenMap *pFencedAttrTokenMap;
291 SvXMLTokenMap *pOperatorAttrTokenMap;
292 SvXMLTokenMap *pAnnotationAttrTokenMap;
293 SvXMLTokenMap *pPresElemTokenMap;
294 SvXMLTokenMap *pPresScriptEmptyElemTokenMap;
295 SvXMLTokenMap *pPresTableElemTokenMap;
296 SvXMLTokenMap *pColorTokenMap;
298 SmNodeStack aNodeStack;
299 sal_Bool bSuccess;
300 String aText;
303 enum SmXMLMathElemTokenMap
305 XML_TOK_MATH
308 enum SmXMLPresLayoutElemTokenMap
310 XML_TOK_SEMANTICS,
311 XML_TOK_MSTYLE,
312 XML_TOK_MERROR,
313 XML_TOK_MPHANTOM,
314 XML_TOK_MROW,
315 XML_TOK_MFRAC,
316 XML_TOK_MSQRT,
317 XML_TOK_MROOT,
318 XML_TOK_MSUB,
319 XML_TOK_MSUP,
320 XML_TOK_MSUBSUP,
321 XML_TOK_MMULTISCRIPTS,
322 XML_TOK_MUNDER,
323 XML_TOK_MOVER,
324 XML_TOK_MUNDEROVER,
325 XML_TOK_MTABLE,
326 XML_TOK_MACTION,
327 XML_TOK_MFENCED,
328 XML_TOK_MPADDED
331 enum SmXMLPresLayoutAttrTokenMap
333 XML_TOK_FONTWEIGHT,
334 XML_TOK_FONTSTYLE,
335 XML_TOK_FONTSIZE,
336 XML_TOK_FONTFAMILY,
337 XML_TOK_COLOR
341 enum SmXMLFencedAttrTokenMap
343 XML_TOK_OPEN,
344 XML_TOK_CLOSE
348 enum SmXMLPresTableElemTokenMap
350 XML_TOK_MTR,
351 XML_TOK_MTD
354 enum SmXMLPresElemTokenMap
356 XML_TOK_ANNOTATION,
357 XML_TOK_MI,
358 XML_TOK_MN,
359 XML_TOK_MO,
360 XML_TOK_MTEXT,
361 XML_TOK_MSPACE,
362 XML_TOK_MS,
363 XML_TOK_MALIGNGROUP
366 enum SmXMLPresScriptEmptyElemTokenMap
368 XML_TOK_MPRESCRIPTS,
369 XML_TOK_NONE
372 enum SmXMLOperatorAttrTokenMap
374 XML_TOK_STRETCHY
377 enum SmXMLAnnotationAttrTokenMap
379 XML_TOK_ENCODING
383 class SmXMLExport : public SvXMLExport
385 public:
386 // #110680#
387 SmXMLExport(
388 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
389 sal_uInt16 nExportFlags=EXPORT_ALL);
391 virtual ~SmXMLExport() {};
393 // XServiceInfo (override parent method)
394 ::rtl::OUString SAL_CALL getImplementationName()
395 throw( ::com::sun::star::uno::RuntimeException );
397 void _ExportAutoStyles() {}
398 void _ExportMasterStyles() {}
399 void _ExportContent();
400 sal_uInt32 exportDoc(enum ::binfilter::xmloff::token::XMLTokenEnum eClass);
402 virtual void GetViewSettings(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aProps);
403 virtual void GetConfigurationSettings(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aProps);
405 sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
406 sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException);
407 static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId()
408 throw();
410 sal_Bool GetSuccess() {return bSuccess;}
412 protected:
413 void ExportNodes(const SmNode *pIn,int nLevel);
414 void ExportTable(const SmNode *pIn,int nLevel);
415 void ExportLine(const SmNode *pNode,int nLevel);
416 void ExportExpression(const SmNode *pNode,int nLevel);
417 void ExportText(const SmNode *pNode, int nLevel);
418 void ExportMath(const SmNode *pNode, int nLevel);
419 void ExportPolygon(const SmNode *pNode, int nLevel);
420 void ExportBinaryHorizontal(const SmNode *pNode,int nLevel);
421 void ExportUnaryHorizontal(const SmNode *pNode,int nLevel);
422 void ExportBrace(const SmNode *pNode, int nLevel);
423 void ExportBinaryVertical(const SmNode *pNode,int nLevel);
424 void ExportSubSupScript(const SmNode *pNode,int nLevel);
425 void ExportRoot(const SmNode *pNode, int nLevel);
426 void ExportOperator(const SmNode *pNode, int nLevel);
427 void ExportAttributes(const SmNode *pNode, int nLevel);
428 void ExportFont(const SmNode *pNode, int nLevel);
429 void ExportVerticalBrace(const SmNode *pNode, int nLevel);
430 void ExportMatrix(const SmNode *pNode, int nLevel);
431 private:
432 const SmNode *pTree;
433 String aText;
434 sal_Bool bSuccess;
436 } //namespace binfilter
437 #endif