diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-10-08 18:00:34 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-10-08 18:14:55 +0200 |
commit | ab52bb712c335e88cf100b3b8336a46b7673eb98 (patch) | |
tree | 724b951cef11afe5c5059fba7fb0808069ebcf42 /sw | |
parent | d61f8185e660a6820351b8cea3ac51d344f0ab3e (diff) |
DOCX export: fix handling of shapes containing and also anchored inside tables
Change-Id: I6f23bd0e0553b8f6435537b542fc82ee55a64c03
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/textbox-table.docx | bin | 0 -> 16404 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 11 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 27 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 16 |
4 files changed, 54 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/textbox-table.docx b/sw/qa/extras/ooxmlexport/data/textbox-table.docx Binary files differnew file mode 100644 index 000000000000..8c06f5eeb088 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/textbox-table.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 9b493398767a..279be0030435 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -424,6 +424,17 @@ DECLARE_OOXMLEXPORT_TEST(testMultiPageToc, "multi-page-toc.docx") CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(getRun(getParagraphOfText(1, xHeaderText), 1), "TextPortionType")); } +DECLARE_OOXMLEXPORT_TEST(testTextboxTable, "textbox-table.docx") +{ + // We wrote not-well-formed XML during export for this one: + // Shape with textbox, having a table and also anchored inside a table. + + // Just make sure that we have both tables. + uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTables->getCount()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 95b0ea42af9b..2529b1a496fc 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -5090,20 +5090,47 @@ void DocxAttributeOutput::WriteOutliner(const OutlinerParaObject& rParaObj) m_pSerializer->endElementNS( XML_w, XML_txbxContent ); } +DocxTableExportContext::DocxTableExportContext(ww8::WW8TableInfo::Pointer_t& pTableInfo, bool& bTableCellOpen, sal_uInt32& nTableDepth) +{ + m_pTableInfo = pTableInfo; + pTableInfo = ww8::WW8TableInfo::Pointer_t(new ww8::WW8TableInfo()); + + m_bTableCellOpen = bTableCellOpen; + bTableCellOpen = false; + + m_nTableDepth = nTableDepth; + nTableDepth = 0; +} + +void DocxTableExportContext::restore(ww8::WW8TableInfo::Pointer_t& pTableInfo, bool& bTableCellOpen, sal_uInt32& nTableDepth) +{ + pTableInfo = m_pTableInfo; + bTableCellOpen = m_bTableCellOpen; + nTableDepth = m_nTableDepth; +} + void DocxAttributeOutput::WriteTextBox(uno::Reference<drawing::XShape> xShape) { + DocxTableExportContext aTableExportContext(m_rExport.mpTableInfo, m_tableReference->m_bTableCellOpen, m_tableReference->m_nTableDepth); + SwFrmFmt* pTextBox = SwTextBoxHelper::findTextBox(xShape); const SwPosition* pAnchor = pTextBox->GetAnchor().GetCntntAnchor(); sw::Frame aFrame(*pTextBox, *pAnchor); m_rExport.SdrExporter().writeDMLTextFrame(&aFrame, m_anchorId++, /*bTextBoxOnly=*/true); + + aTableExportContext.restore(m_rExport.mpTableInfo, m_tableReference->m_bTableCellOpen, m_tableReference->m_nTableDepth); } void DocxAttributeOutput::WriteVMLTextBox(uno::Reference<drawing::XShape> xShape) { + DocxTableExportContext aTableExportContext(m_rExport.mpTableInfo, m_tableReference->m_bTableCellOpen, m_tableReference->m_nTableDepth); + SwFrmFmt* pTextBox = SwTextBoxHelper::findTextBox(xShape); const SwPosition* pAnchor = pTextBox->GetAnchor().GetCntntAnchor(); sw::Frame aFrame(*pTextBox, *pAnchor); m_rExport.SdrExporter().writeVMLTextFrame(&aFrame, /*bTextBoxOnly=*/true); + + aTableExportContext.restore(m_rExport.mpTableInfo, m_tableReference->m_bTableCellOpen, m_tableReference->m_nTableDepth); } oox::drawingml::DrawingML& DocxAttributeOutput::GetDrawingML() diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 30faa7f7bba5..eebee0e8f72c 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -106,6 +106,22 @@ struct PageMargins }; /** + * All the information that should be stashed away when we're in the middle of + * of a table export and still have to do something else, e.g. export a shape. + */ +class DocxTableExportContext +{ + ww8::WW8TableInfo::Pointer_t m_pTableInfo; + bool m_bTableCellOpen; + sal_uInt32 m_nTableDepth; +public: + /// Stores the passed parameters and resets them to their default value. + DocxTableExportContext(ww8::WW8TableInfo::Pointer_t& pTableInfo, bool& bTableCellOpen, sal_uInt32& nTableDepth); + /// Restores the remembered state. + void restore(ww8::WW8TableInfo::Pointer_t& pTableInfo, bool& bTableCellOpen, sal_uInt32& nTableDepth); +}; + +/** * A structure that holds flags for the table export. */ struct TableReference |