# HG changeset patch
# User Michael Stahl <mst@openoffice.org>
# Date 1287500617 -7200
# Node ID 3b79c4a0ec8d9f07212819c60ca4ebccc0e75c8d
# Parent  4698be8920fb74b5f3a22d155837443419d73138
rtftok01: tables

diff --git a/writerfilter/source/rtftok/RTFDestination.hxx b/writerfilter/source/rtftok/RTFDestination.hxx
--- a/writerfilter/source/rtftok/RTFDestination.hxx
+++ b/writerfilter/source/rtftok/RTFDestination.hxx
@@ -322,11 +322,17 @@
     void SetCharacterSprm(Id const id, RTFValue::Pointer_t const& pValue);
     void SetParagraphSprm(Id const id, RTFValue::Pointer_t const& pValue);
     void SetSectionSprm(Id const id, RTFValue::Pointer_t const& pValue);
+    void SetTableRowSprm(Id const id, RTFValue::Pointer_t const& pValue);
+    void SetTableCellSprm(Id const id, RTFValue::Pointer_t const& pValue);
     void ResetCharacterProperties();
     void ResetParagraphProperties();
     void ResetSectionProperties();
+    void ResetTableRowProperties();
+    void ResetTableCellProperties();
     void ParagraphBreak();
     void SectionBreak();
+    void TableRowBreak();
+    void TableCellBreak();
 
 protected:
     RTFScannerHandlerImpl & GetHandler() { return m_rHandler; }
diff --git a/writerfilter/source/rtftok/RTFDocumentImpl.cxx b/writerfilter/source/rtftok/RTFDocumentImpl.cxx
--- a/writerfilter/source/rtftok/RTFDocumentImpl.cxx
+++ b/writerfilter/source/rtftok/RTFDocumentImpl.cxx
@@ -238,7 +238,35 @@
         m_SectionProperties = SectionProperties();
     };
 
-    // table properties
+    // table row properties
+    struct TableRowProperties
+    {
+    public:
+        explicit TableRowProperties()
+        { }
+        Attributes_t m_Attributes;
+        Attributes_t m_Sprms;
+    };
+    TableRowProperties m_TableRowProperties;
+
+    void ResetTableRowProperties(/*Attributes_t const& rDefaults*/) {
+        m_TableRowProperties = TableRowProperties();
+    };
+
+    // table cell properties
+    struct TableCellProperties
+    {
+    public:
+        explicit TableCellProperties()
+        { }
+        Attributes_t m_Attributes;
+        Attributes_t m_Sprms;
+    };
+    TableCellProperties m_TableCellProperties;
+
+    void ResetTableCellProperties(/*Attributes_t const& rDefaults*/) {
+        m_TableCellProperties = TableCellProperties();
+    };
 
 #if 0
     void Reset() {
@@ -451,6 +479,12 @@
     void SetSectionSprm(Id const id, RTFValue::Pointer_t const& pValue) {
         GetCurrentGroup().m_SectionProperties.m_Sprms[id] = pValue;
     }
+    void SetTableRowSprm(Id const id, RTFValue::Pointer_t const& pValue) {
+        GetCurrentGroup().m_TableRowProperties.m_Sprms[id] = pValue;
+    }
+    void SetTableCellSprm(Id const id, RTFValue::Pointer_t const& pValue) {
+        GetCurrentGroup().m_TableCellProperties.m_Sprms[id] = pValue;
+    }
     void ResetCharacterProperties() {
         GetCurrentGroup().ResetCharacterProperties(m_Defaults);
     }
@@ -460,6 +494,12 @@
     void ResetSectionProperties() {
         GetCurrentGroup().ResetSectionProperties();
     }
+    void ResetTableRowProperties() {
+        GetCurrentGroup().ResetTableRowProperties();
+    }
+    void ResetTableCellProperties() {
+        GetCurrentGroup().ResetTableCellProperties();
+    }
 
 private:
     void checkStrings()
@@ -537,6 +577,18 @@
 }
 
 void
+RTFDestination::SetTableRowSprm(Id const id, RTFValue::Pointer_t const& pValue)
+{
+    GetHandler().SetTableRowSprm(id, pValue);
+}
+
+void
+RTFDestination::SetTableCellSprm(Id const id, RTFValue::Pointer_t const& pValue)
+{
+    GetHandler().SetTableCellSprm(id, pValue);
+}
+
+void
 RTFDestination::ResetCharacterProperties()
 {
     GetHandler().ResetCharacterProperties();
@@ -555,14 +607,31 @@
 }
 
 void
