diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-06-23 10:31:05 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-06-23 17:03:31 +0200 |
commit | 50383c547f440ee28680d5e10c074884648747dc (patch) | |
tree | faea39b18df8cb748b3fc6491c2d329548aa4e80 | |
parent | fad37294ec76178f6987ef8d381663c95581d8ef (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.
(cherry picked from commit 2aad85f84235f362604b5fd385bb77de839d2014)
Conflicts:
sw/qa/uibase/shells/shells.cxx
Change-Id: Ib54e06a2e2f2e1c65951fdec302e59e63c71d008
-rw-r--r-- | sw/CppunitTest_sw_uibase_shells.mk | 73 | ||||
-rw-r--r-- | sw/Module_sw.mk | 1 | ||||
-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 | 95 | ||||
-rw-r--r-- | sw/source/uibase/shells/basesh.cxx | 4 |
5 files changed, 173 insertions, 0 deletions
diff --git a/sw/CppunitTest_sw_uibase_shells.mk b/sw/CppunitTest_sw_uibase_shells.mk new file mode 100644 index 000000000000..1e79b0a17387 --- /dev/null +++ b/sw/CppunitTest_sw_uibase_shells.mk @@ -0,0 +1,73 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sw_uibase_shells)) + +$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_uibase_shells)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_uibase_shells, \ + sw/qa/uibase/shells/shells \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sw_uibase_shells, \ + comphelper \ + cppu \ + cppuhelper \ + editeng \ + sal \ + sfx \ + svl \ + svx \ + svxcore \ + sw \ + test \ + unotest \ + utl \ + vcl \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sw_uibase_shells,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_uibase_shells,\ + -I$(SRCDIR)/sw/inc \ + -I$(SRCDIR)/sw/source/core/inc \ + -I$(SRCDIR)/sw/source/uibase/inc \ + -I$(SRCDIR)/sw/qa/extras/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sw_uibase_shells,\ + udkapi \ + offapi \ + oovbaapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sw_uibase_shells)) +$(eval $(call gb_CppunitTest_use_vcl,sw_uibase_shells)) + +$(eval $(call gb_CppunitTest_use_rdb,sw_uibase_shells,services)) + +$(eval $(call gb_CppunitTest_use_custom_headers,sw_uibase_shells,\ + officecfg/registry \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,sw_uibase_shells)) + +$(eval $(call gb_CppunitTest_use_uiconfigs,sw_uibase_shells, \ + modules/swriter \ +)) + +$(eval $(call gb_CppunitTest_use_more_fonts,sw_uibase_shells)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index 6560faab37ae..6a017917725d 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -79,6 +79,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_mailmerge \ CppunitTest_sw_globalfilter \ CppunitTest_sw_unowriter \ + CppunitTest_sw_uibase_shells \ )) ifneq ($(ENABLE_HEADLESS),TRUE) 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 new file mode 100644 index 000000000000..c0f1b18a3298 --- /dev/null +++ b/sw/qa/uibase/shells/shells.cxx @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <swmodeltestbase.hxx> + +#include <com/sun/star/frame/DispatchHelper.hpp> + +#include <sfx2/dispatch.hxx> +#include <sfx2/viewfrm.hxx> +#include <svx/svdpage.hxx> +#include <editeng/eeitem.hxx> +#include <editeng/adjustitem.hxx> +#include <editeng/outlobj.hxx> +#include <editeng/editobj.hxx> + +#include <IDocumentContentOperations.hxx> +#include <cmdid.h> +#include <fmtanchr.hxx> +#include <view.hxx> +#include <wrtsh.hxx> +#include <IDocumentDrawModelAccess.hxx> +#include <drawdoc.hxx> + +static char const DATA_DIRECTORY[] = "/sw/qa/uibase/shells/data/"; + +namespace +{ +void dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, + const OUString& rCommand, + const uno::Sequence<beans::PropertyValue>& rPropertyValues) +{ + uno::Reference<frame::XController> xController + = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController(); + CPPUNIT_ASSERT(xController.is()); + uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xFrame.is()); + + uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext(); + uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext)); + CPPUNIT_ASSERT(xDispatchHelper.is()); + + xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues); +} +} + +/// Covers sw/source/uibase/shells/ fixes. +class SwUibaseShellsTest : public SwModelTestBase +{ +public: + SwDoc* createDoc(const char* pName = nullptr); +}; + +SwDoc* SwUibaseShellsTest::createDoc(const char* pName) +{ + if (!pName) + loadURL("private:factory/swriter", nullptr); + else + load(DATA_DIRECTORY, pName); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + return pTextDoc->GetDocShell()->GetDoc(); +} + +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 4ed0849265ff..be774cd72805 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -667,6 +667,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() ) |