diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-06-23 10:31:05 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-06-23 11:33:27 +0200 |
commit | 2aad85f84235f362604b5fd385bb77de839d2014 (patch) | |
tree | 37beb0b2303e01fd74e57342d6c8f1a96257d41e /sw/qa | |
parent | 797ffc29450f46dd6683886e7436453ce9fb4d72 (diff) |
sw: fix missing OLE preview on updating links
Regression from commit 74844277cc2194c9e43f5bd7a6f78a9603da32f3 (disable
generation of ole previews in ODF format until after load, 2016-09-13),
if the document has charts without previews, it's loaded, fields are
updated and saved, we no longer generate those previews.
Given that Tools -> Update -> Update all is always an explicit user
action, restore the permission to update OLE previews / links before
performing the actual update.
With this, comphelper::EmbeddedObjectContainer::StoreAsChildren() will
generate those missing previews inside the getUserAllowsLinkUpdate()
conditional block.
Change-Id: Ib54e06a2e2f2e1c65951fdec302e59e63c71d008
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96928
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/uibase/shells/data/ole-save-preview-update.odt | bin | 0 -> 16006 bytes | |||
-rw-r--r-- | sw/qa/uibase/shells/shells.cxx | 33 |
2 files changed, 30 insertions, 3 deletions
diff --git a/sw/qa/uibase/shells/data/ole-save-preview-update.odt b/sw/qa/uibase/shells/data/ole-save-preview-update.odt Binary files differnew file mode 100644 index 000000000000..353ce7fa050c --- /dev/null +++ b/sw/qa/uibase/shells/data/ole-save-preview-update.odt diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx index c1012d6af1d1..fbdf35758156 100644 --- a/sw/qa/uibase/shells/shells.cxx +++ b/sw/qa/uibase/shells/shells.cxx @@ -26,16 +26,21 @@ #include <IDocumentDrawModelAccess.hxx> #include <drawdoc.hxx> +static char const DATA_DIRECTORY[] = "/sw/qa/uibase/shells/data/"; + /// Covers sw/source/uibase/shells/ fixes. class SwUibaseShellsTest : public SwModelTestBase { public: - SwDoc* createDoc(); + SwDoc* createDoc(const char* pName = nullptr); }; -SwDoc* SwUibaseShellsTest::createDoc() +SwDoc* SwUibaseShellsTest::createDoc(const char* pName) { - loadURL("private:factory/swriter", nullptr); + if (!pName) + loadURL("private:factory/swriter", nullptr); + else + load(DATA_DIRECTORY, pName); SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); CPPUNIT_ASSERT(pTextDoc); @@ -112,6 +117,28 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testShapeTextAlignment) #endif } +CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testOleSavePreviewUpdate) +{ + // Load a document with 2 charts in it. The second is down enough that you have to scroll to + // trigger its rendering. Previews are missing for both. + createDoc("ole-save-preview-update.odt"); + + // Explicitly update OLE previews, etc. + dispatchCommand(mxComponent, ".uno:UpdateAll", {}); + + // Save the document and see if we get the previews. + 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()); + + // Without the accompanying fix in place, this test would have failed, because the object + // replacements were not generated, even after UpdateAll. + CPPUNIT_ASSERT(xNameAccess->hasByName("ObjectReplacements/Object 1")); + CPPUNIT_ASSERT(xNameAccess->hasByName("ObjectReplacements/Object 2")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |