Kaydet (Commit) c4fc38a8 authored tarafından Vitaliy Anderson's avatar Vitaliy Anderson Kaydeden (comit) Mike Kaganski

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/34931Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 8240be91
......@@ -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) \
))
......
This diff was suppressed by a .gitattributes entry.
......@@ -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();
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment