summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--starmath/source/document.cxx7
-rw-r--r--starmath/source/makefile.mk5
-rw-r--r--starmath/source/mathml.cxx532
-rw-r--r--starmath/source/mathml.hxx43
-rw-r--r--starmath/util/sm.map3
5 files changed, 428 insertions, 162 deletions
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index ed3019ad627c..57f1b3dbdcc8 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: document.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: cmc $ $Date: 2001-02-19 08:27:13 $
+ * last change: $Author: mib $ $Date: 2001-03-07 14:27:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -716,7 +716,8 @@ BOOL SmDocShell::Load(SvStorage *pStor)
if (bRet = (1 == aEquation.Parse(pStor)))
Parse();
}
- else if( pStor->IsStream(C2S("Content.xml")))
+ else if( pStor->IsStream(C2S("content.xml")) ||
+ pStor->IsStream(C2S("Content.xml")) )
{
// is this a fabulous math package ?
SmXMLWrapper aEquation(GetModel());
diff --git a/starmath/source/makefile.mk b/starmath/source/makefile.mk
index 388ed0fd0a5f..f66ec0184452 100644
--- a/starmath/source/makefile.mk
+++ b/starmath/source/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.3 $
+# $Revision: 1.4 $
#
-# last change: $Author: cmc $ $Date: 2000-11-15 10:47:20 $
+# last change: $Author: mib $ $Date: 2001-03-07 14:27:21 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -118,6 +118,7 @@ SLOFILES = \
EXCEPTIONSFILES = \
$(SLO)$/frmload.obj \
+ $(SLO)$/mathml.obj \
$(SLO)$/unomodel.obj
diff --git a/starmath/source/mathml.cxx b/starmath/source/mathml.cxx
index b7d40311976f..b23cf99b65b5 100644
--- a/starmath/source/mathml.cxx
+++ b/starmath/source/mathml.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: mathml.cxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: cmc $ $Date: 2001-02-27 14:55:15 $
+ * last change: $Author: mib $ $Date: 2001-03-07 14:27:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -97,6 +97,10 @@ one go*/
#include <osl/mutex.hxx>
#endif
+#ifndef _COM_SUN_STAR_UNO_ANY_H_
+#include <com/sun/star/uno/Any.h>
+#endif
+
#ifndef _XMLOFF_XMLNMSPE_HXX
#include <xmloff/xmlnmspe.hxx>
#endif
@@ -112,6 +116,9 @@ one go*/
#ifndef _XMLOFF_XMLUCONV_HXX
#include <xmloff/xmluconv.hxx>
#endif
+#ifndef _XMLOFF_XMLMETAI_HXX
+#include <xmloff/xmlmetai.hxx>
+#endif
#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_
#include <unotools/processfactory.hxx>
@@ -128,6 +135,9 @@ one go*/
#include <com/sun/star/io/XActiveDataSource.hpp>
#include <com/sun/star/io/XActiveDataControl.hpp>
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::document;
using namespace com::sun::star;
using namespace rtl;
@@ -149,97 +159,169 @@ sal_Unicode UnicodeToStarMath(sal_uInt16 rChar)
return cMathChar;
}
-sal_Bool SmXMLWrapper::Import(SfxMedium &rMedium)
+/// read a component (file + filter version)
+sal_Bool SmXMLWrapper::ReadThroughComponent(
+ Reference<io::XInputStream> xInputStream,
+ Reference<XComponent> xModelComponent,
+ Reference<lang::XMultiServiceFactory> & rFactory,
+ const sal_Char* pFilterName )
{
- sal_Bool bRet=sal_False;
- uno::Reference<io::XActiveDataSource> xSource;
+ DBG_ASSERT(xInputStream.is(), "input stream missing");
+ DBG_ASSERT(xModelComponent.is(), "document missing");
+ DBG_ASSERT(rFactory.is(), "factory missing");
+ DBG_ASSERT(NULL != pFilterName,"I need a service name for the component!");
+
+ // prepare ParserInputSrouce
xml::sax::InputSource aParserInput;
- SvStorageStreamRef xDocStream;
+ aParserInput.aInputStream = xInputStream;
- uno::Reference<lang::XMultiServiceFactory> xServiceFactory(
- utl::getProcessServiceFactory());
- DBG_ASSERT(xServiceFactory.is(), "XMLReader::Read: got no service manager");
+ // get parser
+ Reference< xml::sax::XParser > xParser(
+ rFactory->createInstance(
+ OUString::createFromAscii("com.sun.star.xml.sax.Parser") ),
+ UNO_QUERY );
+ DBG_ASSERT( xParser.is(), "Can't create parser" );
+ if( !xParser.is() )
+ return sal_False;
+
+ // get filter
+ uno::Sequence < uno::Any > aArgs( 0 );
+ Reference< xml::sax::XDocumentHandler > xFilter(
+ rFactory->createInstanceWithArguments(
+ OUString::createFromAscii(pFilterName), aArgs ),
+ UNO_QUERY );
+ DBG_ASSERT( xFilter.is(), "Can't instantiate filter component." );
+ if( !xFilter.is() )
+ return sal_False;
+
+ // connect parser and filter
+ xParser->setDocumentHandler( xFilter );
- if (rMedium.IsStorage())
+ // connect model and filter
+ Reference < XImporter > xImporter( xFilter, UNO_QUERY );
+ xImporter->setTargetDocument( xModelComponent );
+
+ // finally, parser the stream
+ sal_Bool bRet = sal_True;
+ try
+ {
+ xParser->parseStream( aParserInput );
+
+ uno::Reference<lang::XUnoTunnel> xFilterTunnel;
+ xFilterTunnel = uno::Reference<lang::XUnoTunnel>
+ ( xFilter, uno::UNO_QUERY );
+ SmXMLImport *pFilter = (SmXMLImport *)xFilterTunnel->getSomething(
+ SmXMLImport::getUnoTunnelId() );
+ if( pFilter )
+ bRet = pFilter->GetSuccess();
+ }
+ catch( xml::sax::SAXParseException& )
{
- xDocStream = rMedium.GetStorage()->OpenStream
- (C2S("Content.xml"),STREAM_READ|STREAM_NOCREATE);
- aParserInput.aInputStream = new utl::OInputStreamWrapper(*xDocStream);
+ bRet = sal_False;
}
- else
+ catch( xml::sax::SAXException& )
{
- xSource = rMedium.GetDataSource();
- DBG_ASSERT(xSource.is(),"XMLReader::Read: data source missing");
+ bRet = sal_False;
+ }
+ catch( io::IOException& )
+ {
+ bRet = sal_False;
+ }
- // get a pipe for connecting the data source to the parser
- uno::Reference<uno::XInterface> xPipe(xServiceFactory->createInstance(
- OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.Pipe"))));
- DBG_ASSERT(xPipe.is(),"com.sun.star.io.Pipe service missing");
+ // success!
+ return bRet;
+}
- uno::Reference<io::XOutputStream> xPipeOutput(xPipe, uno::UNO_QUERY);
- xSource->setOutputStream(xPipeOutput);
+sal_Bool SmXMLWrapper::ReadThroughComponent(
+ SvStorage* pStorage,
+ Reference<XComponent> xModelComponent,
+ const sal_Char* pStreamName,
+ const sal_Char* pCompatibilityStreamName,
+ Reference<lang::XMultiServiceFactory> & rFactory,
+ const sal_Char* pFilterName )
+{
+ DBG_ASSERT(NULL != pStorage, "Need storage!");
+ DBG_ASSERT(NULL != pStreamName, "Please, please, give me a name!");
+
+ // open stream (and set parser input)
+ OUString sStreamName = OUString::createFromAscii(pStreamName);
+ if (! pStorage->IsStream(sStreamName))
+ {
+ // stream name not found! Then try the compatibility name.
+
+ // do we even have an alternative name?
+ if ( NULL == pCompatibilityStreamName )
+ return sal_False;
- aParserInput.aInputStream = uno::Reference<io::XInputStream>(xPipe,
- uno::UNO_QUERY);
+ // if so, does the stream exist?
+ sStreamName = OUString::createFromAscii(pCompatibilityStreamName);
+ if (! pStorage->IsStream(sStreamName) )
+ return sal_False;
}
- // get parser
- uno::Reference<xml::sax::XParser> xParser(xServiceFactory->createInstance(
- OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser"))),
- uno::UNO_QUERY);
- DBG_ASSERT(xParser.is(),
- "com.sun.star.xml.sax.Parser service missing");
+ // get input stream
+ SvStorageStreamRef xEventsStream;
+ xEventsStream = pStorage->OpenStream( sStreamName,
+ STREAM_READ | STREAM_NOCREATE );
+ xEventsStream->SetBufferSize( 16*1024 );
+ Reference<io::XInputStream> xInputStream =
+ new utl::OInputStreamWrapper( *xEventsStream );
- // get filter
- uno::Sequence < uno::Any > aArgs( 0 );
- uno::Reference< xml::sax::XDocumentHandler > xFilter(
- xServiceFactory->createInstanceWithArguments(
- OUString::createFromAscii("com.sun.star.office.sax.importer.Math"),
- aArgs ), uno::UNO_QUERY );
+ // read from the stream
+ return ReadThroughComponent(
+ xInputStream, xModelComponent, rFactory, pFilterName );
+}
- DBG_ASSERT( xFilter.is(),
- "XMLReader::Read: com.sun.star.xml.sax.importer.Math service missing");
+sal_Bool SmXMLWrapper::Import(SfxMedium &rMedium)
+{
+ sal_Bool bRet=sal_False;
- // connect parser and filter
- xParser->setDocumentHandler(xFilter);
+ uno::Reference<lang::XMultiServiceFactory> xServiceFactory(
+ utl::getProcessServiceFactory());
+ DBG_ASSERT(xServiceFactory.is(), "XMLReader::Read: got no service manager");
+ if( !xServiceFactory.is() )
+ return sal_False;
//Make a model component from our SmModel
uno::Reference< lang::XComponent > xModelComp( rModel, uno::UNO_QUERY );
DBG_ASSERT( xModelComp.is(), "XMLReader::Read: got no model" );
- // connect model and filter
- uno::Reference < document::XImporter > xImporter( xFilter, uno::UNO_QUERY );
- xImporter->setTargetDocument( xModelComp );
-
- xParser->setDocumentHandler(xFilter);
+ if( rMedium.IsStorage())
+ {
+ ReadThroughComponent(
+ rMedium.GetStorage(), xModelComp, "meta.xml", "Meta.xml", xServiceFactory,
+ "com.sun.star.comp.Math.XMLMetaImporter" );
- if (xSource.is())
+ bRet = ReadThroughComponent(
+ rMedium.GetStorage(), xModelComp, "content.xml", "Content.xml", xServiceFactory,
+ "com.sun.star.comp.Math.XMLImporter" );
+ }
+ else
{
+
+ uno::Reference<io::XActiveDataSource> xSource( rMedium.GetDataSource() );
+ DBG_ASSERT(xSource.is(),"XMLReader::Read: data source missing");
+
+ // get a pipe for connecting the data source to the parser
+ Reference< XInterface > xPipe =
+ xServiceFactory->createInstance(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.Pipe")));
+ DBG_ASSERT(xPipe.is(),"com.sun.star.io.Pipe service missing");
+
+ uno::Reference<io::XOutputStream> xPipeOutput(xPipe, uno::UNO_QUERY);
+ xSource->setOutputStream(xPipeOutput);
+
+ Reference<io::XInputStream> xInputStream(xPipe, uno::UNO_QUERY);
+
uno::Reference<io::XActiveDataControl> xSourceControl(
xSource,uno::UNO_QUERY);
xSourceControl->start();
- }
-#ifdef WANTEXCEPT
- try
- {
-#endif
- xParser->parseStream(aParserInput);
- uno::Reference<lang::XUnoTunnel> xFilterTunnel;
- xFilterTunnel = uno::Reference<lang::XUnoTunnel>
- ( xFilter, uno::UNO_QUERY );
- SmXMLImport *pFilter = (SmXMLImport *)xFilterTunnel->getSomething(
- SmXMLImport::getUnoTunnelId() );
- if (pFilter)
- bRet = pFilter->GetSuccess();
-
-#ifdef WANTEXCECT
- }
- catch(...)
- {
- pRet = 0;
+ bRet = ReadThroughComponent(
+ xInputStream, xModelComp, xServiceFactory,
+ "com.sun.star.comp.Math.XMLImporter" );
}
-#endif
+
return bRet;
}
@@ -275,20 +357,19 @@ const uno::Sequence< sal_Int8 > & SmXMLExport::getUnoTunnelId() throw()
return *pSeq;
}
+OUString SAL_CALL SmXMLImport_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLImporter" ) );
+}
+
uno::Sequence< OUString > SAL_CALL SmXMLImport_getSupportedServiceNames()
throw()
{
- const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.office.sax.importer.Math" ));
+ const OUString aServiceName( SmXMLImport_getImplementationName() );
const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
return aSeq;
}
-OUString SAL_CALL SmXMLImport_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "SmXMLImport" ) );
-}
-
uno::Reference< uno::XInterface > SAL_CALL SmXMLImport_createInstance(
const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
throw( uno::Exception )
@@ -296,25 +377,65 @@ uno::Reference< uno::XInterface > SAL_CALL SmXMLImport_createInstance(
return (cppu::OWeakObject*)new SmXMLImport;
}
+OUString SAL_CALL SmXMLExport_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLExporter" ) );
+}
+
uno::Sequence< OUString > SAL_CALL SmXMLExport_getSupportedServiceNames()
throw()
{
- const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.office.sax.exporter.Math" ));
+ const OUString aServiceName( SmXMLExport_getImplementationName());
const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
return aSeq;
}
-OUString SAL_CALL SmXMLExport_getImplementationName() throw()
+uno::Reference< uno::XInterface > SAL_CALL SmXMLExport_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
+ throw( uno::Exception )
{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "SmXMLExport" ) );
+ return (cppu::OWeakObject*)new SmXMLExport;
}
-uno::Reference< uno::XInterface > SAL_CALL SmXMLExport_createInstance(
+
+OUString SAL_CALL SmXMLImportMeta_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLMetaImporter" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SmXMLImportMeta_getSupportedServiceNames()
+ throw()
+{
+ const OUString aServiceName( SmXMLImportMeta_getImplementationName() );
+ const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SmXMLImportMeta_createInstance(
const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
throw( uno::Exception )
{
- return (cppu::OWeakObject*)new SmXMLExport;
+ return (cppu::OWeakObject*)new SmXMLImport( IMPORT_META );
+}
+
+OUString SAL_CALL SmXMLExportMeta_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLMetaExporter" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SmXMLExportMeta_getSupportedServiceNames()
+ throw()
+{
+ const OUString aServiceName( SmXMLExportMeta_getImplementationName());
+ const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SmXMLExportMeta_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
+ throw( uno::Exception )
+{
+ return (cppu::OWeakObject*)new SmXMLExport( EXPORT_META );
}
@@ -380,6 +501,113 @@ void SmXMLImport::endDocument(void)
}
}
+/// export through an XML exporter component (output stream version)
+sal_Bool SmXMLWrapper::WriteThroughComponent(
+ Reference<io::XOutputStream> xOutputStream,
+ Reference<XComponent> xComponent,
+ Reference<lang::XMultiServiceFactory> & rFactory,
+ const sal_Char* pComponentName )
+{
+ DBG_ASSERT(xOutputStream.is(), "I really need an output stream!");
+ DBG_ASSERT(xComponent.is(), "Need component!");
+ DBG_ASSERT(NULL != pComponentName, "Need component name!");
+
+ // get component
+ Reference< io::XActiveDataSource > xSaxWriter(
+ rFactory->createInstance(
+ OUString::createFromAscii("com.sun.star.xml.sax.Writer") ),
+ UNO_QUERY );
+ DBG_ASSERT( xSaxWriter.is(), "can't instantiate XML writer" );
+ if(!xSaxWriter.is())
+ return sal_False;
+
+ // connect XML writer to output stream
+ xSaxWriter->setOutputStream( xOutputStream );
+
+ // prepare arguments (prepend doc handler to given arguments)
+ Reference<xml::sax::XDocumentHandler> xDocHandler( xSaxWriter,UNO_QUERY);
+ Sequence<Any> aArgs( 1 );
+ aArgs[0] <<= xDocHandler;
+
+ // get filter component
+ Reference< document::XExporter > xExporter(
+ rFactory->createInstanceWithArguments(
+ OUString::createFromAscii(pComponentName), aArgs), UNO_QUERY);
+ DBG_ASSERT( xExporter.is(),
+ "can't instantiate export filter component" );
+ if( !xExporter.is() )
+ return sal_False;
+
+
+ // connect model and filter
+ xExporter->setSourceDocument( xComponent );
+
+ // filter!
+ Reference < XFilter > xFilter( xExporter, UNO_QUERY );
+ uno::Sequence< beans::PropertyValue > aProps(0);
+ xFilter->filter( aProps );
+
+ uno::Reference<lang::XUnoTunnel> xFilterTunnel;
+ xFilterTunnel = uno::Reference<lang::XUnoTunnel>
+ ( xFilter, uno::UNO_QUERY );
+ SmXMLExport *pFilter = (SmXMLExport *)xFilterTunnel->getSomething(
+ SmXMLExport::getUnoTunnelId() );
+ return pFilter ? pFilter->GetSuccess() : sal_True;
+}
+
+/// export through an XML exporter component (storage version)
+sal_Bool SmXMLWrapper::WriteThroughComponent(
+ SvStorage* pStorage,
+ Reference<XComponent> xComponent,
+ const sal_Char* pStreamName,
+ Reference<lang::XMultiServiceFactory> & rFactory,
+ const sal_Char* pComponentName,
+ sal_Bool bCompress )
+{
+ DBG_ASSERT(NULL != pStorage, "Need storage!");
+ DBG_ASSERT(NULL != pStreamName, "Need stream name!");
+
+ Reference< io::XOutputStream > xOutputStream;
+ SvStorageStreamRef xDocStream;
+
+ // open stream
+ OUString sStreamName = OUString::createFromAscii(pStreamName);
+ xDocStream = pStorage->OpenStream( sStreamName,
+ STREAM_WRITE | STREAM_SHARE_DENYWRITE );
+ if (! xDocStream.Is())
+ return sal_False;
+ DBG_ASSERT(xDocStream.Is(), "Can't create output stream in package!");
+
+ String aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) );
+ OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") );
+ uno::Any aAny;
+ aAny <<= aMime;
+ xDocStream->SetProperty( aPropName, aAny );
+
+ if( !bCompress )
+ {
+ aPropName = String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("Compressed") );
+ sal_Bool bFalse = sal_False;
+ aAny.setValue( &bFalse, ::getBooleanCppuType() );
+ xDocStream->SetProperty( aPropName, aAny );
+ }
+
+ // set buffer and create outputstream
+ xDocStream->SetBufferSize( 16*1024 );
+ xOutputStream = new utl::OOutputStreamWrapper( *xDocStream );
+
+ // write the stuff
+ sal_Bool bRet = WriteThroughComponent(
+ xOutputStream, xComponent, rFactory,
+ pComponentName );
+
+ // finally, commit stream.
+ if( bRet )
+ xDocStream->Commit();
+
+ return bRet;
+}
+
sal_Bool SmXMLWrapper::Export(SfxMedium &rMedium)
{
sal_Bool bRet=sal_False;
@@ -387,102 +615,71 @@ sal_Bool SmXMLWrapper::Export(SfxMedium &rMedium)
xServiceFactory(utl::getProcessServiceFactory());
DBG_ASSERT(xServiceFactory.is(),"got no service manager");
- uno::Reference<io::XOutputStream> xOut;
- SvStorageStreamRef xDocStream;
+ //Get model
+ uno::Reference< lang::XComponent > xModelComp(rModel, uno::UNO_QUERY );
if (!bFlat) //Storage (Package) of Stream
{
SvStorage *pStg = rMedium.GetOutputStorage(sal_True);
- xDocStream = pStg->OpenStream
- (C2S("Content.xml"),STREAM_WRITE|STREAM_SHARE_DENYWRITE);
- xOut = new utl::OOutputStreamWrapper(*xDocStream);
+ bRet = WriteThroughComponent(
+ pStg, xModelComp, "meta.xml", xServiceFactory,
+ "com.sun.star.comp.Math.XMLMetaExporter", sal_False );
+ if( bRet )
+ WriteThroughComponent(
+ pStg, xModelComp, "content.xml", xServiceFactory,
+ "com.sun.star.comp.Math.XMLExporter" );
}
else
{
SvStream *pStream = rMedium.GetOutStream();
- xOut = new utl::OOutputStreamWrapper(*pStream);
+ uno::Reference<io::XOutputStream> xOut( new utl::OOutputStreamWrapper(*pStream) );
+ bRet = WriteThroughComponent(
+ xOut, xModelComp, xServiceFactory,
+ "com.sun.star.comp.Math.XMLExporter" );
}
-
- uno::Reference<io::XActiveDataSource> xWriter(
- xServiceFactory->createInstance(
- OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer"))),
- uno::UNO_QUERY);
- DBG_ASSERT(xWriter.is(),"com.sun.star.xml.sax.Writer service missing");
-
- //connect writer and output stream
- xWriter->setOutputStream(xOut);
-
- //get filter
- uno::Reference< xml::sax::XDocumentHandler > xHandler(xWriter,
- uno::UNO_QUERY);
- uno::Sequence< uno::Any > aArgs(1);
- uno::Any *pArgs = aArgs.getArray();
- *pArgs <<= xHandler;
-
- uno::Reference<document::XExporter> xExporter(
- xServiceFactory->createInstanceWithArguments(
- OUString::createFromAscii("com.sun.star.office.sax.exporter.Math"),
- aArgs),uno::UNO_QUERY);
- DBG_ASSERT(xExporter.is(),"com.sun.star.office.sax.exporter.Math service missing");
- if (!xExporter.is())
- return bRet;
-
- //Get model
- uno::Reference< lang::XComponent > xModelComp(rModel, uno::UNO_QUERY );
-
- // connect model and filter
- xExporter->setSourceDocument( xModelComp );
- uno::Reference< document::XFilter> xFilter(xExporter,uno::UNO_QUERY);
-
- // would the MathML filter care about having an original file name?
- // I don't think so
- uno::Sequence< beans::PropertyValue > aProps(0);
- xFilter->filter(aProps);
-
-
- uno::Reference<lang::XUnoTunnel> xFilterTunnel;
- xFilterTunnel = uno::Reference<lang::XUnoTunnel>
- ( xFilter, uno::UNO_QUERY );
- SmXMLExport *pFilter = (SmXMLExport *)xFilterTunnel->getSomething(
- SmXMLExport::getUnoTunnelId() );
- if (pFilter)
- bRet = pFilter->GetSuccess();
-
return bRet;
}
-SmXMLExport::SmXMLExport() : SvXMLExport(MAP_INCH,sXML_math) , pTree(0) ,
+SmXMLExport::SmXMLExport(sal_uInt16 nExportFlags) : SvXMLExport(MAP_INCH,sXML_math, nExportFlags) , pTree(0) ,
bSuccess(sal_False),pText(0)
{}
sal_uInt32 SmXMLExport::exportDoc(const sal_Char *pClass)
{
- uno::Reference <frame::XModel> xModel = GetModel();
- uno::Reference <lang::XUnoTunnel> xTunnel;
- xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
- SmModel *pModel = reinterpret_cast<SmModel *>
- (xTunnel->getSomething(SmModel::getUnoTunnelId()));
-
- if (pModel)
+ if( (getExportFlags() & EXPORT_CONTENT) == 0 )
{
- SmDocShell *pDocShell =
- static_cast<SmDocShell*>(pModel->GetObjectShell());
- pTree = pDocShell->GetFormulaTree();
- pText = &(pDocShell->GetText());
+ SvXMLExport::exportDoc( pClass );
}
+ else
+ {
+ uno::Reference <frame::XModel> xModel = GetModel();
+ uno::Reference <lang::XUnoTunnel> xTunnel;
+ xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
+ SmModel *pModel = reinterpret_cast<SmModel *>
+ (xTunnel->getSomething(SmModel::getUnoTunnelId()));
- GetDocHandler()->startDocument();
+ if (pModel)
+ {
+ SmDocShell *pDocShell =
+ static_cast<SmDocShell*>(pModel->GetObjectShell());
+ pTree = pDocShell->GetFormulaTree();
+ pText = &(pDocShell->GetText());
+ }
- /*Add xmlns line*/
- SvXMLAttributeList &rList = GetAttrList();
- rList.AddAttribute(GetNamespaceMap().GetAttrNameByIndex(
- XML_NAMESPACE_MATH_IDX),sCDATA,GetNamespaceMap().GetNameByIndex(
- XML_NAMESPACE_MATH_IDX));
+ GetDocHandler()->startDocument();
+
+ /*Add xmlns line*/
+ SvXMLAttributeList &rList = GetAttrList();
+ rList.AddAttribute(GetNamespaceMap().GetAttrNameByIndex(
+ XML_NAMESPACE_MATH_IDX),sCDATA,GetNamespaceMap().GetNameByIndex(
+ XML_NAMESPACE_MATH_IDX));
+
+ //I think we need something like ImplExportEntities();
+ _ExportContent();
+ GetDocHandler()->endDocument();
+ }
- //I think we need something like ImplExportEntities();
- _ExportContent();
- GetDocHandler()->endDocument();
bSuccess=sal_True;
return 0;
}
@@ -532,6 +729,7 @@ public:
void EndElement();
};
+
/*avert thy gaze from the proginator*/
class SmXMLRowContext_Impl : public SmXMLDocContext_Impl
{
@@ -1692,6 +1890,32 @@ public:
void EndElement();
};
+class SmXMLOfficeContext_Impl : public SvXMLImportContext
+{
+public:
+ SmXMLOfficeContext_Impl( SmXMLImport &rImport, sal_uInt16 nPrfx,
+ const OUString& rLName)
+ : SvXMLImportContext(rImport,nPrfx,rLName) {}
+ virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList > &xAttrList);
+};
+
+SvXMLImportContext *SmXMLOfficeContext_Impl::CreateChildContext(sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList > &xAttrList)
+{
+ SvXMLImportContext *pContext = 0;
+ if( XML_NAMESPACE_OFFICE == nPrefix &&
+ rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sXML_meta) ) )
+ pContext = new SfxXMLMetaContext( GetImport(),
+ XML_NAMESPACE_OFFICE, rLocalName,
+ GetImport().GetModel() );
+ else
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
static __FAR_DATA SvXMLTokenMapEntry aPresLayoutElemTokenMap[] =
{
@@ -2472,6 +2696,10 @@ SvXMLImportContext *SmXMLImport::CreateContext(sal_uInt16 nPrefix,
const OUString &rLocalName,
const uno::Reference <xml::sax::XAttributeList> &xAttrList)
{
+ if( XML_NAMESPACE_OFFICE == nPrefix &&
+ rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sXML_document_meta ) ) )
+ return new SmXMLOfficeContext_Impl( *this,nPrefix,rLocalName);
+ else
return new SmXMLDocContext_Impl(*this,nPrefix,rLocalName);
}
diff --git a/starmath/source/mathml.hxx b/starmath/source/mathml.hxx
index 6a4c65099769..2fdaf6bc2521 100644
--- a/starmath/source/mathml.hxx
+++ b/starmath/source/mathml.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: mathml.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: cmc $ $Date: 2001-02-05 10:36:18 $
+ * last change: $Author: mib $ $Date: 2001-03-07 14:27:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,6 +73,11 @@
#endif
class SfxMedium;
+class SvStorage;
+namespace com { namespace sun { namespace star { namespace io {
+ class XInputStream;
+ class XOutputStream;
+} } } }
class SmXMLWrapper
{
@@ -86,14 +91,42 @@ private:
sal_Bool bFlat; //set true for export to flat .mml, set false for
//export to a .sxm (or whatever) package
+ sal_Bool ReadThroughComponent(
+ ::com::sun::star::uno::Reference<::com::sun::star::io::XInputStream> xInputStream,
+ ::com::sun::star::uno::Reference<::com::sun::star::lang::XComponent> xModelComponent,
+ ::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & rFactory,
+ const sal_Char* pFilterName );
+
+ sal_Bool ReadThroughComponent(
+ SvStorage* pStorage,
+ ::com::sun::star::uno::Reference<::com::sun::star::lang::XComponent> xModelComponent,
+ const sal_Char* pStreamName,
+ const sal_Char* pCompatibilityStreamName,
+ ::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & rFactory,
+ const sal_Char* pFilterName );
+
+ sal_Bool WriteThroughComponent(
+ ::com::sun::star::uno::Reference<::com::sun::star::io::XOutputStream> xOutputStream,
+ ::com::sun::star::uno::Reference<::com::sun::star::lang::XComponent> xComponent,
+ ::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & rFactory,
+ const sal_Char* pComponentName );
+ sal_Bool WriteThroughComponent(
+ SvStorage* pStorage,
+ ::com::sun::star::uno::Reference<::com::sun::star::lang::XComponent> xComponent,
+ const sal_Char* pStreamName,
+ ::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & rFactory,
+ const sal_Char* pComponentName,
+ sal_Bool bCompress=sal_True );
+
};
class SmXMLImport : public SvXMLImport
{
public:
- SmXMLImport() :
- pMathElemTokenMap(0), pPresLayoutElemTokenMap(0), pPresElemTokenMap(0),
+ SmXMLImport(sal_uInt16 nImportFlags=IMPORT_ALL) :
+ SvXMLImport( nImportFlags ),
+ pMathElemTokenMap(0), pPresLayoutElemTokenMap(0), pPresElemTokenMap(0),
pPresScriptEmptyElemTokenMap(0), pPresTableElemTokenMap(0),
pPresLayoutAttrTokenMap(0),pFencedAttrTokenMap(0),
pOperatorAttrTokenMap(0),pColorTokenMap(0),pAnnotationAttrTokenMap(0),
@@ -358,7 +391,7 @@ enum SmXMLAnnotationAttrTokenMap
class SmXMLExport : public SvXMLExport
{
public:
- SmXMLExport();
+ SmXMLExport(sal_uInt16 nExportFlags=EXPORT_ALL);
SmXMLExport(const SmNode *pIn,const rtl::OUString &rFileName,
com::sun::star::uno::Reference<
com::sun::star::xml::sax::XDocumentHandler> &rHandler) :
diff --git a/starmath/util/sm.map b/starmath/util/sm.map
index 898b3dcbcd20..31a82ad7dad0 100644
--- a/starmath/util/sm.map
+++ b/starmath/util/sm.map
@@ -4,6 +4,9 @@ SM_1_0 {
CreateObjSmDocShellDll;
InitSmDll;
DeInitSmDll;
+ component_getImplementationEnvironment;
+ component_writeInfo;
+ component_getFactory;
local:
*;
};