/Users/ericb/Desktop/SRC680_m247/starmath/source/mathml.hxx

Go to the documentation of this file.
00001 /*************************************************************************
00002  *
00003  *  OpenOffice.org - a multi-platform office productivity suite
00004  *
00005  *  $RCSfile: mathml.hxx,v $
00006  *
00007  *  $Revision: 1.28 $
00008  *
00009  *  last change: $Author: kz $ $Date: 2005/10/05 15:01:38 $
00010  *
00011  *  The Contents of this file are made available subject to
00012  *  the terms of GNU Lesser General Public License Version 2.1.
00013  *
00014  *
00015  *    GNU Lesser General Public License Version 2.1
00016  *    =============================================
00017  *    Copyright 2005 by Sun Microsystems, Inc.
00018  *    901 San Antonio Road, Palo Alto, CA 94303, USA
00019  *
00020  *    This library is free software; you can redistribute it and/or
00021  *    modify it under the terms of the GNU Lesser General Public
00022  *    License version 2.1, as published by the Free Software Foundation.
00023  *
00024  *    This library is distributed in the hope that it will be useful,
00025  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00026  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00027  *    Lesser General Public License for more details.
00028  *
00029  *    You should have received a copy of the GNU Lesser General Public
00030  *    License along with this library; if not, write to the Free Software
00031  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00032  *    MA  02111-1307  USA
00033  *
00034  ************************************************************************/
00035 #ifndef MATHML_HXX
00036 #define MATHML_HXX
00037 #ifndef _SDXMLIMP_HXX
00038 #include <xmloff/xmlimp.hxx>
00039 #endif
00040 #ifndef _SDXMLEXP_HXX
00041 #include <xmloff/xmlexp.hxx>
00042 #endif
00043 #ifndef _XMLOFF_DOCUMENTSETTINGSCONTEXT_HXX
00044 #include <xmloff/DocumentSettingsContext.hxx>
00045 #endif
00046 #ifndef _XMLOFF_XMLTOKEN_HXX
00047 #include <xmloff/xmltoken.hxx>
00048 #endif
00049 
00050 #ifndef NODE_HXX
00051 #include <node.hxx>
00052 #endif
00053 
00054 class SfxMedium;
00055 namespace com { namespace sun { namespace star {
00056         namespace io {
00057                 class XInputStream;
00058                 class XOutputStream; }
00059     namespace beans {
00060         class XPropertySet; }
00061 } } }
00062 
00063 
00064 class SmXMLWrapper
00065 {
00066 public:
00067         SmXMLWrapper(com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rRef)
00068                 : xModel(rRef), bFlat(sal_True) {}
00069     ULONG Import(SfxMedium &rMedium);
00070         sal_Bool Export(SfxMedium &rMedium);
00071         void SetFlat(sal_Bool bIn) {bFlat = bIn;}
00072 private:
00073         com::sun::star::uno::Reference<com::sun::star::frame::XModel> xModel;
00074         sal_Bool bFlat;         //set true for export to flat .mml, set false for
00075                                                 //export to a .sxm (or whatever) package
00076 
00077     ULONG ReadThroughComponent(
00078                 ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xInputStream,
00079                 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModelComponent,
00080                 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
00081                 ::com::sun::star::uno::Reference< 
00082             ::com::sun::star::beans::XPropertySet > & rPropSet,
00083         const sal_Char* pFilterName,
00084         sal_Bool bEncrypted );
00085 
00086     ULONG ReadThroughComponent(
00087          const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
00088                 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModelComponent,
00089                 const sal_Char* pStreamName,
00090                 const sal_Char* pCompatibilityStreamName,
00091                 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
00092                 ::com::sun::star::uno::Reference< 
00093             ::com::sun::star::beans::XPropertySet > & rPropSet,
00094                 const sal_Char* pFilterName );
00095 
00096         sal_Bool WriteThroughComponent(
00097                 ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
00098             xOutputStream,
00099                 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
00100             xComponent,
00101                 ::com::sun::star::uno::Reference<
00102             ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
00103                 ::com::sun::star::uno::Reference<
00104             ::com::sun::star::beans::XPropertySet > & rPropSet,
00105                 const sal_Char* pComponentName );
00106         sal_Bool WriteThroughComponent(
00107         const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStor,
00108                 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
00109             xComponent,
00110                 const sal_Char* pStreamName,
00111                 ::com::sun::star::uno::Reference<
00112             ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
00113                 ::com::sun::star::uno::Reference<
00114             ::com::sun::star::beans::XPropertySet > & rPropSet,
00115                 const sal_Char* pComponentName,
00116                 sal_Bool bCompress=sal_True );
00117 };
00118 
00119 
00120 class SmXMLImport : public SvXMLImport
00121 {
00122 public:
00123         // #110680#
00124         SmXMLImport(
00125                 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
00126                 sal_uInt16 nImportFlags=IMPORT_ALL);
00127 
00128         // #110680#
00129         SmXMLImport(
00130                 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
00131                 com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rModel,
00132                 const rtl::OUString &rFileName);
00133     
00134     // XServiceInfo (override parent method)
00135     ::rtl::OUString SAL_CALL getImplementationName()
00136         throw( ::com::sun::star::uno::RuntimeException );
00137 
00138     void SAL_CALL endDocument(void)
00139                 throw( ::com::sun::star::xml::sax::SAXException,
00140                 ::com::sun::star::uno::RuntimeException );
00141         sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
00142                 sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException);
00143         static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId()
00144                 throw();
00145         SvXMLImportContext *CreateContext(sal_uInt16 nPrefix,
00146                 const rtl::OUString &rLocalName,
00147                 const com::sun::star::uno::Reference <
00148                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00149         SvXMLImportContext *CreateMathContext(sal_uInt16 nPrefix,
00150                 const rtl::OUString &rLocalName,
00151                 const com::sun::star::uno::Reference <
00152                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00153         SvXMLImportContext *CreateRowContext(sal_uInt16 nPrefix,
00154                 const rtl::OUString &rLocalName,
00155                 const com::sun::star::uno::Reference <
00156                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00157         SvXMLImportContext *CreateFracContext(sal_uInt16 nPrefix,
00158                 const rtl::OUString &rLocalName,
00159                 const com::sun::star::uno::Reference <
00160                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00161         SvXMLImportContext *CreateNumberContext(sal_uInt16 nPrefix,
00162                 const rtl::OUString &rLocalName,
00163                 const com::sun::star::uno::Reference <
00164                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00165         SvXMLImportContext *CreateTextContext(sal_uInt16 nPrefix,
00166                 const rtl::OUString &rLocalName,
00167                 const com::sun::star::uno::Reference <
00168                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00169         SvXMLImportContext *CreateAnnotationContext(sal_uInt16 nPrefix,
00170                 const rtl::OUString &rLocalName,
00171                 const com::sun::star::uno::Reference <
00172                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00173         SvXMLImportContext *CreateStringContext(sal_uInt16 nPrefix,
00174                 const rtl::OUString &rLocalName,
00175                 const com::sun::star::uno::Reference <
00176                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00177         SvXMLImportContext *CreateIdentifierContext(sal_uInt16 nPrefix,
00178                 const rtl::OUString &rLocalName,
00179                 const com::sun::star::uno::Reference <
00180                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00181         SvXMLImportContext *CreateOperatorContext(sal_uInt16 nPrefix,
00182                 const rtl::OUString &rLocalName,
00183                 const com::sun::star::uno::Reference <
00184                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00185         SvXMLImportContext *CreateSpaceContext(sal_uInt16 nPrefix,
00186                 const rtl::OUString &rLocalName,
00187                 const com::sun::star::uno::Reference <
00188                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00189         SvXMLImportContext *CreateSqrtContext(sal_uInt16 nPrefix,
00190                 const rtl::OUString &rLocalName,
00191                 const com::sun::star::uno::Reference <
00192                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00193         SvXMLImportContext *CreateRootContext(sal_uInt16 nPrefix,
00194                 const rtl::OUString &rLocalName,
00195                 const com::sun::star::uno::Reference <
00196                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00197         SvXMLImportContext *CreateStyleContext(sal_uInt16 nPrefix,
00198                 const rtl::OUString &rLocalName,
00199                 const com::sun::star::uno::Reference <
00200                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00201         SvXMLImportContext *CreatePaddedContext(sal_uInt16 nPrefix,
00202                 const rtl::OUString &rLocalName,
00203                 const com::sun::star::uno::Reference <
00204                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00205         SvXMLImportContext *CreatePhantomContext(sal_uInt16 nPrefix,
00206                 const rtl::OUString &rLocalName,
00207                 const com::sun::star::uno::Reference <
00208                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00209         SvXMLImportContext *CreateFencedContext(sal_uInt16 nPrefix,
00210                 const rtl::OUString &rLocalName,
00211                 const com::sun::star::uno::Reference <
00212                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00213         SvXMLImportContext *CreateErrorContext(sal_uInt16 nPrefix,
00214                 const rtl::OUString &rLocalName,
00215                 const com::sun::star::uno::Reference <
00216                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00217         SvXMLImportContext *CreateSubContext(sal_uInt16 nPrefix,
00218                 const rtl::OUString &rLocalName,
00219                 const com::sun::star::uno::Reference <
00220                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00221         SvXMLImportContext *CreateSupContext(sal_uInt16 nPrefix,
00222                 const rtl::OUString &rLocalName,
00223                 const com::sun::star::uno::Reference <
00224                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00225         SvXMLImportContext *CreateSubSupContext(sal_uInt16 nPrefix,
00226                 const rtl::OUString &rLocalName,
00227                 const com::sun::star::uno::Reference <
00228                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00229         SvXMLImportContext *CreateUnderContext(sal_uInt16 nPrefix,
00230                 const rtl::OUString &rLocalName,
00231                 const com::sun::star::uno::Reference <
00232                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00233         SvXMLImportContext *CreateOverContext(sal_uInt16 nPrefix,
00234                 const rtl::OUString &rLocalName,
00235                 const com::sun::star::uno::Reference <
00236                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00237         SvXMLImportContext *CreateUnderOverContext(sal_uInt16 nPrefix,
00238                 const rtl::OUString &rLocalName,
00239                 const com::sun::star::uno::Reference <
00240                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00241         SvXMLImportContext *CreateMultiScriptsContext(sal_uInt16 nPrefix,
00242                 const rtl::OUString &rLocalName,
00243                 const com::sun::star::uno::Reference <
00244                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00245         SvXMLImportContext *CreateNoneContext(sal_uInt16 nPrefix,
00246                 const rtl::OUString &rLocalName,
00247                 const com::sun::star::uno::Reference <
00248                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00249         SvXMLImportContext *CreatePrescriptsContext(sal_uInt16 nPrefix,
00250                 const rtl::OUString &rLocalName,
00251                 const com::sun::star::uno::Reference <
00252                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00253         SvXMLImportContext *CreateTableContext(sal_uInt16 nPrefix,
00254                 const rtl::OUString &rLocalName,
00255                 const com::sun::star::uno::Reference <
00256                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00257         SvXMLImportContext *CreateTableRowContext(sal_uInt16 nPrefix,
00258                 const rtl::OUString &rLocalName,
00259                 const com::sun::star::uno::Reference <
00260                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00261         SvXMLImportContext *CreateTableCellContext(sal_uInt16 nPrefix,
00262                 const rtl::OUString &rLocalName,
00263                 const com::sun::star::uno::Reference <
00264                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00265         SvXMLImportContext *CreateAlignGroupContext(sal_uInt16 nPrefix,
00266                 const rtl::OUString &rLocalName,
00267                 const com::sun::star::uno::Reference <
00268                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00269         SvXMLImportContext *CreateActionContext(sal_uInt16 nPrefix,
00270                 const rtl::OUString &rLocalName,
00271                 const com::sun::star::uno::Reference <
00272                 com::sun::star::xml::sax::XAttributeList> &xAttrList);
00273     
00274         const SvXMLTokenMap &GetPresLayoutElemTokenMap();
00275         const SvXMLTokenMap &GetPresLayoutAttrTokenMap();
00276         const SvXMLTokenMap &GetFencedAttrTokenMap();
00277         const SvXMLTokenMap &GetOperatorAttrTokenMap();
00278         const SvXMLTokenMap &GetAnnotationAttrTokenMap();
00279         const SvXMLTokenMap &GetPresElemTokenMap();
00280         const SvXMLTokenMap &GetPresScriptEmptyElemTokenMap();
00281         const SvXMLTokenMap &GetPresTableElemTokenMap();
00282         const SvXMLTokenMap &GetColorTokenMap();
00283         virtual ~SmXMLImport() throw ();
00284         SmNodeStack & GetNodeStack() {return aNodeStack;}
00285         SmNode *GetTree() { return aNodeStack.Pop();}
00286         sal_Bool GetSuccess() { return bSuccess; }
00287         String &GetText() { return aText;}
00288 
00289         virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps);
00290         virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps);
00291 
00292 private:
00293         SvXMLTokenMap *pPresLayoutElemTokenMap;
00294         SvXMLTokenMap *pPresLayoutAttrTokenMap;
00295         SvXMLTokenMap *pFencedAttrTokenMap;
00296         SvXMLTokenMap *pOperatorAttrTokenMap;
00297         SvXMLTokenMap *pAnnotationAttrTokenMap;
00298         SvXMLTokenMap *pPresElemTokenMap;
00299         SvXMLTokenMap *pPresScriptEmptyElemTokenMap;
00300         SvXMLTokenMap *pPresTableElemTokenMap;
00301         SvXMLTokenMap *pColorTokenMap;
00302 
00303                 SmNodeStack aNodeStack;
00304                 sal_Bool bSuccess;
00305                 String aText;
00306 };
00307 
00308 enum SmXMLMathElemTokenMap
00309 {
00310     XML_TOK_MATH
00311 };
00312 
00313 enum SmXMLPresLayoutElemTokenMap
00314 {
00315         XML_TOK_SEMANTICS,
00316         XML_TOK_MSTYLE,
00317         XML_TOK_MERROR,
00318         XML_TOK_MPHANTOM,
00319         XML_TOK_MROW,
00320         XML_TOK_MFRAC,
00321         XML_TOK_MSQRT,
00322         XML_TOK_MROOT,
00323         XML_TOK_MSUB,
00324         XML_TOK_MSUP,
00325         XML_TOK_MSUBSUP,
00326         XML_TOK_MMULTISCRIPTS,
00327         XML_TOK_MUNDER,
00328         XML_TOK_MOVER,
00329         XML_TOK_MUNDEROVER,
00330         XML_TOK_MTABLE,
00331         XML_TOK_MACTION,
00332         XML_TOK_MFENCED,
00333         XML_TOK_MPADDED
00334 };
00335 
00336 enum SmXMLPresLayoutAttrTokenMap
00337 {
00338         XML_TOK_FONTWEIGHT,
00339         XML_TOK_FONTSTYLE,
00340         XML_TOK_FONTSIZE,
00341         XML_TOK_FONTFAMILY,
00342         XML_TOK_COLOR
00343 };
00344 
00345 
00346 enum SmXMLFencedAttrTokenMap
00347 {
00348         XML_TOK_OPEN,
00349         XML_TOK_CLOSE
00350 };
00351 
00352 
00353 enum SmXMLPresTableElemTokenMap
00354 {
00355         XML_TOK_MTR,
00356         XML_TOK_MTD
00357 };
00358 
00359 enum SmXMLPresElemTokenMap
00360 {
00361         XML_TOK_ANNOTATION,
00362         XML_TOK_MI,
00363         XML_TOK_MN,
00364         XML_TOK_MO,
00365         XML_TOK_MTEXT,
00366         XML_TOK_MSPACE,
00367         XML_TOK_MS,
00368         XML_TOK_MALIGNGROUP
00369 };
00370 
00371 enum SmXMLPresScriptEmptyElemTokenMap
00372 {
00373         XML_TOK_MPRESCRIPTS,
00374         XML_TOK_NONE
00375 };
00376 
00377 enum SmXMLOperatorAttrTokenMap
00378 {
00379         XML_TOK_STRETCHY
00380 };
00381 
00382 enum SmXMLAnnotationAttrTokenMap
00383 {
00384         XML_TOK_ENCODING
00385 };
00386 
00387 
00388 class SmXMLExport : public SvXMLExport
00389 {
00390 public:
00391         // #110680#
00392         SmXMLExport(
00393                 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
00394                 sal_uInt16 nExportFlags=EXPORT_ALL);
00395         
00396         // #110680#
00397         SmXMLExport(
00398                 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
00399                 const SmNode *pIn,
00400                 const rtl::OUString &rFileName,
00401             com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler> &rHandler);
00402 
00403         virtual ~SmXMLExport() {};
00404 
00405     // XServiceInfo (override parent method)
00406     ::rtl::OUString SAL_CALL getImplementationName()
00407         throw( ::com::sun::star::uno::RuntimeException );
00408 
00409     void _ExportAutoStyles() {}
00410         void _ExportMasterStyles() {}
00411         void _ExportContent();
00412         sal_uInt32 exportDoc(enum ::xmloff::token::XMLTokenEnum eClass);
00413 
00414     virtual void GetViewSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps);
00415     virtual void GetConfigurationSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps);
00416 
00417         sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
00418                 sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException);
00419         static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId()
00420                 throw();
00421 
00422         sal_Bool GetSuccess() {return bSuccess;}
00423 
00424 protected:
00425         void ExportNodes(const SmNode *pIn,int nLevel);
00426         void ExportTable(const SmNode *pIn,int nLevel);
00427         void ExportLine(const SmNode *pNode,int nLevel);
00428         void ExportExpression(const SmNode *pNode,int nLevel);
00429         void ExportText(const SmNode *pNode, int nLevel);
00430         void ExportMath(const SmNode *pNode, int nLevel);
00431         void ExportPolygon(const SmNode *pNode, int nLevel);
00432         void ExportBinaryHorizontal(const SmNode *pNode,int nLevel);
00433         void ExportUnaryHorizontal(const SmNode *pNode,int nLevel);
00434         void ExportBrace(const SmNode *pNode, int nLevel);
00435         void ExportBinaryVertical(const SmNode *pNode,int nLevel);
00436         void ExportSubSupScript(const SmNode *pNode,int nLevel);
00437         void ExportRoot(const SmNode *pNode, int nLevel);
00438         void ExportOperator(const SmNode *pNode, int nLevel);
00439         void ExportAttributes(const SmNode *pNode, int nLevel);
00440         void ExportFont(const SmNode *pNode, int nLevel);
00441         void ExportVerticalBrace(const SmNode *pNode, int nLevel);
00442         void ExportMatrix(const SmNode *pNode, int nLevel);
00443     void ExportBlank(const SmNode *pNode, int nLevel);
00444 private:
00445         const SmNode *pTree;
00446     String        aText;
00447         sal_Bool bSuccess;
00448 };
00449 #endif

Generated on Wed Feb 20 17:21:57 2008 for maths by  doxygen 1.5.1