sfx2/source/view/sfxbasecontroller.cxx | 12 +- sw/CppunitTest_sw_uibase_uiview.mk | 73 ++++++++++++++ sw/CppunitTest_sw_updateall_object_replacements.mk | 73 -------------- sw/Module_sw.mk | 2 sw/qa/uibase/uiview/data/update-replacement-nosetting.odt |binary sw/qa/uibase/uiview/uiview.cxx | 33 +++++- sw/source/uibase/uiview/view.cxx | 2 7 files changed, 112 insertions(+), 83 deletions(-)
New commits: commit c3e355ce26f42c5f8367bb8bd8bce9b288f623c3 Author: Miklos Vajna <[email protected]> AuthorDate: Wed Nov 18 17:55:13 2020 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Thu Nov 19 11:07:23 2020 +0100 sw replacement image creation: fix this when an ODT's settings.xml is invalid This builds on top of commit c123bfff501229f398a1b679fc7434b82d53685c (Bin overly eager early return that stops replacement image creation, 2020-08-20), and handles a similar case, when SwView::ReadUserDataSequence() is not called at all. The result is the same: no shell is selected on the command dispatcher stack, so .uno:UpdateAll is ignored and the replacement images are not created. (cherry picked from commit 693f12ad57912c2356a197d9a794e6108ce79ef2) Change-Id: If8b74424b0ad88e63129fd8f7efd09f85e300895 diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index a4706277e869..92fa53c1c1e7 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -1334,12 +1334,18 @@ void SfxBaseController::ConnectSfxFrame_Impl( const ConnectSfxFrame i_eConnect ) break; } } - if ( nViewDataIndex < nCount ) + if (nViewDataIndex < nCount || !xViewData.is()) { Sequence< PropertyValue > aViewData; - OSL_VERIFY( xViewData->getByIndex( nViewDataIndex ) >>= aViewData ); - if ( aViewData.hasElements() ) + if (xViewData.is()) + { + OSL_VERIFY(xViewData->getByIndex(nViewDataIndex) >>= aViewData); + } + if (aViewData.hasElements() || !xViewData.is()) + { + // Tolerate empty xViewData, ReadUserDataSequence() has side effects. m_pData->m_pViewShell->ReadUserDataSequence( aViewData ); + } } } catch (const Exception&) diff --git a/sw/qa/uibase/uiview/data/update-replacement-nosetting.odt b/sw/qa/uibase/uiview/data/update-replacement-nosetting.odt new file mode 100644 index 000000000000..055c3d1a2c2a Binary files /dev/null and b/sw/qa/uibase/uiview/data/update-replacement-nosetting.odt differ diff --git a/sw/qa/uibase/uiview/uiview.cxx b/sw/qa/uibase/uiview/uiview.cxx index 8827cea10752..4d622aafaa5f 100644 --- a/sw/qa/uibase/uiview/uiview.cxx +++ b/sw/qa/uibase/uiview/uiview.cxx @@ -12,6 +12,7 @@ #include <unotools/mediadescriptor.hxx> #include <comphelper/processfactory.hxx> #include <osl/file.hxx> +#include <comphelper/propertyvalue.hxx> #include <com/sun/star/frame/DispatchHelper.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> @@ -87,6 +88,30 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testUpdateAllObjectReplacements) CPPUNIT_ASSERT(xNameAccess->hasByName("ObjectReplacements/Components_1")); } +CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testUpdateReplacementNosetting) +{ + // Load a copy of the document in hidden mode. + OUString aSourceURL + = m_directories.getURLFromSrc(DATA_DIRECTORY) + "update-replacement-nosetting.odt"; + CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, osl::File::copy(aSourceURL, maTempFile.GetURL())); + mxComponent = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.text.TextDocument", + { comphelper::makePropertyValue("Hidden", true) }); + + // Update "everything" (including object replacements) and save it. + dispatchCommand(mxComponent, ".uno:UpdateAll", {}); + uno::Reference<frame::XStorable2> xStorable(mxComponent, uno::UNO_QUERY); + xStorable->storeSelf({}); + + // Check the contents of the updated copy. + uno::Reference<uno::XComponentContext> xContext = comphelper::getProcessComponentContext(); + uno::Reference<packages::zip::XZipFileAccess2> xNameAccess + = packages::zip::ZipFileAccess::createWithURL(xContext, maTempFile.GetURL()); + + // Without the accompanying fix in place, this test would have failed, because the embedded + // object replacement image was not generated. + CPPUNIT_ASSERT(xNameAccess->hasByName("ObjectReplacements/Components")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx index 04daaadd73ca..d7837c800bfb 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -1281,8 +1281,6 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue > if(GetDocShell()->IsPreview()||m_bIsPreviewDoubleClick) return; bool bIsOwnDocument = lcl_IsOwnDocument( *this ); - if (!rSequence.hasElements()) - return; SET_CURR_SHELL(m_pWrtShell.get()); const SwRect& rRect = m_pWrtShell->GetCharRect(); commit 4f3ed4ef1e358f898ef6bd41e384cf335966e14c Author: Miklos Vajna <[email protected]> AuthorDate: Tue Sep 8 20:55:32 2020 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Thu Nov 19 10:58:28 2020 +0100 sw: rename CppunitTest_sw_updateall_object_replacements to sw_uibase_uiview All these new test suites are named in a way, so that in case the fix is in sw/source/foo/bar/, then the matching test suite is sw_foo_bar. Rename to this schema, so next time a bug is fixed in that directory, we don't need to add a new suite. (cherry picked from commit 0be6168c5a7b1493a22222dc0967b5e8a0153386) Conflicts: sw/CppunitTest_sw_updateall_object_replacements.mk sw/Module_sw.mk Change-Id: I968711754cb587cc2f97fff6431be416b477728f diff --git a/sw/CppunitTest_sw_uibase_uiview.mk b/sw/CppunitTest_sw_uibase_uiview.mk new file mode 100644 index 000000000000..66c95375bd56 --- /dev/null +++ b/sw/CppunitTest_sw_uibase_uiview.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_uiview)) + +$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_uibase_uiview)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_uibase_uiview, \ + sw/qa/uibase/uiview/uiview \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sw_uibase_uiview, \ + comphelper \ + cppu \ + cppuhelper \ + sal \ + sfx \ + svxcore \ + sw \ + test \ + unotest \ + utl \ + vcl \ + svt \ + tl \ + svl \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sw_uibase_uiview,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_uibase_uiview,\ + -I$(SRCDIR)/sw/inc \ + -I$(SRCDIR)/sw/source/core/inc \ + -I$(SRCDIR)/sw/source/uibase/inc \ + -I$(SRCDIR)/sw/qa/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sw_uibase_uiview,\ + udkapi \ + offapi \ + oovbaapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sw_uibase_uiview)) +$(eval $(call gb_CppunitTest_use_vcl,sw_uibase_uiview)) + +$(eval $(call gb_CppunitTest_use_rdb,sw_uibase_uiview,services)) + +$(eval $(call gb_CppunitTest_use_custom_headers,sw_uibase_uiview,\ + officecfg/registry \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,sw_uibase_uiview)) + +$(eval $(call gb_CppunitTest_use_uiconfigs,sw_uibase_uiview, \ + modules/swriter \ +)) + +$(eval $(call gb_CppunitTest_use_more_fonts,sw_uibase_uiview)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/CppunitTest_sw_updateall_object_replacements.mk b/sw/CppunitTest_sw_updateall_object_replacements.mk deleted file mode 100644 index e6bd9ca09425..000000000000 --- a/sw/CppunitTest_sw_updateall_object_replacements.mk +++ /dev/null @@ -1,73 +0,0 @@ -# -*- 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_updateall_object_replacements)) - -$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_updateall_object_replacements)) - -$(eval $(call gb_CppunitTest_add_exception_objects,sw_updateall_object_replacements, \ - sw/qa/core/updateall_objectreplacements \ -)) - -$(eval $(call gb_CppunitTest_use_libraries,sw_updateall_object_replacements, \ - comphelper \ - cppu \ - cppuhelper \ - sal \ - sfx \ - svxcore \ - sw \ - test \ - unotest \ - utl \ - vcl \ - svt \ - tl \ - svl \ -)) - -$(eval $(call gb_CppunitTest_use_externals,sw_updateall_object_replacements,\ - boost_headers \ - libxml2 \ -)) - -$(eval $(call gb_CppunitTest_set_include,sw_updateall_object_replacements,\ - -I$(SRCDIR)/sw/inc \ - -I$(SRCDIR)/sw/source/core/inc \ - -I$(SRCDIR)/sw/source/uibase/inc \ - -I$(SRCDIR)/sw/qa/inc \ - $$(INCLUDE) \ -)) - -$(eval $(call gb_CppunitTest_use_api,sw_updateall_object_replacements,\ - udkapi \ - offapi \ - oovbaapi \ -)) - -$(eval $(call gb_CppunitTest_use_ure,sw_updateall_object_replacements)) -$(eval $(call gb_CppunitTest_use_vcl,sw_updateall_object_replacements)) - -$(eval $(call gb_CppunitTest_use_rdb,sw_updateall_object_replacements,services)) - -$(eval $(call gb_CppunitTest_use_custom_headers,sw_updateall_object_replacements,\ - officecfg/registry \ -)) - -$(eval $(call gb_CppunitTest_use_configuration,sw_updateall_object_replacements)) - -$(eval $(call gb_CppunitTest_use_uiconfigs,sw_updateall_object_replacements, \ - modules/swriter \ -)) - -$(eval $(call gb_CppunitTest_use_more_fonts,sw_updateall_object_replacements)) - -# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index 7050954e74fb..653f97335f92 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -118,7 +118,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_core_objectpositioning \ CppunitTest_sw_core_unocore \ CppunitTest_sw_core_crsr \ - CppunitTest_sw_updateall_object_replacements \ + CppunitTest_sw_uibase_uiview \ )) ifneq ($(DISABLE_GUI),TRUE) diff --git a/sw/qa/core/data/updateall-objectreplacements.odt b/sw/qa/uibase/uiview/data/updateall-objectreplacements.odt similarity index 100% rename from sw/qa/core/data/updateall-objectreplacements.odt rename to sw/qa/uibase/uiview/data/updateall-objectreplacements.odt diff --git a/sw/qa/core/updateall_objectreplacements.cxx b/sw/qa/uibase/uiview/uiview.cxx similarity index 93% rename from sw/qa/core/updateall_objectreplacements.cxx rename to sw/qa/uibase/uiview/uiview.cxx index 92997d498e59..8827cea10752 100644 --- a/sw/qa/core/updateall_objectreplacements.cxx +++ b/sw/qa/uibase/uiview/uiview.cxx @@ -23,14 +23,14 @@ #include <wrtsh.hxx> #include <swdtflvr.hxx> -char const DATA_DIRECTORY[] = "/sw/qa/core/data/"; +char const DATA_DIRECTORY[] = "/sw/qa/uibase/uiview/data/"; -/// Covers sw/source/core/undo/ fixes. -class SwCoreUpdateAllObjectReplacementsTest : public SwModelTestBase +/// Covers sw/source/uibase/uiview/ fixes. +class SwUibaseUiviewTest : public SwModelTestBase { }; -CPPUNIT_TEST_FIXTURE(SwCoreUpdateAllObjectReplacementsTest, testDoIt) +CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testUpdateAllObjectReplacements) { // Make a temporary copy of the test document utl::TempFile tmp; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
