summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sfx2/docfile.hxx2
-rw-r--r--sfx2/source/doc/docfile.cxx11
-rw-r--r--sfx2/source/doc/objstor.cxx2
-rw-r--r--sw/qa/extras/uiwriter/data/tdf117225.odtbin0 -> 11015 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx43
5 files changed, 57 insertions, 1 deletions
diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx
index 06a7f9623764..ce73db5342f1 100644
--- a/include/sfx2/docfile.hxx
+++ b/include/sfx2/docfile.hxx
@@ -270,6 +270,8 @@ public:
SAL_DLLPRIVATE SignatureState GetCachedSignatureState_Impl();
SAL_DLLPRIVATE void SetCachedSignatureState_Impl( SignatureState nState );
+ void SetHasEmbeddedObjects(bool bHasEmbeddedObjects);
+
static css::uno::Sequence < css::util::RevisionTag > GetVersionList(
const css::uno::Reference< css::embed::XStorage >& xStorage );
static OUString CreateTempCopyWithExt( const OUString& aURL );
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index cd257837ef30..a589d1134d90 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -288,6 +288,8 @@ public:
// in this case the member will hold this information
SignatureState m_nSignatureState;
+ bool m_bHasEmbeddedObjects = false;
+
util::DateTime m_aDateTime;
explicit SfxMedium_Impl();
@@ -3525,6 +3527,10 @@ OUString GetLogicBase(std::unique_ptr<SfxMedium_Impl> const & pImpl)
aLogicBase.clear();
}
+ if (pImpl->m_bHasEmbeddedObjects)
+ // Embedded objects would mean a special base, ignore that.
+ aLogicBase.clear();
+
return aLogicBase;
}
}
@@ -3828,6 +3834,11 @@ void SfxMedium::SetCachedSignatureState_Impl( SignatureState nState )
pImpl->m_nSignatureState = nState;
}
+void SfxMedium::SetHasEmbeddedObjects(bool bHasEmbeddedObjects)
+{
+ pImpl->m_bHasEmbeddedObjects = bHasEmbeddedObjects;
+}
+
bool SfxMedium::HasStorage_Impl() const
{
return pImpl->xStorage.is();
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 02b5d7bcb0c5..244de5869a34 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -1239,7 +1239,9 @@ bool SfxObjectShell::SaveTo_Impl
// if the url is not provided ( means the document is based on a stream ) this code is not
// reachable.
rMedium.CloseAndRelease();
+ rMedium.SetHasEmbeddedObjects(GetEmbeddedObjectContainer().HasEmbeddedObjects());
rMedium.GetOutputStorage();
+ rMedium.SetHasEmbeddedObjects(false);
}
}
else if ( !bStorageBasedSource && !bStorageBasedTarget )
diff --git a/sw/qa/extras/uiwriter/data/tdf117225.odt b/sw/qa/extras/uiwriter/data/tdf117225.odt
new file mode 100644
index 000000000000..9e31eb6b2090
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf117225.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 735bbe8f7cd0..2d4aa322db4c 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -120,7 +120,29 @@
#include <iodetect.hxx>
#include <wrthtml.hxx>
-static char const DATA_DIRECTORY[] = "/sw/qa/extras/uiwriter/data/";
+namespace
+{
+char const DATA_DIRECTORY[] = "/sw/qa/extras/uiwriter/data/";
+
+int CountFilesInDirectory(const OUString &rURL)
+{
+ int nRet = 0;
+
+ osl::Directory aDir(rURL);
+ CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, aDir.open());
+
+ osl::DirectoryItem aItem;
+ osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type);
+ while (aDir.getNextItem(aItem) == osl::FileBase::E_None)
+ {
+ aItem.getFileStatus(aFileStatus);
+ if (aFileStatus.getFileType() != osl::FileStatus::Directory)
+ ++nRet;
+ }
+
+ return nRet;
+}
+}
class SwUiWriterTest : public SwModelTestBase, public HtmlTestTools
{
@@ -319,6 +341,7 @@ public:
void testTdf116403();
void testHtmlCopyImages();
void testTdf116789();
+ void testTdf117225();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -511,6 +534,7 @@ public:
CPPUNIT_TEST(testTdf116403);
CPPUNIT_TEST(testHtmlCopyImages);
CPPUNIT_TEST(testTdf116789);
+ CPPUNIT_TEST(testTdf117225);
CPPUNIT_TEST_SUITE_END();
private:
@@ -6191,6 +6215,23 @@ void SwUiWriterTest::testTdf116789()
CPPUNIT_ASSERT_EQUAL(xText1, xText2);
}
+void SwUiWriterTest::testTdf117225()
+{
+ // Test that saving a document with an embedded object does not leak
+ // tempfiles in the directory of the target file.
+ OUString aTargetDirectory = m_directories.getURLFromWorkdir("/CppunitTest/sw_uiwriter.test.user/");
+ OUString aTargetFile = aTargetDirectory + "tdf117225.odt";
+ OUString aSourceFile = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf117225.odt";
+ osl::File::copy(aSourceFile, aTargetFile);
+ mxComponent = loadFromDesktop(aTargetFile);
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ int nExpected = CountFilesInDirectory(aTargetDirectory);
+ xStorable->store();
+ int nActual = CountFilesInDirectory(aTargetDirectory);
+ // nActual was nExpected + 1, i.e. we leaked a tempfile.
+ CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();