diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-11-11 14:31:18 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-11-11 22:40:41 +0100 |
commit | 1abf4e6d07ca0ac31bc54f812df84efc82d2af1b (patch) | |
tree | 40053fb54077d81a94f273a3adb9660aea09068b | |
parent | 6ab5c9e99dccec23a80eb1980dc46986b8c5abca (diff) |
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 <vmiklos@collabora.com>
Tested-by: Jenkins
-rw-r--r-- | sw/qa/uibase/uno/data/cond-field-cached-value.docx | bin | 0 -> 12164 bytes | |||
-rw-r--r-- | sw/qa/uibase/uno/uno.cxx | 16 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 7 |
3 files changed, 22 insertions, 1 deletions
diff --git a/sw/qa/uibase/uno/data/cond-field-cached-value.docx b/sw/qa/uibase/uno/data/cond-field-cached-value.docx Binary files differnew file mode 100644 index 000000000000..a19b1240c914 --- /dev/null +++ b/sw/qa/uibase/uno/data/cond-field-cached-value.docx 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; |