Repository.mk | 1 chart2/CppunitTest_chart2_pivot_chart_test.mk | 1 chart2/Library_chart2.mk | 1 chart2/Library_chart2api.mk | 32 ++++ chart2/Module_chart2.mk | 1 chart2/inc/pch/precompiled_chart2api.cxx | 12 + chart2/qa/extras/PivotChartTest.cxx | 56 +++---- chart2/source/api/AbstractPivotTableDataProvider.cxx | 16 ++ chart2/source/controller/main/ChartController_Window.cxx | 10 - chart2/source/model/main/ChartModel.cxx | 7 chart2/source/model/main/ChartModel_Persistence.cxx | 9 - chart2/source/view/main/ChartView.cxx | 17 +- chart2/source/view/main/VLegend.cxx | 16 +- include/chart2/AbstractPivotTableDataProvider.hxx | 86 ++++++++++++ include/chart2/chart2apidllapi.h | 30 ++++ offapi/UnoApi_offapi.mk | 1 offapi/com/sun/star/chart2/data/XPivotTableDataProvider.idl | 75 ---------- sc/Library_sc.mk | 1 sc/inc/PivotTableDataProvider.hxx | 39 ++--- sc/source/ui/unoobj/ChartTools.cxx | 28 +-- sc/source/ui/unoobj/PivotTableDataProvider.cxx | 24 +-- sc/source/ui/unoobj/TablePivotChart.cxx | 9 - sc/ucalc_setup.mk | 1 solenv/gbuild/extensions/pre_MergedLibsList.mk | 1 xmloff/CppunitTest_xmloff_uxmloff.mk | 1 xmloff/Library_xo.mk | 1 xmloff/source/chart/SchXMLChartContext.cxx | 12 - xmloff/source/chart/SchXMLExport.cxx | 9 - xmloff/source/chart/SchXMLSeries2Context.cxx | 12 - xmloff/source/chart/SchXMLTools.cxx | 9 - 30 files changed, 319 insertions(+), 199 deletions(-)
New commits: commit 1bd04a5413783608b15efe61d943c8f615b4ecec Author: Noel Grandin <[email protected]> AuthorDate: Tue Nov 25 10:50:06 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed Nov 26 10:06:23 2025 +0100 [API CHANGE] remove XPivotTableDataProvider in favor of a regular C++ interface class, since this is purely used internally to LO Change-Id: I84991efb1b0c8829e2175dc083b0f8627fcb1712 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194512 Code-Style: Noel Grandin <[email protected]> Tested-by: Noel Grandin <[email protected]> Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/Repository.mk b/Repository.mk index d6219fccf094..0a8fc3727ddd 100644 --- a/Repository.mk +++ b/Repository.mk @@ -401,6 +401,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \ basegfx \ bib \ chart2 \ + chart2api \ $(call gb_Helper_optional,OPENCL,clew) \ $(if $(filter $(OS),WNT),,cmdmail) \ configmgr \ diff --git a/chart2/CppunitTest_chart2_pivot_chart_test.mk b/chart2/CppunitTest_chart2_pivot_chart_test.mk index 1c4beda696cb..af882dbeac8c 100644 --- a/chart2/CppunitTest_chart2_pivot_chart_test.mk +++ b/chart2/CppunitTest_chart2_pivot_chart_test.mk @@ -22,6 +22,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,chart2_pivot_chart_test, \ $(eval $(call gb_CppunitTest_use_libraries,chart2_pivot_chart_test, \ basegfx \ + chart2api \ comphelper \ cppu \ cppuhelper \ diff --git a/chart2/Library_chart2.mk b/chart2/Library_chart2.mk index 48697de3772c..187b640189f0 100644 --- a/chart2/Library_chart2.mk +++ b/chart2/Library_chart2.mk @@ -34,6 +34,7 @@ $(eval $(call gb_Library_use_custom_headers,chart2,\ $(eval $(call gb_Library_use_libraries,chart2,\ basegfx \ + chart2api \ comphelper \ cppu \ cppuhelper \ diff --git a/chart2/Library_chart2api.mk b/chart2/Library_chart2api.mk new file mode 100644 index 000000000000..f84455a4b5be --- /dev/null +++ b/chart2/Library_chart2api.mk @@ -0,0 +1,32 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_Library_Library,chart2api)) + +$(eval $(call gb_Library_set_include,chart2api,\ + $$(INCLUDE) \ +)) + +$(eval $(call gb_Library_set_precompiled_header,chart2api,chart2/inc/pch/precompiled_chart2api)) + +$(eval $(call gb_Library_add_defs,chart2api,\ + -DCHART2API_DLLIMPLEMENTATION \ +)) + +$(eval $(call gb_Library_use_sdk_api,chart2api)) + +$(eval $(call gb_Library_use_libraries,chart2api,\ +)) + +$(eval $(call gb_Library_add_exception_objects,chart2api,\ + chart2/source/api/AbstractPivotTableDataProvider \ +)) + + +# vim: set noet sw=4 ts=4: diff --git a/chart2/Module_chart2.mk b/chart2/Module_chart2.mk index e0aa69e3b097..909e11e4bfc9 100644 --- a/chart2/Module_chart2.mk +++ b/chart2/Module_chart2.mk @@ -14,6 +14,7 @@ $(eval $(call gb_Module_Module,chart2)) $(eval $(call gb_Module_add_targets,chart2,\ Library_chart2 \ + Library_chart2api \ UIConfig_chart2 \ )) diff --git a/chart2/inc/pch/precompiled_chart2api.cxx b/chart2/inc/pch/precompiled_chart2api.cxx new file mode 100644 index 000000000000..13706600c7a2 --- /dev/null +++ b/chart2/inc/pch/precompiled_chart2api.cxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "precompiled_chart2api.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/inc/pch/precompiled_chart2api.hxx b/chart2/inc/pch/precompiled_chart2api.hxx new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/chart2/qa/extras/PivotChartTest.cxx b/chart2/qa/extras/PivotChartTest.cxx index d20660e331ad..b320855aa84b 100644 --- a/chart2/qa/extras/PivotChartTest.cxx +++ b/chart2/qa/extras/PivotChartTest.cxx @@ -25,8 +25,8 @@ #include <com/sun/star/util/XNumberFormatTypes.hpp> #include <com/sun/star/util/NumberFormat.hpp> -#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> #include <com/sun/star/chart2/data/XTextualDataSequence.hpp> +#include <chart2/AbstractPivotTableDataProvider.hxx> namespace com::sun::star::table { class XCellRange; } namespace com::sun::star::util { class XNumberFormats; } @@ -734,26 +734,26 @@ void PivotChartTest::testPivotTableDataProvider_PivotTableFields() CPPUNIT_ASSERT(xChartDoc.is()); - uno::Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider(xChartDoc->getDataProvider(), UNO_QUERY_THROW); - uno::Sequence<chart2::data::PivotTableFieldEntry> aFieldEntries; + chart2api::AbstractPivotTableDataProvider* pPivotTableDataProvider + = dynamic_cast<chart2api::AbstractPivotTableDataProvider*>(xChartDoc->getDataProvider().get()); - aFieldEntries = xPivotTableDataProvider->getColumnFields(); + auto rColFieldEntries = pPivotTableDataProvider->getColumnFields(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aFieldEntries.getLength()); - CPPUNIT_ASSERT_EQUAL(u"Country"_ustr, aFieldEntries[0].Name); - CPPUNIT_ASSERT_EQUAL(u"Type"_ustr, aFieldEntries[1].Name); + CPPUNIT_ASSERT_EQUAL(size_t(2), rColFieldEntries.size()); + CPPUNIT_ASSERT_EQUAL(u"Country"_ustr, rColFieldEntries[0].Name); + CPPUNIT_ASSERT_EQUAL(u"Type"_ustr, rColFieldEntries[1].Name); - aFieldEntries = xPivotTableDataProvider->getRowFields(); + auto rRowFieldEntries = pPivotTableDataProvider->getRowFields(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aFieldEntries.getLength()); - CPPUNIT_ASSERT_EQUAL(u"City"_ustr, aFieldEntries[0].Name); - CPPUNIT_ASSERT_EQUAL(u"Data"_ustr, aFieldEntries[1].Name); + CPPUNIT_ASSERT_EQUAL(size_t(2), rRowFieldEntries.size()); + CPPUNIT_ASSERT_EQUAL(u"City"_ustr, rRowFieldEntries[0].Name); + CPPUNIT_ASSERT_EQUAL(u"Data"_ustr, rRowFieldEntries[1].Name); - aFieldEntries = xPivotTableDataProvider->getDataFields(); + auto rDataFieldEntries = pPivotTableDataProvider->getDataFields(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aFieldEntries.getLength()); - CPPUNIT_ASSERT_EQUAL(u"Sum - Sales T1"_ustr, aFieldEntries[0].Name); - CPPUNIT_ASSERT_EQUAL(u"Sum - Sales T2"_ustr, aFieldEntries[1].Name); + CPPUNIT_ASSERT_EQUAL(size_t(2), rDataFieldEntries.size()); + CPPUNIT_ASSERT_EQUAL(u"Sum - Sales T1"_ustr, rDataFieldEntries[0].Name); + CPPUNIT_ASSERT_EQUAL(u"Sum - Sales T2"_ustr, rDataFieldEntries[1].Name); // Data to column fields lclModifyOrientation(xDataPilotDescriptor, u"Data", sheet::DataPilotFieldOrientation_COLUMN); @@ -766,25 +766,25 @@ void PivotChartTest::testPivotTableDataProvider_PivotTableFields() lclModifyOrientation(xDataPilotDescriptor, u"Country", sheet::DataPilotFieldOrientation_COLUMN); // set the XPivotTableDataProvider again as the old one was exchanged - xPivotTableDataProvider.set(xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW); + pPivotTableDataProvider = dynamic_cast<chart2api::AbstractPivotTableDataProvider*>(xChartDoc->getDataProvider().get()); - aFieldEntries = xPivotTableDataProvider->getColumnFields(); + auto rColFieldEntries2 = pPivotTableDataProvider->getColumnFields(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aFieldEntries.getLength()); - CPPUNIT_ASSERT_EQUAL(u"Data"_ustr, aFieldEntries[0].Name); - CPPUNIT_ASSERT_EQUAL(u"Type"_ustr, aFieldEntries[1].Name); - CPPUNIT_ASSERT_EQUAL(u"Country"_ustr, aFieldEntries[2].Name); + CPPUNIT_ASSERT_EQUAL(size_t(3), rColFieldEntries2.size()); + CPPUNIT_ASSERT_EQUAL(u"Data"_ustr, rColFieldEntries2[0].Name); + CPPUNIT_ASSERT_EQUAL(u"Type"_ustr, rColFieldEntries2[1].Name); + CPPUNIT_ASSERT_EQUAL(u"Country"_ustr, rColFieldEntries2[2].Name); - aFieldEntries = xPivotTableDataProvider->getRowFields(); + auto rRowFieldEntries2 = pPivotTableDataProvider->getRowFields(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aFieldEntries.getLength()); - CPPUNIT_ASSERT_EQUAL(u"City"_ustr, aFieldEntries[0].Name); + CPPUNIT_ASSERT_EQUAL(size_t(1), rRowFieldEntries2.size()); + CPPUNIT_ASSERT_EQUAL(u"City"_ustr, rRowFieldEntries2[0].Name); - aFieldEntries = xPivotTableDataProvider->getDataFields(); + auto rDataFieldEntries2 = pPivotTableDataProvider->getDataFields(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aFieldEntries.getLength()); - CPPUNIT_ASSERT_EQUAL(u"Sum - Sales T1"_ustr, aFieldEntries[0].Name); - CPPUNIT_ASSERT_EQUAL(u"Sum - Sales T2"_ustr, aFieldEntries[1].Name); + CPPUNIT_ASSERT_EQUAL(size_t(2), rDataFieldEntries2.size()); + CPPUNIT_ASSERT_EQUAL(u"Sum - Sales T1"_ustr, rDataFieldEntries2[0].Name); + CPPUNIT_ASSERT_EQUAL(u"Sum - Sales T2"_ustr, rDataFieldEntries2[1].Name); } void PivotChartTest::testPivotChartRowFieldInOutlineMode() diff --git a/chart2/source/api/AbstractPivotTableDataProvider.cxx b/chart2/source/api/AbstractPivotTableDataProvider.cxx new file mode 100644 index 000000000000..8f0dbc4f9942 --- /dev/null +++ b/chart2/source/api/AbstractPivotTableDataProvider.cxx @@ -0,0 +1,16 @@ +/* -*- 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/. + */ +#include <chart2/AbstractPivotTableDataProvider.hxx> + +namespace chart2api +{ +AbstractPivotTableDataProvider::~AbstractPivotTableDataProvider() {} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index f418f121eb66..23436a40c2f2 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -56,7 +56,6 @@ #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> -#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> #include <com/sun/star/awt/PopupMenuDirection.hpp> #include <com/sun/star/frame/DispatchHelper.hpp> @@ -64,6 +63,7 @@ #include <com/sun/star/frame/XPopupMenuController.hpp> #include <com/sun/star/awt/Rectangle.hpp> +#include <chart2/AbstractPivotTableDataProvider.hxx> #include <comphelper/lok.hxx> #include <comphelper/propertysequence.hxx> #include <comphelper/propertyvalue.hxx> @@ -1998,12 +1998,12 @@ void ChartController::sendPopupRequest(std::u16string_view rCID, tools::Rectangl if (!pChartModel) return; - uno::Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider; - xPivotTableDataProvider.set(pChartModel->getDataProvider(), uno::UNO_QUERY); - if (!xPivotTableDataProvider.is()) + chart2api::AbstractPivotTableDataProvider* pPivotTableDataProvider = + dynamic_cast<chart2api::AbstractPivotTableDataProvider*>(pChartModel->getDataProvider().get()); + if (!pPivotTableDataProvider) return; - OUString sPivotTableName = xPivotTableDataProvider->getPivotTableName(); + OUString sPivotTableName = pPivotTableDataProvider->getPivotTableName(); css::uno::Reference<css::awt::XRequestCallback> xPopupRequest = pChartModel->getPopupRequest(); PopupRequest* pPopupRequest = dynamic_cast<PopupRequest*>(xPopupRequest.get()); diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index b360e934e2c0..4fd9041f67f3 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -44,7 +44,7 @@ #include <comphelper/dumpxmltostring.hxx> #include <com/sun/star/chart/ChartDataRowSource.hpp> -#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> +#include <chart2/AbstractPivotTableDataProvider.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> @@ -1387,8 +1387,9 @@ bool ChartModel::isDataFromSpreadsheet() bool ChartModel::isDataFromPivotTable() const { - uno::Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider(m_xDataProvider, uno::UNO_QUERY); - return xPivotTableDataProvider.is(); + chart2api::AbstractPivotTableDataProvider* pPivotTableDataProvider = + dynamic_cast<chart2api::AbstractPivotTableDataProvider*>(m_xDataProvider.get()); + return pPivotTableDataProvider != nullptr; } rtl::Reference< BaseCoordinateSystem > ChartModel::getFirstCoordinateSystem() diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx index c819fab153c2..db66318834ff 100644 --- a/chart2/source/model/main/ChartModel_Persistence.cxx +++ b/chart2/source/model/main/ChartModel_Persistence.cxx @@ -48,7 +48,7 @@ #include <com/sun/star/ucb/CommandFailedException.hpp> #include <com/sun/star/ucb/ContentCreationException.hpp> -#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> +#include <chart2/AbstractPivotTableDataProvider.hxx> #include <ucbhelper/content.hxx> #include <unotools/ucbstreamhelper.hxx> @@ -683,11 +683,12 @@ void SAL_CALL ChartModel::removeModifyListener( // util::XModifyListener void SAL_CALL ChartModel::modified( const lang::EventObject& rEvenObject) { - uno::Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider(rEvenObject.Source, uno::UNO_QUERY); - if (xPivotTableDataProvider.is()) + chart2api::AbstractPivotTableDataProvider* pPivotTableDataProvider = + dynamic_cast<chart2api::AbstractPivotTableDataProvider*>(rEvenObject.Source.get()); + if (pPivotTableDataProvider) { lockControllers(); - uno::Reference<chart2::data::XDataProvider> xDataProvider(xPivotTableDataProvider, uno::UNO_QUERY); + uno::Reference<chart2::data::XDataProvider> xDataProvider(rEvenObject.Source, uno::UNO_QUERY); try { uno::Sequence<beans::PropertyValue> aArguments = diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 1b20e34939ad..94d5724c2219 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -86,7 +86,6 @@ #include <com/sun/star/chart2/StackingDirection.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> -#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> #include <com/sun/star/chart2/data/PivotTableFieldEntry.hpp> #include <com/sun/star/drawing/GraphicExportFilter.hpp> #include <com/sun/star/embed/Aspects.hpp> @@ -99,6 +98,7 @@ #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> +#include <chart2/AbstractPivotTableDataProvider.hxx> #include <svl/itempool.hxx> #include <svl/ctloptions.hxx> #include <comphelper/classids.hxx> @@ -1214,8 +1214,9 @@ void lcl_createButtons(const rtl::Reference<SvxShapeGroupAnyD>& xPageShapes, ChartModel& rModel, awt::Rectangle& rRemainingSpace) { - uno::Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider(rModel.getDataProvider(), uno::UNO_QUERY); - if (!xPivotTableDataProvider.is()) + chart2api::AbstractPivotTableDataProvider* pPivotTableDataProvider = + dynamic_cast<chart2api::AbstractPivotTableDataProvider*>(rModel.getDataProvider().get()); + if (!pPivotTableDataProvider) return; uno::Reference<beans::XPropertySet> xModelPage(rModel.getPageBackground()); @@ -1224,18 +1225,18 @@ void lcl_createButtons(const rtl::Reference<SvxShapeGroupAnyD>& xPageShapes, tools::Long x = 0; - if (xPivotTableDataProvider->getPageFields().hasElements()) + if (!pPivotTableDataProvider->getPageFields().empty()) { x = 0; - const css::uno::Sequence<chart2::data::PivotTableFieldEntry> aPivotFieldEntries = xPivotTableDataProvider->getPageFields(); + const std::vector<chart2::data::PivotTableFieldEntry>& aPivotFieldEntries = pPivotTableDataProvider->getPageFields(); for (css::chart2::data::PivotTableFieldEntry const & rPageFieldEntry : aPivotFieldEntries) { VButton aButton; aButton.init(xPageShapes); awt::Point aNewPosition(rRemainingSpace.X + x + 100, rRemainingSpace.Y + 100); sal_Int32 nDimensionIndex = rPageFieldEntry.DimensionIndex; - OUString aFieldOutputDescription = xPivotTableDataProvider->getFieldOutputDescription(nDimensionIndex); + OUString aFieldOutputDescription = pPivotTableDataProvider->getFieldOutputDescription(nDimensionIndex); aButton.setLabel(rPageFieldEntry.Name + " | " + aFieldOutputDescription); aButton.setCID("FieldButton.Page." + OUString::number(nDimensionIndex)); aButton.setPosition(aNewPosition); @@ -1252,11 +1253,11 @@ void lcl_createButtons(const rtl::Reference<SvxShapeGroupAnyD>& xPageShapes, aSize = awt::Size(3000, 700); // size of the button - if (!xPivotTableDataProvider->getRowFields().hasElements()) + if (pPivotTableDataProvider->getRowFields().empty()) return; x = 200; - const css::uno::Sequence<chart2::data::PivotTableFieldEntry> aPivotFieldEntries = xPivotTableDataProvider->getRowFields(); + const std::vector<chart2::data::PivotTableFieldEntry>& aPivotFieldEntries = pPivotTableDataProvider->getRowFields(); for (css::chart2::data::PivotTableFieldEntry const & rRowFieldEntry : aPivotFieldEntries) { VButton aButton; diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index 0c2fbc588454..37f43031d2d2 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -37,8 +37,8 @@ #include <com/sun/star/chart2/LegendPosition.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> -#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> #include <com/sun/star/chart2/data/PivotTableFieldEntry.hpp> +#include <chart2/AbstractPivotTableDataProvider.hxx> #include <rtl/math.hxx> #include <svl/ctloptions.hxx> #include <comphelper/diagnose_ex.hxx> @@ -834,18 +834,19 @@ std::vector<std::shared_ptr<VButton>> lcl_createButtons( { std::vector<std::shared_ptr<VButton>> aButtons; - uno::Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider(rModel.getDataProvider(), uno::UNO_QUERY); - if (!xPivotTableDataProvider.is()) + chart2api::AbstractPivotTableDataProvider* pPivotTableDataProvider = + dynamic_cast<chart2api::AbstractPivotTableDataProvider*>(rModel.getDataProvider().get()); + if (!pPivotTableDataProvider) return aButtons; - if (!xPivotTableDataProvider->getColumnFields().hasElements()) + if (pPivotTableDataProvider->getColumnFields().empty()) return aButtons; awt::Size aSize(2000, 700); int x = 100; int y = 100; - const css::uno::Sequence<chart2::data::PivotTableFieldEntry> aPivotFieldEntries = xPivotTableDataProvider->getColumnFields(); + const std::vector<chart2::data::PivotTableFieldEntry>& aPivotFieldEntries = pPivotTableDataProvider->getColumnFields(); for (chart2::data::PivotTableFieldEntry const & sColumnFieldEntry : aPivotFieldEntries) { auto pButton = std::make_shared<VButton>(); @@ -999,8 +1000,9 @@ void VLegend::createShapes( bool bSymbolsLeftSide = lcl_shouldSymbolsBePlacedOnTheLeftSide( m_xLegend, m_nDefaultWritingMode ); - uno::Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider( mrModel.getDataProvider(), uno::UNO_QUERY ); - bool bIsPivotChart = xPivotTableDataProvider.is(); + chart2api::AbstractPivotTableDataProvider* pPivotTableDataProvider = + dynamic_cast<chart2api::AbstractPivotTableDataProvider*>(mrModel.getDataProvider().get()); + bool bIsPivotChart = pPivotTableDataProvider != nullptr; if ( !aViewEntries.empty() || bIsPivotChart ) { diff --git a/include/chart2/AbstractPivotTableDataProvider.hxx b/include/chart2/AbstractPivotTableDataProvider.hxx new file mode 100644 index 000000000000..46c04034e514 --- /dev/null +++ b/include/chart2/AbstractPivotTableDataProvider.hxx @@ -0,0 +1,86 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <chart2/chart2apidllapi.h> +#include <com/sun/star/chart2/data/PivotTableFieldEntry.hpp> +#include <com/sun/star/chart2/data/XDataSequence.hpp> +#include <vector> + +namespace chart2api +{ +/** + * Data provider specific for pivot chart data. + */ +class CHART2API_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") AbstractPivotTableDataProvider +{ +public: + /** names of column fields from the associated pivot table + */ + virtual const std::vector<::css::chart2::data::PivotTableFieldEntry>& + getColumnFields() const = 0; + /** names of row fields from the associated pivot table + */ + virtual const std::vector<::css::chart2::data::PivotTableFieldEntry>& getRowFields() const = 0; + /** names of page fields from the associated pivot table + */ + virtual const std::vector<::css::chart2::data::PivotTableFieldEntry>& getPageFields() const = 0; + /** names of data fields from the associated pivot table + */ + virtual const std::vector<::css::chart2::data::PivotTableFieldEntry>& getDataFields() const = 0; + /** get the associated pivot table name + */ + virtual const OUString& getPivotTableName() const = 0; + /** set the associated pivot table name + */ + virtual void setPivotTableName(const OUString& sPivotTableName) = 0; + /** check if the associated pivot table exists + */ + virtual bool hasPivotTable() const = 0; + /** creates a single data sequence of values for the given data series index. + * + * @param nIndex + * index of the data series + */ + virtual ::css::uno::Reference<::css::chart2::data::XDataSequence> + createDataSequenceOfValuesByIndex(sal_Int32 nIndex) = 0; + /** creates a single data sequence of label(s) for the given data series index. + * + * @param nIndex + * index of the data series + */ + virtual ::css::uno::Reference<::css::chart2::data::XDataSequence> + createDataSequenceOfLabelsByIndex(sal_Int32 nIndex) = 0; + /** creates a single data sequence of categories. + */ + virtual ::css::uno::Reference<::css::chart2::data::XDataSequence> + createDataSequenceOfCategories() = 0; + /** field output description: either "- all -", "- multiple -", or specific value + * + * @param nDimensionIndex + * dimension index of the field + */ + virtual OUString getFieldOutputDescription(sal_Int32 nDimensionIndex) const = 0; + + virtual ~AbstractPivotTableDataProvider(); +}; + +} // namespace chart2api + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/chart2/chart2apidllapi.h b/include/chart2/chart2apidllapi.h new file mode 100644 index 000000000000..a8507f4e75d5 --- /dev/null +++ b/include/chart2/chart2apidllapi.h @@ -0,0 +1,30 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <sal/types.h> + +#if defined(CHART2API_DLLIMPLEMENTATION) +#define CHART2API_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define CHART2API_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif +#define CHART2API_DLLPRIVATE SAL_DLLPRIVATE + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 97d776847092..9ea3611da259 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -2038,7 +2038,6 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/chart2/data,\ XLabeledDataSequence \ XLabeledDataSequence2 \ XNumericalDataSequence \ - XPivotTableDataProvider \ XRangeHighlighter \ XRangeXMLConversion \ XSheetDataProvider \ diff --git a/offapi/com/sun/star/chart2/data/XPivotTableDataProvider.idl b/offapi/com/sun/star/chart2/data/XPivotTableDataProvider.idl deleted file mode 100644 index dd07af5aba1e..000000000000 --- a/offapi/com/sun/star/chart2/data/XPivotTableDataProvider.idl +++ /dev/null @@ -1,75 +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/. - */ - -module com { module sun { module star { module chart2 { module data { - -/** - * Data provider specific for pivot chart data. - * - * @since LibreOffice 5.4 - */ -interface XPivotTableDataProvider : com::sun::star::uno::XInterface -{ - /** names of column fields from the associated pivot table - */ - sequence<com::sun::star::chart2::data::PivotTableFieldEntry> getColumnFields(); - - /** names of row fields from the associated pivot table - */ - sequence<com::sun::star::chart2::data::PivotTableFieldEntry> getRowFields(); - - /** names of page fields from the associated pivot table - */ - sequence<com::sun::star::chart2::data::PivotTableFieldEntry> getPageFields(); - - /** names of data fields from the associated pivot table - */ - sequence<com::sun::star::chart2::data::PivotTableFieldEntry> getDataFields(); - - /** get the associated pivot table name - */ - string getPivotTableName(); - - /** set the associated pivot table name - */ - void setPivotTableName([in] string sPivotTableName); - - /** check if the associated pivot table exists - */ - boolean hasPivotTable(); - - /** creates a single data sequence of values for the given data series index. - * - * @param nIndex - * index of the data series - */ - XDataSequence createDataSequenceOfValuesByIndex([in] long nIndex); - - /** creates a single data sequence of label(s) for the given data series index. - * - * @param nIndex - * index of the data series - */ - XDataSequence createDataSequenceOfLabelsByIndex([in] long nIndex); - - /** creates a single data sequence of categories. - */ - XDataSequence createDataSequenceOfCategories(); - - /** field output description: either "- all -", "- multiple -", or specific value - * - * @param nDimensionIndex - * dimension index of the field - */ - string getFieldOutputDescription([in] long nDimensionIndex); -}; - -};};};};}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index eb705ac493db..be0b0686168c 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -67,6 +67,7 @@ endif $(eval $(call gb_Library_use_libraries,sc,\ avmedia \ basegfx \ + chart2api \ comphelper \ cppu \ cppuhelper \ diff --git a/sc/inc/PivotTableDataProvider.hxx b/sc/inc/PivotTableDataProvider.hxx index dd2d5dd585dc..2396fa13de9d 100644 --- a/sc/inc/PivotTableDataProvider.hxx +++ b/sc/inc/PivotTableDataProvider.hxx @@ -10,12 +10,12 @@ #pragma once #include <com/sun/star/chart2/data/XDataProvider.hpp> -#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> #include <com/sun/star/chart2/data/PivotTableFieldEntry.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/util/XModifyBroadcaster.hpp> +#include <chart2/AbstractPivotTableDataProvider.hxx> #include <svl/lstner.hxx> #include <cppuhelper/implbase.hxx> #include <rtl/ustring.hxx> @@ -37,13 +37,14 @@ struct ValueAndFormat; class PivotTableDataSequence; typedef cppu::WeakImplHelper<css::chart2::data::XDataProvider, - css::chart2::data::XPivotTableDataProvider, css::beans::XPropertySet, css::lang::XServiceInfo, css::util::XModifyBroadcaster> PivotTableDataProvider_Base; -class PivotTableDataProvider final : public PivotTableDataProvider_Base, public SfxListener +class PivotTableDataProvider final : public PivotTableDataProvider_Base, + public chart2api::AbstractPivotTableDataProvider, + public SfxListener { public: @@ -73,30 +74,30 @@ public: virtual css::uno::Reference<css::sheet::XRangeSelection> SAL_CALL getRangeSelection() override; - // XPivotTableDataProvider - virtual css::uno::Sequence<css::chart2::data::PivotTableFieldEntry> SAL_CALL - getColumnFields() override; - virtual css::uno::Sequence<css::chart2::data::PivotTableFieldEntry> SAL_CALL - getRowFields() override; - virtual css::uno::Sequence<css::chart2::data::PivotTableFieldEntry> SAL_CALL - getPageFields() override; - virtual css::uno::Sequence<css::chart2::data::PivotTableFieldEntry> SAL_CALL - getDataFields() override; + // AbstractPivotTableDataProvider + virtual const std::vector<css::chart2::data::PivotTableFieldEntry>& + getColumnFields() const override; + virtual const std::vector<css::chart2::data::PivotTableFieldEntry>& + getRowFields() const override; + virtual const std::vector<css::chart2::data::PivotTableFieldEntry>& + getPageFields() const override; + virtual const std::vector<css::chart2::data::PivotTableFieldEntry>& + getDataFields() const override; - virtual OUString SAL_CALL getPivotTableName() override; + virtual const OUString & getPivotTableName() const override; - virtual void SAL_CALL setPivotTableName(const OUString& sPivotTableName) override; + virtual void setPivotTableName(const OUString& sPivotTableName) override; - virtual sal_Bool SAL_CALL hasPivotTable() override; + virtual bool hasPivotTable() const override; - virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL + virtual css::uno::Reference<css::chart2::data::XDataSequence> createDataSequenceOfValuesByIndex(sal_Int32 nIndex) override; - virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL + virtual css::uno::Reference<css::chart2::data::XDataSequence> createDataSequenceOfLabelsByIndex(sal_Int32 nIndex) override; - virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL + virtual css::uno::Reference<css::chart2::data::XDataSequence> createDataSequenceOfCategories() override; - virtual OUString SAL_CALL getFieldOutputDescription(sal_Int32 nPageFieldIndex) override; + virtual OUString getFieldOutputDescription(sal_Int32 nPageFieldIndex) const override; // XPropertySet virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; diff --git a/sc/source/ui/unoobj/ChartTools.cxx b/sc/source/ui/unoobj/ChartTools.cxx index eabb6a84dcec..82419ec2ceed 100644 --- a/sc/source/ui/unoobj/ChartTools.cxx +++ b/sc/source/ui/unoobj/ChartTools.cxx @@ -12,9 +12,9 @@ #include <docsh.hxx> #include <drwlayer.hxx> -#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/embed/XEmbeddedObject.hpp> +#include <chart2/AbstractPivotTableDataProvider.hxx> #include <svx/svditer.hxx> #include <svx/svdoole2.hxx> #include <svx/svdpage.hxx> @@ -25,10 +25,10 @@ namespace sctools { namespace { -uno::Reference<chart2::data::XPivotTableDataProvider> +chart2api::AbstractPivotTableDataProvider* getPivotTableDataProvider(const SdrOle2Obj* pOleObject) { - uno::Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider; + chart2api::AbstractPivotTableDataProvider* pPivotTableDataProvider = nullptr; const uno::Reference<embed::XEmbeddedObject>& xObject = pOleObject->GetObjRef(); if (xObject.is()) @@ -36,20 +36,20 @@ getPivotTableDataProvider(const SdrOle2Obj* pOleObject) uno::Reference<chart2::XChartDocument> xChartDoc(xObject->getComponent(), uno::UNO_QUERY); if (xChartDoc.is()) { - xPivotTableDataProvider.set(uno::Reference<chart2::data::XPivotTableDataProvider>( - xChartDoc->getDataProvider(), uno::UNO_QUERY)); + pPivotTableDataProvider = dynamic_cast<chart2api::AbstractPivotTableDataProvider*>( + xChartDoc->getDataProvider().get()); } } - return xPivotTableDataProvider; + return pPivotTableDataProvider; } OUString getAssociatedPivotTableName(const SdrOle2Obj* pOleObject) { OUString aPivotTableName; - uno::Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider; - xPivotTableDataProvider.set(getPivotTableDataProvider(pOleObject)); - if (xPivotTableDataProvider.is()) - aPivotTableName = xPivotTableDataProvider->getPivotTableName(); + chart2api::AbstractPivotTableDataProvider* pPivotTableDataProvider + = getPivotTableDataProvider(pOleObject); + if (pPivotTableDataProvider) + aPivotTableName = pPivotTableDataProvider->getPivotTableName(); return aPivotTableName; } @@ -82,12 +82,12 @@ SdrOle2Obj* ChartIterator::next() { SdrOle2Obj* pOleObject = static_cast<SdrOle2Obj*>(pObject); - uno::Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider; - xPivotTableDataProvider.set(getPivotTableDataProvider(pOleObject)); + chart2api::AbstractPivotTableDataProvider* pPivotTableDataProvider + = getPivotTableDataProvider(pOleObject); - if (xPivotTableDataProvider.is() && m_eChartSourceType == ChartSourceType::PIVOT_TABLE) + if (pPivotTableDataProvider && m_eChartSourceType == ChartSourceType::PIVOT_TABLE) return pOleObject; - else if (!xPivotTableDataProvider.is() && m_eChartSourceType == ChartSourceType::CELL_RANGE) + else if (!pPivotTableDataProvider && m_eChartSourceType == ChartSourceType::CELL_RANGE) return pOleObject; } pObject = m_oIterator->Next(); diff --git a/sc/source/ui/unoobj/PivotTableDataProvider.cxx b/sc/source/ui/unoobj/PivotTableDataProvider.cxx index 0083cbdeabf8..3b07eeeb0b8f 100644 --- a/sc/source/ui/unoobj/PivotTableDataProvider.cxx +++ b/sc/source/ui/unoobj/PivotTableDataProvider.cxx @@ -718,27 +718,27 @@ uno::Reference<sheet::XRangeSelection> SAL_CALL PivotTableDataProvider::getRange // XPivotTableDataProvider ======================================================== -uno::Sequence<chart2::data::PivotTableFieldEntry> PivotTableDataProvider::getColumnFields() +const std::vector<chart2::data::PivotTableFieldEntry>& PivotTableDataProvider::getColumnFields() const { - return comphelper::containerToSequence(m_aColumnFields); + return m_aColumnFields; } -uno::Sequence<chart2::data::PivotTableFieldEntry> PivotTableDataProvider::getRowFields() +const std::vector<chart2::data::PivotTableFieldEntry>& PivotTableDataProvider::getRowFields() const { - return comphelper::containerToSequence(m_aRowFields); + return m_aRowFields; } -uno::Sequence<chart2::data::PivotTableFieldEntry> PivotTableDataProvider::getPageFields() +const std::vector<chart2::data::PivotTableFieldEntry>& PivotTableDataProvider::getPageFields() const { - return comphelper::containerToSequence(m_aPageFields); + return m_aPageFields; } -uno::Sequence<chart2::data::PivotTableFieldEntry> PivotTableDataProvider::getDataFields() +const std::vector<chart2::data::PivotTableFieldEntry>& PivotTableDataProvider::getDataFields() const { - return comphelper::containerToSequence(m_aDataFields); + return m_aDataFields; } -OUString PivotTableDataProvider::getPivotTableName() +const OUString & PivotTableDataProvider::getPivotTableName() const { return m_sPivotTableName; } @@ -751,7 +751,7 @@ void PivotTableDataProvider::setPivotTableName(const OUString& sPivotTableName) m_sPivotTableName = sPivotTableName; } -sal_Bool PivotTableDataProvider::hasPivotTable() +bool PivotTableDataProvider::hasPivotTable() const { if (m_sPivotTableName.isEmpty()) return false; @@ -798,11 +798,11 @@ uno::Reference<css::chart2::data::XDataSequence> return assignFirstCategoriesToDataSequence(); } -OUString PivotTableDataProvider::getFieldOutputDescription(sal_Int32 nDimensionIndex) +OUString PivotTableDataProvider::getFieldOutputDescription(sal_Int32 nDimensionIndex) const { if (nDimensionIndex < 0) return OUString(); - return m_aFieldOutputDescriptionMap[size_t(nDimensionIndex)]; + return m_aFieldOutputDescriptionMap.at(size_t(nDimensionIndex)); } // XModifyBroadcaster ======================================================== diff --git a/sc/source/ui/unoobj/TablePivotChart.cxx b/sc/source/ui/unoobj/TablePivotChart.cxx index 60dac16f17c9..bf6ed8c66107 100644 --- a/sc/source/ui/unoobj/TablePivotChart.cxx +++ b/sc/source/ui/unoobj/TablePivotChart.cxx @@ -7,9 +7,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/embed/XEmbeddedObject.hpp> +#include <chart2/AbstractPivotTableDataProvider.hxx> #include <svx/svdoole2.hxx> #include <svtools/embedhlp.hxx> #include <utility> @@ -92,11 +92,12 @@ OUString SAL_CALL TablePivotChart::getPivotTableName() if (!xChartDoc.is()) return OUString(); - uno::Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider(xChartDoc->getDataProvider(), uno::UNO_QUERY); - if (!xPivotTableDataProvider.is()) + chart2api::AbstractPivotTableDataProvider* pPivotTableDataProvider = + dynamic_cast<chart2api::AbstractPivotTableDataProvider*>(xChartDoc->getDataProvider().get()); + if (!pPivotTableDataProvider) return OUString(); - return xPivotTableDataProvider->getPivotTableName(); + return pPivotTableDataProvider->getPivotTableName(); } } // end sc namespace diff --git a/sc/ucalc_setup.mk b/sc/ucalc_setup.mk index 41fd99e49ff0..2dfe39ea90ed 100644 --- a/sc/ucalc_setup.mk +++ b/sc/ucalc_setup.mk @@ -42,6 +42,7 @@ $(eval $(call gb_CppunitTest_use_externals,sc_ucalc$(1),\ $(eval $(call gb_CppunitTest_use_libraries,sc_ucalc$(1), \ $(call gb_Helper_optional,AVMEDIA,avmedia) \ basegfx \ + chart2api \ comphelper \ cppu \ cppuhelper \ diff --git a/solenv/gbuild/extensions/pre_MergedLibsList.mk b/solenv/gbuild/extensions/pre_MergedLibsList.mk index 9426178f3d83..b16cc2ddcccc 100644 --- a/solenv/gbuild/extensions/pre_MergedLibsList.mk +++ b/solenv/gbuild/extensions/pre_MergedLibsList.mk @@ -19,6 +19,7 @@ gb_MERGE_LIBRARY_LIST := \ canvasfactory \ canvastools \ chart2 \ + chart2api \ comphelper \ configmgr \ cppcanvas \ diff --git a/xmloff/CppunitTest_xmloff_uxmloff.mk b/xmloff/CppunitTest_xmloff_uxmloff.mk index 35a270191717..af51d0d4491b 100644 --- a/xmloff/CppunitTest_xmloff_uxmloff.mk +++ b/xmloff/CppunitTest_xmloff_uxmloff.mk @@ -38,6 +38,7 @@ $(eval $(call gb_CppunitTest_use_externals,xmloff_uxmloff,\ $(eval $(call gb_CppunitTest_use_libraries,xmloff_uxmloff, \ basegfx \ + chart2api \ comphelper \ cppu \ cppuhelper \ diff --git a/xmloff/Library_xo.mk b/xmloff/Library_xo.mk index 535e71a00124..a2f213ddf328 100644 --- a/xmloff/Library_xo.mk +++ b/xmloff/Library_xo.mk @@ -55,6 +55,7 @@ $(eval $(call gb_Library_use_sdk_api,xo)) $(eval $(call gb_Library_use_libraries,xo,\ basegfx \ + chart2api \ comphelper \ cppu \ cppuhelper \ diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx index 82bf3344cd56..b881a870e7c6 100644 --- a/xmloff/source/chart/SchXMLChartContext.cxx +++ b/xmloff/source/chart/SchXMLChartContext.cxx @@ -48,7 +48,7 @@ #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/data/XDataSink.hpp> -#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> +#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp> #include <com/sun/star/chart2/XDataSeriesContainer.hpp> #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> #include <com/sun/star/chart2/XChartTypeContainer.hpp> @@ -56,6 +56,7 @@ #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/chart2/data/XDataReceiver.hpp> +#include <chart2/AbstractPivotTableDataProvider.hxx> #include <o3tl/safeint.hxx> #include <o3tl/string_view.hxx> @@ -68,7 +69,7 @@ namespace { void lcl_setRoleAtLabeledSequence( - const uno::Reference< chart2::data::XLabeledDataSequence > & xLSeq, + const uno::Reference< css::chart2::data::XLabeledDataSequence > & xLSeq, const OUString &rRole ) { // set role of sequence @@ -278,10 +279,11 @@ void setDataProvider(uno::Reference<chart2::XChartDocument> const & xChartDoc, O { if (bHasDataPilotSource) { - Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider(xProvider, uno::UNO_QUERY); - xPivotTableDataProvider->setPivotTableName(sDataPilotSource); + chart2api::AbstractPivotTableDataProvider* pPivotTableDataProvider = + dynamic_cast<chart2api::AbstractPivotTableDataProvider*>(xProvider.get()); + pPivotTableDataProvider->setPivotTableName(sDataPilotSource); xDataReceiver->attachDataProvider(xProvider); - bHasOwnData = !xPivotTableDataProvider->hasPivotTable(); + bHasOwnData = !pPivotTableDataProvider->hasPivotTable(); } else { diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index f475718c6088..d66684b64dbd 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -90,7 +90,6 @@ #include <com/sun/star/chart2/data/XDataSink.hpp> #include <com/sun/star/chart2/data/XDataProvider.hpp> #include <com/sun/star/chart2/data/XDatabaseDataProvider.hpp> -#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp> #include <com/sun/star/chart2/data/XTextualDataSequence.hpp> #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> @@ -102,6 +101,7 @@ #include <com/sun/star/embed/XVisualObject.hpp> #include <com/sun/star/container/XChild.hpp> +#include <chart2/AbstractPivotTableDataProvider.hxx> #include <comphelper/diagnose_ex.hxx> #include "MultiPropertySetHandler.hxx" #include "PropertyMap.hxx" @@ -1253,10 +1253,11 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument > mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE ); } - Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider(xNewDoc->getDataProvider(), uno::UNO_QUERY); - if (xPivotTableDataProvider.is() && nCurrentODFVersion & SvtSaveOptions::ODFSVER_EXTENDED) + chart2api::AbstractPivotTableDataProvider* pPivotTableDataProvider = + dynamic_cast<chart2api::AbstractPivotTableDataProvider*>(xNewDoc->getDataProvider().get()); + if (pPivotTableDataProvider && nCurrentODFVersion & SvtSaveOptions::ODFSVER_EXTENDED) { - OUString sPivotTableName = xPivotTableDataProvider->getPivotTableName(); + OUString sPivotTableName = pPivotTableDataProvider->getPivotTableName(); mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_DATA_PILOT_SOURCE, sPivotTableName); } diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx index 04c5508c447b..654cc4187dfe 100644 --- a/xmloff/source/chart/SchXMLSeries2Context.cxx +++ b/xmloff/source/chart/SchXMLSeries2Context.cxx @@ -27,7 +27,6 @@ #include <com/sun/star/chart2/XRegressionCurve.hpp> #include <com/sun/star/chart2/XRegressionCurveContainer.hpp> #include <com/sun/star/chart2/data/XDataSink.hpp> -#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/XDataPointCustomLabelField.hpp> @@ -44,6 +43,7 @@ #include <com/sun/star/embed/Aspects.hpp> #include <com/sun/star/embed/XVisualObject.hpp> +#include <chart2/AbstractPivotTableDataProvider.hxx> #include <comphelper/processfactory.hxx> #include <sal/log.hxx> @@ -428,14 +428,14 @@ void SchXMLSeries2Context::startFastElement (sal_Int32 /*Element*/, } Reference<chart2::data::XDataProvider> xDataProvider(mxNewDoc->getDataProvider()); - Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider(xDataProvider, uno::UNO_QUERY); + chart2api::AbstractPivotTableDataProvider* pPivotTableDataProvider = dynamic_cast<chart2api::AbstractPivotTableDataProvider*>(xDataProvider.get()); Reference<chart2::data::XDataSequence> xSequenceValues; // values - if (xPivotTableDataProvider.is()) // is pivot chart + if (pPivotTableDataProvider) // is pivot chart { - xSequenceValues.set(xPivotTableDataProvider->createDataSequenceOfValuesByIndex(mnSeriesIndex)); + xSequenceValues.set(pPivotTableDataProvider->createDataSequenceOfValuesByIndex(mnSeriesIndex)); } else { @@ -460,9 +460,9 @@ void SchXMLSeries2Context::startFastElement (sal_Int32 /*Element*/, // label Reference<chart2::data::XDataSequence> xSequenceLabel; - if (xPivotTableDataProvider.is()) + if (pPivotTableDataProvider) { - xSequenceLabel.set(xPivotTableDataProvider->createDataSequenceOfLabelsByIndex(mnSeriesIndex)); + xSequenceLabel.set(pPivotTableDataProvider->createDataSequenceOfLabelsByIndex(mnSeriesIndex)); } else { diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx index 2cda1e39c5a2..8daa0403c9ca 100644 --- a/xmloff/source/chart/SchXMLTools.cxx +++ b/xmloff/source/chart/SchXMLTools.cxx @@ -37,7 +37,6 @@ #include <com/sun/star/chart2/data/XDataProvider.hpp> #include <com/sun/star/chart2/data/XDataReceiver.hpp> #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp> -#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> #include <com/sun/star/chart2/FormattedString.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> @@ -47,6 +46,7 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp> +#include <chart2/AbstractPivotTableDataProvider.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/diagnose_ex.hxx> #include <comphelper/sequence.hxx> @@ -494,10 +494,11 @@ void CreateCategories( } Reference<chart2::data::XDataSequence> xSequence; - Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider(xDataProvider, uno::UNO_QUERY); - if (xPivotTableDataProvider.is()) + chart2api::AbstractPivotTableDataProvider* pPivotTableDataProvider = + dynamic_cast<chart2api::AbstractPivotTableDataProvider*>(xDataProvider.get()); + if (pPivotTableDataProvider) { - xSequence.set(xPivotTableDataProvider->createDataSequenceOfCategories()); + xSequence.set(pPivotTableDataProvider->createDataSequenceOfCategories()); } else {
