[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Jan 19 14:28:26 PST 2015


 sw/qa/extras/odfexport/data/gerrit13858.odt |binary
 sw/qa/extras/odfexport/odfexport.cxx        |   10 +++++++
 sw/source/core/docnode/node.cxx             |    3 ++
 sw/source/filter/xml/xmltble.cxx            |   38 +++++++++++++++++-----------
 4 files changed, 37 insertions(+), 14 deletions(-)

New commits:
commit e15e4d3888c1ebd229acd8e676d28115edf622e3
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Sat Dec 27 12:11:43 2014 +0100

    fdo#84714 ODT export: write <loext:table> inside <draw:custom-shape>
    
    (cherry picked from commit e4de5b40eb7220da2d337eb98d7905a98dc12c72)
    (cherry picked from commit 80eb001e6a861c68f2915d4eebded5e36e1875f6)
    
    Change-Id: I543ec24f8825bcc7c35acc106402f4fc6b4b5d79
    Reviewed-on: https://gerrit.libreoffice.org/13858
    Tested-by: Michael Stahl <mstahl at redhat.com>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/qa/extras/odfexport/data/gerrit13858.odt b/sw/qa/extras/odfexport/data/gerrit13858.odt
new file mode 100644
index 0000000..9b3dd37
Binary files /dev/null and b/sw/qa/extras/odfexport/data/gerrit13858.odt differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 2a706b6..df5da9c 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -402,6 +402,11 @@ DECLARE_ODFEXPORT_TEST(testTextboxRoundedCorners, "textbox-rounded-corners.odt")
     uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1, xText), uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
     CPPUNIT_ASSERT_EQUAL(OUString("a"), xCell->getString());
+
+    // Table inside a textbox should be in the extension namespace.
+    if (xmlDocPtr pXmlDoc = parseExport("content.xml"))
+        // This failed, as draw:custom-shape had a table:table child.
+        assertXPath(pXmlDoc, "//draw:custom-shape/loext:table", "name", "Table1");
 }
 
 DECLARE_ODFEXPORT_TEST(testImageWithSpecialID, "document_with_two_images_with_special_IDs.odt")
@@ -459,6 +464,11 @@ DECLARE_ODFEXPORT_TEST(testFdo86963, "fdo86963.odt")
     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
 }
 
