summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-11-11 14:31:18 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-11-16 12:55:23 +0100
commitff225dfc7712cc12d82b0286709a3153852d9ee7 (patch)
tree367ce01386ee5a6b25bd2a54759e8edae75642a5
parent177f97d465feceb6663dd180b7dab51f945765aa (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. (cherry picked from commit 1abf4e6d07ca0ac31bc54f812df84efc82d2af1b) Conflicts: sw/qa/uibase/uno/uno.cxx Change-Id: I4f5c032648f8fc2aff98e4f8c883492375c7752d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105923 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--sw/CppunitTest_sw_uibase_uno.mk73
-rw-r--r--sw/Module_sw.mk1
-rw-r--r--sw/qa/uibase/uno/data/cond-field-cached-value.docxbin0 -> 12164 bytes
-rw-r--r--sw/qa/uibase/uno/uno.cxx37
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx7
5 files changed, 117 insertions, 1 deletions
diff --git a/sw/CppunitTest_sw_uibase_uno.mk b/sw/CppunitTest_sw_uibase_uno.mk
new file mode 100644
index 000000000000..5f6e3cc2c07d
--- /dev/null
+++ b/sw/CppunitTest_sw_uibase_uno.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_uno))
+
+$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_uibase_uno))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_uibase_uno, \
+ sw/qa/uibase/uno/uno \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_uibase_uno, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ editeng \
+ sal \
+ sfx \
+ svl \
+ svx \
+ svxcore \
+ sw \
+ test \
+ unotest \
+ utl \
+ vcl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sw_uibase_uno,\
+ boost_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_uibase_uno,\
+ -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_uno,\
+ udkapi \
+ offapi \
+ oovbaapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sw_uibase_uno))
+$(eval $(call gb_CppunitTest_use_vcl,sw_uibase_uno))
+
+$(eval $(call gb_CppunitTest_use_rdb,sw_uibase_uno,services))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,sw_uibase_uno,\
+ officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sw_uibase_uno))
+
+$(eval $(call gb_CppunitTest_use_uiconfigs,sw_uibase_uno, \
+ modules/swriter \
+))
+
+$(eval $(call gb_CppunitTest_use_more_fonts,sw_uibase_uno))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 280d7f25627c..e6fb99d5f88c 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -116,6 +116,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
CppunitTest_sw_core_layout \
CppunitTest_sw_core_unocore \
CppunitTest_sw_core_crsr \
+ CppunitTest_sw_uibase_uno \
))
ifneq ($(DISABLE_GUI),TRUE)
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
new file mode 100644
index 000000000000..9f63e00716ff
--- /dev/null
+++ b/sw/qa/uibase/uno/uno.cxx
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include <swmodeltestbase.hxx>
+
+#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
+{
+};
+
+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 2c4d8066b035..156f0b0d629c 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -1992,7 +1992,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;