[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 <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2025-11-26 10:06:23 +01:00
committed by Noel Grandin
parent 48b61a5d6d
commit 1bd04a5413
31 changed files with 319 additions and 199 deletions
+1
View File
@@ -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 \
@@ -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 \
+1
View File
@@ -34,6 +34,7 @@ $(eval $(call gb_Library_use_custom_headers,chart2,\
$(eval $(call gb_Library_use_libraries,chart2,\
basegfx \
chart2api \
comphelper \
cppu \
cppuhelper \
+32
View File
@@ -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:
+1
View File
@@ -14,6 +14,7 @@ $(eval $(call gb_Module_Module,chart2))
$(eval $(call gb_Module_add_targets,chart2,\
Library_chart2 \
Library_chart2api \
UIConfig_chart2 \
))
+12
View File
@@ -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: */
+28 -28
View File
@@ -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()
@@ -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: */
@@ -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());
+4 -3
View File
@@ -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()
@@ -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 =
+9 -8
View File
@@ -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;
+9 -7
View File
@@ -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 )
{
@@ -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: */
+30
View File
@@ -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: */
-1
View File
@@ -2038,7 +2038,6 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/chart2/data,\
XLabeledDataSequence \
XLabeledDataSequence2 \
XNumericalDataSequence \
XPivotTableDataProvider \
XRangeHighlighter \
XRangeXMLConversion \
XSheetDataProvider \
@@ -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: */
+1
View File
@@ -67,6 +67,7 @@ endif
$(eval $(call gb_Library_use_libraries,sc,\
avmedia \
basegfx \
chart2api \
comphelper \
cppu \
cppuhelper \
+20 -19
View File
@@ -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;
+14 -14
View File
@@ -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();
+12 -12
View File
@@ -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 ========================================================
+5 -4
View File
@@ -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
+1
View File
@@ -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 \
@@ -19,6 +19,7 @@ gb_MERGE_LIBRARY_LIST := \
canvasfactory \
canvastools \
chart2 \
chart2api \
comphelper \
configmgr \
cppcanvas \
+1
View File
@@ -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 \
+1
View File
@@ -55,6 +55,7 @@ $(eval $(call gb_Library_use_sdk_api,xo))
$(eval $(call gb_Library_use_libraries,xo,\
basegfx \
chart2api \
comphelper \
cppu \
cppuhelper \
+7 -5
View File
@@ -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
{
+5 -4
View File
@@ -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);
}
+6 -6
View File
@@ -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
{
+5 -4
View File
@@ -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
{