Kaydet (Commit) e4de5b40 authored tarafından Miklos Vajna's avatar Miklos Vajna

fdo#84714 ODT export: write <loext:table> inside <draw:custom-shape>

Change-Id: I543ec24f8825bcc7c35acc106402f4fc6b4b5d79
üst 62391c28
...@@ -400,6 +400,11 @@ DECLARE_ODFEXPORT_TEST(testTextboxRoundedCorners, "textbox-rounded-corners.odt") ...@@ -400,6 +400,11 @@ DECLARE_ODFEXPORT_TEST(testTextboxRoundedCorners, "textbox-rounded-corners.odt")
uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1, xText), uno::UNO_QUERY); uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1, xText), uno::UNO_QUERY);
uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("a"), xCell->getString()); 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(testFdo86963, "fdo86963.odt") DECLARE_ODFEXPORT_TEST(testFdo86963, "fdo86963.odt")
......
...@@ -717,6 +717,9 @@ SwFrmFmt* SwNode::GetFlyFmt() const ...@@ -717,6 +717,9 @@ SwFrmFmt* SwNode::GetFlyFmt() const
for( size_t n = 0; n < rFrmFmtTbl.size(); ++n ) for( size_t n = 0; n < rFrmFmtTbl.size(); ++n )
{ {
SwFrmFmt* pFmt = rFrmFmtTbl[n]; SwFrmFmt* pFmt = rFrmFmtTbl[n];
// Only Writer fly frames can contain Writer nodes.
if (pFmt->Which() != RES_FLYFRMFMT)
continue;
const SwFmtCntnt& rCntnt = pFmt->GetCntnt(); const SwFmtCntnt& rCntnt = pFmt->GetCntnt();
if( rCntnt.GetCntntIdx() && if( rCntnt.GetCntntIdx() &&
&rCntnt.GetCntntIdx()->GetNode() == pSttNd ) &rCntnt.GetCntntIdx()->GetNode() == pSttNd )
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include "xmlexp.hxx" #include "xmlexp.hxx"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <o3tl/sorted_vector.hxx> #include <o3tl/sorted_vector.hxx>
#include <textboxhelper.hxx>
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
...@@ -461,10 +462,11 @@ class SwXMLTableInfo_Impl ...@@ -461,10 +462,11 @@ class SwXMLTableInfo_Impl
const SwTable *pTable; const SwTable *pTable;
Reference < XTextSection > xBaseSection; Reference < XTextSection > xBaseSection;
bool bBaseSectionValid; bool bBaseSectionValid;
sal_uInt32 m_nPrefix;
public: public:
inline SwXMLTableInfo_Impl( const SwTable *pTbl ); inline SwXMLTableInfo_Impl( const SwTable *pTbl, sal_uInt16 nPrefix );
const SwTable *GetTable() const { return pTable; } const SwTable *GetTable() const { return pTable; }
const SwFrmFmt *GetTblFmt() const { return pTable->GetFrmFmt(); } const SwFrmFmt *GetTblFmt() const { return pTable->GetFrmFmt(); }
...@@ -472,11 +474,14 @@ public: ...@@ -472,11 +474,14 @@ public:
bool IsBaseSectionValid() const { return bBaseSectionValid; } bool IsBaseSectionValid() const { return bBaseSectionValid; }
const Reference < XTextSection >& GetBaseSection() const { return xBaseSection; } const Reference < XTextSection >& GetBaseSection() const { return xBaseSection; }
inline void SetBaseSection( const Reference < XTextSection >& rBase ); 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 ), pTable( pTbl ),
bBaseSectionValid( false ) bBaseSectionValid( false ),
m_nPrefix(nPrefix)
{ {
} }
...@@ -719,7 +724,7 @@ void SwXMLExport::ExportTableAutoStyles( const SwTableNode& rTblNd ) ...@@ -719,7 +724,7 @@ void SwXMLExport::ExportTableAutoStyles( const SwTableNode& rTblNd )
SwXMLTableColumnsSortByWidth_Impl aExpCols; SwXMLTableColumnsSortByWidth_Impl aExpCols;
SwXMLTableFrmFmtsSort_Impl aExpRows; SwXMLTableFrmFmtsSort_Impl aExpRows;
SwXMLTableFrmFmtsSort_Impl aExpCells; SwXMLTableFrmFmtsSort_Impl aExpCells;
SwXMLTableInfo_Impl aTblInfo( &rTbl ); SwXMLTableInfo_Impl aTblInfo( &rTbl, XML_NAMESPACE_TABLE );
ExportTableLinesAutoStyles( rTbl.GetTabLines(), nAbsWidth, nBaseWidth, ExportTableLinesAutoStyles( rTbl.GetTabLines(), nAbsWidth, nBaseWidth,
pTblFmt->GetName(), aExpCols, aExpRows, aExpCells, pTblFmt->GetName(), aExpCols, aExpRows, aExpCells,
aTblInfo, true); aTblInfo, true);
...@@ -828,7 +833,7 @@ void SwXMLExport::ExportTableBox( const SwTableBox& rBox, ...@@ -828,7 +833,7 @@ void SwXMLExport::ExportTableBox( const SwTableBox& rBox,
} }
// export cell element // export cell element
SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, SvXMLElementExport aElem( *this, rTblInfo.GetPrefix(),
XML_TABLE_CELL, true, true ); XML_TABLE_CELL, true, true );
// export cell content // export cell content
...@@ -879,8 +884,7 @@ void SwXMLExport::ExportTableLine( const SwTableLine& rLine, ...@@ -879,8 +884,7 @@ void SwXMLExport::ExportTableLine( const SwTableLine& rLine,
} }
{ {
SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, SvXMLElementExport aElem( *this, rTblInfo.GetPrefix(), XML_TABLE_ROW, true, true );
XML_TABLE_ROW, true, true );
const SwTableBoxes& rBoxes = rLine.GetTabBoxes(); const SwTableBoxes& rBoxes = rLine.GetTabBoxes();
const size_t nBoxes = rBoxes.size(); const size_t nBoxes = rBoxes.size();
...@@ -1001,8 +1005,7 @@ void SwXMLExport::ExportTableLines( const SwTableLines& rLines, ...@@ -1001,8 +1005,7 @@ void SwXMLExport::ExportTableLines( const SwTableLines& rLines,
} }
{ {
SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, SvXMLElementExport aElem( *this, rTblInfo.GetPrefix(), XML_TABLE_COLUMN, true, true );
XML_TABLE_COLUMN, true, true );
} }
nColRep = 1; nColRep = 1;
...@@ -1065,9 +1068,16 @@ void SwXMLExport::ExportTable( const SwTableNode& rTblNd ) ...@@ -1065,9 +1068,16 @@ void SwXMLExport::ExportTable( const SwTableNode& rTblNd )
EncodeStyleName( pTblFmt->GetName() ) ); 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, SvXMLElementExport aElem( *this, nPrefix, XML_TABLE, true, true );
true, true );
// export DDE source (if this is a DDE table) // export DDE source (if this is a DDE table)
if ( rTbl.ISA(SwDDETable) ) if ( rTbl.ISA(SwDDETable) )
...@@ -1101,7 +1111,7 @@ void SwXMLExport::ExportTable( const SwTableNode& rTblNd ) ...@@ -1101,7 +1111,7 @@ void SwXMLExport::ExportTable( const SwTableNode& rTblNd )
XML_DDE_SOURCE, true, false); XML_DDE_SOURCE, true, false);
} }
SwXMLTableInfo_Impl aTblInfo( &rTbl ); SwXMLTableInfo_Impl aTblInfo( &rTbl, nPrefix );
ExportTableLines( rTbl.GetTabLines(), aTblInfo, rTbl.GetRowsToRepeat() ); ExportTableLines( rTbl.GetTabLines(), aTblInfo, rTbl.GetRowsToRepeat() );
BOOST_FOREACH( SwTableLine *pLine, ((SwTable &)rTbl).GetTabLines() ) BOOST_FOREACH( SwTableLine *pLine, ((SwTable &)rTbl).GetTabLines() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment