Kaydet (Commit) c78f918a authored tarafından Luke Deller's avatar Luke Deller Kaydeden (comit) Miklos Vajna

Full colour table borders in .doc export

Currently LO writes table cell border information to .doc files as part
of the "sprmTDefTable" property, but this only supports the WW8 (Word '97)
BRC (BoRder Control) structure which can only select from 16 colours.
There is no newer version of this property.

This commit adds output of an alternate property "sprmTSetBrc" which
specifies border details for a sequence of cells.  There is a WW9
(Word 2000) version of this property supporting full colours.

For LO I have used the constant name NS_sprm::LN_TSetBorder following
the existing naming convention here, which is to use *Border for the WW9
version because *Brc is taken for the WW8 version.

Conflicts:
	include/filter/msfilter/sprmids.hxx

Change-Id: Ie091d91c6d187e1c2542f59f58cec9a373a23e11
üst 5fa564d4
...@@ -252,6 +252,7 @@ namespace NS_sprm { ...@@ -252,6 +252,7 @@ namespace NS_sprm {
const sal_uInt16 LN_TFBiDi = 0x560b; const sal_uInt16 LN_TFBiDi = 0x560b;
const sal_uInt16 LN_THTMLProps = 0x740c; const sal_uInt16 LN_THTMLProps = 0x740c;
const sal_uInt16 LN_TSetBrc80 = 0xd620; const sal_uInt16 LN_TSetBrc80 = 0xd620;
const sal_uInt16 LN_TSetBrc = 0xd62f;
const sal_uInt16 LN_TInsert = 0x7621; const sal_uInt16 LN_TInsert = 0x7621;
const sal_uInt16 LN_TDelete = 0x5622; const sal_uInt16 LN_TDelete = 0x5622;
const sal_uInt16 LN_TDxaCol = 0x7623; const sal_uInt16 LN_TDxaCol = 0x7623;
......
...@@ -1953,6 +1953,7 @@ void WW8AttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTa ...@@ -1953,6 +1953,7 @@ void WW8AttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTa
TableVerticalCell( pTableTextNodeInfoInner ); TableVerticalCell( pTableTextNodeInfoInner );
TableOrientation( pTableTextNodeInfoInner ); TableOrientation( pTableTextNodeInfoInner );
TableSpacing( pTableTextNodeInfoInner ); TableSpacing( pTableTextNodeInfoInner );
TableCellBorders( pTableTextNodeInfoInner );
} }
} }
} }
...@@ -2413,6 +2414,38 @@ void WW8AttributeOutput::TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointe ...@@ -2413,6 +2414,38 @@ void WW8AttributeOutput::TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointe
} }
} }
void WW8AttributeOutput::TableCellBorders(
ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
{
if (!m_rWW8Export.bWrtWW8)
return;
const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
const SwTableLine * pTabLine = pTabBox->GetUpper();
const SwTableBoxes & rTabBoxes = pTabLine->GetTabBoxes();
sal_uInt8 nBoxes = std::min<size_t>(rTabBoxes.size(), 255);
const SvxBoxItem * pLastBox = 0;
sal_uInt8 nSeqStart = 0; // start of sequence of cells with same borders
// Detect sequences of cells which have the same borders, and output
// a border description for each such cell range.
for ( unsigned n = 0; n <= nBoxes; ++n )
{
const SvxBoxItem * pBox = (n == nBoxes) ? 0 :
&rTabBoxes[n]->GetFrmFmt()->GetBox();
if( !pLastBox )
pLastBox = pBox;
else if( !pBox || *pLastBox != *pBox )
{
// This cell has different borders than the previous cell,
// so output the borders for the preceding cell range.
m_rWW8Export.Out_CellRangeBorders(pLastBox, nSeqStart, n);
nSeqStart = n;
pLastBox = pBox;
}
}
}
void WW8AttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) void WW8AttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
{ {
const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox(); const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
......
...@@ -1087,6 +1087,8 @@ public: ...@@ -1087,6 +1087,8 @@ public:
void Out_SwFmtBox(const SvxBoxItem& rBox, bool bShadow); void Out_SwFmtBox(const SvxBoxItem& rBox, bool bShadow);
void Out_SwFmtTableBox( ww::bytes& rO, const SvxBoxItem * rBox ); void Out_SwFmtTableBox( ww::bytes& rO, const SvxBoxItem * rBox );
void Out_CellRangeBorders(const SvxBoxItem * pBox, sal_uInt8 nStart,
sal_uInt8 nLimit);
sal_uInt8 TransCol( const Color& rCol ); sal_uInt8 TransCol( const Color& rCol );
bool TransBrush(const Color& rCol, WW8_SHD& rShd); bool TransBrush(const Color& rCol, WW8_SHD& rShd);
WW8_BRCVer9 TranslateBorderLine(const ::editeng::SvxBorderLine& pLine, WW8_BRCVer9 TranslateBorderLine(const ::editeng::SvxBorderLine& pLine,
......
...@@ -4442,6 +4442,32 @@ void WW8Export::Out_SwFmtTableBox( ww::bytes& rO, const SvxBoxItem * pBox ) ...@@ -4442,6 +4442,32 @@ void WW8Export::Out_SwFmtTableBox( ww::bytes& rO, const SvxBoxItem * pBox )
} }
} }
void WW8Export::Out_CellRangeBorders( const SvxBoxItem * pBox, sal_uInt8 nStart,
sal_uInt8 nLimit )
{
static const sal_uInt16 aBorders[] =
{
BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT
};
for( int i = 0; i < 4; ++i )
{
const SvxBorderLine* pLn = 0;
if (pBox != NULL)
pLn = pBox->GetLine( aBorders[i] );
if (!pLn)
continue;
InsUInt16( NS_sprm::LN_TSetBrc );
pO->push_back( 11 );
pO->push_back( nStart );
pO->push_back( nLimit );
pO->push_back( 1<<i );
WW8_BRCVer9 aBrcVer9 = TranslateBorderLine( *pLn, 0, false );
pO->insert( pO->end(), aBrcVer9.aBits1, aBrcVer9.aBits2+4 );
}
}
void WW8AttributeOutput::FormatBox( const SvxBoxItem& rBox ) void WW8AttributeOutput::FormatBox( const SvxBoxItem& rBox )
{ {
// Fly um Grafik-> keine Umrandung hier, da // Fly um Grafik-> keine Umrandung hier, da
......
...@@ -471,6 +471,9 @@ protected: ...@@ -471,6 +471,9 @@ protected:
/// Output the bold etc. attributes, the Complex Text Layout version /// Output the bold etc. attributes, the Complex Text Layout version
void OutputWW8AttributeCTL( sal_uInt8 nId, bool bVal ); void OutputWW8AttributeCTL( sal_uInt8 nId, bool bVal );
void TableCellBorders(
ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
}; };
#endif // INCLUDED_SW_SOURCE_FILTER_WW8_WW8ATTRIBUTEOUTPUT_HXX #endif // INCLUDED_SW_SOURCE_FILTER_WW8_WW8ATTRIBUTEOUTPUT_HXX
......
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