summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2016-08-30 13:42:20 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2016-09-23 23:25:49 +0200
commit3c4dfb872d50413b605fb846dfdebd28947026e8 (patch)
treed8c53251254a416528ecdf6babb30a0bd7d71da4 /sw/source/uibase
parent260cd3aeea2d02507dd131ee2028c4f48f7562f8 (diff)
tdf#94987 Create directories for temp filenames
Per default a temporary file is construted from a path and a leading pattern for the filename. For mail merge the filename can be read from a database column. If the path is not existing, a temporary directory is created. Normally the temp file function would fail, if the filename contains a slash and the sub-directory of the filename doesn't exists as a subdirectory of path. To implement tdf#94987, this adds an option to the temp file class to create the parent directories of the filename pattern. Change-Id: I02bf34294dac85598ee153d8cfcf00bc5d7775af
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx29
1 files changed, 16 insertions, 13 deletions
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index ff90ea629dba..86e2d7e171ca 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -1314,7 +1314,6 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
{
nStartRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
- OUString sPath = rMergeDescriptor.sPath;
OUString sColumnData;
// Read the indicated data column, which should contain a valid mail
@@ -1322,28 +1321,32 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
if( bMT_EMAIL || bColumnName )
{
sColumnData = GetDBField( xColumnProp, aColumnDBFormat );
- if( !bMT_EMAIL )
- {
- if (sColumnData.isEmpty())
- sColumnData = "_";
- sPath += sColumnData;
- }
}
// create a new temporary file name - only done once in case of bCreateSingleFile
if( bNeedsTempFiles && ( !bWorkDocInitialized || !bCreateSingleFile ))
{
- INetURLObject aEntry(sPath);
+ OUString sPath = rMergeDescriptor.sPath;
OUString sLeading;
+
//#i97667# if the name is from a database field then it will be used _as is_
- if( !sColumnData.isEmpty() )
- sLeading = sColumnData;
+ if( bColumnName && !bMT_EMAIL )
+ {
+ if (!sColumnData.isEmpty())
+ sLeading = sColumnData;
+ else
+ sLeading = "_";
+ }
else
+ {
+ INetURLObject aEntry( sPath );
sLeading = aEntry.GetBase();
- aEntry.removeSegment();
- sPath = aEntry.GetMainURL( INetURLObject::NO_DECODE );
+ aEntry.removeSegment();
+ sPath = aEntry.GetMainURL( INetURLObject::NO_DECODE );
+ }
+
OUString sExt(comphelper::string::stripStart(pStoreToFilter->GetDefaultExtension(), '*'));
- aTempFile.reset( new utl::TempFile(sLeading, sColumnData.isEmpty(), &sExt, &sPath) );
+ aTempFile.reset( new utl::TempFile(sLeading, sColumnData.isEmpty(), &sExt, &sPath, true) );
if( !aTempFile->IsValid() )
{
ErrorHandler::HandleError( ERRCODE_IO_NOTSUPPORTED );