summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2021-03-16 10:16:02 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-03-17 09:28:46 +0100
commitb6850b9827a13b8f8d9b9749a982e128b7e0e867 (patch)
tree6db2184c97059855abf2d9e7d40a11b30c079026 /sw
parent719ca339f54698482087e17e2271e18ec10de142 (diff)
tdf#52065 sw: revert tdf#45908: Cleaning up the tabs too early
... can cause loops from LO 3.5 commit 36c905d8c2874f6f984d5fbbc07784ec20c43524 The PostFormat for Center and Decimal tabstops is critical since the space they take up is unknown until the following text is evaluated. The search position in these two cases is invalid until the text position is calculated by PostFormat. PostFormat normally returns FALSE, so in almost all cases the rest of NewTabPortion completes. The function only returned early if the start of the tabstop was beyond the right margin. I assume the original intent was to avoid potentially unnecessary processing. However, returning early can cause looping, which the LO 3.5 commit "fixed" by removing everything. Well, just remove the early return and both problems are solved. Change-Id: I4afc4cce8249f90097bc1f263df1a39bc219098d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112559 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/CppunitTest_sw_odfexport2.mk72
-rw-r--r--sw/Module_sw.mk1
-rw-r--r--sw/qa/core/data/README16
-rw-r--r--sw/qa/core/layout/data/tdf45908_invoice.odtbin0 -> 8555 bytes
-rw-r--r--sw/qa/core/layout/layout.cxx6
-rw-r--r--sw/qa/extras/odfexport/data/testTdf52065_centerTabs.odtbin0 -> 11274 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport2.cxx45
-rw-r--r--sw/source/core/text/porlin.hxx2
-rw-r--r--sw/source/core/text/txttab.cxx5
9 files changed, 147 insertions, 0 deletions
diff --git a/sw/CppunitTest_sw_odfexport2.mk b/sw/CppunitTest_sw_odfexport2.mk
new file mode 100644
index 000000000000..4ad073a9e2e2
--- /dev/null
+++ b/sw/CppunitTest_sw_odfexport2.mk
@@ -0,0 +1,72 @@
+# -*- 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_odfexport2))
+
+$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_odfexport2))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_odfexport2, \
+ sw/qa/extras/odfexport/odfexport2 \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_odfexport2, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ sal \
+ sfx \
+ svl \
+ sw \
+ swqahelper \
+ test \
+ tl \
+ unotest \
+ utl \
+ vcl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sw_odfexport2,\
+ boost_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_odfexport2,\
+ -I$(SRCDIR)/sw/inc \
+ -I$(SRCDIR)/sw/source/core/inc \
+ -I$(SRCDIR)/sw/qa/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sw_odfexport2,\
+ udkapi \
+ offapi \
+ oovbaapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sw_odfexport2))
+$(eval $(call gb_CppunitTest_use_vcl,sw_odfexport2))
+
+$(eval $(call gb_CppunitTest_use_rdb,sw_odfexport2,services))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,sw_odfexport2,\
+ officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sw_odfexport2))
+
+$(eval $(call gb_CppunitTest_use_uiconfigs,sw_odfexport2, \
+ modules/swriter \
+ svx \
+))
+
+$(eval $(call gb_CppunitTest_use_more_fonts,sw_odfexport2))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 75bf13e75231..07a79c3ad951 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -96,6 +96,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
CppunitTest_sw_ww8import \
CppunitTest_sw_rtfimport \
CppunitTest_sw_odfexport \
+ CppunitTest_sw_odfexport2 \
CppunitTest_sw_odfimport \
CppunitTest_sw_txtexport \
CppunitTest_sw_txtimport \
diff --git a/sw/qa/core/data/README b/sw/qa/core/data/README
index 2cc9fb3cb58f..a147d4be4c6a 100644
--- a/sw/qa/core/data/README
+++ b/sw/qa/core/data/README
@@ -5,3 +5,19 @@ mdecrypt --bare -a arcfour -o hex -k 435645 -s 3 foo.doc # to unencrypt
mcrypt --bare -a arcfour -o hex -k 435645 -s 3 foo.doc # to create new tests
to get access to the plain files for manual testing.
+
+
+The files in these subdirectories are tested to
+ensure that they import without crashing or hanging.
+Files that crash during export should go into exportdata.
+
+Both data and exportdata are tested with
+make CppunitTest_sw_filters_test or
+make CppunitTest_sw_filters_test2 for ww6.
+
+Files that hang interactively, but pass filters_test
+might be failing because of layout issues. See core/layout.
+
+pass: these files now load - without the fix they crashed or hung.
+fail: these files still fail to load, but not because of crashing or hanging.
+indeterminate: untested temporary holding area - to be sorted as pass/fail.
diff --git a/sw/qa/core/layout/data/tdf45908_invoice.odt b/sw/qa/core/layout/data/tdf45908_invoice.odt
new file mode 100644
index 000000000000..37b76928cbf9
--- /dev/null
+++ b/sw/qa/core/layout/data/tdf45908_invoice.odt
Binary files differ
diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx
index 8db099b6fc1b..7c37eec7fc7a 100644
--- a/sw/qa/core/layout/layout.cxx
+++ b/sw/qa/core/layout/layout.cxx
@@ -389,6 +389,12 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testGutterMarginPageBorder)
#endif
}
+CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTdf45908_invoice)
+{
+ // without the fix, this was hanging (and slowly consuming memory) on fileopen.
+ load(DATA_DIRECTORY, "tdf45908_invoice.odt");
+}
+
CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testVerticallyMergedCellBorder)
{
// Given a document with a table: 2 columns, 5 rows. B2 -> B5 is merged:
diff --git a/sw/qa/extras/odfexport/data/testTdf52065_centerTabs.odt b/sw/qa/extras/odfexport/data/testTdf52065_centerTabs.odt
new file mode 100644
index 000000000000..8cdaf3eb9f31
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/testTdf52065_centerTabs.odt
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport2.cxx b/sw/qa/extras/odfexport/odfexport2.cxx
new file mode 100644
index 000000000000..21455b9d343d
--- /dev/null
+++ b/sw/qa/extras/odfexport/odfexport2.cxx
@@ -0,0 +1,45 @@
+/* -*- 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>
+
+
+class Test : public SwModelTestBase
+{
+public:
+ Test() : SwModelTestBase("/sw/qa/extras/odfexport/data/", "writer8") {}
+
+ /**
+ * Denylist handling
+ */
+ bool mustTestImportOf(const char* filename) const override {
+ // Only test import of .odt document
+ return OString(filename).endsWith(".odt");
+ }
+
+ bool mustValidate(const char* /*filename*/) const override
+ {
+ return true;
+ }
+
+};
+
+DECLARE_ODFEXPORT_TEST(testTdf52065_centerTabs, "testTdf52065_centerTabs.odt")
+{
+ sal_Int32 nTabStop = parseDump("//body/txt[4]/Text[3]", "nWidth").toInt32();
+ // Without the fix, the text was unseen, with a tabstop width of 64057. It should be 3057
+ CPPUNIT_ASSERT(nTabStop < 4000);
+ CPPUNIT_ASSERT(3000 < nTabStop);
+ CPPUNIT_ASSERT_EQUAL(OUString(u"Pečiatka zamestnávateľa"), parseDump("//body/txt[4]/Text[4]", "Portion"));
+}
+
+// This test started in LO 7.2. Use the odfexport.cxx if you intend to backport to 7.1.
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/porlin.hxx b/sw/source/core/text/porlin.hxx
index a71c1112a99b..3f80a96dd7d0 100644
--- a/sw/source/core/text/porlin.hxx
+++ b/sw/source/core/text/porlin.hxx
@@ -116,6 +116,8 @@ public:
bool IsQuoVadisPortion() const { return mnWhichPor == PortionType::QuoVadis; }
bool IsTabLeftPortion() const { return mnWhichPor == PortionType::TabLeft; }
bool IsTabRightPortion() const { return mnWhichPor == PortionType::TabRight; }
+ bool IsTabCenterPortion() const { return mnWhichPor == PortionType::TabCenter; }
+ bool IsTabDecimalPortion() const { return mnWhichPor == PortionType::TabDecimal; }
bool IsFootnoteNumPortion() const { return mnWhichPor == PortionType::FootnoteNum; }
bool IsFootnotePortion() const { return mnWhichPor == PortionType::Footnote; }
bool IsDropPortion() const { return mnWhichPor == PortionType::Drop; }
diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx
index 7ec721b73010..5a3d933f99f1 100644
--- a/sw/source/core/text/txttab.cxx
+++ b/sw/source/core/text/txttab.cxx
@@ -61,6 +61,11 @@ sal_uInt16 SwLineInfo::NumberOfTabStops() const
SwTabPortion *SwTextFormatter::NewTabPortion( SwTextFormatInfo &rInf, bool bAuto ) const
{
+ // Update search location - since Center/Decimal tabstops' width is dependent on the following text.
+ SwTabPortion* pTmpLastTab = rInf.GetLastTab();
+ if (pTmpLastTab && (pTmpLastTab->IsTabCenterPortion() || pTmpLastTab->IsTabDecimalPortion()))
+ pTmpLastTab->PostFormat(rInf);
+
sal_Unicode cFill = 0;
sal_Unicode cDec = 0;
SvxTabAdjust eAdj;