include/svx/svdotable.hxx | 2 ++ svx/source/table/svdotable.cxx | 21 +++++++++++++++++++++ svx/source/table/tablelayouter.cxx | 29 +++++++++++++++++++++++++++++ svx/source/table/tablelayouter.hxx | 2 ++ 4 files changed, 54 insertions(+)
New commits: commit a106165e7fd39215c4717e1486aef05f6af9180f Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Jun 8 12:17:19 2016 +0200 Related: tdf#100269 sd xml dump: expose layout of table shapes So that it's possible to assert the layout from cppunit tests. Change-Id: I09631f978ed44bb1c27806089b6d69c70db643c3 Reviewed-on: https://gerrit.libreoffice.org/26054 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx index e561f6d..d81d37d 100644 --- a/include/svx/svdotable.hxx +++ b/include/svx/svdotable.hxx @@ -281,6 +281,8 @@ public: static void ExportAsRTF( SvStream& rStrm, SdrTableObj& rObj ); static void ImportAsRTF( SvStream& rStrm, SdrTableObj& rObj ); + virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const override; + private: void init( sal_Int32 nColumns, sal_Int32 nRows ); diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index 8c70711..36fa94f 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -57,6 +57,7 @@ #include "svx/xflftrit.hxx" #include "svx/xfltrit.hxx" #include <cppuhelper/implbase.hxx> +#include <libxml/xmlwriter.h> using ::com::sun::star::uno::Any; @@ -238,6 +239,7 @@ public: void connectTableStyle(); void disconnectTableStyle(); virtual bool isInUse() override; + void dumpAsXml(struct _xmlTextWriter* pWriter) const; private: static SdrTableObjImpl* lastLayoutTable; static Rectangle lastLayoutInputRectangle; @@ -624,6 +626,14 @@ bool SdrTableObjImpl::isInUse() return mpTableObj && mpTableObj->IsInserted(); } +void SdrTableObjImpl::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + xmlTextWriterStartElement(pWriter, BAD_CAST("sdrTableObjImpl")); + if (mpLayouter) + mpLayouter->dumpAsXml(pWriter); + xmlTextWriterEndElement(pWriter); +} + // XEventListener @@ -2497,6 +2507,17 @@ void SdrTableObj::uno_unlock() mpImpl->mxTable->unlockBroadcasts(); } +void SdrTableObj::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + xmlTextWriterStartElement(pWriter, BAD_CAST("sdrTableObj")); + xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); + + SdrObject::dumpAsXml(pWriter); + + mpImpl->dumpAsXml(pWriter); + + xmlTextWriterEndElement(pWriter); +} } } diff --git a/svx/source/table/tablelayouter.cxx b/svx/source/table/tablelayouter.cxx index 0f6208c..ae87f50 100644 --- a/svx/source/table/tablelayouter.cxx +++ b/svx/source/table/tablelayouter.cxx @@ -21,6 +21,7 @@ #include <com/sun/star/table/XMergeableCell.hpp> #include <tools/gen.hxx> +#include <libxml/xmlwriter.h> #include "cell.hxx" #include "cellrange.hxx" @@ -1121,6 +1122,34 @@ void TableLayouter::DistributeRows( ::Rectangle& rArea, sal_Int32 nFirstRow, sal } } +void TableLayouter::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + xmlTextWriterStartElement(pWriter, BAD_CAST("tableLayouter")); + + xmlTextWriterStartElement(pWriter, BAD_CAST("columns")); + for (const auto& rColumn : maColumns) + rColumn.dumpAsXml(pWriter); + xmlTextWriterEndElement(pWriter); + + xmlTextWriterStartElement(pWriter, BAD_CAST("rows")); + for (const auto& rRow : maRows) + rRow.dumpAsXml(pWriter); + xmlTextWriterEndElement(pWriter); + + xmlTextWriterEndElement(pWriter); +} + +void TableLayouter::Layout::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + xmlTextWriterStartElement(pWriter, BAD_CAST("layout")); + + xmlTextWriterWriteAttribute(pWriter, BAD_CAST("pos"), BAD_CAST(OString::number(mnPos).getStr())); + xmlTextWriterWriteAttribute(pWriter, BAD_CAST("size"), BAD_CAST(OString::number(mnSize).getStr())); + xmlTextWriterWriteAttribute(pWriter, BAD_CAST("minSize"), BAD_CAST(OString::number(mnMinSize).getStr())); + + xmlTextWriterEndElement(pWriter); +} + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/table/tablelayouter.hxx b/svx/source/table/tablelayouter.hxx index b383455..0ab692c 100644 --- a/svx/source/table/tablelayouter.hxx +++ b/svx/source/table/tablelayouter.hxx @@ -96,6 +96,7 @@ public: void DistributeColumns( ::Rectangle& rArea, sal_Int32 nFirstCol, sal_Int32 nLastCol ); void DistributeRows( ::Rectangle& rArea, sal_Int32 nFirstRow, sal_Int32 nLastRow ); + void dumpAsXml(struct _xmlTextWriter* pWriter) const; private: CellRef getCell( const CellPos& rPos ) const; @@ -125,6 +126,7 @@ private: Layout() : mnPos( 0 ), mnSize( 0 ), mnMinSize( 0 ) {} void clear() { mnPos = 0; mnSize = 0; mnMinSize = 0; } + void dumpAsXml(struct _xmlTextWriter* pWriter) const; }; typedef std::vector< Layout > LayoutVector; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits