tdf#81100 DOCX import: repeat header according to table style

Table style based repeating table header wasn't repeated,
only direct table formatting.

Change-Id: I119e6d32bf22c6c85a84aa42ae4cd6c5f60166b2
Reviewed-on: https://gerrit.libreoffice.org/80053
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
This commit is contained in:
László Németh
2019-10-03 07:59:10 +02:00
parent 1af2f8f75e
commit f9aac900ad
6 changed files with 38 additions and 14 deletions
Binary file not shown.
@@ -974,6 +974,17 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf81100, "tdf81100.docx")
CPPUNIT_ASSERT(pXmlDoc);
// keep "repeat table header" setting of table styles
assertXPath(pXmlDoc, "/w:styles/w:style/w:tblStylePr/w:trPr/w:tblHeader", 4);
xmlDocPtr pDump = parseLayoutDump();
CPPUNIT_ASSERT_EQUAL(3, getPages());
// table starts on page 1 and finished on page 2
// and it has got only a single repeating header line
assertXPath(pDump, "/root/page[2]/body/tab[1]", 1);
assertXPath(pDump, "/root/page[2]/body/tab[1]/row", 2);
assertXPath(pDump, "/root/page[3]/body/tab", 1);
if (!mbExported) // TODO export tblHeader=false
assertXPath(pDump, "/root/page[3]/body/tab/row", 1);
}
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf121597TrackedDeletionOfMultipleParagraphs, "tdf121597.odt")
+1 -1
View File
@@ -3540,7 +3540,7 @@ void DocxAttributeOutput::StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t c
// Header row: tblHeader
const SwTable *pTable = pTableTextNodeInfoInner->getTable( );
if ( pTable->GetRowsToRepeat( ) > pTableTextNodeInfoInner->getRow( ) )
m_pSerializer->singleElementNS(XML_w, XML_tblHeader, FSNS(XML_w, XML_val), "true");
m_pSerializer->singleElementNS(XML_w, XML_tblHeader, FSNS(XML_w, XML_val), "true"); // TODO to overwrite table style may need explicit false
TableRowRedline( pTableTextNodeInfoInner );
TableHeight( pTableTextNodeInfoInner );
@@ -50,6 +50,18 @@ using namespace ::com::sun::star;
using namespace ::std;
#define DEF_BORDER_DIST 190 //0,19cm
#define CNF_FIRST_ROW 0x800
#define CNF_LAST_ROW 0x400
#define CNF_FIRST_COLUMN 0x200
#define CNF_LAST_COLUMN 0x100
#define CNF_ODD_VBAND 0x080
#define CNF_EVEN_VBAND 0x040
#define CNF_ODD_HBAND 0x020
#define CNF_EVEN_HBAND 0x010
#define CNF_FIRST_ROW_LAST_COLUMN 0x008
#define CNF_FIRST_ROW_FIRST_COLUMN 0x004
#define CNF_LAST_ROW_LAST_COLUMN 0x002
#define CNF_LAST_ROW_FIRST_COLUMN 0x001
DomainMapperTableHandler::DomainMapperTableHandler(
css::uno::Reference<css::text::XTextAppendAndConvert> const& xText,
@@ -427,6 +439,10 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
m_aTableProperties->dumpXml();
TagLogger::getInstance().endElement();
#endif
// apply tblHeader setting of the table style
PropertyMapPtr pHeaderStyleProps = pTableStyle->GetProperties(CNF_FIRST_ROW);
if ( pHeaderStyleProps->getProperty(PROP_HEADER_ROW_COUNT) )
m_aTableProperties->Insert(PROP_HEADER_ROW_COUNT, uno::makeAny( sal_Int32(1)), false);
}
}
@@ -630,19 +646,6 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
return pTableStyle;
}
#define CNF_FIRST_ROW 0x800
#define CNF_LAST_ROW 0x400
#define CNF_FIRST_COLUMN 0x200
#define CNF_LAST_COLUMN 0x100
#define CNF_ODD_VBAND 0x080
#define CNF_EVEN_VBAND 0x040
#define CNF_ODD_HBAND 0x020
#define CNF_EVEN_HBAND 0x010
#define CNF_FIRST_ROW_LAST_COLUMN 0x008
#define CNF_FIRST_ROW_FIRST_COLUMN 0x004
#define CNF_LAST_ROW_LAST_COLUMN 0x002
#define CNF_LAST_ROW_FIRST_COLUMN 0x001
CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(TableInfo & rInfo, std::vector<HorizontallyMergedCell>& rMerges)
{
#ifdef DBG_UTIL
@@ -225,7 +225,16 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
insertTableProps(pPropMap);
}
else
{
if ( nIntValue == 0 && m_nRow == 0 )
{
// explicit tblHeader=0 in the first row must overwrite table style
TablePropertyMapPtr pPropMap( new TablePropertyMap );
pPropMap->Insert( PROP_HEADER_ROW_COUNT, uno::makeAny(sal_Int32(0)));
insertTableProps(pPropMap);
}
m_nHeaderRepeat = -1;
}
if (nIntValue)
{
// Store the info that this is a header, we'll need that when we apply table styles.
@@ -162,6 +162,7 @@ void TblStylePrHandler::lcl_sprm(Sprm & rSprm)
break;
case NS_ooxml::LN_CT_TrPrBase_tblHeader:
{
m_pProperties->Insert( PROP_HEADER_ROW_COUNT, uno::makeAny(sal_Int32(1)));
beans::PropertyValue aValue;
aValue.Name = "tblHeader";
aValue.Value <<= true;