diff options
Diffstat (limited to 'filter/source/msfilter/msoleexp.cxx')
-rw-r--r-- | filter/source/msfilter/msoleexp.cxx | 75 |
1 files changed, 20 insertions, 55 deletions
diff --git a/filter/source/msfilter/msoleexp.cxx b/filter/source/msfilter/msoleexp.cxx index 9e68e5cb0ab7..90f04e6ad575 100644 --- a/filter/source/msfilter/msoleexp.cxx +++ b/filter/source/msfilter/msoleexp.cxx @@ -19,10 +19,6 @@ #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/configuration/theDefaultProvider.hpp> -#include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/embed/XEmbeddedObject.hpp> #include <com/sun/star/embed/XEmbedPersist.hpp> #include <com/sun/star/embed/NoVisualAreaSizeException.hpp> @@ -35,9 +31,8 @@ #include <sfx2/fcontnr.hxx> #include <sot/formats.hxx> #include <sot/storage.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <comphelper/fileformat.h> -#include <comphelper/processfactory.hxx> #include <comphelper/propertyvalue.hxx> #include <unotools/streamwrap.hxx> #include <comphelper/storagehelper.hxx> @@ -69,50 +64,20 @@ static SvGlobalName GetEmbeddedVersion( const SvGlobalName& aAppName ) static OUString GetStorageType( const SvGlobalName& aEmbName ) { if ( aEmbName == SvGlobalName( SO3_SM_OLE_EMBED_CLASSID_8 ) ) - return "LibreOffice.MathDocument.1"; + return u"LibreOffice.MathDocument.1"_ustr; else if ( aEmbName == SvGlobalName( SO3_SW_OLE_EMBED_CLASSID_8 ) ) - return "LibreOffice.WriterDocument.1"; + return u"LibreOffice.WriterDocument.1"_ustr; else if ( aEmbName == SvGlobalName( SO3_SC_OLE_EMBED_CLASSID_8 ) ) - return "LibreOffice.CalcDocument.1"; + return u"LibreOffice.CalcDocument.1"_ustr; else if ( aEmbName == SvGlobalName( SO3_SDRAW_OLE_EMBED_CLASSID_8 ) ) - return "LibreOffice.DrawDocument.1"; + return u"LibreOffice.DrawDocument.1"_ustr; else if ( aEmbName == SvGlobalName( SO3_SIMPRESS_OLE_EMBED_CLASSID_8 ) ) - return "LibreOffice.ImpressDocument.1"; + return u"LibreOffice.ImpressDocument.1"_ustr; else if ( aEmbName == SvGlobalName( SO3_SCH_OLE_EMBED_CLASSID_8 ) ) - return "LibreOffice.ChartDocument.1"; + return u"LibreOffice.ChartDocument.1"_ustr; return OUString(); } -static bool UseOldMSExport() -{ - uno::Reference< lang::XMultiServiceFactory > xProvider( - configuration::theDefaultProvider::get( - comphelper::getProcessComponentContext())); - try { - uno::Sequence< uno::Any > aArg{ uno::Any( - OUString( "/org.openoffice.Office.Common/InternalMSExport" )) }; - uno::Reference< container::XNameAccess > xNameAccess( - xProvider->createInstanceWithArguments( - "com.sun.star.configuration.ConfigurationUpdateAccess", - aArg ), - uno::UNO_QUERY ); - if ( xNameAccess.is() ) - { - uno::Any aResult = xNameAccess->getByName( "UseOldExport" ); - - bool bResult; - if ( aResult >>= bResult ) - return bResult; - } - } - catch( const uno::Exception& ) - { - } - - OSL_FAIL( "Could not get access to configuration entry!" ); - return false; -} - void SvxMSExportOLEObjects::ExportOLEObject( const css::uno::Reference < css::embed::XEmbeddedObject>& rObj, SotStorage& rDestStg ) { svt::EmbeddedObjectRef aObj( rObj, embed::Aspects::MSOLE_CONTENT ); @@ -193,17 +158,17 @@ void SvxMSExportOLEObjects::ExportOLEObject( svt::EmbeddedObjectRef const & rObj SvStream* pStream = new SvMemoryStream; ::uno::Reference < io::XOutputStream > xOut = new ::utl::OOutputStreamWrapper( *pStream ); uno::Sequence < beans::PropertyValue > aSeq{ - comphelper::makePropertyValue("OutputStream", xOut), - comphelper::makePropertyValue("FilterName", pExpFilter->GetName()) + comphelper::makePropertyValue(u"OutputStream"_ustr, xOut), + comphelper::makePropertyValue(u"FilterName"_ustr, pExpFilter->GetName()) }; uno::Reference < frame::XStorable > xStor( rObj->getComponent(), uno::UNO_QUERY ); try { - xStor->storeToURL( "private:stream", aSeq ); + xStor->storeToURL( u"private:stream"_ustr, aSeq ); } catch( const uno::Exception& ) {} // #TODO really handle exceptions - interactionalhandler etc. ? - tools::SvRef<SotStorage> xOLEStor = new SotStorage( pStream, true ); + rtl::Reference<SotStorage> xOLEStor = new SotStorage( pStream, true ); xOLEStor->CopyTo( &rDestStg ); rDestStg.Commit(); } @@ -217,15 +182,15 @@ void SvxMSExportOLEObjects::ExportOLEObject( svt::EmbeddedObjectRef const & rObj { // own format, maybe SO6 format or lower SvGlobalName aEmbName = GetEmbeddedVersion( aOwnGlobalName ); - if ( aEmbName != SvGlobalName() && !UseOldMSExport() ) + if ( aEmbName != SvGlobalName() ) { // this is a SO6 embedded object, save in old binary format rDestStg.SetVersion( SOFFICE_FILEFORMAT_31 ); rDestStg.SetClass( aEmbName, SotClipboardFormatId::EMBEDDED_OBJ_OLE, GetStorageType( aEmbName ) ); - tools::SvRef<SotStorageStream> xExtStm = rDestStg.OpenSotStream( - "properties_stream"); + rtl::Reference<SotStorageStream> xExtStm = rDestStg.OpenSotStream( + u"properties_stream"_ustr); bool bExtentSuccess = false; if( !xExtStm->GetError() ) @@ -279,8 +244,8 @@ void SvxMSExportOLEObjects::ExportOLEObject( svt::EmbeddedObjectRef const & rObj if ( bExtentSuccess ) { - tools::SvRef<SotStorageStream> xEmbStm = rDestStg.OpenSotStream( - "package_stream"); + rtl::Reference<SotStorageStream> xEmbStm = rDestStg.OpenSotStream( + u"package_stream"_ustr); if( !xEmbStm->GetError() ) { try @@ -291,9 +256,9 @@ void SvxMSExportOLEObjects::ExportOLEObject( svt::EmbeddedObjectRef const & rObj //TODO/LATER: a "StoreTo" method at embedded object would be nice ::uno::Reference < io::XOutputStream > xOut = new ::utl::OOutputStreamWrapper( *xEmbStm ); uno::Sequence < beans::PropertyValue > aSeq{ comphelper::makePropertyValue( - "OutputStream", xOut) }; + u"OutputStream"_ustr, xOut) }; uno::Reference < frame::XStorable > xStor( rObj->getComponent(), uno::UNO_QUERY ); - xStor->storeToURL( "private:stream", aSeq ); + xStor->storeToURL( u"private:stream"_ustr, aSeq ); } catch( const uno::Exception& ) { @@ -318,7 +283,7 @@ void SvxMSExportOLEObjects::ExportOLEObject( svt::EmbeddedObjectRef const & rObj if ( xPers.is() ) { uno::Sequence < beans::PropertyValue > aEmptySeq; - OUString aTempName( "bla" ); + OUString aTempName( u"bla"_ustr ); try { xPers->storeToEntry( xStor, aTempName, aEmptySeq, aEmptySeq ); @@ -326,7 +291,7 @@ void SvxMSExportOLEObjects::ExportOLEObject( svt::EmbeddedObjectRef const & rObj catch ( const uno::Exception& ) {} - tools::SvRef<SotStorage> xOLEStor = SotStorage::OpenOLEStorage( xStor, aTempName, StreamMode::STD_READ ); + rtl::Reference<SotStorage> xOLEStor = SotStorage::OpenOLEStorage( xStor, aTempName, StreamMode::STD_READ ); xOLEStor->CopyTo( &rDestStg ); rDestStg.Commit(); } |