sw/CppunitTest_sw_ww8import.mk | 1 sw/qa/extras/ww8import/data/tdf105570.doc |binary sw/qa/extras/ww8import/ww8import.cxx | 42 ++++++++++++++++++++++++++++++ sw/source/filter/ww8/ww8par2.cxx | 9 ++---- 4 files changed, 46 insertions(+), 6 deletions(-)
New commits: commit c4fc38a86f77d87263e78fae04a31f19c21fb017 Author: Vitaliy Anderson <[email protected]> Date: Fri Mar 3 06:29:37 2017 -0800 tdf#105570: Treat sprmTTableHeader properly. Only take into account sprmTTableHeader if all previous rows had it. Change-Id: I0f81da366c148963503b4aeba778f5d97aa72d26 Reviewed-on: https://gerrit.libreoffice.org/34931 Tested-by: Jenkins <[email protected]> Reviewed-by: Mike Kaganski <[email protected]> diff --git a/sw/CppunitTest_sw_ww8import.mk b/sw/CppunitTest_sw_ww8import.mk index db85995..d3ae08a 100644 --- a/sw/CppunitTest_sw_ww8import.mk +++ b/sw/CppunitTest_sw_ww8import.mk @@ -35,6 +35,7 @@ $(eval $(call gb_CppunitTest_use_externals,sw_ww8import,\ $(eval $(call gb_CppunitTest_set_include,sw_ww8import,\ -I$(SRCDIR)/sw/inc \ -I$(SRCDIR)/sw/source/core/inc \ + -I$(SRCDIR)/sw/source/uibase/inc \ -I$(SRCDIR)/sw/qa/extras/inc \ $$(INCLUDE) \ )) diff --git a/sw/qa/extras/ww8import/data/tdf105570.doc b/sw/qa/extras/ww8import/data/tdf105570.doc new file mode 100644 index 0000000..1bace77 Binary files /dev/null and b/sw/qa/extras/ww8import/data/tdf105570.doc differ diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index 3727c58..4ec5ca0 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -10,6 +10,9 @@ #include <swmodeltestbase.hxx> #include <com/sun/star/text/XTextTablesSupplier.hpp> +#include <ndtxt.hxx> +#include <viscrs.hxx> +#include <wrtsh.hxx> class Test : public SwModelTestBase { @@ -65,6 +68,45 @@ DECLARE_WW8IMPORT_TEST(testTdf106291, "tdf106291.doc") CPPUNIT_ASSERT(cellHeight.toInt32() > 200); // height might depend on font size } +DECLARE_WW8IMPORT_TEST( testTdf105570, "tdf105570.doc" ) +{ + /***** + * MS-DOC specification ( https://msdn.microsoft.com/en-us/library/cc313153 ) + * ch. 2.6.3, sprmTTableHeader: + * A Bool8 value that specifies that the current table row is a header row. + * If the value is 0x01 but sprmTTableHeader is not applied with a value of 0x01 + * for a previous row in the same table, then this property MUST be ignored. + * + * The document have three tables with three rows. + * Table 1 has { 1, 0, 0 } values of the "repeat as header row" property for each row + * Table 2 has { 1, 1, 0 } + * Table 3 has { 0, 1, 1 } + ****/ + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + SwShellCursor* pShellCursor = pWrtShell->getShellCursor( false ); + SwNodeIndex aIdx = SwNodeIndex( pShellCursor->Start()->nNode ); + + // Find first table + SwTableNode* pTableNd = aIdx.GetNode().FindTableNode(); + + CPPUNIT_ASSERT_EQUAL( sal_uInt16(1), pTableNd->GetTable().GetRowsToRepeat() ); + + // Go to next table + aIdx.Assign( *pTableNd->EndOfSectionNode(), 1 ); + while ( nullptr == (pTableNd = aIdx.GetNode().GetTableNode()) ) ++aIdx; + + CPPUNIT_ASSERT_EQUAL( sal_uInt16(2), pTableNd->GetTable().GetRowsToRepeat() ); + + // Go to next table + aIdx.Assign( *pTableNd->EndOfSectionNode(), 1 ); + while ( nullptr == (pTableNd = aIdx.GetNode().GetTableNode()) ) ++aIdx; + + // As first row hasn't sprmTTableHeader set, all following must be ignored, so no rows must be repeated + CPPUNIT_ASSERT_EQUAL( sal_uInt16(0), pTableNd->GetTable().GetRowsToRepeat() ); +} + // tests should only be added to ww8IMPORT *if* they fail round-tripping in ww8EXPORT CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 6b424a4..6257201 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -1839,7 +1839,6 @@ WW8TabDesc::WW8TabDesc(SwWW8ImplReader* pIoClass, WW8_CP nStartCp) : for (int nLoop = 0; nLoop < 2; ++nLoop) { - bool bRepeatedSprm = false; const sal_uInt8* pParams; while (aSprmIter.GetSprms() && nullptr != (pParams = aSprmIter.GetAktParams())) { @@ -1870,11 +1869,9 @@ WW8TabDesc::WW8TabDesc(SwWW8ImplReader* pIoClass, WW8_CP nStartCp) : pTableBorders90 = pParams; // process at end break; case sprmTTableHeader: - if (!bRepeatedSprm) - { - m_nRowsToRepeat++; - bRepeatedSprm = true; - } + // tdf#105570 + if ( m_nRowsToRepeat == m_nRows ) + m_nRowsToRepeat = (m_nRows + 1); break; case sprmTJc: // sprmTJc - Justification Code _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
