diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-03-29 20:00:09 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-04-06 14:00:11 +0200 |
commit | f106f1812c9d2563064d604f392ece106fbeea2d (patch) | |
tree | b309550c4fe912469763dc7308d681766485ee01 | |
parent | 241de2e297453106e4270f5874773c2b416bc601 (diff) |
Resolves: tdf#117162 ImportDocumentHandler expects data provider to exist
already in its ctor
which changed since...
commit 9009663deb8f0862f419fd99bf0b761c7f923eff
Date: Sun Feb 26 22:48:06 2017 +0100
tdf#83257 [API-CHANGE] Pivot chart implementation
which defers it, take a probably safely backportable approach here to
fix it.
Change-Id: I1863791af7ae737f337993833a9cf1429a3a8028
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132286
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit 78f7bd90b96ac168fdacd1e0cb0693ab3861872a)
also contains...
tdf#117162 ImportDocumentHandler expected XDocumentHandler argument
but SvXMLImport not longer supports XDocumentHandler since
commit fe2b4e7dc6533535736a8f08496f316427386179
Date: Tue Oct 6 18:27:27 2020 +0200
make SvXMLImport fast-parser only
here use a SvXMLLegacyToFastDocHandler to try and glue the two
parts together again. Though the use of reflection::XProxyFactory
is a bit worrying here wrt this change so unforseen side effects
are possible. Full change over to fast-parser only is probably
advisable.
Change-Id: Ie14d1d9fa8534c187efc67a6c1cc0989316c4634
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132285
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit 70f3a94949cce612be9eff14fca94976acfc61a4)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132333
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r-- | chart2/Library_chartcore.mk | 1 | ||||
-rw-r--r-- | chart2/source/model/filter/XMLFilter.cxx | 10 | ||||
-rw-r--r-- | include/xmloff/SchXMLImportHelper.hxx | 3 | ||||
-rw-r--r-- | reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx | 8 | ||||
-rw-r--r-- | reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx | 3 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLChartContext.cxx | 4 |
6 files changed, 24 insertions, 5 deletions
diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk index 73945d783d3a..dd13d9b7b860 100644 --- a/chart2/Library_chartcore.mk +++ b/chart2/Library_chartcore.mk @@ -61,6 +61,7 @@ $(eval $(call gb_Library_use_libraries,chartcore,\ ucbhelper \ utl \ vcl \ + xo \ )) $(eval $(call gb_Library_set_componentfile,chartcore,chart2/source/chartcore)) diff --git a/chart2/source/model/filter/XMLFilter.cxx b/chart2/source/model/filter/XMLFilter.cxx index 6cc27d10f127..0fe76f0cec3a 100644 --- a/chart2/source/model/filter/XMLFilter.cxx +++ b/chart2/source/model/filter/XMLFilter.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/xml/sax/InputSource.hpp> #include <com/sun/star/xml/sax/Writer.hpp> #include <com/sun/star/lang/XMultiComponentFactory.hpp> @@ -50,6 +51,7 @@ #include <com/sun/star/document/GraphicStorageHandler.hpp> #include <tools/diagnose_ex.h> #include <sal/log.hxx> +#include <xmloff/SchXMLImportHelper.hxx> using namespace ::com::sun::star; @@ -449,6 +451,14 @@ ErrCode XMLFilter::impl_ImportStream( { try { + // tdf#117162 reportbuilder expects setDataProvider to be called before ctor + if (m_sDocumentHandler == "com.sun.star.comp.report.ImportDocumentHandler") + { + css::uno::Reference<css::chart2::XChartDocument> xChart(m_xTargetDoc, uno::UNO_QUERY); + if (xChart) + setDataProvider(xChart, OUString()); + } + uno::Sequence< uno::Any > aArgs{ uno::Any(beans::NamedValue("DocumentHandler", uno::Any(xFilter))), uno::Any(beans::NamedValue("Model", uno::Any(m_xTargetDoc))) diff --git a/include/xmloff/SchXMLImportHelper.hxx b/include/xmloff/SchXMLImportHelper.hxx index bec8167fe7a0..446b07387f29 100644 --- a/include/xmloff/SchXMLImportHelper.hxx +++ b/include/xmloff/SchXMLImportHelper.hxx @@ -21,6 +21,7 @@ #include <com/sun/star/uno/Reference.hxx> #include <salhelper/simplereferenceobject.hxx> +#include <xmloff/dllapi.h> #include <xmloff/families.hxx> namespace com::sun::star::chart { class XChartDocument; } @@ -107,6 +108,8 @@ public: const css::uno::Reference< css::chart2::XChartDocument > & xDoc ); }; +XMLOFF_DLLPUBLIC void setDataProvider(css::uno::Reference<css::chart2::XChartDocument> const & xChartDoc, OUString const & sDataPilotSource); + #endif // INCLUDED_XMLOFF_SCHXMLIMPORTHELPER_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx index 3d8b2c1be603..963264436092 100644 --- a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx +++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx @@ -331,13 +331,15 @@ void SAL_CALL ImportDocumentHandler::initialize( const uno::Sequence< uno::Any > { ::osl::MutexGuard aGuard(m_aMutex); comphelper::SequenceAsHashMap aArgs(_aArguments); - m_xDelegatee = aArgs.getUnpackedValueOrDefault("DocumentHandler",m_xDelegatee); + m_xDocumentHandler = aArgs.getUnpackedValueOrDefault("DocumentHandler",m_xDocumentHandler); m_xModel = aArgs.getUnpackedValueOrDefault("Model",m_xModel); - OSL_ENSURE(m_xDelegatee.is(),"No document handler available!"); - if ( !m_xDelegatee.is() || !m_xModel.is() ) + OSL_ENSURE(m_xDocumentHandler.is(), "No document handler available!"); + if (!m_xDocumentHandler.is() || !m_xModel.is()) throw uno::Exception("no delegatee and no model", nullptr); + m_xDelegatee.set(new SvXMLLegacyToFastDocHandler(dynamic_cast<SvXMLImport*>(m_xDocumentHandler.get()))); + m_xDatabaseDataProvider.set(m_xModel->getDataProvider(),uno::UNO_QUERY); if ( !m_xDatabaseDataProvider.is() ) { diff --git a/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx index 342194a9612a..aadea441ca62 100644 --- a/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx +++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx @@ -23,12 +23,14 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <cppuhelper/implbase3.hxx> #include <com/sun/star/xml/sax/XDocumentHandler.hpp> +#include <com/sun/star/xml/sax/XFastDocumentHandler.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XTypeProvider.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/data/XDatabaseDataProvider.hpp> #include <comphelper/uno3.hxx> +#include <xmloff/xmlimp.hxx> #include <memory> class SvXMLTokenMap; @@ -77,6 +79,7 @@ private: ::std::vector< OUString> m_aDetailFields; css::uno::Sequence< css::beans::PropertyValue > m_aArguments; css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference<css::xml::sax::XFastDocumentHandler> m_xDocumentHandler; css::uno::Reference< css::xml::sax::XDocumentHandler > m_xDelegatee; css::uno::Reference< css::uno::XAggregation > m_xProxy; css::uno::Reference< css::lang::XTypeProvider > m_xTypeProvider; diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx index 51a7e1f05d93..331a928feb97 100644 --- a/xmloff/source/chart/SchXMLChartContext.cxx +++ b/xmloff/source/chart/SchXMLChartContext.cxx @@ -244,7 +244,7 @@ static bool lcl_hasServiceName(Reference<lang::XMultiServiceFactory> const & xFa return std::find(aServiceNames.begin(), aServiceNames.end(), rServiceName) != aServiceNames.end(); } -static void lcl_setDataProvider(uno::Reference<chart2::XChartDocument> const & xChartDoc, OUString const & sDataPilotSource) +void setDataProvider(uno::Reference<chart2::XChartDocument> const & xChartDoc, OUString const & sDataPilotSource) { if (!xChartDoc.is()) return; @@ -392,7 +392,7 @@ void SchXMLChartContext::startFastElement( sal_Int32 /*nElement*/, uno::Reference<chart::XChartDocument> xDoc = mrImportHelper.GetChartDocument(); uno::Reference<chart2::XChartDocument> xNewDoc(xDoc, uno::UNO_QUERY); - lcl_setDataProvider(xNewDoc, msDataPilotSource); + setDataProvider(xNewDoc, msDataPilotSource); if( aOldChartTypeName.isEmpty() ) { |