[Libreoffice-commits] core.git: Branch 'feature/mailmerge-cleanup' - 2 commits - include/sfx2 sc/source sfx2/source sw/source
Jan-Marek Glogowski
glogow at fbihome.de
Tue Mar 15 10:57:31 UTC 2016
Rebased ref, commits from common ancestor:
commit ec0b712449caddf3cc9286aa89e9f9a9c69a6f2d
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date: Wed Feb 10 19:24:50 2016 +0100
MM: fix debug document dumping
Previously the debug documents were dumped to the temporary mail
merge directory, which is removed at the end of MM. So this dumps
the document to an extra directory.
Also fixes the broken reinterpret_cast "env" => "int" conversation
to get the real number of documents, which work with multi-digit
numbers.
Change-Id: I456b506e9a70cffdfc93cb3eadd39c454a536343
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 642aedd..6f46ef8 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -850,12 +850,27 @@ static void lcl_RemoveSectionLinks( SwWrtShell& rWorkShell )
static void lcl_SaveDebugDoc( SfxObjectShell *xTargetDocShell,
const char *name, int no = 0 )
{
+ static OUString sTempDirURL;
+ if( sTempDirURL.isEmpty() )
+ {
+ SvtPathOptions aPathOpt;
+ utl::TempFile aTempDir( &aPathOpt.GetTempPath(), true );
+ if( aTempDir.IsValid() )
+ {
+ INetURLObject aTempDirURL( aTempDir.GetURL() );
+ sTempDirURL = aTempDirURL.GetMainURL( INetURLObject::NO_DECODE );
+ SAL_INFO( "sw.mailmerge", "Dump directory: " << sTempDirURL );
+ }
+ }
+ 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);
+ utl::TempFile aTempFile( basename, true, &sExt, &sTempDirURL );
INetURLObject aTempFileURL( aTempFile.GetURL() );
SfxMedium* pDstMed = new SfxMedium(
aTempFileURL.GetMainURL( INetURLObject::NO_DECODE ),
@@ -1101,7 +1116,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
if (!sMaxDumpDocs)
sMaxDumpDocs = "";
else
- nMaxDumpDocs = rtl_ustr_toInt32(reinterpret_cast<const sal_Unicode*>( sMaxDumpDocs ), 10);
+ nMaxDumpDocs = OUString(sMaxDumpDocs, strlen(sMaxDumpDocs), osl_getThreadTextEncoding()).toInt32();
}
::rtl::Reference< MailDispatcher > xMailDispatcher;
commit d9d59717f20a8a9dd8ff9eb5bf2d7fb550e91962
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date: Mon Feb 1 22:00:37 2016 +0100
MM: remove lock from saved documents
Actually we have to call DoSaveCompleted to get rid of the locking.
Instead this adds a parameter to skip the recent file registration
used in non bCreateSingleFile modes.
Change-Id: I57151f08ad8d737007da84c4566685cc37612dfb
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index 9f2f71a..ccc7213 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -327,7 +327,7 @@ public:
bool DoSaveObjectAs( SfxMedium &rNewStor, bool bCommit );
// TODO/LATER: currently only overridden in Calc, should be made non-virtual
- virtual bool DoSaveCompleted( SfxMedium* pNewStor=nullptr );
+ virtual bool DoSaveCompleted( SfxMedium* pNewStor=nullptr, bool bRegisterRecent=true );
bool LoadOwnFormat( SfxMedium& pMedium );
virtual bool SaveAsOwnFormat( SfxMedium& pMedium );
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 4c69ed1..b48e46d 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -2449,9 +2449,9 @@ bool ScDocShell::SaveCompleted( const uno::Reference < embed::XStorage >& xStor
return SfxObjectShell::SaveCompleted( xStor );
}
-bool ScDocShell::DoSaveCompleted( SfxMedium * pNewStor )
+bool ScDocShell::DoSaveCompleted( SfxMedium * pNewStor, bool bRegisterRecent )
{
- bool bRet = SfxObjectShell::DoSaveCompleted( pNewStor );
+ bool bRet = SfxObjectShell::DoSaveCompleted( pNewStor, bRegisterRecent );
// SC_HINT_DOC_SAVED for change ReadOnly -> Read/Write
Broadcast( SfxSimpleHint( SC_HINT_DOC_SAVED ) );
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 23755ba..131a34f 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -203,7 +203,7 @@ public:
virtual void LoadStyles( SfxObjectShell &rSource ) override;
virtual bool SaveCompleted( const css::uno::Reference< css::embed::XStorage >& ) override; // SfxInPlaceObject
- virtual bool DoSaveCompleted( SfxMedium * pNewStor) override; // SfxObjectShell
+ virtual bool DoSaveCompleted( SfxMedium * pNewStor, bool bRegisterRecent ) override; // SfxObjectShell
virtual bool QuerySlotExecutable( sal_uInt16 nSlotId ) override;
virtual void Draw( OutputDevice *, const JobSetup & rSetup,
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index b6de496..62edc74 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -1942,7 +1942,7 @@ bool SfxObjectShell::DoSaveAs( SfxMedium& rMedium )
}
-bool SfxObjectShell::DoSaveCompleted( SfxMedium* pNewMed )
+bool SfxObjectShell::DoSaveCompleted( SfxMedium* pNewMed, bool bRegisterRecent )
{
bool bOk = true;
bool bMedChanged = pNewMed && pNewMed!=pMedium;
@@ -2092,7 +2092,8 @@ bool SfxObjectShell::DoSaveCompleted( SfxMedium* pNewMed )
pMedium->ClearBackup_Impl();
pMedium->LockOrigFileOnDemand( true, false );
- AddToRecentlyUsedList();
+ if (bRegisterRecent)
+ AddToRecentlyUsedList();
return bOk;
}
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 094c97b..642aedd 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -860,7 +860,10 @@ static void lcl_SaveDebugDoc( SfxObjectShell *xTargetDocShell,
SfxMedium* pDstMed = new SfxMedium(
aTempFileURL.GetMainURL( INetURLObject::NO_DECODE ),
STREAM_STD_READWRITE );
- if( !xTargetDocShell->DoSaveAs( *pDstMed ) )
+ bool bAnyError = !xTargetDocShell->DoSaveAs( *pDstMed );
+ // xObjectShell->DoSaveCompleted crashes the mail merge unit tests, so skip it
+ bAnyError |= (0 != xTargetDocShell->GetError());
+ if( bAnyError )
SAL_WARN( "sw.mailmerge", "Error saving: " << aTempFile.GetURL() );
else
SAL_INFO( "sw.mailmerge", "Saved doc as: " << aTempFile.GetURL() );
@@ -900,12 +903,10 @@ static bool lcl_SaveDoc(
rWorkShell.ConvertFieldsToText();
bool bAnyError = !xObjectShell->DoSaveAs(*pDstMed);
-
// Actually this should be a bool... so in case of email and individual
// files, where this is set, we skip the the recently used handling
- if( !decodedURL )
- xObjectShell->DoSaveCompleted( pDstMed );
- bAnyError = bAnyError || xObjectShell->GetError();
+ bAnyError |= !xObjectShell->DoSaveCompleted( pDstMed, !decodedURL );
+ bAnyError |= (0 != xObjectShell->GetError());
if( bAnyError )
{
// error message ??
More information about the Libreoffice-commits
mailing list