From b8fd1a814ffc80f2802c5b980febabcffe9606cb Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 3 Jul 2018 09:07:49 +0200 Subject: [PATCH] tdf#117757 sfx2 save-as: fix leftover temporary files for embedded objects This is really similar to c1676204447df942e766c0780c1580e1f0427b73 (tdf#117225 sfx2: fix leftover temp file when saving doc with embedded objects, 2018-05-14), just this is save as, not save. Change-Id: If78d91262bfbe97846287deb0794e4101ef7b4af Reviewed-on: https://gerrit.libreoffice.org/56842 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- sfx2/source/doc/objstor.cxx | 2 ++ sw/qa/extras/uiwriter/uiwriter.cxx | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index f0fbca97941c..30bc90a80a51 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -1297,7 +1297,9 @@ bool SfxObjectShell::SaveTo_Impl rMedium.CloseAndRelease(); if ( bStorageBasedTarget ) { + rMedium.SetHasEmbeddedObjects(GetEmbeddedObjectContainer().HasEmbeddedObjects()); rMedium.GetOutputStorage(); + rMedium.SetHasEmbeddedObjects(false); } } diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 3dc0e7a233ea..b51fa7483bd8 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -6302,6 +6302,13 @@ void SwUiWriterTest::testTdf117225() int nActual = CountFilesInDirectory(aTargetDirectory); // nActual was nExpected + 1, i.e. we leaked a tempfile. CPPUNIT_ASSERT_EQUAL(nExpected, nActual); + + OUString aTargetFileSaveAs = aTargetDirectory + "tdf117225-save-as.odt"; + xStorable->storeAsURL(aTargetFileSaveAs, {}); + ++nExpected; + nActual = CountFilesInDirectory(aTargetDirectory); + // nActual was nExpected + 1, i.e. we leaked a tempfile. + CPPUNIT_ASSERT_EQUAL(nExpected, nActual); } void SwUiWriterTest::testTdf91801()