summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@frugalware.org>2010-10-14 12:53:40 +0200
committerMiklos Vajna <vmiklos@frugalware.org>2010-10-14 12:53:40 +0200
commit19d016a482e4d1e6b865d1a4ab9d3bb0de47d104 (patch)
tree6a84ebf46441942b38f0a0d0b64be245ddd4f331
parent2f7dd9f4eaf684935a39c45d347d138665b6a294 (diff)
RTF: stacked fix for nested tables
When the first cell of a table contains an other table, the definition of the outer table has to be written after the inner table. Introduce a stack to handle this.
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx36
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.hxx15
2 files changed, 46 insertions, 5 deletions
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index a2931fe35c4d..e7338cd00304 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -299,8 +299,7 @@ void RtfAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextN
{
ww8::WW8TableNodeInfoInner::Pointer_t pInner( pTextNodeInfo->getInnerForDepth( nDepth ) );
- delete m_pTableWrt, m_pTableWrt = NULL;
-
+ m_bLastTable = (nDepth == pTextNodeInfo->getDepth());
StartTable( pInner );
StartTableRow( pInner );
StartTableCell( pInner );
@@ -565,6 +564,7 @@ void RtfAttributeOutput::TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t /*
m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ITAP);
m_aStyles.append((sal_Int32)m_nTableDepth);
}
+ m_bWroteCellInfo = true;
}
void RtfAttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfo*/ )
@@ -904,7 +904,8 @@ void RtfAttributeOutput::StartTable( ww8::WW8TableNodeInfoInner::Pointer_t /*pTa
{
OSL_TRACE("%s", OSL_THIS_FUNC);
- /* noop */
+ // To trigger calling InitTableHelper()
+ delete m_pTableWrt, m_pTableWrt = NULL;
}
void RtfAttributeOutput::StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
@@ -914,6 +915,9 @@ void RtfAttributeOutput::StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t pT
TableDefinition(pTableTextNodeInfoInner);
+ if (!m_bLastTable)
+ m_aTables.push_back(m_aRowDefs.makeStringAndClear());
+
// We'll write the table definition for nested tables later
if ( nCurrentDepth > 1 )
return;
@@ -940,6 +944,12 @@ void RtfAttributeOutput::EndTableCell( )
{
OSL_TRACE("%s, (depth is %d)", OSL_THIS_FUNC, (int)m_nTableDepth);
+ if (!m_bWroteCellInfo)
+ {
+ m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_INTBL);
+ m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_ITAP);
+ m_aAfterRuns.append((sal_Int32)m_nTableDepth);
+ }
if ( m_nTableDepth > 1 )
m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_NESTCELL);
else
@@ -947,6 +957,7 @@ void RtfAttributeOutput::EndTableCell( )
m_bTableCellOpen = false;
m_bTblAfterCell = true;
+ m_bWroteCellInfo = false;
}
void RtfAttributeOutput::EndTableRow( )
@@ -956,11 +967,24 @@ void RtfAttributeOutput::EndTableRow( )
if ( m_nTableDepth > 1 )
{
m_aAfterRuns.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_NESTTABLEPROPRS);
- m_aAfterRuns.append(m_aRowDefs.makeStringAndClear());
+ if (m_aRowDefs.getLength() > 0)
+ m_aAfterRuns.append(m_aRowDefs.makeStringAndClear());
+ else if (m_aTables.size() > 0)
+ {
+ m_aAfterRuns.append(m_aTables.back());
+ m_aTables.pop_back();
+ }
m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_NESTROW "}" "{" OOO_STRING_SVTOOLS_RTF_NONESTTABLES OOO_STRING_SVTOOLS_RTF_PAR "}");
}
else
+ {
+ if (m_aTables.size() > 0)
+ {
+ m_aAfterRuns.append(m_aTables.back());
+ m_aTables.pop_back();
+ }
m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_ROW).append(OOO_STRING_SVTOOLS_RTF_PARD);
+ }
}
void RtfAttributeOutput::EndTable()
@@ -2964,7 +2988,9 @@ RtfAttributeOutput::RtfAttributeOutput( RtfExport &rExport )
m_bTblAfterCell( false ),
m_nColBreakNeeded( false ),
m_bBufferSectionBreaks( false ),
- m_bBufferSectionHeaders( false )
+ m_bBufferSectionHeaders( false ),
+ m_bLastTable( true ),
+ m_bWroteCellInfo( false )
{
OSL_TRACE("%s", OSL_THIS_FUNC);
}
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index cdbc6c61fcd4..c57b4d9c2053 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -539,6 +539,21 @@ private:
bool m_bBufferSectionHeaders;
rtl::OStringBuffer m_aSectionHeaders;
+ /*
+ * Support for starting multiple tables at the same cell.
+ * If the current table is the last started one.
+ */
+ bool m_bLastTable;
+ /*
+ * List of already started but not yet defined tables (need to be defined
+ * after the nested tables).
+ */
+ std::vector< rtl::OString > m_aTables;
+ /*
+ * If cell info is already output.
+ */
+ bool m_bWroteCellInfo;
+
public:
RtfAttributeOutput( RtfExport &rExport );