-RTFDestination::ParagraphBreak()
+RTFDestination::ResetTableRowProperties()
 {
-    RTFGroup const& rGroup( GetHandler().GetCurrentGroup() );
+    GetHandler().ResetTableRowProperties();
+}
+
+void
+RTFDestination::ResetTableCellProperties()
+{
+    GetHandler().ResetTableCellProperties();
+}
+
+static void lcl_SendParagraphProperties(RTFScannerHandlerImpl & rHandler)
+{
+    RTFGroup const& rGroup( rHandler.GetCurrentGroup() );
     writerfilter::Reference<Properties>::Pointer_t const pProperties(
         new RTFRefProperties(
             rGroup.m_ParagraphProperties.m_Attributes,
             rGroup.m_ParagraphProperties.m_Sprms) );
-    GetHandler().GetStream().props(pProperties);
+    rHandler.GetStream().props(pProperties);
+}
+
+void
+RTFDestination::ParagraphBreak()
+{
+    lcl_SendParagraphProperties(GetHandler());
 
     sal_uInt8 const nl(0x0d);
     GetHandler().GetStream().text(& nl, sizeof(nl));
@@ -590,7 +659,48 @@
     GetHandler().GetStream().startParagraphGroup();
 }
 
+void
+RTFDestination::TableRowBreak()
+{
+    lcl_SendParagraphProperties(GetHandler());
 
+    RTFGroup const& rGroup( GetHandler().GetCurrentGroup() );
+    writerfilter::Reference<Properties>::Pointer_t const pProperties(
+        new RTFRefProperties(
+            rGroup.m_TableRowProperties.m_Attributes,
+            rGroup.m_TableRowProperties.m_Sprms) );
+    GetHandler().GetStream().props(pProperties);
+
+    // not 0x07!
+    sal_uInt8 const c(0xd);
+    GetHandler().GetStream().text(& c, sizeof(c));
+
+    //FIXME when to start / end para group ???
+    // after send 0x7 !
+    GetHandler().GetStream().endParagraphGroup();
+    GetHandler().GetStream().startParagraphGroup();
+}
+
+void
+RTFDestination::TableCellBreak()
+{
+    lcl_SendParagraphProperties(GetHandler());
+
+    RTFGroup const& rGroup( GetHandler().GetCurrentGroup() );
+    writerfilter::Reference<Properties>::Pointer_t const pProperties(
+        new RTFRefProperties(
+            rGroup.m_TableCellProperties.m_Attributes,
+            rGroup.m_TableCellProperties.m_Sprms) );
+    GetHandler().GetStream().props(pProperties);
+
+    sal_uInt8 const c(0x7);
+    GetHandler().GetStream().text(& c, sizeof(c));
+
+    //FIXME when to start / end para group ???
+    // after send 0x7 !
+    GetHandler().GetStream().endParagraphGroup();
+    GetHandler().GetStream().startParagraphGroup();
+}
 
 
 static sal_uInt32
diff --git a/writerfilter/source/rtftok/rtfactions.xml b/writerfilter/source/rtftok/rtfactions.xml
--- a/writerfilter/source/rtftok/rtfactions.xml
+++ b/writerfilter/source/rtftok/rtfactions.xml
@@ -565,6 +565,246 @@
     <!-- <ref name="sectspecifygen"/> -->
   </sectprops>
 
