[Libreoffice-commits] core.git: 2 commits - include/filter sw/source

Luke Deller luke at deller.id.au
Sun Apr 6 07:53:39 PDT 2014


 include/filter/msfilter/sprmids.hxx         |    3 +-
 sw/source/filter/ww8/wrtww8.cxx             |   33 ++++++++++++++++++++++++++++
 sw/source/filter/ww8/wrtww8.hxx             |    2 +
 sw/source/filter/ww8/ww8atr.cxx             |   26 ++++++++++++++++++++++
 sw/source/filter/ww8/ww8attributeoutput.hxx |    3 ++
 5 files changed, 66 insertions(+), 1 deletion(-)

New commits:
commit c78f918a7cb267a713804b8feacc3425196d4428
Author: Luke Deller <luke at deller.id.au>
Date:   Fri Apr 4 21:58:16 2014 +1100

    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

diff --git a/include/filter/msfilter/sprmids.hxx b/include/filter/msfilter/sprmids.hxx
index 213ae0c..b12d907 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 343e47c..1a666d0 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 5cd5b0a..8259875 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 5fd495b..c853be0 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 0078a84..d1f628e 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
commit 5fa564d4a95160dee96604ffa2c2b82246ce09f4
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Sun Apr 6 16:38:08 2014 +0200

    filter: LN_TSetBrc -> LN_TSetBrc80 to match spec
    
    Change-Id: I81b78e09130141704c7ec62c1c52bf50d5428dfd

diff --git a/include/filter/msfilter/sprmids.hxx b/include/filter/msfilter/sprmids.hxx
index adddee0..213ae0c 100644
--- a/include/filter/msfilter/sprmids.hxx
+++ b/include/filter/msfilter/sprmids.hxx
@@ -251,7 +251,7 @@ namespace NS_sprm {
     const sal_uInt16 LN_TTlp = 0x740a;
     const sal_uInt16 LN_TFBiDi = 0x560b;
     const sal_uInt16 LN_THTMLProps = 0x740c;
-    const sal_uInt16 LN_TSetBrc = 0xd620;
+    const sal_uInt16 LN_TSetBrc80 = 0xd620;
     const sal_uInt16 LN_TInsert = 0x7621;
     const sal_uInt16 LN_TDelete = 0x5622;
     const sal_uInt16 LN_TDxaCol = 0x7623;


More information about the Libreoffice-commits mailing list