From 3b7c81b9536d8155f4134010aee61d27764f1a5f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 1 Jul 2020 12:03:20 +0200 Subject: sw doc model xml dump: show SdrModel of embedded charts Change-Id: Iae9daefb9b2173736c039d6177d7356c27eb7a33 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97605 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- chart2/Library_chartcore.mk | 1 + chart2/inc/ChartModel.hxx | 6 +++++- chart2/inc/ChartView.hxx | 5 +++++ chart2/source/inc/chartview/DrawModelWrapper.hxx | 2 ++ chart2/source/model/main/ChartModel.cxx | 14 ++++++++++++++ chart2/source/view/main/ChartView.cxx | 14 ++++++++++++++ chart2/source/view/main/DrawModelWrapper.cxx | 11 +++++++++++ 7 files changed, 52 insertions(+), 1 deletion(-) (limited to 'chart2') diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk index f42dfecd42fe..063e77d42305 100644 --- a/chart2/Library_chartcore.mk +++ b/chart2/Library_chartcore.mk @@ -27,6 +27,7 @@ $(eval $(call gb_Library_set_precompiled_header,chartcore,chart2/inc/pch/precomp $(eval $(call gb_Library_use_externals,chartcore,\ boost_headers \ + libxml2 \ )) ifeq ($(DISABLE_GUI),) diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx index 8c9c4ad69344..8f1defa197be 100644 --- a/chart2/inc/ChartModel.hxx +++ b/chart2/inc/ChartModel.hxx @@ -52,6 +52,7 @@ #include #include #include +#include #include @@ -105,7 +106,7 @@ typedef cppu::WeakImplHelper< class UndoManager; class ChartView; -class OOO_DLLPUBLIC_CHARTTOOLS ChartModel final : public impl::ChartModel_Base +class OOO_DLLPUBLIC_CHARTTOOLS ChartModel final : public impl::ChartModel_Base, public sfx2::XmlDump { private: @@ -465,6 +466,9 @@ public: void removeDataProviders(); + /// See sfx2::XmlDump::dumpAsXml(). + void dumpAsXml(xmlTextWriterPtr pWriter) const override; + private: sal_Int32 mnStart; sal_Int32 mnEnd; diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx index de9459ed6573..437d49527974 100644 --- a/chart2/inc/ChartView.hxx +++ b/chart2/inc/ChartView.hxx @@ -39,6 +39,7 @@ #include #include +#include namespace com::sun::star::drawing { class XDrawPage; } namespace com::sun::star::drawing { class XShapes; } @@ -92,6 +93,7 @@ class ChartView final : public ::cppu::WeakImplHelper< > , public ExplicitValueProvider , private SfxListener + , public sfx2::XmlDump { private: void init(); @@ -179,6 +181,9 @@ public: void setViewDirty(); + /// See sfx2::XmlDump::dumpAsXml(). + void dumpAsXml(xmlTextWriterPtr pWriter) const override; + private: //methods void createShapes(); void createShapes2D( const css::awt::Size& rPageSize ); diff --git a/chart2/source/inc/chartview/DrawModelWrapper.hxx b/chart2/source/inc/chartview/DrawModelWrapper.hxx index 3bc0b4fef2cf..bd9189dbff88 100644 --- a/chart2/source/inc/chartview/DrawModelWrapper.hxx +++ b/chart2/source/inc/chartview/DrawModelWrapper.hxx @@ -86,6 +86,8 @@ public: static SdrObject* getNamedSdrObject( const OUString& rName, SdrObjList const * pObjList ); static bool removeShape( const css::uno::Reference< css::drawing::XShape >& xShape ); + + void dumpAsXml(xmlTextWriterPtr pWriter) const override; }; } //namespace chart #endif diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 96c49fb56655..4f1d055f6a13 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -56,6 +56,7 @@ #include #include #include +#include using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Reference; @@ -738,6 +739,19 @@ void ChartModel::removeDataProviders() m_xDataProvider.clear(); } +void ChartModel::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + xmlTextWriterStartElement(pWriter, BAD_CAST("ChartModel")); + xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); + + if (mxChartView.is()) + { + mxChartView->dumpAsXml(pWriter); + } + + xmlTextWriterEndElement(pWriter); +} + sal_Bool SAL_CALL ChartModel::hasInternalDataProvider() { return m_xDataProvider.is() && m_xInternalDataProvider.is(); diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 4b6b1fa9b48f..faa7fbe3511a 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -103,6 +103,7 @@ #include #include +#include namespace com::sun::star::chart2 { class XChartDocument; } namespace chart { @@ -2890,6 +2891,19 @@ OUString ChartView::dump() #endif } +void ChartView::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + xmlTextWriterStartElement(pWriter, BAD_CAST("ChartView")); + xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); + + if (m_pDrawModelWrapper) + { + m_pDrawModelWrapper->dumpAsXml(pWriter); + } + + xmlTextWriterEndElement(pWriter); +} + void ChartView::setViewDirty() { osl::MutexGuard aGuard(maTimeMutex); diff --git a/chart2/source/view/main/DrawModelWrapper.cxx b/chart2/source/view/main/DrawModelWrapper.cxx index 6403e0eea192..1d9bc2914ce2 100644 --- a/chart2/source/view/main/DrawModelWrapper.cxx +++ b/chart2/source/view/main/DrawModelWrapper.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -324,6 +325,16 @@ bool DrawModelWrapper::removeShape( const uno::Reference< drawing::XShape >& xSh return false; } +void DrawModelWrapper::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + xmlTextWriterStartElement(pWriter, BAD_CAST("DrawModelWrapper")); + xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); + + SdrModel::dumpAsXml(pWriter); + + xmlTextWriterEndElement(pWriter); +} + } //namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit