1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: mathml.hxx,v $
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 ************************************************************************/
33 #include <xmloff/xmlimp.hxx>
36 #include <xmloff/xmlexp.hxx>
38 #include <xmloff/DocumentSettingsContext.hxx>
39 #include <xmloff/xmltoken.hxx>
43 namespace com
{ namespace sun
{ namespace star
{
46 class XOutputStream
; }
55 SmXMLWrapper(com::sun::star::uno::Reference
<com::sun::star::frame::XModel
> &rRef
)
56 : xModel(rRef
), bFlat(sal_True
) {}
57 ULONG
Import(SfxMedium
&rMedium
);
58 sal_Bool
Export(SfxMedium
&rMedium
);
59 void SetFlat(sal_Bool bIn
) {bFlat
= bIn
;}
61 com::sun::star::uno::Reference
<com::sun::star::frame::XModel
> xModel
;
62 sal_Bool bFlat
; //set true for export to flat .mml, set false for
63 //export to a .sxm (or whatever) package
65 ULONG
ReadThroughComponent(
66 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XInputStream
> xInputStream
,
67 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
> xModelComponent
,
68 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> & rFactory
,
69 ::com::sun::star::uno::Reference
<
70 ::com::sun::star::beans::XPropertySet
> & rPropSet
,
71 const sal_Char
* pFilterName
,
72 sal_Bool bEncrypted
);
74 ULONG
ReadThroughComponent(
75 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& xStorage
,
76 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
> xModelComponent
,
77 const sal_Char
* pStreamName
,
78 const sal_Char
* pCompatibilityStreamName
,
79 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> & rFactory
,
80 ::com::sun::star::uno::Reference
<
81 ::com::sun::star::beans::XPropertySet
> & rPropSet
,
82 const sal_Char
* pFilterName
);
84 sal_Bool
WriteThroughComponent(
85 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XOutputStream
>
87 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
>
89 ::com::sun::star::uno::Reference
<
90 ::com::sun::star::lang::XMultiServiceFactory
> & rFactory
,
91 ::com::sun::star::uno::Reference
<
92 ::com::sun::star::beans::XPropertySet
> & rPropSet
,
93 const sal_Char
* pComponentName
);
94 sal_Bool
WriteThroughComponent(
95 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& xStor
,
96 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
>
98 const sal_Char
* pStreamName
,
99 ::com::sun::star::uno::Reference
<
100 ::com::sun::star::lang::XMultiServiceFactory
> & rFactory
,
101 ::com::sun::star::uno::Reference
<
102 ::com::sun::star::beans::XPropertySet
> & rPropSet
,
103 const sal_Char
* pComponentName
,
104 sal_Bool bCompress
=sal_True
);
108 class SmXMLImport
: public SvXMLImport
113 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xServiceFactory
,
114 sal_uInt16 nImportFlags
=IMPORT_ALL
);
116 #ifdef TL_NOT_USED_YET
119 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xServiceFactory
,
120 com::sun::star::uno::Reference
<com::sun::star::frame::XModel
> &rModel
,
121 const rtl::OUString
&rFileName
);
122 #endif //TL_NOT_USED_YET
124 // XServiceInfo (override parent method)
125 ::rtl::OUString SAL_CALL
getImplementationName()
126 throw( ::com::sun::star::uno::RuntimeException
);
128 void SAL_CALL
endDocument(void)
129 throw( ::com::sun::star::xml::sax::SAXException
,
130 ::com::sun::star::uno::RuntimeException
);
131 sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
<
132 sal_Int8
>& rId
) throw(::com::sun::star::uno::RuntimeException
);
133 static const ::com::sun::star::uno::Sequence
< sal_Int8
> & getUnoTunnelId()
135 SvXMLImportContext
*CreateContext(sal_uInt16 nPrefix
,
136 const rtl::OUString
&rLocalName
,
137 const com::sun::star::uno::Reference
<
138 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
139 SvXMLImportContext
*CreateMathContext(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
*CreateRowContext(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
*CreateFracContext(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
*CreateNumberContext(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
*CreateTextContext(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
*CreateAnnotationContext(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
*CreateStringContext(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
*CreateIdentifierContext(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
*CreateOperatorContext(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
*CreateSpaceContext(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
*CreateSqrtContext(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
*CreateRootContext(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
*CreateStyleContext(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
*CreatePaddedContext(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
*CreatePhantomContext(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
*CreateFencedContext(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
*CreateErrorContext(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
*CreateSubContext(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
*CreateSupContext(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
*CreateSubSupContext(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
*CreateUnderContext(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
*CreateOverContext(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
*CreateUnderOverContext(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
*CreateMultiScriptsContext(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
*CreateNoneContext(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
*CreatePrescriptsContext(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
*CreateTableContext(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
*CreateTableRowContext(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
*CreateTableCellContext(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
*CreateAlignGroupContext(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
*CreateActionContext(sal_uInt16 nPrefix
,
260 const rtl::OUString
&rLocalName
,
261 const com::sun::star::uno::Reference
<
262 com::sun::star::xml::sax::XAttributeList
> &xAttrList
);
264 const SvXMLTokenMap
&GetPresLayoutElemTokenMap();
265 const SvXMLTokenMap
&GetPresLayoutAttrTokenMap();
266 const SvXMLTokenMap
&GetFencedAttrTokenMap();
267 const SvXMLTokenMap
&GetOperatorAttrTokenMap();
268 const SvXMLTokenMap
&GetAnnotationAttrTokenMap();
269 const SvXMLTokenMap
&GetPresElemTokenMap();
270 const SvXMLTokenMap
&GetPresScriptEmptyElemTokenMap();
271 const SvXMLTokenMap
&GetPresTableElemTokenMap();
272 const SvXMLTokenMap
&GetColorTokenMap();
273 virtual ~SmXMLImport() throw ();
274 SmNodeStack
& GetNodeStack() {return aNodeStack
;}
275 SmNode
*GetTree() { return aNodeStack
.Pop();}
276 sal_Bool
GetSuccess() { return bSuccess
; }
277 String
&GetText() { return aText
;}
279 virtual void SetViewSettings(const com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
>& aViewProps
);
280 virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
>& aViewProps
);
283 SvXMLTokenMap
*pPresLayoutElemTokenMap
;
284 SvXMLTokenMap
*pPresLayoutAttrTokenMap
;
285 SvXMLTokenMap
*pFencedAttrTokenMap
;
286 SvXMLTokenMap
*pOperatorAttrTokenMap
;
287 SvXMLTokenMap
*pAnnotationAttrTokenMap
;
288 SvXMLTokenMap
*pPresElemTokenMap
;
289 SvXMLTokenMap
*pPresScriptEmptyElemTokenMap
;
290 SvXMLTokenMap
*pPresTableElemTokenMap
;
291 SvXMLTokenMap
*pColorTokenMap
;
293 SmNodeStack aNodeStack
;
298 enum SmXMLMathElemTokenMap
303 enum SmXMLPresLayoutElemTokenMap
316 XML_TOK_MMULTISCRIPTS
,
326 enum SmXMLPresLayoutAttrTokenMap
336 enum SmXMLFencedAttrTokenMap
343 enum SmXMLPresTableElemTokenMap
349 enum SmXMLPresElemTokenMap
361 enum SmXMLPresScriptEmptyElemTokenMap
367 enum SmXMLOperatorAttrTokenMap
372 enum SmXMLAnnotationAttrTokenMap
378 class SmXMLExport
: public SvXMLExport
383 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xServiceFactory
,
384 sal_uInt16 nExportFlags
=EXPORT_ALL
);
386 #ifdef TL_NOT_USED_YET
389 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xServiceFactory
,
391 const rtl::OUString
&rFileName
,
392 com::sun::star::uno::Reference
< com::sun::star::xml::sax::XDocumentHandler
> &rHandler
);
393 #endif //TL_NOT_USED_YET
395 virtual ~SmXMLExport() {};
397 // XServiceInfo (override parent method)
398 ::rtl::OUString SAL_CALL
getImplementationName()
399 throw( ::com::sun::star::uno::RuntimeException
);
401 void _ExportAutoStyles() {}
402 void _ExportMasterStyles() {}
403 void _ExportContent();
404 sal_uInt32
exportDoc(enum ::xmloff::token::XMLTokenEnum eClass
);
406 virtual void GetViewSettings(com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
>& aProps
);
407 virtual void GetConfigurationSettings(com::sun::star::uno::Sequence
<com::sun::star::beans::PropertyValue
>& aProps
);
409 sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
<
410 sal_Int8
>& rId
) throw(::com::sun::star::uno::RuntimeException
);
411 static const ::com::sun::star::uno::Sequence
< sal_Int8
> & getUnoTunnelId()
414 sal_Bool
GetSuccess() {return bSuccess
;}
417 void ExportNodes(const SmNode
*pIn
,int nLevel
);
418 void ExportTable(const SmNode
*pIn
,int nLevel
);
419 void ExportLine(const SmNode
*pNode
,int nLevel
);
420 void ExportExpression(const SmNode
*pNode
,int nLevel
);
421 void ExportText(const SmNode
*pNode
, int nLevel
);
422 void ExportMath(const SmNode
*pNode
, int nLevel
);
423 void ExportPolygon(const SmNode
*pNode
, int nLevel
);
424 void ExportBinaryHorizontal(const SmNode
*pNode
,int nLevel
);
425 void ExportUnaryHorizontal(const SmNode
*pNode
,int nLevel
);
426 void ExportBrace(const SmNode
*pNode
, int nLevel
);
427 void ExportBinaryVertical(const SmNode
*pNode
,int nLevel
);
428 void ExportSubSupScript(const SmNode
*pNode
,int nLevel
);
429 void ExportRoot(const SmNode
*pNode
, int nLevel
);
430 void ExportOperator(const SmNode
*pNode
, int nLevel
);
431 void ExportAttributes(const SmNode
*pNode
, int nLevel
);
432 void ExportFont(const SmNode
*pNode
, int nLevel
);
433 void ExportVerticalBrace(const SmNode
*pNode
, int nLevel
);
434 void ExportMatrix(const SmNode
*pNode
, int nLevel
);
435 void ExportBlank(const SmNode
*pNode
, int nLevel
);