+  <trowprops>
+    <ref name="trowd" action="ResetTableRowProperties()"/>
+    <!-- <ref name="irow"/> -->
+    <!-- <ref name="irowband"/> -->
+    <ref name="row" tokenid="sprm:PRow" value="1" action="TableRowBreak()"/>
+    <ref name="nestrow" action="TableRowBreak()"/>
+    <!-- <ref name="lastrow"/> -->
+    <!-- <ref name="nesttableprops"/> -->
+    <!-- <ref name="nonesttables"/> -->
+    <ref name="trgaph" tokenid="0x9602"/>
+
+    <!-- <ref name="trauth"/> -->
+    <!-- <ref name="trdate"/> -->
+
+    <!-- <ref name="tbllkborder"/> -->
+    <!-- <ref name="tbllkshading"/> -->
+    <!-- <ref name="tbllkfont"/> -->
+    <!-- <ref name="tbllkcolor"/> -->
+    <!-- <ref name="tbllkbestfit"/> -->
+    <!-- <ref name="tbllkhdrrows"/> -->
+    <!-- <ref name="tbllklastrow"/> -->
+    <!-- <ref name="tbllkhdrcols"/> -->
+    <!-- <ref name="tbllklastcol"/> -->
+    <!-- <ref name="tbllknorowband"/> -->
+    <!-- <ref name="tbllknocolband"/> -->
+
+    <!-- <ref name="taprtl"/> -->
+    <!-- <ref name="trautofit"/> -->
+    <ref name="trhdr" tokenid="ooxml:CT_TrPrBase_tblHeader" value="1"/>
+    <ref name="trkeep" tokenid="sprm:TCantSplit" value="1"/>
+    <!-- <ref name="trkeepfollow"/> -->
+    <!-- <ref name="trleft"/> -->
+    <ref name="trqc" tokenid="ooxml:CT_TrPrBase_jc" value="1"/>
+    <ref name="trql" tokenid="ooxml:CT_TrPrBase_jc" value="0"/>
+    <ref name="trqr" tokenid="ooxml:CT_TrPrBase_jc" value="2"/>
+    <!-- <ref name="trrh" tokenid="ooxml:CT_TrPrBase_trHeight"/> FIXME this looks complicated -->
+    <ref name="trrh" tokenid="0x9407"/>
+    <!-- <ref name="trpaddb"/> -->
+    <!-- <ref name="trpaddl"/> -->
+    <!-- <ref name="trpaddr"/> -->
+    <!-- <ref name="trpaddt"/> -->
+    <!-- <ref name="trpaddfb"/> -->
+    <!-- <ref name="trpaddfl"/> -->
+    <!-- <ref name="trpaddfr"/> -->
+    <!-- <ref name="trpaddft"/> -->
+    <!-- <ref name="trspdb"/> -->
+    <!-- <ref name="trspdl"/> -->
+    <!-- <ref name="trspdr"/> -->
+    <!-- <ref name="trspdt"/> -->
+    <!-- <ref name="trspdfb"/> -->
+    <!-- <ref name="trspdfl"/> -->
+    <!-- <ref name="trspdfr"/> -->
+    <!-- <ref name="trspdft"/> -->
+    <!-- <ref name="trpadob"/> -->
+    <!-- <ref name="trpadol"/> -->
+    <!-- <ref name="trpador"/> -->
+    <!-- <ref name="trpadot"/> -->
+    <!-- <ref name="trpadofb"/> -->
+    <!-- <ref name="trpadofl"/> -->
+    <!-- <ref name="trpadofr"/> -->
+    <!-- <ref name="trpadoft"/> -->
+    <!-- <ref name="trspob"/> -->
+    <!-- <ref name="trspol"/> -->
+    <!-- <ref name="trspor"/> -->
+    <!-- <ref name="trspot"/> -->
+    <!-- <ref name="trspofb"/> -->
+    <!-- <ref name="trspofl"/> -->
+    <!-- <ref name="trspofr"/> -->
+    <!-- <ref name="trspoft"/> -->
+    <ref name="trwWidth" tokenid="ooxml:CT_TblPrBase_tblW"/>
+    <!-- <ref name="trftsWidth" tokenid="ooxml:CT_TblPrBase_tblW"/>
+    need a mapping here with trwWidth-->
+    <!-- <ref name="trwWidthB"/> -->
+    <!-- <ref name="trftsWidthB"/> -->
+    <!-- <ref name="trwWidthA"/> -->
+    <!-- <ref name="trftsWidthA"/> -->
+    <ref name="tblind" tokenid="ooxml:CT_TblPrBase_tblInd"/>
+    <!-- <ref name="tblindtype" tokenid="ooxml:CT_TblPrBase_tblInd"/>
+    need a mapping here, and combine with tblind...
+    -->
+
+    <!-- ooxml::LN_CT_TblPrBase_shd: how does this work -->
+    <!-- <ref name="trcbpat"/> -->
+    <!-- <ref name="trcfpat"/> -->
+    <!-- <ref name="trpat"/> -->
+    <!-- <ref name="trshdng"/> -->
+    <!-- <ref name="trbgbdiag"/> -->
+    <!-- <ref name="trbgcross"/> -->
+    <!-- <ref name="trbgdcross"/> -->
+    <!-- <ref name="trbgdkbdiag"/> -->
+    <!-- <ref name="trbgdkcross"/> -->
+    <!-- <ref name="trbgdkdcross"/> -->
+    <!-- <ref name="trbgdkfdiag"/> -->
+    <!-- <ref name="trbgdkhor"/> -->
+    <!-- <ref name="trbgdkvert"/> -->
+    <!-- <ref name="trbgfdiag"/> -->
+    <!-- <ref name="trbghoriz"/> -->
+    <!-- <ref name="trbgvert"/> -->
+
+    <!-- <ref name="tdfrmtxtLeft"/> -->
+    <!-- <ref name="tdfrmtxtRight"/> -->
+    <!-- <ref name="tdfrmtxtTop"/> -->
+    <!-- <ref name="tdfrmtxtBottom"/> -->
+    <!-- <ref name="tabsnoovrlp"/> -->
+    <!-- <ref name="tphcol"/> -->
+    <!-- <ref name="tphmrg"/> -->
+    <!-- <ref name="tphpg"/> -->
+    <!-- <ref name="tposnegx"/> -->
+    <!-- <ref name="tposnegy"/> -->
+    <!-- <ref name="tposx"/> -->
+    <!-- <ref name="tposxc"/> -->
+    <!-- <ref name="tposxi"/> -->
+    <!-- <ref name="tposxl"/> -->
+    <!-- <ref name="tposxo"/> -->
+    <!-- <ref name="tposxr"/> -->
+    <!-- <ref name="tposy"/> -->
+    <!-- <ref name="tposyb"/> -->
+    <!-- <ref name="tposyc"/> -->
+    <!-- <ref name="tposyil"/> -->
+    <!-- <ref name="tposyin"/> -->
+    <!-- <ref name="tposyout"/> -->
+    <!-- <ref name="tposyt"/> -->
+    <!-- <ref name="tpvmrg"/> -->
+    <!-- <ref name="tpvpara"/> -->
+    <!-- <ref name="tpvpg"/> -->
+
+    <!-- <ref name="rtlrow"/> -->
+    <!-- <ref name="ltrrow"/> -->
+
+    <!-- ooxml::LN_CT_TblPrBase_tblBorders: how does this work -->
+    <!-- <ref name="trbrdrt"/> -->
+    <!-- <ref name="trbrdrl"/> -->
+    <!-- <ref name="trbrdrb"/> -->
+    <!-- <ref name="trbrdrr"/> -->
+    <!-- <ref name="trbrdrh"/> -->
+    <!-- <ref name="trbrdrv"/> -->
+
+
+  </trowprops>
+  <tcellprops>
+    <ref name="tcelld" action="ResetTableRowProperties()"/>
+    <ref name="nestcell" action="TableCellBreak()"/>
+    <!-- <ref name="cellx"/> -->
+    <ref name="cell" action="TableCellBreak()"/>
+    <!-- <ref name="clmgf"/> --> <!-- ooxml::CT_TcPrBase_gridSpan different? -->
+    <!-- <ref name="clmrg"/> -->
+    <ref name="clvmgf" tokenid="ooxml:CT_TcPrBase_vMerge"
+                         value="NS_ooxml::LN_Value_ST_Merge_restart"/>
+    <ref name="clvmrg" tokenid="ooxml:CT_TcPrBase_vMerge"
+                         value="NS_ooxml::LN_Value_ST_Merge_continue"/>
+
+    <!-- <ref name="clFitText"/> -->
+    <!-- <ref name="clNoWrap"/> -->
+    <!-- <ref name="clpadl" tokenid="ooxml:CT_TblPrBase_tblCellMar" "ooxml:CT_TblCellMar_left"/> -->
+    <!-- <ref name="clpadt" tokenid="ooxml:CT_TblPrBase_tblCellMar" "ooxml:CT_TblCellMar_top"/> -->
+    <!-- <ref name="clpadb" tokenid="ooxml:CT_TblPrBase_tblCellMar" "ooxml:CT_TblCellMar_bottom"/> -->
+    <!-- <ref name="clpadr" tokenid="ooxml:CT_TblPrBase_tblCellMar" "ooxml:CT_TblCellMar_right
+"/> -->
+    <!-- <ref name="clpadfl"/> -->
+    <!-- <ref name="clpadft"/> -->
+    <!-- <ref name="clpadfb"/> -->
+    <!-- <ref name="clpadfr"/> -->
+    <!-- <ref name="clspl"/> -->
+    <!-- <ref name="clspt"/> -->
+    <!-- <ref name="clspb"/> -->
+    <!-- <ref name="clspr"/> -->
+    <!-- <ref name="clspfl"/> -->
+    <!-- <ref name="clspft"/> -->
+    <!-- <ref name="clspfb"/> -->
+    <!-- <ref name="clspfr"/> -->
+    <!-- <ref name="clwWidth"/> -->
+    <!-- <ref name="clftsWidth"/> -->
+    <!-- <ref name="clhidemark"/> -->
+
+    <!-- <ref name="clins"/> -->
+    <!-- <ref name="cldel"/> -->
+    <!-- <ref name="clmrgd"/> -->
+    <!-- <ref name="clmrgdr"/> -->
+    <!-- <ref name="clsplit"/> -->
+    <!-- <ref name="clsplitr"/> -->
+    <!-- <ref name="clinsauth"/> -->
+    <!-- <ref name="clinsdttm"/> -->
+    <!-- <ref name="cldelauth"/> -->
+    <!-- <ref name="cldeldttm"/> -->
+    <!-- <ref name="clmrgdauth"/> -->
+    <!-- <ref name="clmrgddttm"/> -->
+
+    <!-- ooxml::LN_CT_TcPrBase_tcBorders: how does this work -->
+    <!-- <ref name="brdrnil"/> -->
+    <!-- <ref name="clbrdrb"/> -->
+    <!-- <ref name="clbrdrt"/> -->
+    <!-- <ref name="clbrdrl"/> -->
+    <!-- <ref name="clbrdrr"/> -->
+    <!-- <ref name="cldglu"/> -->
+    <!-- <ref name="cldgll"/> -->
+
+    <!-- ooxml::CT_TcPrBase_shd looks somehow different? -->
+    <!-- <ref name="clshdrawnil"/> -->
+    <!-- <ref name="clshdng"/> -->
+    <!-- <ref name="clshdngraw"/> -->
+    <!-- <ref name="clbghoriz"/> -->
+    <!-- <ref name="rawclbghoriz"/> -->
+    <!-- <ref name="clbgvert"/> -->
+    <!-- <ref name="rawclbgvert"/> -->
+    <!-- <ref name="clbgfdiag"/> -->
+    <!-- <ref name="rawclbgfdiag"/> -->
+    <!-- <ref name="clbgbdiag"/> -->
+    <!-- <ref name="rawclbgbdiag"/> -->
+    <!-- <ref name="clbgcross"/> -->
+    <!-- <ref name="rawclbgcross"/> -->
+    <!-- <ref name="clbgdcross"/> -->
+    <!-- <ref name="rawclbgdcross"/> -->
+    <!-- <ref name="clbgdkhor"/> -->
+    <!-- <ref name="rawclbgdkhor"/> -->
+    <!-- <ref name="clbgdkvert"/> -->
+    <!-- <ref name="rawclbgdkvert"/> -->
+    <!-- <ref name="clbgdkfdiag"/> -->
+    <!-- <ref name="rawclbgdkfdiag"/> -->
+    <!-- <ref name="clbgdkbdiag"/> -->
+    <!-- <ref name="rawclbgdkbdiag"/> -->
+    <!-- <ref name="clbgdkcross"/> -->
+    <!-- <ref name="rawclbgdkcross"/> -->
+    <!-- <ref name="clbgdkdcross"/> -->
+    <!-- <ref name="rawclbgdkdcross"/> -->
+    <!-- <ref name="clcfpat"/> -->
+    <!-- <ref name="clcfpatraw"/> -->
+    <!-- <ref name="clcbpat"/> -->
+    <!-- <ref name="clcbpatraw"/> -->
+
+    <ref name="clvertalt" tokenid="ooxml:CT_TcPrBase_vAlign" value="0"/>
+    <ref name="clvertalc" tokenid="ooxml:CT_TcPrBase_vAlign" value="1"/>
+    <ref name="clvertalb" tokenid="ooxml:CT_TcPrBase_vAlign" value="3"/>
+
+    <!-- <ref name="cltxlrtb"/> -->
+    <!-- <ref name="cltxtbrl"/> -->
+    <!-- <ref name="cltxbtlr"/> -->
+    <!-- <ref name="cltxlrtbv"/> -->
+    <!-- <ref name="cltxtbrlv"/> -->
+  </tcellprops>
+
   <special>
     <!-- <ref name="chdate"/> -->
     <!-- <ref name="chdpl"/> -->
