sw/qa/extras/uiwriter/data/tdf144840.odt |binary
 sw/qa/extras/uiwriter/uiwriter3.cxx      |   41 +++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

New commits:
commit a12727702b4132bb0576062afe68e39a87a6a426
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu Oct 14 18:27:43 2021 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Oct 14 23:30:58 2021 +0200

    tdf#144840: sw_uiwriter3: Add unittest
    
    Change-Id: I6c43d5c4dbcebf9bd61ba66b37f9c872d0ea7cc8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123594
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/uiwriter/data/tdf144840.odt 
b/sw/qa/extras/uiwriter/data/tdf144840.odt
new file mode 100644
index 000000000000..cb611262b879
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf144840.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index cc9f2f385845..d6aec38d1d11 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -13,6 +13,7 @@
 #include <vcl/TypeSerializer.hxx>
 #include <com/sun/star/drawing/GraphicExportFilter.hpp>
 #include <IDocumentDrawModelAccess.hxx>
+#include <com/sun/star/table/TableBorder2.hpp>
 #include <com/sun/star/text/TextContentAnchorType.hpp>
 #include <com/sun/star/text/XTextFrame.hpp>
 #include <com/sun/star/text/XTextTablesSupplier.hpp>
@@ -418,6 +419,46 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132597)
     CPPUNIT_ASSERT_EQUAL(1, getPages());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf144840)
+{
+    SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf144840.odt");
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+    CPPUNIT_ASSERT_EQUAL(1, getPages());
+    uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> 
xIndexAccess(xTextTablesSupplier->getTextTables(),
+                                                         uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
+
+    dispatchCommand(mxComponent, ".uno:SelectAll", {});
+
+    rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
+    xTransfer->Cut();
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount());
+
+    // Paste special as RTF
+    uno::Sequence<beans::PropertyValue> aPropertyValues = 
comphelper::InitPropertySequence(
+        { { "SelectedFormat", 
uno::makeAny(static_cast<sal_uInt32>(SotClipboardFormatId::RTF)) } });
+
+    dispatchCommand(mxComponent, ".uno:ClipboardFormatItems", aPropertyValues);
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
+
+    uno::Reference<text::XTextTable> xTextTable(xIndexAccess->getByIndex(0), 
uno::UNO_QUERY);
+
+    table::TableBorder2 tableBorder = 
getProperty<table::TableBorder2>(xTextTable, "TableBorder2");
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: 4
+    // - Actual  : 0
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(4), tableBorder.TopLine.LineWidth);
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(4), tableBorder.LeftLine.LineWidth);
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(4), tableBorder.RightLine.LineWidth);
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(4), tableBorder.BottomLine.LineWidth);
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf131963)
 {
     SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf131963.docx");

Reply via email to