summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Deller <luke@deller.id.au>2014-04-04 21:58:16 +1100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-04-06 16:53:04 +0200
commitc78f918a7cb267a713804b8feacc3425196d4428 (patch)
tree519790f5f31858c29226f79995791096f9f6d018
parent5fa564d4a95160dee96604ffa2c2b82246ce09f4 (diff)
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
-rw-r--r--include/filter/msfilter/sprmids.hxx1
-rw-r--r--sw/source/filter/ww8/wrtww8.cxx33
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx2
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx26
-rw-r--r--sw/source/filter/ww8/ww8attributeoutput.hxx3
5 files changed, 65 insertions, 0 deletions
diff --git a/include/filter/msfilter/sprmids.hxx b/include/filter/msfilter/sprmids.hxx
index 213ae0cd46dc..b12d907e8d31 100644
--- a/include/filter/msfilter/sprmids.hxx
+++ b/include/filter/msfilter/sprmids.hxx
@@ -252,6 +252,7 @@ namespace NS_sprm {
const sal_uInt16 LN_TFBiDi = 0x560b;
const sal_uInt16 LN_THTMLProps = 0x740c;
const sal_uInt16 LN_TSetBrc80 = 0xd620;
+ const sal_uInt16 LN_TSetBrc = 0xd62f;
const sal_uInt16 LN_TInsert = 0x7621;
const sal_uInt16 LN_TDelete = 0x5622;
const sal_uInt16 LN_TDxaCol = 0x7623;
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 343e47cac173..1a666d0bb15e 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -1953,6 +1953,7 @@ void WW8AttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTa
TableVerticalCell( pTableTextNodeInfoInner );
TableOrientation( pTableTextNodeInfoInner );
TableSpacing( pTableTextNodeInfoInner );
+ TableCellBorders( pTableTextNodeInfoInner );
}
}
}
@@ -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 )
{
const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 5cd5b0a79cec..82598759628b 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -1087,6 +1087,8 @@ public:
void Out_SwFmtBox(const SvxBoxItem& rBox, bool bShadow);
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 );
bool TransBrush(const Color& rCol, WW8_SHD& rShd);
WW8_BRCVer9 TranslateBorderLine(const ::editeng::SvxBorderLine& pLine,
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 5fd495bca1e7..c853be03c01c 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -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 )
{
// Fly um Grafik-> keine Umrandung hier, da
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
index 0078a84cbe9b..d1f628e722b5 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -471,6 +471,9 @@ protected:
/// Output the bold etc. attributes, the Complex Text Layout version
void OutputWW8AttributeCTL( sal_uInt8 nId, bool bVal );
+ void TableCellBorders(
+ ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
+
};
#endif // INCLUDED_SW_SOURCE_FILTER_WW8_WW8ATTRIBUTEOUTPUT_HXX