[Libreoffice-commits] core.git: 2 commits - sw/qa sw/source xmloff/source
Miklos Vajna
vmiklos at collabora.co.uk
Sat Dec 27 03:14:16 PST 2014
sw/qa/extras/odfexport/odfexport.cxx | 5 +++++
sw/source/core/docnode/node.cxx | 3 +++
sw/source/filter/xml/xmltble.cxx | 34 ++++++++++++++++++++++------------
sw/source/filter/xml/xmltbli.cxx | 4 +++-
xmloff/source/text/txtimp.cxx | 1 +
5 files changed, 34 insertions(+), 13 deletions(-)
New commits:
commit e4de5b40eb7220da2d337eb98d7905a98dc12c72
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>
Change-Id: I543ec24f8825bcc7c35acc106402f4fc6b4b5d79
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 41c4ed9..194fc34 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -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::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(testFdo86963, "fdo86963.odt")
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 98126b7..14af4ce 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -717,6 +717,9 @@ SwFrmFmt* SwNode::GetFlyFmt() const
for( size_t 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 d426787..a698c94 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();
@@ -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() )
commit 62391c28fae5099dd1f67c322867933fcb05bc9f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Sat Dec 27 12:11:36 2014 +0100
fdo#84714 ODT import: read <loext:table> inside <draw:custom-shape>
A later version of ODF will hopefully allow <table:table> here as well,
but read <loext:table> in the meantime.
Change-Id: I42a461e0a6e9eff9387379acbab9660a155ecefe
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index b6d3bdd..0d33b74 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -105,10 +105,12 @@ static SvXMLTokenMapEntry aTableElemTokenMap[] =
XML_TOK_TABLE_HEADER_COLS },
{ XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS, XML_TOK_TABLE_COLS },
{ XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, XML_TOK_TABLE_COL },
+ { XML_NAMESPACE_LO_EXT, XML_TABLE_COLUMN, XML_TOK_TABLE_COL },
{ XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS,
XML_TOK_TABLE_HEADER_ROWS },
{ XML_NAMESPACE_TABLE, XML_TABLE_ROWS, XML_TOK_TABLE_ROWS },
{ XML_NAMESPACE_TABLE, XML_TABLE_ROW, XML_TOK_TABLE_ROW },
+ { XML_NAMESPACE_LO_EXT, XML_TABLE_ROW, XML_TOK_TABLE_ROW },
{ XML_NAMESPACE_OFFICE, XML_DDE_SOURCE,
XML_TOK_OFFICE_DDE_SOURCE },
@@ -968,7 +970,7 @@ SvXMLImportContext *SwXMLTableRowContext_Impl::CreateChildContext(
{
SvXMLImportContext *pContext = 0;
- if( XML_NAMESPACE_TABLE == nPrefix )
+ if( XML_NAMESPACE_TABLE == nPrefix || XML_NAMESPACE_LO_EXT == nPrefix )
{
if( IsXMLToken( rLocalName, XML_TABLE_CELL ) )
{
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx
index 3d9b547..6649327 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -85,6 +85,7 @@ static const SvXMLTokenMapEntry aTextElemTokenMap[] =
{ XML_NAMESPACE_DRAW, XML_FRAME, XML_TOK_TEXT_FRAME_PAGE },
{ XML_NAMESPACE_DRAW, XML_A, XML_TOK_DRAW_A_PAGE },
{ XML_NAMESPACE_TABLE,XML_TABLE, XML_TOK_TABLE_TABLE },
+ { XML_NAMESPACE_LO_EXT,XML_TABLE, XML_TOK_TABLE_TABLE },
{ XML_NAMESPACE_TEXT, XML_VARIABLE_DECLS, XML_TOK_TEXT_VARFIELD_DECLS },
{ XML_NAMESPACE_TEXT, XML_USER_FIELD_DECLS, XML_TOK_TEXT_USERFIELD_DECLS },
{ XML_NAMESPACE_TEXT, XML_SEQUENCE_DECLS, XML_TOK_TEXT_SEQUENCE_DECLS },
More information about the Libreoffice-commits
mailing list