diff options
Diffstat (limited to 'filter/source/xsltdialog/xmlfilterjar.cxx')
-rw-r--r-- | filter/source/xsltdialog/xmlfilterjar.cxx | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/filter/source/xsltdialog/xmlfilterjar.cxx b/filter/source/xsltdialog/xmlfilterjar.cxx index 3ddaed0df05c..01ec7af8ccd8 100644 --- a/filter/source/xsltdialog/xmlfilterjar.cxx +++ b/filter/source/xsltdialog/xmlfilterjar.cxx @@ -37,7 +37,7 @@ #include <unotools/streamwrap.hxx> #include <unotools/tempfile.hxx> #include <svl/urihelper.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <tools/stream.hxx> #include <tools/urlobj.hxx> @@ -60,7 +60,7 @@ using namespace com::sun::star::io; using ::rtl::Uri; -constexpr OUStringLiteral sVndSunStarPackage(u"vnd.sun.star.Package:"); +constexpr OUString sVndSunStarPackage(u"vnd.sun.star.Package:"_ustr); XMLFilterJarHelper::XMLFilterJarHelper( const Reference< XComponentContext >& rxContext ) : mxContext( rxContext ), @@ -85,8 +85,7 @@ static Reference< XInterface > addFolder( Reference< XInterface > const & xRootF if ( rName == ".." || rName == "." ) throw lang::IllegalArgumentException(); - Sequence< Any > aArgs(1); - aArgs[0] <<= true; + Sequence< Any > aArgs{ Any(true) }; Reference< XInterface > xFolder( xFactory->createInstanceWithArguments(aArgs) ); Reference< XNamed > xNamed( xFolder, UNO_QUERY ); @@ -110,7 +109,7 @@ static void addFile_( Reference< XInterface > const & xRootFolder, Reference< XS if( xSink.is() && xTunnel.is()) { Reference< XNameContainer > xNameContainer(xRootFolder, UNO_QUERY ); - xNameContainer->insertByName(encodeZipUri( aName ), makeAny(xTunnel)); + xNameContainer->insertByName(encodeZipUri( aName ), Any(xTunnel)); xSink->setInputStream( xInput ); } } @@ -147,14 +146,10 @@ bool XMLFilterJarHelper::savePackage( const OUString& rPackageURL, const std::ve // create the package jar file - Sequence< Any > aArguments( 2 ); - aArguments[ 0 ] <<= rPackageURL; - - // let ZipPackage be used ( no manifest.xml is required ) - beans::NamedValue aArg; - aArg.Name = "StorageFormat"; - aArg.Value <<= OUString(ZIP_STORAGE_FORMAT_STRING); - aArguments[ 1 ] <<= aArg; + Sequence< Any > aArguments{ Any(rPackageURL), + // let ZipPackage be used ( no manifest.xml is required ) + Any(beans::NamedValue( + "StorageFormat", Any(ZIP_STORAGE_FORMAT_STRING))) }; Reference< XHierarchicalNameAccess > xIfc( mxContext->getServiceManager()->createInstanceWithArgumentsAndContext( @@ -196,20 +191,18 @@ bool XMLFilterJarHelper::savePackage( const OUString& rPackageURL, const std::ve } // create TypeDetection.xcu - utl::TempFile aTempFile; - aTempFile.EnableKillingFile(); - OUString aTempFileURL( aTempFile.GetURL() ); + utl::TempFileFast aTempFile; + SvStream* pStream = aTempFile.GetStream(StreamMode::READWRITE); { - osl::File aOutputFile( aTempFileURL ); - (void)aOutputFile.open(osl_File_OpenFlag_Write); - Reference< XOutputStream > xOS( new OSLOutputStreamWrapper( aOutputFile ) ); + Reference< XOutputStream > xOS( new ::utl::OOutputStreamWrapper( *pStream ) ); TypeDetectionExporter aExporter( mxContext ); aExporter.doExport(xOS,rFilters); } - Reference< XInputStream > XIS( new utl::OSeekableInputStreamWrapper( new SvFileStream(aTempFileURL, StreamMode::READ ), true ) ); + pStream->Seek(0); + Reference< XInputStream > XIS( new utl::OSeekableInputStreamWrapper( *pStream ) ); addFile_( xRootFolder, xFactory, XIS, "TypeDetection.xcu" ); Reference< XChangesBatch > xBatch( xIfc, UNO_QUERY ); @@ -237,14 +230,11 @@ void XMLFilterJarHelper::openPackage( const OUString& rPackageURL, { // create the package jar file - Sequence< Any > aArguments( 2 ); - aArguments[ 0 ] <<= rPackageURL; - // let ZipPackage be used ( no manifest.xml is required ) beans::NamedValue aArg; aArg.Name = "StorageFormat"; - aArg.Value <<= OUString(ZIP_STORAGE_FORMAT_STRING); - aArguments[ 1 ] <<= aArg; + aArg.Value <<= ZIP_STORAGE_FORMAT_STRING; + Sequence< Any > aArguments{ Any(rPackageURL), Any(aArg) }; Reference< XHierarchicalNameAccess > xIfc( mxContext->getServiceManager()->createInstanceWithArgumentsAndContext( @@ -307,7 +297,7 @@ bool XMLFilterJarHelper::copyFiles( const Reference< XHierarchicalNameAccess >& return bOk; } -bool XMLFilterJarHelper::copyFile( const Reference< XHierarchicalNameAccess >& xIfc, OUString& rURL, const OUString& rTargetURL ) +bool XMLFilterJarHelper::copyFile( const Reference< XHierarchicalNameAccess >& xIfc, OUString& rURL, std::u16string_view rTargetURL ) { if( !rURL.matchIgnoreAsciiCase( sVndSunStarPackage ) ) return true; @@ -316,8 +306,8 @@ bool XMLFilterJarHelper::copyFile( const Reference< XHierarchicalNameAccess >& x { OUString szPackagePath( encodeZipUri( rURL.copy( sVndSunStarPackage.getLength() ) ) ); - if ( ::comphelper::OStorageHelper::PathHasSegment( szPackagePath, ".." ) - || ::comphelper::OStorageHelper::PathHasSegment( szPackagePath, "." ) ) + if ( ::comphelper::OStorageHelper::PathHasSegment( szPackagePath, u".." ) + || ::comphelper::OStorageHelper::PathHasSegment( szPackagePath, u"." ) ) throw lang::IllegalArgumentException(); if( xIfc->hasByHierarchicalName( szPackagePath ) ) |