summaryrefslogtreecommitdiff
path: root/sw/qa/uibase/uiview/uiview.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-11-18 17:55:13 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-11-19 01:37:50 +0100
commit693f12ad57912c2356a197d9a794e6108ce79ef2 (patch)
tree458c5bdb26728a85e9d864896b049afb559ca330 /sw/qa/uibase/uiview/uiview.cxx
parent69b12a6eb3616d15035310eeb0c3dbc7aefcb5c1 (diff)
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. Change-Id: If8b74424b0ad88e63129fd8f7efd09f85e300895 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106068 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/qa/uibase/uiview/uiview.cxx')
-rw-r--r--sw/qa/uibase/uiview/uiview.cxx25
1 files changed, 25 insertions, 0 deletions
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: */