main/starmath/source/mathmlexport.cxx
/// export through an XML exporter component (output stream version)
export through an XML exporter component (output stream version)
export through an XML exporter component ( output stream version )
sal_Bool SmXMLExportWrapper::WriteThroughComponent(
    Reference<io::XOutputStream> xOutputStream,
    Reference<XComponent> xComponent,
    Reference<lang::XMultiServiceFactory> & rFactory,
    Reference<beans::XPropertySet> & rPropSet,
    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!");
    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;
    xSaxWriter->setOutputStream( xOutputStream );
    Reference<xml::sax::XDocumentHandler> xDocHandler( xSaxWriter,UNO_QUERY);
    Sequence<Any> aArgs( 2 );
    aArgs[0] <<= xDocHandler;
    aArgs[1] <<= rPropSet;
    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;
    xExporter->setSourceDocument( xComponent );
    Reference < XFilter > xFilter( xExporter, UNO_QUERY );
    uno::Sequence< PropertyValue > aProps(0);
    xFilter->filter( aProps );
    uno::Reference<lang::XUnoTunnel> xFilterTunnel;
    xFilterTunnel = uno::Reference<lang::XUnoTunnel>
        ( xFilter, uno::UNO_QUERY );
    SmXMLExport *pFilter = reinterpret_cast< SmXMLExport * >(
                sal::static_int_cast< sal_uIntPtr >(
                xFilterTunnel->getSomething( SmXMLExport::getUnoTunnelId() )));
    return pFilter ? pFilter->GetSuccess() : sal_True;
}
sal_Bool SmXMLExportWrapper :: WriteThroughComponent ( Reference < io :: XOutputStream > xOutputStream , Reference < XComponent > xComponent , Reference < lang :: XMultiServiceFactory > & rFactory , Reference < beans :: XPropertySet > & rPropSet , const sal_Char * pComponentName ) { DBG_ASSERT ( xOutputStream . is ( ) , " " ) ; DBG_ASSERT ( xComponent . is ( ) , " " ) ; DBG_ASSERT ( NULL != pComponentName , " " ) ; Reference < io :: XActiveDataSource > xSaxWriter ( rFactory -> createInstance ( OUString :: createFromAscii ( " " ) ) , UNO_QUERY ) ; DBG_ASSERT ( xSaxWriter . is ( ) , " " ) ; if ( ! xSaxWriter . is ( ) ) return sal_False ; xSaxWriter -> setOutputStream ( xOutputStream ) ; Reference < xml :: sax :: XDocumentHandler > xDocHandler ( xSaxWriter , UNO_QUERY ) ; Sequence < Any > aArgs ( 2 ) ; aArgs [ 0 ] <<= xDocHandler ; aArgs [ 1 ] <<= rPropSet ; Reference < document :: XExporter > xExporter ( rFactory -> createInstanceWithArguments ( OUString :: createFromAscii ( pComponentName ) , aArgs ) , UNO_QUERY ) ; DBG_ASSERT ( xExporter . is ( ) , " " ) ; if ( ! xExporter . is ( ) ) return sal_False ; xExporter -> setSourceDocument ( xComponent ) ; Reference < XFilter > xFilter ( xExporter , UNO_QUERY ) ; uno :: Sequence < PropertyValue > aProps ( 0 ) ; xFilter -> filter ( aProps ) ; uno :: Reference < lang :: XUnoTunnel > xFilterTunnel ; xFilterTunnel = uno :: Reference < lang :: XUnoTunnel > ( xFilter , uno :: UNO_QUERY ) ; SmXMLExport * pFilter = reinterpret_cast < SmXMLExport * > ( sal :: static_int_cast < sal_uIntPtr > ( xFilterTunnel -> getSomething ( SmXMLExport :: getUnoTunnelId ( ) ) ) ) ; return pFilter ? pFilter -> GetSuccess ( ) : sal_True ; }
export through an XML exporter component (output stream version)
export through an XML exporter component ( output stream version )
// get component // connect XML writer to output stream // prepare arguments (prepend doc handler to given arguments) // get filter component // connect model and filter // filter!