NFC ww8export: fix outright lies and false insinuations

and other general cleanup
related to tdf#98409 - see proof example there.

The outright lie is that cell border defaults come from the
first row and the first column. Instead, margins actually
are defined for each row, and come from the last column.
And there are no defaults for the border lines themselves.

The insinuation is that these are table level settings
that only should occur once, but most of them are per-row
settings and all of them happen repeatedly.

The three functions that appear to repeat table level
definitions probably should run only once, but that is
likely tricky to do with table-in-table situations,
so no intention to do that here in a
NoFunctionalChange patch.

Change-Id: I9fa60902389668256b147df6bf9a2e972cf9174a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92700
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
Justin Luth
2020-04-22 13:44:33 +03:00
committed by Miklos Vajna
parent 7e82d7bf88
commit aa12bf1a82
2 changed files with 19 additions and 13 deletions

View File

@@ -2043,16 +2043,19 @@ void WW8AttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTa
m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
}
TableDefinition( pTableTextNodeInfoInner );
TableHeight( pTableTextNodeInfoInner );
TableBackgrounds( pTableTextNodeInfoInner );
TableDefaultBorders( pTableTextNodeInfoInner );
TableCanSplit( pTableTextNodeInfoInner );
// Most of these are per-row definitions, not per-table,
// so likely some the per-table functions are unnecessarily re-defined...
TableBidi( pTableTextNodeInfoInner );
TableVerticalCell( pTableTextNodeInfoInner );
TableOrientation( pTableTextNodeInfoInner );
TableSpacing( pTableTextNodeInfoInner );
TableCellBorders( pTableTextNodeInfoInner );
TableDefinition( pTableTextNodeInfoInner ); //per row definitions
TableHeight( pTableTextNodeInfoInner ); //per row definitions
TableBackgrounds( pTableTextNodeInfoInner ); //per row definitions
// Since this isEndOfLine, cell margin defaults for each row come from last column.
TableDefaultBorders( pTableTextNodeInfoInner ); //per row definitions
TableCanSplit( pTableTextNodeInfoInner ); //per row definitions
TableVerticalCell( pTableTextNodeInfoInner ); //per row definitions
TableCellBorders( pTableTextNodeInfoInner ); //per row definitions
}
}
}
@@ -2526,20 +2529,22 @@ void AttributeOutputBase::GetTablePageSize( ww8::WW8TableNodeInfoInner const * p
void WW8AttributeOutput::TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
{
// This function name is misleading because it is not a table default, but a row default,
// and it also only sets default cell margins (aka border padding).
// The specs suggest there is no way to define default border lines/colors.
const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
const SwFrameFormat * pFrameFormat = pTabBox->GetFrameFormat();
//Set Default, just taken from the first cell of the first
//row
static const SvxBoxItemLine aBorders[] =
{
SvxBoxItemLine::TOP, SvxBoxItemLine::LEFT,
SvxBoxItemLine::BOTTOM, SvxBoxItemLine::RIGHT
};
// Set row default cell margins using this last cell in the row
for ( int i = 0; i < 4; ++i )
{
SwWW8Writer::InsUInt16( *m_rWW8Export.pO, 0xD634 );
SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::sprmTCellPaddingDefault );
m_rWW8Export.pO->push_back( sal_uInt8(6) );
m_rWW8Export.pO->push_back( sal_uInt8(0) );
m_rWW8Export.pO->push_back( sal_uInt8(1) );

View File

@@ -4512,6 +4512,9 @@ void WW8Export::Out_SwFormatTableBox( ww::bytes& rO, const SvxBoxItem * pBox )
void WW8Export::Out_CellRangeBorders( const SvxBoxItem * pBox, sal_uInt8 nStart,
sal_uInt8 nLimit )
{
if ( !pBox )
return;
static const SvxBoxItemLine aBorders[] =
{
SvxBoxItemLine::TOP, SvxBoxItemLine::LEFT, SvxBoxItemLine::BOTTOM, SvxBoxItemLine::RIGHT
@@ -4519,9 +4522,7 @@ void WW8Export::Out_CellRangeBorders( const SvxBoxItem * pBox, sal_uInt8 nStart,
for( int i = 0; i < 4; ++i )
{
const SvxBorderLine* pLn = nullptr;
if (pBox != nullptr)
pLn = pBox->GetLine( aBorders[i] );
const SvxBorderLine* pLn = pBox->GetLine( aBorders[i] );
if (!pLn)
continue;