From f238cebb57200ce38796fad8f78801446943ebff Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Fri, 4 Mar 2011 15:56:41 -0300 Subject: Fix bug #532 - "QNetworkSession documentation formatting broken" Reviewer: Marcelo Lira Lauro Moura --- generators/qtdoc/qtdocgenerator.cpp | 6 ++++ tests/sphinxtabletest.cpp | 58 +++++++++++++++++++++++++++++++++++++ tests/sphinxtabletest.h | 1 + 3 files changed, 65 insertions(+) diff --git a/generators/qtdoc/qtdocgenerator.cpp b/generators/qtdoc/qtdocgenerator.cpp index cd78b858e..ae7dcadf4 100644 --- a/generators/qtdoc/qtdocgenerator.cpp +++ b/generators/qtdoc/qtdocgenerator.cpp @@ -718,10 +718,14 @@ void QtXmlToSphinx::Table::normalize() int col; QtXmlToSphinx::Table& self = *this; + //QDoc3 generates tables with wrong number of columns. We have to + //check and if necessary, merge the last columns. + int maxCols = self.at(0).count(); // add col spans for (row = 0; row < count(); ++row) { for (col = 0; col < at(row).count(); ++col) { QtXmlToSphinx::TableCell& cell = self[row][col]; + bool mergeCols = (col >= maxCols); if (cell.colSpan > 0) { QtXmlToSphinx::TableCell newCell; newCell.colSpan = -1; @@ -730,6 +734,8 @@ void QtXmlToSphinx::Table::normalize() } cell.colSpan = 0; col++; + } else if (mergeCols) { + self[row][maxCols - 1].data += " " + cell.data; } } } diff --git a/tests/sphinxtabletest.cpp b/tests/sphinxtabletest.cpp index a35d11926..c1ba59e60 100644 --- a/tests/sphinxtabletest.cpp +++ b/tests/sphinxtabletest.cpp @@ -262,6 +262,64 @@ void SphinxTableTest::testRowSpan2() \n")); } +void SphinxTableTest::testBrokenTable() +{ + const char* xml = "\ +\ +
\ + \ + Header 1\ + \ + \ + Header 2\ + \ +
\ + \ + \ + 1.1\ + \ + \ + 1.2\ + \ + \ + \ + \ + 2 2\ + \ + \ + 2 3\ + \ + \ + 2 4\ + \ + \ + 2 5\ + \ + \ + \ + \ + 3 1\ + \ + \ + 3 2\ + \ + \ + 3 3\ + \ + \ +
"; + QCOMPARE(transformXml(xml), QString("\ + +--------+------------+\n\ + |Header 1|Header 2 |\n\ + +--------+------------+\n\ + |1.1 |1.2 |\n\ + +--------+------------+\n\ + |2 2 2 3 2 4 2 5|\n\ + +--------+------------+\n\ + |3 1 |3 2 3 3 |\n\ + +--------+------------+\n\ +\n")); +} QTEST_APPLESS_MAIN( SphinxTableTest ) diff --git a/tests/sphinxtabletest.h b/tests/sphinxtabletest.h index 57d8937d0..e056021b5 100644 --- a/tests/sphinxtabletest.h +++ b/tests/sphinxtabletest.h @@ -39,6 +39,7 @@ private slots: void testColSpan(); void testComplexTable(); void testRowSpan2(); + void testBrokenTable(); private: QtDocGenerator* m_generator; -- cgit v1.2.3