summaryrefslogtreecommitdiff
path: root/sw/qa/uibase
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-12-02 17:08:41 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-12-02 23:20:32 +0100
commit37892b97d00de29a86c735aaaff47c12e66e78ad (patch)
tree4b79fd444349769d9c5e93b5846894ac918520b8 /sw/qa/uibase
parentd6c3a3116648415dd324b139ade99f5fb4e46379 (diff)
sw: update previews of OLE objects on "update all"
Charts were already updated, it was not consistent that other embedded objects are not updated. This is especially useful if an ODT file is manipulated by a 3rd-party, then loaded into Writer just to update the previews of OLE objects. Change-Id: If61aa037739c593abade933dcdd5474ad566b3e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126253 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/qa/uibase')
-rw-r--r--sw/qa/uibase/shells/data/ole-preview-update.odtbin0 -> 20265 bytes
-rw-r--r--sw/qa/uibase/shells/shells.cxx23
2 files changed, 23 insertions, 0 deletions
diff --git a/sw/qa/uibase/shells/data/ole-preview-update.odt b/sw/qa/uibase/shells/data/ole-preview-update.odt
new file mode 100644
index 000000000000..3fd4d264628e
--- /dev/null
+++ b/sw/qa/uibase/shells/data/ole-preview-update.odt
Binary files differ
diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx
index e1f5d048c018..bae2c4ab350a 100644
--- a/sw/qa/uibase/shells/shells.cxx
+++ b/sw/qa/uibase/shells/shells.cxx
@@ -24,6 +24,7 @@
#include <editeng/editobj.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertyvalue.hxx>
+#include <unotools/ucbstreamhelper.hxx>
#include <IDocumentContentOperations.hxx>
#include <cmdid.h>
@@ -133,6 +134,28 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testOleSavePreviewUpdate)
CPPUNIT_ASSERT(xNameAccess->hasByName("ObjectReplacements/Object 2"));
}
+CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testOlePreviewUpdate)
+{
+ // Given a document with an embedded Writer object:
+ load(DATA_DIRECTORY, "ole-preview-update.odt");
+
+ // When updating "all" (including OLE previews):
+ dispatchCommand(mxComponent, ".uno:UpdateAll", {});
+
+ // Then make sure the preview is no longer a 0-sized stream:
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ xStorable->storeToURL(maTempFile.GetURL(), {});
+ uno::Reference<packages::zip::XZipFileAccess2> xNameAccess
+ = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory),
+ maTempFile.GetURL());
+ uno::Reference<io::XInputStream> xInputStream(
+ xNameAccess->getByName("ObjectReplacements/Object 1"), uno::UNO_QUERY);
+ std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true));
+ // Without the accompanying fix in place, this test would have failed, the stream was still
+ // empty.
+ CPPUNIT_ASSERT_GREATER(static_cast<sal_uInt64>(0), pStream->remainingSize());
+}
+
CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testBibliographyUrlContextMenu)
{
// Given a document with a bibliography field: