use more string_view in utl::TempFile
Change-Id: I151c66479053b9b5b7699a4938a622b4320aeaa0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140104 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
ca3d526a24
commit
898ba5beb4
19 changed files with 37 additions and 51 deletions
|
@ -2477,10 +2477,8 @@ OUString ODbaseTable::createTempFile()
|
|||
if ( aIdent.lastIndexOf('/') != (aIdent.getLength()-1) )
|
||||
aIdent += "/";
|
||||
|
||||
OUString sTempName(aIdent);
|
||||
OUString sExt("." + m_pConnection->getExtension());
|
||||
OUString sName(m_Name);
|
||||
TempFile aTempFile(sName, true, &sExt, &sTempName);
|
||||
TempFile aTempFile(m_Name, true, sExt, &aIdent);
|
||||
if(!aTempFile.IsValid())
|
||||
getConnection()->throwGenericSQLException(STR_COULD_NOT_ALTER_TABLE, *this);
|
||||
|
||||
|
|
|
@ -418,8 +418,7 @@ void XMLFilterTestDialog::doExport( const Reference< XComponent >& xComp )
|
|||
Reference< XStorable > xStorable( xComp, UNO_QUERY );
|
||||
if( xStorable.is() )
|
||||
{
|
||||
OUString const ext(".xml");
|
||||
utl::TempFile aTempFile(u"", true, &ext);
|
||||
utl::TempFile aTempFile(u"", true, u".xml");
|
||||
OUString aTempFileURL( aTempFile.GetURL() );
|
||||
|
||||
const application_info_impl* pAppInfo = getApplicationInfo( m_xFilterInfo->maExportService );
|
||||
|
@ -578,8 +577,7 @@ void XMLFilterTestDialog::import( const OUString& rURL )
|
|||
|
||||
if( m_xCBXDisplaySource->get_active() )
|
||||
{
|
||||
OUString const ext(".xml");
|
||||
TempFile aTempFile(u"", true, &ext);
|
||||
TempFile aTempFile(u"", true, u".xml");
|
||||
OUString aTempFileURL( aTempFile.GetURL() );
|
||||
|
||||
Reference< XImportFilter > xImporter( mxContext->getServiceManager()->createInstanceWithContext( "com.sun.star.documentconversion.XSLTFilter", mxContext ), UNO_QUERY );
|
||||
|
|
|
@ -3485,10 +3485,7 @@ void AutoRecovery::implts_generateNewTempURL(const OUString& sBack
|
|||
|
||||
// TODO: Must we strip some illegal signs - if we use the title?
|
||||
|
||||
OUString sName(sUniqueName.makeStringAndClear());
|
||||
OUString sExtension(rInfo.Extension);
|
||||
OUString sPath(sBackupPath);
|
||||
::utl::TempFile aTempFile(sName, true, &sExtension, &sPath, true);
|
||||
::utl::TempFile aTempFile(sUniqueName, true, rInfo.Extension, &sBackupPath, true);
|
||||
|
||||
rInfo.NewTempURL = aTempFile.GetURL();
|
||||
}
|
||||
|
|
|
@ -252,7 +252,7 @@ public:
|
|||
SAL_DLLPRIVATE void DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent );
|
||||
SAL_DLLPRIVATE void DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent,
|
||||
std::u16string_view aPrefix,
|
||||
const OUString& aExtension,
|
||||
std::u16string_view aExtension,
|
||||
const OUString& aDestDir );
|
||||
|
||||
SAL_DLLPRIVATE bool UseBackupToRestore_Impl( ::ucbhelper::Content& aOriginalContent,
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
The temporary object is created in the local file system, even if there is no UCB that can access it.
|
||||
If the given folder is part of the local file system, the TempFile is created in this folder.
|
||||
*/
|
||||
TempFile( const OUString* pParent=nullptr, bool bDirectory=false );
|
||||
TempFile( const OUString* pParent = nullptr, bool bDirectory=false );
|
||||
|
||||
/**
|
||||
Same as above; additionally the name starts with some given characters followed by a counter ( example:
|
||||
|
@ -68,8 +68,8 @@ public:
|
|||
@param bCreateParentDirs If rLeadingChars contains a slash, this will create the required
|
||||
parent directories.
|
||||
*/
|
||||
TempFile( std::u16string_view rLeadingChars, bool _bStartWithZero=true, const OUString* pExtension=nullptr,
|
||||
const OUString* pParent=nullptr, bool bCreateParentDirs=false );
|
||||
TempFile( std::u16string_view rLeadingChars, bool _bStartWithZero=true, std::u16string_view pExtension={},
|
||||
const OUString* pParent = nullptr, bool bCreateParentDirs=false );
|
||||
|
||||
TempFile(TempFile && other) noexcept;
|
||||
|
||||
|
|
|
@ -172,11 +172,11 @@ OUString OReportEngineJFree::getNewOutputName()
|
|||
if ( sName.isEmpty() )
|
||||
sName = m_xReport->getName();
|
||||
{
|
||||
::utl::TempFile aTestFile(sName, false, &sExt);
|
||||
::utl::TempFile aTestFile(sName, false, sExt);
|
||||
if ( !aTestFile.IsValid() )
|
||||
{
|
||||
sName = RptResId(RID_STR_REPORT);
|
||||
::utl::TempFile aFile(sName, false, &sExt);
|
||||
::utl::TempFile aFile(sName, false, sExt);
|
||||
sFileURL = aFile.GetURL();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -3444,8 +3444,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportDBF(SvStream &rStream)
|
|||
aTmpDir.EnableKillingFile();
|
||||
OUString sTmpDir = aTmpDir.GetURL();
|
||||
|
||||
OUString sExtension(".dbf");
|
||||
utl::TempFile aTempInput(u"", true, &sExtension, &sTmpDir);
|
||||
utl::TempFile aTempInput(u"", true, u".dbf", &sTmpDir);
|
||||
aTempInput.EnableKillingFile();
|
||||
|
||||
SvStream* pInputStream = aTempInput.GetStream(StreamMode::WRITE);
|
||||
|
|
|
@ -21,7 +21,7 @@ private:
|
|||
{
|
||||
FileFormat* pFormat = getFormat(HTML);
|
||||
OUString aExt = "." + OUString::createFromAscii(pFormat->pName);
|
||||
utl::TempFile aTempFile(u"", true, &aExt);
|
||||
utl::TempFile aTempFile(u"", true, aExt);
|
||||
aTempFile.EnableKillingFile();
|
||||
exportTo(xDocShRef.get(), pFormat, aTempFile);
|
||||
return parseHtml(aTempFile);
|
||||
|
|
|
@ -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::TempFile aTempFile(u"NewHelp", true, aExtension, parent, false );
|
||||
|
||||
SvStream* pStream = aTempFile.GetStream(StreamMode::WRITE);
|
||||
pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8);
|
||||
|
|
|
@ -2513,13 +2513,13 @@ void SfxMedium::Transfer_Impl()
|
|||
|
||||
void SfxMedium::DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent,
|
||||
std::u16string_view aPrefix,
|
||||
const OUString& aExtension,
|
||||
std::u16string_view aExtension,
|
||||
const OUString& aDestDir )
|
||||
{
|
||||
if ( !pImpl->m_aBackupURL.isEmpty() )
|
||||
return; // the backup was done already
|
||||
|
||||
::utl::TempFile aTransactTemp( aPrefix, true, &aExtension, &aDestDir );
|
||||
::utl::TempFile aTransactTemp( aPrefix, true, aExtension, &aDestDir );
|
||||
|
||||
INetURLObject aBackObj( aTransactTemp.GetURL() );
|
||||
OUString aBackupName = aBackObj.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset );
|
||||
|
@ -4270,9 +4270,9 @@ OUString SfxMedium::CreateTempCopyWithExt( std::u16string_view aURL )
|
|||
if ( !aURL.empty() )
|
||||
{
|
||||
size_t nPrefixLen = aURL.rfind( '.' );
|
||||
OUString aExt = ( nPrefixLen == std::u16string_view::npos ) ? OUString() : OUString(aURL.substr( nPrefixLen ));
|
||||
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::TempFile( u"", true, aExt ).GetURL();
|
||||
if ( !aNewTempFileURL.isEmpty() )
|
||||
{
|
||||
INetURLObject aSource( aURL );
|
||||
|
@ -4342,10 +4342,10 @@ OUString SfxMedium::SwitchDocumentToTempFile()
|
|||
if ( !aOrigURL.isEmpty() )
|
||||
{
|
||||
sal_Int32 nPrefixLen = aOrigURL.lastIndexOf( '.' );
|
||||
OUString const aExt = (nPrefixLen == -1)
|
||||
? OUString()
|
||||
: aOrigURL.copy(nPrefixLen);
|
||||
OUString aNewURL = ::utl::TempFile( u"", true, &aExt ).GetURL();
|
||||
std::u16string_view aExt = (nPrefixLen == -1)
|
||||
? std::u16string_view()
|
||||
: aOrigURL.subView(nPrefixLen);
|
||||
OUString aNewURL = ::utl::TempFile( u"", true, aExt ).GetURL();
|
||||
|
||||
// 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.
|
||||
|
|
|
@ -77,8 +77,7 @@ void* GraphicHelper::getEnhMetaFileFromGDI_Impl( const GDIMetaFile* pGDIMeta )
|
|||
#ifdef _WIN32
|
||||
if ( pGDIMeta )
|
||||
{
|
||||
OUString const aStr(".emf");
|
||||
::utl::TempFile aTempFile( u"", true, &aStr );
|
||||
::utl::TempFile aTempFile( u"", true, u".emf" );
|
||||
|
||||
OUString aMetaFile = aTempFile.GetFileName();
|
||||
OUString aMetaURL = aTempFile.GetURL();
|
||||
|
|
|
@ -240,7 +240,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const OUString& rPath, bool bOutline,
|
|||
OUString sLeading(aEntry.GetBase());
|
||||
aEntry.removeSegment();
|
||||
OUString sPath = aEntry.GetMainURL( INetURLObject::DecodeMechanism::NONE );
|
||||
utl::TempFile aTemp(sLeading, true, &sExt, &sPath);
|
||||
utl::TempFile aTemp(sLeading, true, sExt, &sPath);
|
||||
aTemp.EnableKillingFile();
|
||||
|
||||
DateTime aTmplDate( DateTime::SYSTEM );
|
||||
|
@ -315,7 +315,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const OUString& rPath, bool bOutline,
|
|||
pDoc->GetNodes().GetEndOfContent().GetIndex() )
|
||||
pDoc->GetNodes().Delete( aIdx );
|
||||
|
||||
utl::TempFile aTempFile2(sLeading, true, &sExt, &sPath);
|
||||
utl::TempFile aTempFile2(sLeading, true, sExt, &sPath);
|
||||
sFileName = aTempFile2.GetURL();
|
||||
SfxMedium* pTmpMed = new SfxMedium( sFileName,
|
||||
StreamMode::STD_READWRITE );
|
||||
|
|
|
@ -367,11 +367,10 @@ IMPL_LINK_NOARG(SwAddressListDialog, CreateHdl_Impl, weld::Button&, void)
|
|||
|
||||
uno::Reference<sdb::XDocumentDataSource> xDS(xNewInstance, UNO_QUERY_THROW);
|
||||
uno::Reference<frame::XStorable> xStore(xDS->getDatabaseDocument(), UNO_QUERY_THROW);
|
||||
OUString const sExt(".odb");
|
||||
OUString sTmpName;
|
||||
{
|
||||
OUString sHomePath(SvtPathOptions().GetWorkPath());
|
||||
utl::TempFile aTempFile(sFind, true, &sExt, &sHomePath);
|
||||
utl::TempFile aTempFile(sFind, true, u".odb", &sHomePath);
|
||||
aTempFile.EnableKillingFile();
|
||||
sTmpName = aTempFile.GetURL();
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ SwMailMergeLayoutPage::SwMailMergeLayoutPage(weld::Container* pPage, SwMailMerge
|
|||
//creating with extension is not supported by a static method :-(
|
||||
OUString const sExt(
|
||||
comphelper::string::stripStart(pSfxFlt->GetDefaultExtension(),'*'));
|
||||
utl::TempFile aTempFile( u"", true, &sExt );
|
||||
utl::TempFile aTempFile( u"", true, sExt );
|
||||
m_sExampleURL = aTempFile.GetURL();
|
||||
aTempFile.EnableKillingFile();
|
||||
}
|
||||
|
|
|
@ -786,12 +786,11 @@ static void lcl_SaveDebugDoc( SfxObjectShell *xTargetDocShell,
|
|||
if( sTempDirURL.isEmpty() )
|
||||
return;
|
||||
|
||||
const OUString sExt( ".odt" );
|
||||
OUString basename = OUString::createFromAscii( name );
|
||||
if (no > 0)
|
||||
basename += OUString::number(no) + "-";
|
||||
// aTempFile is not deleted, but that seems to be intentional
|
||||
utl::TempFile aTempFile( basename, true, &sExt, &sTempDirURL );
|
||||
utl::TempFile aTempFile( basename, true, u".odt", &sTempDirURL );
|
||||
INetURLObject aTempFileURL( aTempFile.GetURL() );
|
||||
auto pDstMed = std::make_unique<SfxMedium>(
|
||||
aTempFileURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ),
|
||||
|
@ -1324,7 +1323,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
|
|||
}
|
||||
|
||||
OUString sExt(comphelper::string::stripStart(pStoreToFilter->GetDefaultExtension(), '*'));
|
||||
aTempFile.reset( new utl::TempFile(sLeading, sColumnData.isEmpty(), &sExt, &sPrefix, true) );
|
||||
aTempFile.reset( new utl::TempFile(sLeading, sColumnData.isEmpty(), sExt, &sPrefix, true) );
|
||||
if( !aTempFile->IsValid() )
|
||||
{
|
||||
ErrorHandler::HandleError( ERRCODE_IO_NOTSUPPORTED );
|
||||
|
@ -2743,9 +2742,8 @@ OUString LoadAndRegisterDataSource_Impl(DBConnURIType type, const uno::Reference
|
|||
if (aOwnURL.isEmpty())
|
||||
{
|
||||
// Cannot embed, as embedded data source would need the URL of the parent document.
|
||||
OUString const sOutputExt = ".odb";
|
||||
OUString sHomePath(SvtPathOptions().GetWorkPath());
|
||||
utl::TempFile aTempFile(sNewName, true, &sOutputExt, pDestDir ? pDestDir : &sHomePath);
|
||||
utl::TempFile aTempFile(sNewName, true, u".odb", pDestDir ? pDestDir : &sHomePath);
|
||||
const OUString& sTmpName = aTempFile.GetURL();
|
||||
xStore->storeAsURL(sTmpName, uno::Sequence<beans::PropertyValue>());
|
||||
}
|
||||
|
|
|
@ -77,9 +77,8 @@ OUString lcl_CheckFileName( const OUString& rNewFilePath,
|
|||
return sRet;
|
||||
}
|
||||
|
||||
OUString rSG = SwGlossaries::GetExtension();
|
||||
//generate generic name
|
||||
utl::TempFile aTemp(u"group", true, &rSG, &rNewFilePath);
|
||||
utl::TempFile aTemp(u"group", true, SwGlossaries::GetExtension(), &rNewFilePath);
|
||||
aTemp.EnableKillingFile();
|
||||
|
||||
INetURLObject aTempURL( aTemp.GetURL() );
|
||||
|
|
|
@ -767,7 +767,7 @@ uno::Any SAL_CALL SwXMailMerge::execute(
|
|||
FILTER_XML,
|
||||
SwDocShell::Factory().GetFilterContainer() );
|
||||
OUString aExtension(comphelper::string::stripStart(pSfxFlt->GetDefaultExtension(), '*'));
|
||||
utl::TempFile aTempFile( u"SwMM", true, &aExtension );
|
||||
utl::TempFile aTempFile( u"SwMM", true, aExtension );
|
||||
m_aTmpFileName = aTempFile.GetURL();
|
||||
|
||||
Reference< XStorable > xStorable( xCurModel, UNO_QUERY );
|
||||
|
|
|
@ -246,7 +246,7 @@ namespace
|
|||
};
|
||||
|
||||
static OUString lcl_createName(
|
||||
std::u16string_view rLeadingChars, Tokens & tokens, const OUString* pExtension,
|
||||
std::u16string_view rLeadingChars, Tokens & tokens, std::u16string_view pExtension,
|
||||
const OUString* pParent, bool bDirectory, bool bKeep, bool bLock,
|
||||
bool bCreateParentDirs )
|
||||
{
|
||||
|
@ -270,8 +270,8 @@ static OUString lcl_createName(
|
|||
while (tokens.next(&token))
|
||||
{
|
||||
OUString aTmp( aName + token );
|
||||
if ( pExtension )
|
||||
aTmp += *pExtension;
|
||||
if ( !pExtension.empty() )
|
||||
aTmp += pExtension;
|
||||
else
|
||||
aTmp += ".tmp";
|
||||
if ( bDirectory )
|
||||
|
@ -342,7 +342,7 @@ static OUString CreateTempName_Impl( const OUString* pParent, bool bKeep, bool b
|
|||
aEyeCatcher += aPidString;
|
||||
#endif
|
||||
UniqueTokens t;
|
||||
return lcl_createName( aEyeCatcher, t, nullptr, pParent, bDir, bKeep,
|
||||
return lcl_createName( aEyeCatcher, t, u"", pParent, bDir, bKeep,
|
||||
false, false);
|
||||
}
|
||||
|
||||
|
@ -365,7 +365,7 @@ TempFile::TempFile( const OUString* pParent, bool bDirectory )
|
|||
}
|
||||
|
||||
TempFile::TempFile( std::u16string_view rLeadingChars, bool _bStartWithZero,
|
||||
const OUString* pExtension, const OUString* pParent,
|
||||
std::u16string_view pExtension, const OUString* pParent,
|
||||
bool bCreateParentDirs )
|
||||
: bIsDirectory( false )
|
||||
, bKillingFileEnabled( false )
|
||||
|
|
|
@ -1730,8 +1730,7 @@ void PngFilterTest::testMsGifInPng()
|
|||
aFilterProperty.Value <<= aAdditionalChunkSequence;
|
||||
uno::Sequence<beans::PropertyValue> aPNGParameters{ aFilterProperty };
|
||||
// Export the png with the chunk
|
||||
OUString ext = u".png";
|
||||
utl::TempFile aTempFile(u"testPngExportMsGif", true, &ext);
|
||||
utl::TempFile aTempFile(u"testPngExportMsGif", true, u".png");
|
||||
if (!bKeepTemp)
|
||||
aTempFile.EnableKillingFile();
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue