summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-06-23 10:31:05 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-07-01 11:17:09 +0200
commitb7a465c9403cf198df3424e9893c323b9d305026 (patch)
tree8150c21a58e8fc6729d03d5a685267fc26077154
parent5637b974912b29805be8af85d39086bab5697aa1 (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 (cherry picked from commit 2aad85f84235f362604b5fd385bb77de839d2014) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97492
-rw-r--r--sw/qa/uibase/shells/data/ole-save-preview-update.odtbin0 -> 16006 bytes
-rw-r--r--sw/qa/uibase/shells/shells.cxx33
-rw-r--r--sw/source/uibase/shells/basesh.cxx4
3 files changed, 34 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
new file mode 100644
index 000000000000..353ce7fa050c
--- /dev/null
+++ b/sw/qa/uibase/shells/data/ole-save-preview-update.odt
Binary files differ
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: */
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index 2265ea10bb2a..2253441310f0 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -717,6 +717,10 @@ void SwBaseShell::Execute(SfxRequest &rReq)
case FN_UPDATE_ALL:
{
+ comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer
+ = GetObjectShell()->getEmbeddedObjectContainer();
+ rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true);
+
SwView& rTempView = GetView();
rSh.EnterStdMode();
if( !rSh.GetLinkManager().GetLinks().empty() )