summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2019-08-21 19:41:17 +0300
committerMiklos Vajna <vmiklos@collabora.com>2019-08-28 09:28:38 +0200
commit4a4e0cb67eab422dffda6f3339031db5b62be77a (patch)
tree0f9d6cc79b3fd8ab810f980da8664ddf6f4e15c2 /sw/qa
parent3780d305ae1607458029af3c9452bad251490461 (diff)
tdf#126784 sw: only distribute across selected columns
partial revert of LO6.2 commit ab18c17d70e1dcf5cf9db38256d35e6af479373e because MERGED cells had a very unexpected effect on the columns that were altered. Unselected columns are INCLUDED in the calculation IF they extend over the selected columns when SwTableSearchType::Col uses the entire table column. The last table in the unit test demonstrates why the regressive behaviour was included. A user can make an ugly layout if they don't choose a good set of columns. However, the merged cell really changes the way the calculation works, and since giving power to the user is ultimately the best, just revert the portion that tries to save the user from themself. I struggled then and now to get a good enough understanding to improve the documentation - which really is needed since reading it didn't help me a lot. However, since my understanding was and is obviously flawed, I'll just revert back to the original wording. Change-Id: Icf8f01f095652e2a023e0398852f43aa6b90332f Reviewed-on: https://gerrit.libreoffice.org/77985 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/uiwriter/data2/tdf126784_distributeSelectedColumns.odtbin0 -> 21302 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx31
2 files changed, 31 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data2/tdf126784_distributeSelectedColumns.odt b/sw/qa/extras/uiwriter/data2/tdf126784_distributeSelectedColumns.odt
new file mode 100644
index 000000000000..90c23c56a32d
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data2/tdf126784_distributeSelectedColumns.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 01ee96f67ee6..d8e939be005d 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -10,6 +10,7 @@
#include <swmodeltestbase.hxx>
#include <com/sun/star/awt/FontSlant.hpp>
#include <com/sun/star/frame/DispatchHelper.hpp>
+#include <com/sun/star/text/TableColumnSeparator.hpp>
#include <comphelper/propertysequence.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <svx/svdpage.hxx>
@@ -42,6 +43,7 @@ public:
void testTdf54819();
void testTdf109376_redline();
void testTdf109376();
+ void testTdf126784_distributeSelectedColumns();
void testTdf108687_tabstop();
void testTdf119571();
void testTdf119019();
@@ -60,6 +62,7 @@ public:
CPPUNIT_TEST(testTdf101534);
CPPUNIT_TEST(testTdf54819);
CPPUNIT_TEST(testTdf109376_redline);
+ CPPUNIT_TEST(testTdf126784_distributeSelectedColumns);
CPPUNIT_TEST(testTdf109376);
CPPUNIT_TEST(testTdf108687_tabstop);
CPPUNIT_TEST(testTdf119571);
@@ -360,6 +363,34 @@ void SwUiWriterTest2::testTdf109376()
CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM));
}
+void SwUiWriterTest2::testTdf126784_distributeSelectedColumns()
+{
+ SwDoc* pDoc = createDoc("tdf126784_distributeSelectedColumns.odt");
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+ uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(),
+ uno::UNO_QUERY);
+ uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<table::XTableRows> xTableRows = xTextTable->getRows();
+
+ auto aSeq = getProperty<uno::Sequence<text::TableColumnSeparator>>(xTableRows->getByIndex(0),
+ "TableColumnSeparators");
+ sal_Int16 nOrigCol2Pos = aSeq[0].Position;
+ sal_Int16 nOrigCol3Pos = aSeq[1].Position;
+
+ //Select column 1 and 2
+ pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false);
+
+ lcl_dispatchCommand(mxComponent, ".uno:DistributeColumns", {});
+
+ aSeq = getProperty<uno::Sequence<text::TableColumnSeparator>>(xTableRows->getByIndex(0),
+ "TableColumnSeparators");
+ CPPUNIT_ASSERT_MESSAGE("Second column should shrink", nOrigCol2Pos < aSeq[0].Position);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Last column shouldn't change", nOrigCol3Pos, aSeq[1].Position);
+}
+
void SwUiWriterTest2::testTdf108687_tabstop()
{
SwDoc* pDoc = createDoc("tdf108687_tabstop.odt");