diff options
-rw-r--r-- | chart2/inc/ChartModel.hxx | 12 | ||||
-rw-r--r-- | chart2/inc/ChartView.hxx | 7 | ||||
-rw-r--r-- | chart2/qa/extras/xshape/chart2xshape.cxx | 14 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController_Window.cxx | 2 | ||||
-rw-r--r-- | chart2/source/inc/dumpxmltostring.hxx | 41 | ||||
-rw-r--r-- | chart2/source/model/main/ChartModel.cxx | 10 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 8 | ||||
-rw-r--r-- | include/sfx2/xmldump.hxx | 29 | ||||
-rw-r--r-- | offapi/com/sun/star/qa/XDumper.idl | 3 | ||||
-rw-r--r-- | svtools/source/misc/embedhlp.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/ole/ndole.cxx | 1 |
11 files changed, 83 insertions, 56 deletions
diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx index b877e47db5e0..8c876d8b95e6 100644 --- a/chart2/inc/ChartModel.hxx +++ b/chart2/inc/ChartModel.hxx @@ -52,10 +52,11 @@ #include <cppuhelper/implbase.hxx> #include <comphelper/interfacecontainer2.hxx> #include <vcl/GraphicObject.hxx> -#include <sfx2/xmldump.hxx> #include <memory> +typedef struct _xmlTextWriter* xmlTextWriterPtr; + namespace com::sun::star::awt { class XRequestCallback; } namespace com::sun::star::chart2::data { class XDataProvider; } namespace com::sun::star::document { class XFilter; } @@ -113,7 +114,7 @@ class UndoManager; class ChartView; class OOO_DLLPUBLIC_CHARTTOOLS SAL_LOPLUGIN_ANNOTATE("crosscast") ChartModel final : - public impl::ChartModel_Base, public sfx2::XmlDump + public impl::ChartModel_Base { private: @@ -452,7 +453,7 @@ public: virtual void SAL_CALL update() override; // XDumper - virtual OUString SAL_CALL dump() override; + virtual OUString SAL_CALL dump(OUString const & kind) override; // normal methods css::uno::Reference< css::util::XNumberFormatsSupplier > const & @@ -474,10 +475,9 @@ public: const rtl::Reference< ::chart::ChartTypeManager > & getTypeManager() const { return m_xChartTypeManager; } - /// See sfx2::XmlDump::dumpAsXml(). - void dumpAsXml(xmlTextWriterPtr pWriter) const override; - private: + void dumpAsXml(xmlTextWriterPtr pWriter) const; + sal_Int32 mnStart; sal_Int32 mnEnd; }; diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx index 5c7e70e97900..5f0665877e3d 100644 --- a/chart2/inc/ChartView.hxx +++ b/chart2/inc/ChartView.hxx @@ -43,7 +43,6 @@ #include <memory> #include <vcl/timer.hxx> -#include <sfx2/xmldump.hxx> namespace com::sun::star::drawing { class XDrawPage; } namespace com::sun::star::drawing { class XShapes; } @@ -97,7 +96,6 @@ class OOO_DLLPUBLIC_CHARTVIEW ChartView final : public ::cppu::WeakImplHelper< > , public ExplicitValueProvider , private SfxListener - , public sfx2::XmlDump { private: void init(); @@ -180,14 +178,13 @@ public: virtual ::sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< ::sal_Int8 >& aIdentifier ) override; // XDumper - virtual OUString SAL_CALL dump() override; + virtual OUString SAL_CALL dump(OUString const & kind) override; void setViewDirty(); css::uno::Reference<css::uno::XComponentContext> const& getComponentContext() { return m_xCC;} - /// See sfx2::XmlDump::dumpAsXml(). - void dumpAsXml(xmlTextWriterPtr pWriter) const override; + void dumpAsXml(xmlTextWriterPtr pWriter) const; private: //methods void createShapes(); diff --git a/chart2/qa/extras/xshape/chart2xshape.cxx b/chart2/qa/extras/xshape/chart2xshape.cxx index 23e3f93eaafa..92605a71199c 100644 --- a/chart2/qa/extras/xshape/chart2xshape.cxx +++ b/chart2/qa/extras/xshape/chart2xshape.cxx @@ -63,6 +63,11 @@ private: namespace { +OUString getShapeDump(css::uno::Reference<css::chart::XChartDocument> const& doc) +{ + return css::uno::Reference<css::qa::XDumper>(doc, css::uno::UNO_QUERY_THROW)->dump("shapes"); +} + bool checkDumpAgainstFile(std::u16string_view rDump, std::u16string_view aFilePath, char const* toleranceFile) { @@ -80,8 +85,7 @@ OUString Chart2XShapeTest::getXShapeDumpString() { uno::Reference<chart::XChartDocument> xChartDoc(getChartCompFromSheet(0, 0, mxComponent), UNO_QUERY_THROW); - uno::Reference<qa::XDumper> xDumper(xChartDoc, UNO_QUERY_THROW); - return xDumper->dump(); + return getShapeDump(xChartDoc); } xmlDocUniquePtr Chart2XShapeTest::getXShapeDumpXmlDoc() @@ -132,8 +136,7 @@ void Chart2XShapeTest::testTdf149204() // - Attr: sizeX loadFromURL(u"pptx/tdf149204.pptx"); uno::Reference<chart::XChartDocument> xChartDoc = getChartDocFromDrawImpress(0, 0); - uno::Reference<qa::XDumper> xDumper(xChartDoc, UNO_QUERY_THROW); - compareAgainstReference(xDumper->dump(), u"tdf149204.xml"); + compareAgainstReference(getShapeDump(xChartDoc), u"tdf149204.xml"); } void Chart2XShapeTest::testTdf151424() @@ -251,8 +254,7 @@ void Chart2XShapeTest::testTdf88154LabelRotatedLayout() { loadFromURL(u"pptx/tdf88154_LabelRotatedLayout.pptx"); uno::Reference<chart::XChartDocument> xChartDoc = getChartDocFromDrawImpress(0, 5); - uno::Reference<qa::XDumper> xDumper(xChartDoc, UNO_QUERY_THROW); - OUString rDump = xDumper->dump(); + OUString rDump = getShapeDump(xChartDoc); OString aXmlDump = OUStringToOString(rDump, RTL_TEXTENCODING_UTF8); xmlDocUniquePtr pXmlDoc(xmlParseDoc(reinterpret_cast<const xmlChar*>(aXmlDump.getStr()))); diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 018419b0eacf..70ab5436e148 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -1563,7 +1563,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) rtl::Reference< ChartModel > xChartModel = getChartModel(); if(xChartModel.is()) { - OUString aDump = xChartModel->dump(); + OUString aDump = xChartModel->dump("shapes"); SAL_WARN("chart2", aDump); } } diff --git a/chart2/source/inc/dumpxmltostring.hxx b/chart2/source/inc/dumpxmltostring.hxx new file mode 100644 index 000000000000..d03f1cab9d45 --- /dev/null +++ b/chart2/source/inc/dumpxmltostring.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include <sal/config.h> + +#include <libxml/tree.h> +#include <libxml/xmlwriter.h> + +#include <new> + +namespace chart +{ +template <typename F> OUString dumpXmlToString(F f) +{ + auto const buf = xmlBufferCreate(); + if (buf == nullptr) + { + throw std::bad_alloc(); + } + auto const writer = xmlNewTextWriterMemory(buf, 0); + if (writer == nullptr) + { + throw std::bad_alloc(); + } + f(writer); + xmlFreeTextWriter(writer); + OString s(reinterpret_cast<char const*>(xmlBufferContent(buf)), xmlBufferLength(buf)); + xmlBufferFree(buf); + return OStringToOUString(s, RTL_TEXTENCODING_ISO_8859_1); //TODO +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 781fc7c8e08a..0564f83703b8 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -36,6 +36,7 @@ #include <PopupRequest.hxx> #include <ModifyListenerHelper.hxx> #include <Diagram.hxx> +#include <dumpxmltostring.hxx> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> @@ -1257,12 +1258,17 @@ uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL ChartM } //XDumper -OUString SAL_CALL ChartModel::dump() +OUString SAL_CALL ChartModel::dump(OUString const & kind) { + if (kind.isEmpty()) { + return dumpXmlToString([this](auto writer) { return dumpAsXml(writer); }); + } + + // kind == "shapes": uno::Reference< qa::XDumper > xDumper( createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY ); if (xDumper.is()) - return xDumper->dump(); + return xDumper->dump(kind); return OUString(); } diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 584dfdb5ea72..2de5611c5ed0 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -56,6 +56,7 @@ #include <DateHelper.hxx> #include <ExplicitCategoriesProvider.hxx> #include <defines.hxx> +#include <dumpxmltostring.hxx> #include <unonames.hxx> #include <editeng/frmdiritem.hxx> #include <editeng/eeitem.hxx> @@ -1784,8 +1785,13 @@ uno::Sequence< OUString > ChartView::getAvailableServiceNames() return aServiceNames; } -OUString ChartView::dump() +OUString ChartView::dump(OUString const & kind) { + if (kind.isEmpty()) { + return dumpXmlToString([this](auto writer) { return dumpAsXml(writer); }); + } + + // kind == "shapes": #if HAVE_FEATURE_DESKTOP // Used for unit tests and in chartcontroller only, no need to drag in this when cross-compiling // for non-desktop diff --git a/include/sfx2/xmldump.hxx b/include/sfx2/xmldump.hxx deleted file mode 100644 index cd32d73299e0..000000000000 --- a/include/sfx2/xmldump.hxx +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#pragma once - -#include <sal/types.h> - -typedef struct _xmlTextWriter* xmlTextWriterPtr; - -namespace sfx2 -{ -/// Implemented by objects that can be dumped to xml for debugging purposes. -class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI SAL_LOPLUGIN_ANNOTATE("crosscast") XmlDump -{ -public: - virtual void dumpAsXml(xmlTextWriterPtr pWriter) const = 0; - -protected: - ~XmlDump() noexcept = default; -}; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/qa/XDumper.idl b/offapi/com/sun/star/qa/XDumper.idl index f980ac04a02d..0722b8b5bdd4 100644 --- a/offapi/com/sun/star/qa/XDumper.idl +++ b/offapi/com/sun/star/qa/XDumper.idl @@ -24,10 +24,11 @@ interface XDumper : com::sun::star::uno::XInterface { /** * dump the content into a string + * @param kind What kind of data to dump (for objects that know how to dump different data). * @since LibreOffice 3.6 */ - string dump(); + string dump([in] string kind); }; } ; // chart2 diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx index 053a30835d2d..d784b20a4a39 100644 --- a/svtools/source/misc/embedhlp.cxx +++ b/svtools/source/misc/embedhlp.cxx @@ -51,12 +51,12 @@ #include <com/sun/star/embed/XStateChangeListener.hpp> #include <com/sun/star/embed/XLinkageSupport.hpp> #include <com/sun/star/chart2/XDefaultSizeTransmitter.hpp> +#include <com/sun/star/qa/XDumper.hpp> #include <embeddedobj/embeddedupdate.hxx> #include <cppuhelper/implbase.hxx> #include <vcl/svapp.hxx> #include <comphelper/diagnose_ex.hxx> #include <tools/debug.hxx> -#include <sfx2/xmldump.hxx> #include <memory> using namespace com::sun::star; @@ -287,10 +287,14 @@ struct EmbeddedObjectRef_Impl (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mxObj")); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("symbol"), BAD_CAST(typeid(*mxObj).name())); - auto pComponent = dynamic_cast<sfx2::XmlDump*>(mxObj->getComponent().get()); - if (pComponent) + css::uno::Reference<css::qa::XDumper> pComponent( + mxObj->getComponent(), css::uno::UNO_QUERY); + if (pComponent.is()) { - pComponent->dumpAsXml(pWriter); + auto const s = pComponent->dump(""); + auto const s1 = OUStringToOString(s, RTL_TEXTENCODING_ISO_8859_1); //TODO + (void)xmlTextWriterWriteRawLen( + pWriter, reinterpret_cast<xmlChar const *>(s1.getStr()), s1.getLength()); } (void)xmlTextWriterEndElement(pWriter); diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx index a5210d22d339..831dcaef6faf 100644 --- a/sw/source/core/ole/ndole.cxx +++ b/sw/source/core/ole/ndole.cxx @@ -56,7 +56,6 @@ #include <atomic> #include <deque> #include <libxml/xmlwriter.h> -#include <sfx2/xmldump.hxx> #include <osl/diagnose.h> #include <flyfrm.hxx> |