tdf#117757 sfx2 save-as: fix leftover temporary files for embedded objects

This is really similar to c167620444
(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 <vmiklos@collabora.co.uk>
Tested-by: Jenkins
This commit is contained in:
Miklos Vajna
2018-07-03 09:07:49 +02:00
parent de7e83969b
commit b8fd1a814f
2 changed files with 9 additions and 0 deletions

View File

@@ -1297,7 +1297,9 @@ bool SfxObjectShell::SaveTo_Impl
rMedium.CloseAndRelease();
if ( bStorageBasedTarget )
{
rMedium.SetHasEmbeddedObjects(GetEmbeddedObjectContainer().HasEmbeddedObjects());
rMedium.GetOutputStorage();
rMedium.SetHasEmbeddedObjects(false);
}
}

View File

@@ -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()