sw/qa/filter/md/data/tables.md |    3 ++
 sw/qa/filter/md/md.cxx         |   52 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)

New commits:
commit d80cade3e0564f584b946ef7ffe1a575f3329239
Author:     Ujjawal Kumar <randomfores...@gmail.com>
AuthorDate: Sun Jul 20 14:36:09 2025 +0530
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Aug 27 09:21:18 2025 +0200

    tdf#162153 Markdown Filter: Add unit test for tables
    
    Conflicts:
            sw/qa/filter/md/md.cxx
    
    Change-Id: I1ed04926b11e1d287ba92359949f61491ae42943
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190262
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/filter/md/data/tables.md b/sw/qa/filter/md/data/tables.md
new file mode 100644
index 000000000000..af2228b01059
--- /dev/null
+++ b/sw/qa/filter/md/data/tables.md
@@ -0,0 +1,3 @@
+| Left-aligned |                                                          
Center-aligned                                                          | 
Right-aligned |
+| :---         |                                                               
:---:                                                              |          
---: |
+| data1        | data2 
![LibreOffice](https://wiki.documentfoundation.org/images/7/74/LibreOffice_Initial-Artwork-Logo_ColorLogoBasic_2000px.png)
 | data3         |
diff --git a/sw/qa/filter/md/md.cxx b/sw/qa/filter/md/md.cxx
index f39cc500e6d7..ab1c30abde3d 100644
--- a/sw/qa/filter/md/md.cxx
+++ b/sw/qa/filter/md/md.cxx
@@ -11,6 +11,8 @@
 
 #include <swmodeltestbase.hxx>
 
+#include <com/sun/star/style/ParagraphAdjust.hpp>
+
 namespace
 {
 /**
@@ -126,6 +128,56 @@ CPPUNIT_TEST_FIXTURE(Test, testList)
     CPPUNIT_ASSERT_EQUAL(OUString("Unordered"), getParagraph(2)->getString());
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTables)
+{
+    setImportFilterName("Markdown");
+    createSwDoc("tables.md");
+
+    uno::Reference<text::XTextContent> const xtable(getParagraphOrTable(1));
+
+    // cell A1
+
+    uno::Reference<text::XText> xCellText(getCell(xtable, u"A1"_ustr), 
uno::UNO_QUERY_THROW);
+
+    CPPUNIT_ASSERT_EQUAL(u"Left-aligned"_ustr, xCellText->getString());
+
+    uno::Reference<text::XTextCursor> xCursor = xCellText->createTextCursor();
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(style::ParagraphAdjust_LEFT),
+                         getProperty<sal_Int16>(xCursor, u"ParaAdjust"_ustr));
+
+    // cell B1
+    xCellText.set(getCell(xtable, u"B1"_ustr), uno::UNO_QUERY_THROW);
+
+    CPPUNIT_ASSERT_EQUAL(u"Center-aligned"_ustr, xCellText->getString());
+
+    xCursor = xCellText->createTextCursor();
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(style::ParagraphAdjust_CENTER),
+                         getProperty<sal_Int16>(xCursor, u"ParaAdjust"_ustr));
+
+    // cell C1
+    xCellText.set(getCell(xtable, u"C1"_ustr), uno::UNO_QUERY_THROW);
+
+    CPPUNIT_ASSERT_EQUAL(u"Right-aligned"_ustr, xCellText->getString());
+
+    xCursor = xCellText->createTextCursor();
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(style::ParagraphAdjust_RIGHT),
+                         getProperty<sal_Int16>(xCursor, u"ParaAdjust"_ustr));
+
+    // cell A2
+    CPPUNIT_ASSERT(getCell(xtable, u"A2"_ustr, u"data1"_ustr).is());
+
+    // cell B2
+    xCellText.set(getCell(xtable, u"B2"_ustr), uno::UNO_QUERY_THROW);
+
+    uno::Reference<text::XTextContent> xContent(getShape(1), 
uno::UNO_QUERY_THROW);
+
+    CPPUNIT_ASSERT_EQUAL(u"data2 "_ustr, xCellText->getString());
+    CPPUNIT_ASSERT_EQUAL(xCellText, xContent->getAnchor()->getText());
+
+    // cell C2
+    CPPUNIT_ASSERT(getCell(xtable, u"C2"_ustr, u"data3"_ustr).is());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */

Reply via email to