summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/uibase/uno/data/cond-field-cached-value.docxbin0 -> 12164 bytes
-rw-r--r--sw/qa/uibase/uno/uno.cxx16
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx7
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
new file mode 100644
index 000000000000..a19b1240c914
--- /dev/null
+++ b/sw/qa/uibase/uno/data/cond-field-cached-value.docx
Binary files 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;