sw/qa/uibase/uno/data/cond-field-cached-value.docx |binary sw/qa/uibase/uno/uno.cxx | 16 ++++++++++++++++ sw/source/uibase/uno/unotxdoc.cxx | 7 ++++++- 3 files changed, 22 insertions(+), 1 deletion(-)
New commits: commit 1abf4e6d07ca0ac31bc54f812df84efc82d2af1b Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Nov 11 14:31:18 2020 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Nov 11 22:40:41 2020 +0100 DOCX import: don't throw away cached value of SwHiddenTextField ... ... when we also have an SwUserField. The problem is that a DocVariable gets imported as an SwUserField, but then SwDocUpdateField::InsertFieldType() marks the field as dirty. This causes IsFieldsDirty() to return true, so then DocumentTimerManager::GetNextIdleJob() decides to recalc all fields. This leads to loosing the cached result of conditional fields. Change-Id: I4f5c032648f8fc2aff98e4f8c883492375c7752d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105596 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/uibase/uno/data/cond-field-cached-value.docx b/sw/qa/uibase/uno/data/cond-field-cached-value.docx new file mode 100644 index 000000000000..a19b1240c914 Binary files /dev/null and b/sw/qa/uibase/uno/data/cond-field-cached-value.docx differ diff --git a/sw/qa/uibase/uno/uno.cxx b/sw/qa/uibase/uno/uno.cxx index 23c1829ab7de..4c6dc724b712 100644 --- a/sw/qa/uibase/uno/uno.cxx +++ b/sw/qa/uibase/uno/uno.cxx @@ -11,6 +11,10 @@ #include <com/sun/star/util/XCloseable.hpp> +#include <vcl/scheduler.hxx> + +char const DATA_DIRECTORY[] = "/sw/qa/uibase/uno/data/"; + /// Covers sw/source/uibase/uno/ fixes. class SwUibaseUnoTest : public SwModelTestBase { @@ -31,6 +35,18 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUnoTest, testLockControllers) mxComponent.clear(); } +CPPUNIT_TEST_FIXTURE(SwUibaseUnoTest, testCondFieldCachedValue) +{ + load(DATA_DIRECTORY, "cond-field-cached-value.docx"); + Scheduler::ProcessEventsToIdle(); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : + // i.e. the conditional field lost its cached content. + getParagraph(2, "1"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index c77f92073b20..bd56d0c7dcb4 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -1978,7 +1978,12 @@ void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any& bool bBool = {}; if (aValue >>= bBool) { // HACK: writerfilter has to use API to set this :( - pDoc->SetInWriterfilterImport(bBool); + bool bOld = pDoc->IsInWriterfilterImport(); + pDoc->SetInWriterfilterImport(bBool); + if (bOld && !bBool) + { + pDoc->getIDocumentFieldsAccess().SetFieldsDirty(false, nullptr, 0); + } } } break; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits