diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-09-21 20:54:00 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-29 09:11:18 +0200 |
commit | 4b95451f859bac8e05956ce12df17f1ee410032d (patch) | |
tree | 2ebe03c8ecbba3c9179d33c346774e037fcfc224 /sfx2 | |
parent | a08468c1a5255d3fb04cd8a0dc627acdea40426a (diff) |
split utl::TempFile into fast and named variants
which makes it easier to know what each variant requires
to stay on it's happy path
Change-Id: I3275a2543573367714bc78092e882f6535507285
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140469
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/qa/cppunit/test_misc.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/appl/flatpak.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/appl/sfxhelp.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/appl/xpackcreator.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/mailmodel.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 17 | ||||
-rw-r--r-- | sfx2/source/doc/graphhelp.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/printhelper.cxx | 10 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 3 |
11 files changed, 25 insertions, 30 deletions
diff --git a/sfx2/qa/cppunit/test_misc.cxx b/sfx2/qa/cppunit/test_misc.cxx index 1bf90cfbc218..ae721c50c892 100644 --- a/sfx2/qa/cppunit/test_misc.cxx +++ b/sfx2/qa/cppunit/test_misc.cxx @@ -80,7 +80,7 @@ CPPUNIT_TEST_FIXTURE(MiscTest, testODFCustomMetadata) uno::Sequence<beans::PropertyValue> mimeArgs({ beans::PropertyValue("MediaType", -1, uno::Any(OUString("application/vnd.oasis.opendocument.text")), beans::PropertyState_DIRECT_VALUE) }); - utl::TempFile aTempFile; + utl::TempFileNamed aTempFile; xProps->storeToMedium(aTempFile.GetURL(), mimeArgs); // check that custom metadata is preserved @@ -111,7 +111,7 @@ CPPUNIT_TEST_FIXTURE(MiscTest, testNoThumbnail) #endif uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY); CPPUNIT_ASSERT(xStorable.is()); - utl::TempFile aTempFile; + utl::TempFileNamed aTempFile; aTempFile.EnableKillingFile(); uno::Sequence<beans::PropertyValue> aProperties( comphelper::InitPropertySequence({ { "NoThumbnail", uno::Any(true) } })); @@ -193,7 +193,7 @@ CPPUNIT_TEST_FIXTURE(MiscTest, testHardLinks) CPPUNIT_TEST_FIXTURE(MiscTest, testOverwrite) { // tdf#60237 - try to overwrite an existing file using the different settings of the Overwrite option - utl::TempFile aTempFile; + utl::TempFileNamed aTempFile; aTempFile.EnableKillingFile(); uno::Reference<lang::XComponent> xComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument"); diff --git a/sfx2/source/appl/flatpak.cxx b/sfx2/source/appl/flatpak.cxx index 2ed2fe2101d8..c6edf6f23276 100644 --- a/sfx2/source/appl/flatpak.cxx +++ b/sfx2/source/appl/flatpak.cxx @@ -72,13 +72,12 @@ bool flatpak::createTemporaryHtmlDirectory(OUString ** url) { if (!parent.endsWith("/")) { parent += "/"; } - auto const tmp = utl::TempFile(&parent, true); - if (!tmp.IsValid()) { + temporaryHtmlDirectoryStatus.url = utl::CreateTempURL(&parent, true); + if (temporaryHtmlDirectoryStatus.url.isEmpty()) { SAL_WARN( "sfx.appl", "LIBO_FLATPAK mode failure creating temp dir at <" << parent << ">"); return false; } - temporaryHtmlDirectoryStatus.url = tmp.GetURL(); temporaryHtmlDirectoryStatus.created = true; } *url = &temporaryHtmlDirectoryStatus.url; diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx index 01641418de9f..d4c9bc7f5a6f 100644 --- a/sfx2/source/appl/sfxhelp.cxx +++ b/sfx2/source/appl/sfxhelp.cxx @@ -961,7 +961,7 @@ static bool impl_showOfflineHelp(const OUString& rURL, weld::Widget* pDialogPare if (flatpak::isFlatpak() && !flatpak::createTemporaryHtmlDirectory(&parent)) { return false; } - ::utl::TempFile aTempFile(u"NewHelp", true, aExtension, parent, false ); + ::utl::TempFileNamed aTempFile(u"NewHelp", true, aExtension, parent, false ); SvStream* pStream = aTempFile.GetStream(StreamMode::WRITE); pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8); diff --git a/sfx2/source/appl/xpackcreator.cxx b/sfx2/source/appl/xpackcreator.cxx index b9aa2b53cdcf..29ebcc615552 100644 --- a/sfx2/source/appl/xpackcreator.cxx +++ b/sfx2/source/appl/xpackcreator.cxx @@ -65,7 +65,7 @@ void SAL_CALL OPackageStructureCreator::convertToPackage( const OUString& aFolde ::ucbhelper::Content aContent; if( ::ucbhelper::Content::create( aFolderUrl, xComEnv, comphelper::getProcessComponentContext(), aContent ) ) { - OUString aTempURL = ::utl::TempFile().GetURL(); + OUString aTempURL = ::utl::CreateTempURL(); try { if ( aContent.isFolder() ) { diff --git a/sfx2/source/dialog/mailmodel.cxx b/sfx2/source/dialog/mailmodel.cxx index 382a677369f4..35845bf7d2cf 100644 --- a/sfx2/source/dialog/mailmodel.cxx +++ b/sfx2/source/dialog/mailmodel.cxx @@ -457,9 +457,7 @@ SfxMailModel::SaveResult SfxMailModel::SaveDocumentAsFormat( // This makes it possible to store the file for "send document as e-mail" // with the original file name. We cannot use the original file as // some mail programs need exclusive access. - ::utl::TempFile aTempDir( nullptr, true ); - - INetURLObject aFilePathObj( aTempDir.GetURL() ); + INetURLObject aFilePathObj( ::utl::CreateTempURL(nullptr, true) ); aFilePathObj.insertName( aFileName ); aFilePathObj.setExtension( aExtension ); diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 826e77f2533a..a0f789884d4c 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -399,7 +399,7 @@ public: uno::Sequence < util::RevisionTag > aVersions; - std::unique_ptr<::utl::TempFile> pTempFile; + std::unique_ptr<::utl::TempFileNamed> pTempFile; uno::Reference<embed::XStorage> xStorage; uno::Reference<embed::XStorage> m_xZipStorage; @@ -1785,8 +1785,7 @@ uno::Reference < embed::XStorage > SfxMedium::GetStorage( bool bCreateTempFile ) if ( pStream && pStream->GetError() == ERRCODE_NONE ) { // Unpack Stream in TempDir - ::utl::TempFile aTempFile; - const OUString& aTmpName = aTempFile.GetURL(); + const OUString aTmpName = ::utl::CreateTempURL(); SvFileStream aTmpStream( aTmpName, SFX_STREAM_READWRITE ); pStream->ReadStream( aTmpStream ); @@ -2519,7 +2518,7 @@ void SfxMedium::DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalCont if ( !pImpl->m_aBackupURL.isEmpty() ) return; // the backup was done already - ::utl::TempFile aTransactTemp( aPrefix, true, aExtension, &aDestDir ); + ::utl::TempFileNamed aTransactTemp( aPrefix, true, aExtension, &aDestDir ); INetURLObject aBackObj( aTransactTemp.GetURL() ); OUString aBackupName = aBackObj.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset ); @@ -3324,7 +3323,7 @@ void SfxMedium::CompleteReOpen() bool bUseInteractionHandler = pImpl->bUseInteractionHandler; pImpl->bUseInteractionHandler = false; - std::unique_ptr<::utl::TempFile> pTmpFile; + std::unique_ptr<::utl::TempFileNamed> pTmpFile; if ( pImpl->pTempFile ) { pTmpFile = std::move(pImpl->pTempFile); @@ -3831,7 +3830,7 @@ void SfxMedium::CreateTempFile( bool bReplace ) } OUString aLogicBase = GetLogicBase(GetURLObject(), pImpl); - pImpl->pTempFile.reset(new ::utl::TempFile(&aLogicBase)); + pImpl->pTempFile.reset(new ::utl::TempFileNamed(&aLogicBase)); pImpl->pTempFile->EnableKillingFile(); pImpl->m_aName = pImpl->pTempFile->GetFileName(); OUString aTmpURL = pImpl->pTempFile->GetURL(); @@ -3927,7 +3926,7 @@ void SfxMedium::CreateTempFileNoCopy() pImpl->pTempFile.reset(); OUString aLogicBase = GetLogicBase(GetURLObject(), pImpl); - pImpl->pTempFile.reset(new ::utl::TempFile(&aLogicBase)); + pImpl->pTempFile.reset(new ::utl::TempFileNamed(&aLogicBase)); pImpl->pTempFile->EnableKillingFile(); pImpl->m_aName = pImpl->pTempFile->GetFileName(); if ( pImpl->m_aName.isEmpty() ) @@ -4272,7 +4271,7 @@ OUString SfxMedium::CreateTempCopyWithExt( std::u16string_view aURL ) size_t nPrefixLen = aURL.rfind( '.' ); std::u16string_view aExt = ( nPrefixLen == std::u16string_view::npos ) ? std::u16string_view() : aURL.substr( nPrefixLen ); - OUString aNewTempFileURL = ::utl::TempFile( u"", true, aExt ).GetURL(); + OUString aNewTempFileURL = ::utl::CreateTempURL( u"", true, aExt ); if ( !aNewTempFileURL.isEmpty() ) { INetURLObject aSource( aURL ); @@ -4345,7 +4344,7 @@ OUString SfxMedium::SwitchDocumentToTempFile() std::u16string_view aExt = (nPrefixLen == -1) ? std::u16string_view() : aOrigURL.subView(nPrefixLen); - OUString aNewURL = ::utl::TempFile( u"", true, aExt ).GetURL(); + OUString aNewURL = ::utl::CreateTempURL( u"", true, aExt ); // TODO/LATER: In future the aLogicName should be set to shared folder URL // and a temporary file should be created. Transport_Impl should be impossible then. diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx index 84da6209172a..754d5692f8c7 100644 --- a/sfx2/source/doc/graphhelp.cxx +++ b/sfx2/source/doc/graphhelp.cxx @@ -77,7 +77,7 @@ void* GraphicHelper::getEnhMetaFileFromGDI_Impl( const GDIMetaFile* pGDIMeta ) #ifdef _WIN32 if ( pGDIMeta ) { - ::utl::TempFile aTempFile( u"", true, u".emf" ); + ::utl::TempFileNamed aTempFile( u"", true, u".emf" ); OUString aMetaFile = aTempFile.GetFileName(); OUString aMetaURL = aTempFile.GetURL(); diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 98e87e2963f5..6c83b4066466 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -248,7 +248,7 @@ bool SfxObjectShell::PutURLContentsToVersionStream_Impl( OUString SfxObjectShell::CreateTempCopyOfStorage_Impl( const uno::Reference< embed::XStorage >& xStorage ) { - OUString aTempURL = ::utl::TempFile().GetURL(); + OUString aTempURL = ::utl::CreateTempURL(); DBG_ASSERT( !aTempURL.isEmpty(), "Can't create a temporary file!\n" ); if ( !aTempURL.isEmpty() ) diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx index cd2dc78bb0c0..732aca4f3a33 100644 --- a/sfx2/source/doc/printhelper.cxx +++ b/sfx2/source/doc/printhelper.cxx @@ -461,11 +461,11 @@ class ImplUCBPrintWatcher : public ::osl::Thread /// this describes the target location for the printed temp file OUString m_sTargetURL; /// it holds the temp file alive, till the print job will finish and remove it from disk automatically if the object die - ::utl::TempFile* m_pTempFile; + ::utl::TempFileNamed* m_pTempFile; public: /* initialize this watcher but don't start it */ - ImplUCBPrintWatcher( SfxPrinter* pPrinter, ::utl::TempFile* pTempFile, OUString sTargetURL ) + ImplUCBPrintWatcher( SfxPrinter* pPrinter, ::utl::TempFileNamed* pTempFile, OUString sTargetURL ) : m_pPrinter ( pPrinter ) , m_sTargetURL(std::move( sTargetURL )) , m_pTempFile ( pTempFile ) @@ -508,7 +508,7 @@ class ImplUCBPrintWatcher : public ::osl::Thread the thread, if finishing of the job was detected outside this thread. But it must be called without using a corresponding thread for the given parameter! */ - static void moveAndDeleteTemp( ::utl::TempFile** ppTempFile, std::u16string_view sTargetURL ) + static void moveAndDeleteTemp( ::utl::TempFileNamed** ppTempFile, std::u16string_view sTargetURL ) { // move the file try @@ -577,7 +577,7 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& // a local one we can suppress this special handling. Because then vcl makes all // right for us. OUString sUcbUrl; - ::utl::TempFile* pUCBPrintTempFile = nullptr; + ::utl::TempFileNamed* pUCBPrintTempFile = nullptr; uno::Sequence < beans::PropertyValue > aCheckedArgs( rOptions.getLength() ); auto pCheckedArgs = aCheckedArgs.getArray(); @@ -654,7 +654,7 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& // Execution of the print job will be done later by executing // a slot ... if(!pUCBPrintTempFile) - pUCBPrintTempFile = new ::utl::TempFile(); + pUCBPrintTempFile = new ::utl::TempFileNamed(); pUCBPrintTempFile->EnableKillingFile(); //FIXME: does it work? diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index de2e9e2bc235..ebfa497aaef1 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -2057,7 +2057,7 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla try { - utl::TempFile aTmp; + utl::TempFileNamed aTmp; aTmp.EnableKillingFile(); storeToURL( aTmp.GetURL(), Sequence < beans::PropertyValue >() ); std::unique_ptr<SvStream> pStream(aTmp.GetStream( StreamMode::READ )); diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 2e53fa583828..fe7991553afc 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -616,9 +616,8 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) { SAL_WARN("sfx.view", "cannot create Flatpak html temp dir"); } - ::utl::TempFile aTempDir( parent, true ); - INetURLObject aFilePathObj( aTempDir.GetURL() ); + INetURLObject aFilePathObj( ::utl::CreateTempURL(parent, true) ); aFilePathObj.insertName( aFileName ); aFilePathObj.setExtension( u"htm" ); |