+DECLARE_ODFEXPORT_TEST(testGerrit13858, "gerrit13858.odt")
+{
+    // Just make sure the output is valid.
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 2103ffd..d57b18f 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -717,6 +717,9 @@ SwFrmFmt* SwNode::GetFlyFmt() const
             for( sal_uInt16 n = 0; n < rFrmFmtTbl.size(); ++n )
             {
                 SwFrmFmt* pFmt = rFrmFmtTbl[n];
+                // Only Writer fly frames can contain Writer nodes.
+                if (pFmt->Which() != RES_FLYFRMFMT)
+                    continue;
                 const SwFmtCntnt& rCntnt = pFmt->GetCntnt();
                 if( rCntnt.GetCntntIdx() &&
                     &rCntnt.GetCntntIdx()->GetNode() == pSttNd )
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index 6e4b800..0460e06 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -50,6 +50,7 @@
 #include "xmlexp.hxx"
 #include <boost/foreach.hpp>
 #include <o3tl/sorted_vector.hxx>
+#include <textboxhelper.hxx>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -461,10 +462,11 @@ class SwXMLTableInfo_Impl
     const SwTable *pTable;
     Reference < XTextSection > xBaseSection;
     bool bBaseSectionValid;
+    sal_uInt32 m_nPrefix;
 
 public:
 
-    inline SwXMLTableInfo_Impl( const SwTable *pTbl );
+    inline SwXMLTableInfo_Impl( const SwTable *pTbl, sal_uInt16 nPrefix );
 
     const SwTable *GetTable() const { return pTable; }
     const SwFrmFmt *GetTblFmt() const { return pTable->GetFrmFmt(); }
@@ -472,11 +474,14 @@ public:
     bool IsBaseSectionValid() const { return bBaseSectionValid; }
     const Reference < XTextSection >& GetBaseSection() const { return xBaseSection; }
     inline void SetBaseSection( const Reference < XTextSection >& rBase );
+    /// The namespace (table or loext) that should be used for the elements.
+    sal_uInt16 GetPrefix() const { return m_nPrefix; }
 };
 
-inline SwXMLTableInfo_Impl::SwXMLTableInfo_Impl( const SwTable *pTbl ) :
+inline SwXMLTableInfo_Impl::SwXMLTableInfo_Impl( const SwTable *pTbl, sal_uInt16 nPrefix ) :
     pTable( pTbl ),
-    bBaseSectionValid( false )
+    bBaseSectionValid( false ),
+    m_nPrefix(nPrefix)
 {
 }
 
@@ -719,7 +724,7 @@ void SwXMLExport::ExportTableAutoStyles( const SwTableNode& rTblNd )
         SwXMLTableColumnsSortByWidth_Impl aExpCols;
         SwXMLTableFrmFmtsSort_Impl aExpRows;
         SwXMLTableFrmFmtsSort_Impl aExpCells;
-        SwXMLTableInfo_Impl aTblInfo( &rTbl );
+        SwXMLTableInfo_Impl aTblInfo( &rTbl, XML_NAMESPACE_TABLE );
         ExportTableLinesAutoStyles( rTbl.GetTabLines(), nAbsWidth, nBaseWidth,
                                     pTblFmt->GetName(), aExpCols, aExpRows, aExpCells,
                                     aTblInfo, true);
@@ -828,7 +833,7 @@ void SwXMLExport::ExportTableBox( const SwTableBox& rBox,
                 }
 
                 // export cell element
-                SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
+                SvXMLElementExport aElem( *this, rTblInfo.GetPrefix(),
                                         XML_TABLE_CELL, true, true );
 
                 // export cell content
@@ -879,8 +884,7 @@ void SwXMLExport::ExportTableLine( const SwTableLine& rLine,
     }
 
     {
-        SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
-                                  XML_TABLE_ROW, true, true );
+        SvXMLElementExport aElem( *this, rTblInfo.GetPrefix(), XML_TABLE_ROW, true, true );
         const SwTableBoxes& rBoxes = rLine.GetTabBoxes();
         const size_t nBoxes = rBoxes.size();
 
@@ -894,7 +898,7 @@ void SwXMLExport::ExportTableLine( const SwTableLine& rLine,
             const long nRowSpan = pBox->getRowSpan();
             if( nRowSpan < 1 )
             {
-                SvXMLElementExport aElem2( *this, XML_NAMESPACE_TABLE,
+                SvXMLElementExport aElem2( *this, rTblInfo.GetPrefix(),
                                           XML_COVERED_TABLE_CELL, true,
                                           false );
             }
@@ -927,7 +931,7 @@ void SwXMLExport::ExportTableLine( const SwTableLine& rLine,
 
             for( size_t i=nOldCol; i<nCol; ++i )
             {
-                SvXMLElementExport aElemExport( *this, XML_NAMESPACE_TABLE,
+                SvXMLElementExport aElemExport( *this, rTblInfo.GetPrefix(),
                                           XML_COVERED_TABLE_CELL, true,
                                           false );
             }
@@ -1001,8 +1005,7 @@ void SwXMLExport::ExportTableLines( const SwTableLines& rLines,
             }
 
             {
-                SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE,
-                                          XML_TABLE_COLUMN, true, true );
+                SvXMLElementExport aElem( *this, rTblInfo.GetPrefix(), XML_TABLE_COLUMN, true, true );
             }
 
             nColRep = 1;
@@ -1065,9 +1068,16 @@ void SwXMLExport::ExportTable( const SwTableNode& rTblNd )
                       EncodeStyleName( pTblFmt->GetName() ) );
     }
 
+    sal_uInt16 nPrefix = XML_NAMESPACE_TABLE;
+    if (const SwFrmFmt* pFlyFormat = rTblNd.GetFlyFmt())
+    {
+        std::set<const SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(rTblNd.GetDoc());
+        if (aTextBoxes.find(pFlyFormat) != aTextBoxes.end())
+            nPrefix = XML_NAMESPACE_LO_EXT;
+    }
+
     {
-        SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_TABLE,
-                                  true, true );
+        SvXMLElementExport aElem( *this, nPrefix, XML_TABLE, true, true );
 
         // export DDE source (if this is a DDE table)
         if ( rTbl.ISA(SwDDETable) )
@@ -1101,7 +1111,7 @@ void SwXMLExport::ExportTable( const SwTableNode& rTblNd )
                                        XML_DDE_SOURCE, true, false);
         }
 
-        SwXMLTableInfo_Impl aTblInfo( &rTbl );
+        SwXMLTableInfo_Impl aTblInfo( &rTbl, nPrefix );
         ExportTableLines( rTbl.GetTabLines(), aTblInfo, rTbl.GetRowsToRepeat() );
 
         BOOST_FOREACH( SwTableLine *pLine, ((SwTable &)rTbl).GetTabLines() )


More information about the Libreoffice-commits mailing list