main/starmath/source/mathmlexport.cxx
/// export through an XML exporter component (storage version)
export through an XML exporter component (storage version)
export through an XML exporter component ( storage version )
sal_Bool SmXMLExportWrapper::WriteThroughComponent(
    const Reference < embed::XStorage >& xStorage,
    Reference<XComponent> xComponent,
    const sal_Char* pStreamName,
    Reference<lang::XMultiServiceFactory> & rFactory,
    Reference<beans::XPropertySet> & rPropSet,
    const sal_Char* pComponentName,
    sal_Bool bCompress
    )
{
    DBG_ASSERT(xStorage.is(), "Need storage!");
    DBG_ASSERT(NULL != pStreamName, "Need stream name!");
    Reference < io::XStream > xStream;
    OUString sStreamName = OUString::createFromAscii(pStreamName);
    try
    {
        xStream = xStorage->openStreamElement( sStreamName,
            embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
    }
    catch ( uno::Exception& )
    {
        DBG_ERROR( "Can't create output stream in package!" );
        return sal_False;
    }
    String aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) );
    OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") );
    uno::Any aAny;
    aAny <<= aMime;
    uno::Reference < beans::XPropertySet > xSet( xStream, uno::UNO_QUERY );
    xSet->setPropertyValue( aPropName, aAny );
    if ( !bCompress )
    {
        aPropName = String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("Compressed") );
        sal_Bool bFalse = sal_False;
        aAny.setValue( &bFalse, ::getBooleanCppuType() );
        xSet->setPropertyValue( aPropName, aAny );
    }
    OUString aTmpPropName( RTL_CONSTASCII_USTRINGPARAM("UseCommonStoragePasswordEncryption") );
    sal_Bool bTrue = sal_True;
    aAny.setValue( &bTrue, ::getBooleanCppuType() );
    xSet->setPropertyValue( aTmpPropName, aAny );
    if ( rPropSet.is() )
    {
        OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("StreamName") );
        rPropSet->setPropertyValue( sPropName, makeAny( sStreamName ) );
    }
    sal_Bool bRet = WriteThroughComponent( xStream->getOutputStream(), xComponent, rFactory,
        rPropSet, pComponentName );
    return bRet;
}
sal_Bool SmXMLExportWrapper :: WriteThroughComponent ( const Reference < embed :: XStorage > & xStorage , Reference < XComponent > xComponent , const sal_Char * pStreamName , Reference < lang :: XMultiServiceFactory > & rFactory , Reference < beans :: XPropertySet > & rPropSet , const sal_Char * pComponentName , sal_Bool bCompress ) { DBG_ASSERT ( xStorage . is ( ) , " " ) ; DBG_ASSERT ( NULL != pStreamName , " " ) ; Reference < io :: XStream > xStream ; OUString sStreamName = OUString :: createFromAscii ( pStreamName ) ; try { xStream = xStorage -> openStreamElement ( sStreamName , embed :: ElementModes :: READWRITE | embed :: ElementModes :: TRUNCATE ) ; } catch ( uno :: Exception & ) { DBG_ERROR ( " " ) ; return sal_False ; } String aPropName ( String :: CreateFromAscii ( RTL_CONSTASCII_STRINGPARAM ( " " ) ) ) ; OUString aMime ( RTL_CONSTASCII_USTRINGPARAM ( " " ) ) ; uno :: Any aAny ; aAny <<= aMime ; uno :: Reference < beans :: XPropertySet > xSet ( xStream , uno :: UNO_QUERY ) ; xSet -> setPropertyValue ( aPropName , aAny ) ; if ( ! bCompress ) { aPropName = String :: CreateFromAscii ( RTL_CONSTASCII_STRINGPARAM ( " " ) ) ; sal_Bool bFalse = sal_False ; aAny . setValue ( & bFalse , :: getBooleanCppuType ( ) ) ; xSet -> setPropertyValue ( aPropName , aAny ) ; } OUString aTmpPropName ( RTL_CONSTASCII_USTRINGPARAM ( " " ) ) ; sal_Bool bTrue = sal_True ; aAny . setValue ( & bTrue , :: getBooleanCppuType ( ) ) ; xSet -> setPropertyValue ( aTmpPropName , aAny ) ; if ( rPropSet . is ( ) ) { OUString sPropName ( RTL_CONSTASCII_USTRINGPARAM ( " " ) ) ; rPropSet -> setPropertyValue ( sPropName , makeAny ( sStreamName ) ) ; } sal_Bool bRet = WriteThroughComponent ( xStream -> getOutputStream ( ) , xComponent , rFactory , rPropSet , pComponentName ) ; return bRet ; }
export through an XML exporter component (storage version)
export through an XML exporter component ( storage version )
// open stream // even plain stream must be encrypted in encrypted document // set Base URL // write the stuff // stream is closed by SAX parser //if ( bRet ) //    xStream->getOutputStream()->closeOutput();