diff --git a/writerfilter/source/rtftok/rtfcontrols.xsl b/writerfilter/source/rtftok/rtfcontrols.xsl
--- a/writerfilter/source/rtftok/rtfcontrols.xsl
+++ b/writerfilter/source/rtftok/rtfcontrols.xsl
@@ -46,10 +46,14 @@
     </xsl:variable>
     <xsl:variable name="token">
       <xsl:choose>
-        <xsl:when test="starts-with(@tokenid, 'sprm')">
+        <xsl:when test="starts-with(@tokenid, 'sprm:')">
           <xsl:text>NS_sprm::LN_</xsl:text>
           <xsl:value-of select="substring(@tokenid, 6)"/>
         </xsl:when>
+        <xsl:when test="starts-with(@tokenid, 'ooxml:')">
+          <xsl:text>NS_ooxml::LN_</xsl:text>
+          <xsl:value-of select="substring(@tokenid, 7)"/>
+        </xsl:when>
         <xsl:when test="starts-with(@tokenid, '0x')">
           <xsl:value-of select="@tokenid"/>
         </xsl:when>
@@ -61,7 +65,7 @@
     <xsl:text>{&#xA;</xsl:text>
     <xsl:if test="@tokenid">
       <xsl:choose>
-        <xsl:when test="$type='flag'">
+        <xsl:when test="$type='flag' or $type='symbol'">
           <xsl:choose>
             <xsl:when test="@value">
               <xsl:text>RTFValue::Pointer_t const pValue(</xsl:text>
@@ -118,7 +122,7 @@
         </xsl:otherwise>
       </xsl:choose>
       <xsl:choose>
-        <xsl:when test="starts-with(@tokenid, 'sprm') or starts-with(@tokenid, '0x')">
+        <xsl:when test="starts-with(@tokenid, 'sprm:') or starts-with(@tokenid, 'ooxml:') or starts-with(@tokenid, '0x')">
           <xsl:choose>
             <xsl:when test="$kind='character'">
               <xsl:text>rDestination.SetCharacterSprm(</xsl:text>
@@ -129,6 +133,12 @@
             <xsl:when test="$kind='section'">
               <xsl:text>rDestination.SetSectionSprm(</xsl:text>
             </xsl:when>
+            <xsl:when test="$kind='tablerow'">
+              <xsl:text>rDestination.SetTableRowSprm(</xsl:text>
+            </xsl:when>
+            <xsl:when test="$kind='tablecell'">
+              <xsl:text>rDestination.SetTableCellSprm(</xsl:text>
+            </xsl:when>
             <xsl:otherwise>
               <xsl:text>UNKNOWN KIND: </xsl:text>
               <xsl:value-of select="$kind"/>
@@ -175,6 +185,7 @@
 
 #include &lt;doctok/resourceids.hxx&gt;
 #include &lt;doctok/sprmids.hxx&gt;
+#include &lt;ooxml/resourceids.hxx&gt;
 
 #include &lt;rtftok/RTFTokens.hxx&gt;
 
@@ -210,6 +221,16 @@
         <xsl:with-param name="kind">section</xsl:with-param>
       </xsl:call-template>
     </xsl:for-each>
+    <xsl:for-each select="document('rtfactions.xml')/actions/trowprops/ref">
+      <xsl:call-template name="handle-case">
+        <xsl:with-param name="kind">tablerow</xsl:with-param>
+      </xsl:call-template>
+    </xsl:for-each>
+    <xsl:for-each select="document('rtfactions.xml')/actions/tcellprops/ref">
+      <xsl:call-template name="handle-case">
+        <xsl:with-param name="kind">tablecell</xsl:with-param>
+      </xsl:call-template>
+    </xsl:for-each>
     <xsl:for-each select="document('rtfactions.xml')/actions/special/ref">
       <xsl:call-template name="handle-case">
         <xsl:with-param name="kind">special</xsl:with-param>
diff --git a/writerfilter/source/rtftok/spectobnf.xsl b/writerfilter/source/rtftok/spectobnf.xsl
--- a/writerfilter/source/rtftok/spectobnf.xsl
+++ b/writerfilter/source/rtftok/spectobnf.xsl
@@ -653,6 +653,11 @@
       <xsl:with-param name="number">2</xsl:with-param>
     </xsl:call-template>
     <xsl:call-template name="chrfmtetc">
+      <xsl:with-param name="define">tblfmt</xsl:with-param>
+      <xsl:with-param name="search">Table Definitions</xsl:with-param>
+      <xsl:with-param name="number">3</xsl:with-param>
+    </xsl:call-template>
+    <xsl:call-template name="chrfmtetc">
       <xsl:with-param name="define">unicode_rtf</xsl:with-param>
       <xsl:with-param name="search">Unicode RTF</xsl:with-param>
     </xsl:call-template>
