summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-08-22 19:51:37 +0200
committerMiklos Vajna <vmiklos@collabora.com>2023-08-23 08:03:59 +0200
commit7c15750cecea2aeb05653c0ee67b933d969b1f0b (patch)
treeb32ab6171bbc52a61eb47cc0e5a0f517476c9b0f /sw/qa
parent1530584a7214ca92b457b24ebf5f0e444d805dca (diff)
tdf#155510 ODT import: ignore props of covered table cells, unless in comp mode
The problem was that the A5 cell on page 2 used to have a solid background, but this was lost after commit 1001dbaef4dec2b51c25ed8343bab6910f1219e1 (ODT import: handle style name of covered cells, 2021-03-19). Covered cell formatting was interesting for cell borders, in Word compat mode the covered cell can have its own border style, so e.g. there is left border on a vertically merged cell till its center, but not after its center. Fix the problem by limiting the import of covered cell formatting to the case when the TABLE_ROW_KEEP compat flag is on, to keep both native ODT and ODT-from-Word documents happy. If there is a need, some smarter way of merging properties could be implemented in the future. Change-Id: Icc1e6f48d9f5a0379d9a9052a1f5b9ae3f294477 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155957 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/filter/xml/data/covered-cell-background.odtbin0 -> 11710 bytes
-rw-r--r--sw/qa/filter/xml/xml.cxx61
2 files changed, 61 insertions, 0 deletions
diff --git a/sw/qa/filter/xml/data/covered-cell-background.odt b/sw/qa/filter/xml/data/covered-cell-background.odt
new file mode 100644
index 000000000000..99b77630a00d
--- /dev/null
+++ b/sw/qa/filter/xml/data/covered-cell-background.odt
Binary files differ
diff --git a/sw/qa/filter/xml/xml.cxx b/sw/qa/filter/xml/xml.cxx
new file mode 100644
index 000000000000..a0a21f5f4335
--- /dev/null
+++ b/sw/qa/filter/xml/xml.cxx
@@ -0,0 +1,61 @@
+/* -*- 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 <frameformats.hxx>
+#include <frmatr.hxx>
+#include <swtable.hxx>
+
+namespace
+{
+/**
+ * Covers sw/source/filter/xml/ fixes.
+ *
+ * Note that these tests are meant to be simple: either load a file and assert some result or build
+ * a document model with code, export and assert that result.
+ *
+ * Keep using the various sw_<format>import/export suites for multiple filter calls inside a single
+ * test.
+ */
+class Test : public SwModelTestBase
+{
+public:
+ Test()
+ : SwModelTestBase("/sw/qa/filter/xml/data/", "writer8")
+ {
+ }
+};
+
+CPPUNIT_TEST_FIXTURE(Test, testCoveredCellBackground)
+{
+ // Given a document with a table with vertically merged cells, with a solid background:
+ createSwDoc("covered-cell-background.odt");
+
+ // When checking the background of the last row's first covered table cell:
+ SwDoc* pDoc = getSwDoc();
+ const SwTableFormat* pTableFormat = (*pDoc->GetTableFrameFormats())[0];
+ SwTable* pTable = SwTable::FindTable(pTableFormat);
+ SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTableBox("A5"));
+ SwFrameFormat* pCellFormat = pBox->GetFrameFormat();
+ const SvxBrushItem& rBackground = pCellFormat->GetAttrSet().GetBackground();
+
+ // Then make sure the covered cell has a solid background, just like other cells in the first
+ // column:
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: rgba[e8f2a1ff]
+ // - Actual : rgba[ffffff00]
+ // i.e. part of the merged cell had a bad white background.
+ CPPUNIT_ASSERT_EQUAL(Color(0xe8f2a1), rBackground.GetColor());
+}
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */