summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2017-03-01 22:36:41 +0100
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2017-03-30 23:52:42 +0200
commit754884d767b349d0d55f585aab9c518c791dd174 (patch)
treebd9d3e9d154e30fb79cf2ed47ab7a17ec3b14b59
parent4e762c91a40ceb3c47cc5b89252255f3fbd8584b (diff)
pivotcharts: modify the pivot chart when the pivot table changes
Change-Id: I971e8bf90aaf2363adf3aa530b2cc8fd02abd273
-rw-r--r--chart2/source/model/main/ChartModel.cxx9
-rw-r--r--chart2/source/model/main/ChartModel_Persistence.cxx34
2 files changed, 39 insertions, 4 deletions
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index 814bd315928b..d12e8b54418d 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -63,6 +63,7 @@
#include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/document/DocumentProperties.hpp>
#include <com/sun/star/chart2/XTimeBased.hpp>
+#include <com/sun/star/util/XModifyBroadcaster.hpp>
#include <svl/zforlist.hxx>
@@ -744,7 +745,7 @@ Reference< chart2::data::XDataSource > ChartModel::impl_createDefaultData()
xIni->initialize(aArgs);
}
//create data
- uno::Sequence< beans::PropertyValue > aArgs( 4 );
+ uno::Sequence<beans::PropertyValue> aArgs(4);
aArgs[0] = beans::PropertyValue(
"CellRangeRepresentation", -1,
uno::Any( OUString("all") ), beans::PropertyState_DIRECT_VALUE );
@@ -816,6 +817,12 @@ void SAL_CALL ChartModel::attachDataProvider( const uno::Reference< chart2::data
}
}
+ uno::Reference<util::XModifyBroadcaster> xModifyBroadcaster(xDataProvider, uno::UNO_QUERY);
+ if (xModifyBroadcaster.is())
+ {
+ xModifyBroadcaster->addModifyListener(this);
+ }
+
m_xDataProvider.set( xDataProvider );
m_xInternalDataProvider.clear();
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx
index c19aeaf7c4d6..da7ba9cccbfc 100644
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -22,8 +22,10 @@
#include "macros.hxx"
#include "ChartViewHelper.hxx"
#include "ChartModelHelper.hxx"
+#include "DataSourceHelper.hxx"
#include "AxisHelper.hxx"
#include "ThreeDHelper.hxx"
+#include "DiagramHelper.hxx"
#include <com/sun/star/chart2/LegendPosition.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
@@ -49,6 +51,7 @@
#include <vcl/cvtgrf.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/storagehelper.hxx>
+#include <comphelper/sequence.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
@@ -704,10 +707,35 @@ void SAL_CALL ChartModel::removeModifyListener(
}
// util::XModifyListener
-void SAL_CALL ChartModel::modified( const lang::EventObject& )
+void SAL_CALL ChartModel::modified( const lang::EventObject& rEvenObject)
{
- if( m_nInLoad == 0 )
- setModified( true );
+ uno::Reference<chart2::data::XDataProvider> xDataProvider(rEvenObject.Source, uno::UNO_QUERY);
+ if (xDataProvider.is())
+ {
+ lockControllers();
+ Reference<frame::XModel> xModel(this);
+ try
+ {
+ uno::Sequence<beans::PropertyValue> aArguments =
+ DataSourceHelper::createArguments("PivotChart", uno::Sequence<sal_Int32>(), true, true, true);
+
+ Reference<chart2::data::XDataSource> xDataSource(xDataProvider->createDataSource(aArguments));
+ Reference<lang::XMultiServiceFactory> xFactory(getChartTypeManager(), uno::UNO_QUERY);
+ Reference<chart2::XDiagram> xDiagram(getFirstDiagram());
+
+ DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram(xDiagram, xFactory);
+ css::uno::Reference<css::chart2::XChartTypeTemplate> xChartTypeTemplate(aTemplateAndService.first);
+ xChartTypeTemplate->changeDiagramData(xDiagram, xDataSource, aArguments);
+ }
+ catch (const uno::Exception & ex)
+ {
+ ASSERT_EXCEPTION(ex);
+ }
+ unlockControllers();
+ }
+
+ if (m_nInLoad == 0)
+ setModified(true);
}
// lang::XEventListener (base of util::XModifyListener)