[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Oct 8 09:15:31 PDT 2014


 sw/qa/extras/ooxmlexport/data/textbox-table.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx         |   11 +++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx     |   27 +++++++++++++++++++++++
 sw/source/filter/ww8/docxattributeoutput.hxx     |   16 +++++++++++++
 4 files changed, 54 insertions(+)

New commits:
commit ab52bb712c335e88cf100b3b8336a46b7673eb98
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Oct 8 18:00:34 2014 +0200

    DOCX export: fix handling of shapes containing and also anchored inside tables
    
    Change-Id: I6f23bd0e0553b8f6435537b542fc82ee55a64c03

diff --git a/sw/qa/extras/ooxmlexport/data/textbox-table.docx b/sw/qa/extras/ooxmlexport/data/textbox-table.docx
new file mode 100644
index 0000000..8c06f5e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/textbox-table.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 9b49339..279be00 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 95b0ea4..2529b1a 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 30faa7f..eebee0e 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


More information about the Libreoffice-commits mailing list