[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - chart2/inc chart2/source offapi/com offapi/UnoApi_offapi.mk sc/inc sc/source

2017-12-22 Thread Vasily Melenchuk
Rebased ref, commits from common ancestor:
commit 5a8c4244d33ad257d4cd81b40c612ff294015492
Author: Vasily Melenchuk 
Date:   Fri Nov 10 18:37:25 2017 +0300

tdf#113572: allow switching to data range in copypasted chart

- enable data range toolbar button for charts with internal
  data table and possiblilty to switch to data range
- show warning before destoying data table
- recreation of data provider

Conflicts:
chart2/inc/ChartModel.hxx
chart2/inc/strings.hrc
chart2/source/controller/main/ChartController.cxx
chart2/source/controller/main/ControllerCommandDispatch.cxx
sc/source/ui/unoobj/docuno.cxx

Change-Id: I46c703b579cd32405b02543aa5b9e3a74e4b36b6
Reviewed-on: https://gerrit.libreoffice.org/46981
Reviewed-by: Thorsten Behrens 
Tested-by: Thorsten Behrens 

diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx
index b3caaad412c4..f254103e961f 100644
--- a/chart2/inc/ChartModel.hxx
+++ b/chart2/inc/ChartModel.hxx
@@ -579,6 +579,8 @@ public:
 void getNextTimePoint();
 void setTimeBasedRange(sal_Int32 nStart, sal_Int32 nEnd);
 
+void removeDataProviders();
+
 OpenGLWindow* getOpenGLWindow() { return mpOpenGLWindow;}
 
 private:
diff --git a/chart2/source/controller/dialogs/Strings.src 
b/chart2/source/controller/dialogs/Strings.src
index c9d18eb62391..96f7f5598b2a 100644
--- a/chart2/source/controller/dialogs/Strings.src
+++ b/chart2/source/controller/dialogs/Strings.src
@@ -34,6 +34,11 @@ String STR_DLG_STEPPED_LINE_PROPERTIES
 Text [ en-US ] = "Stepped Lines" ;
 };
 
+String STR_DLG_REMOVE_DATA_TABLE
+{
+Text [ en-US ] = "Do you want to delete data table and switch to data 
ranges?" ;
+};
+
 String STR_PAGE_CHARTTYPE
 {
 Text [ en-US ] = "Chart Type" ;
diff --git a/chart2/source/controller/main/ChartController.cxx 
b/chart2/source/controller/main/ChartController.cxx
index 8482c16a6513..f87f5c74f798 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -66,12 +66,14 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -1395,21 +1397,56 @@ void ChartController::executeDispatch_SourceData()
 //convert properties to ItemSet
 uno::Reference< XChartDocument >   xChartDoc( getModel(), uno::UNO_QUERY );
 OSL_ENSURE( xChartDoc.is(), "Invalid XChartDocument" );
-if( !xChartDoc.is())
+if( !xChartDoc.is() )
 return;
 
-UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard(
-SCH_RESSTR(STR_ACTION_EDIT_DATA_RANGES), m_xUndoManager );
-if( xChartDoc.is())
+// If there is a data table we should ask user if we really want to 
destroy it
+// and switch to data ranges.
+ChartModel& rModel = dynamic_cast(*xChartDoc.get());
+if ( rModel.hasInternalDataProvider() )
 {
+// Check if we will able to create data provider later
+Reference< lang::XServiceInfo > xParentServiceInfo( 
rModel.getParent(), uno::UNO_QUERY );
+if ( !xParentServiceInfo.is() || 
!xParentServiceInfo->supportsService("com.sun.star.chart2.XDataProviderCreator")
 )
+return;
+
 SolarMutexGuard aSolarGuard;
-ScopedVclPtrInstance< ::chart::DataSourceDialog > aDlg( 
m_pChartWindow, xChartDoc, m_xCC );
-if( aDlg->Execute() == RET_OK )
+
+ScopedVclPtrInstance< MessageDialog > aQueryBox( m_pChartWindow, 
SchResId( STR_DLG_REMOVE_DATA_TABLE ), VCL_MESSAGE_QUESTION, 
VCL_BUTTONS_YES_NO);
+
+// If "No" then just return
+if (aQueryBox->Execute() == RET_NO)
+return;
+
+// Remove data table
+rModel.removeDataProviders();
+
+// Ask parent document to create new data provider
+css::uno::Reference< com::sun::star::chart2::XDataProviderCreator > 
xCreatorDoc(
+rModel.getParent(), uno::UNO_QUERY );
+OSL_ENSURE( xCreatorDoc.is(), "Invalid XDataProviderCreator" );
+
+if ( xCreatorDoc.is() )
 {
-impl_adaptDataSeriesAutoResize();
-aUndoGuard.commit();
+uno::Reference< data::XDataProvider > xDataProvider = 
xCreatorDoc->createDataProvider();
+OSL_ENSURE( xCreatorDoc.is(), "Data provider was not created" );
+if ( xDataProvider.is() )
+{
+rModel.attachDataProvider(xDataProvider);
+}
 }
 }
+
+UndoLiveUpdateGuard aUndoGuard(
+SchResId(STR_ACTION_EDIT_DATA_RANGES), m_xUndoManager);
+
+SolarMutexGuard aSolarGuard;
+ScopedVclPtrInstance< ::chart::DataSourceDialog > aDlg( m_pChartWindow, 
xChartDoc, m_xCC );
+if( aDlg->Execute() == RET_OK )
+{
+impl_adaptDataSeriesAutoResize();
+aUndoGuard.commit();
+}
 }
 
 void 

[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - chart2/inc chart2/source offapi/com offapi/UnoApi_offapi.mk sc/inc sc/source

2017-12-22 Thread Vasily Melenchuk
 chart2/inc/ChartModel.hxx   |2 
 chart2/source/controller/dialogs/Strings.src|5 +
 chart2/source/controller/main/ChartController.cxx   |   53 ++--
 chart2/source/controller/main/ControllerCommandDispatch.cxx |   17 +++
 chart2/source/inc/Strings.hrc   |4 
 chart2/source/model/main/ChartModel.cxx |8 +
 offapi/UnoApi_offapi.mk |1 
 offapi/com/sun/star/chart2/XDataProviderCreator.idl |   50 +++
 sc/inc/docuno.hxx   |7 +
 sc/source/ui/unoobj/docuno.cxx  |   15 +++
 10 files changed, 151 insertions(+), 11 deletions(-)

New commits:
commit 43d52c3840202fa2b24c47744c11bb436ab7d3e9
Author: Vasily Melenchuk 
Date:   Fri Nov 10 18:37:25 2017 +0300

tdf#113572: allow switching to data range in copypasted chart

- enable data range toolbar button for charts with internal
  data table and possiblilty to switch to data range
- show warning before destoying data table
- recreation of data provider

Conflicts:
chart2/inc/ChartModel.hxx
chart2/inc/strings.hrc
chart2/source/controller/main/ChartController.cxx
chart2/source/controller/main/ControllerCommandDispatch.cxx
sc/source/ui/unoobj/docuno.cxx

Change-Id: I46c703b579cd32405b02543aa5b9e3a74e4b36b6
Reviewed-on: https://gerrit.libreoffice.org/46981
Reviewed-by: Thorsten Behrens 
Tested-by: Thorsten Behrens 

diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx
index b3caaad412c4..f254103e961f 100644
--- a/chart2/inc/ChartModel.hxx
+++ b/chart2/inc/ChartModel.hxx
@@ -579,6 +579,8 @@ public:
 void getNextTimePoint();
 void setTimeBasedRange(sal_Int32 nStart, sal_Int32 nEnd);
 
+void removeDataProviders();
+
 OpenGLWindow* getOpenGLWindow() { return mpOpenGLWindow;}
 
 private:
diff --git a/chart2/source/controller/dialogs/Strings.src 
b/chart2/source/controller/dialogs/Strings.src
index c9d18eb62391..96f7f5598b2a 100644
--- a/chart2/source/controller/dialogs/Strings.src
+++ b/chart2/source/controller/dialogs/Strings.src
@@ -34,6 +34,11 @@ String STR_DLG_STEPPED_LINE_PROPERTIES
 Text [ en-US ] = "Stepped Lines" ;
 };
 
+String STR_DLG_REMOVE_DATA_TABLE
+{
+Text [ en-US ] = "Do you want to delete data table and switch to data 
ranges?" ;
+};
+
 String STR_PAGE_CHARTTYPE
 {
 Text [ en-US ] = "Chart Type" ;
diff --git a/chart2/source/controller/main/ChartController.cxx 
b/chart2/source/controller/main/ChartController.cxx
index 8482c16a6513..f87f5c74f798 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -66,12 +66,14 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -1395,21 +1397,56 @@ void ChartController::executeDispatch_SourceData()
 //convert properties to ItemSet
 uno::Reference< XChartDocument >   xChartDoc( getModel(), uno::UNO_QUERY );
 OSL_ENSURE( xChartDoc.is(), "Invalid XChartDocument" );
-if( !xChartDoc.is())
+if( !xChartDoc.is() )
 return;
 
-UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard(
-SCH_RESSTR(STR_ACTION_EDIT_DATA_RANGES), m_xUndoManager );
-if( xChartDoc.is())
+// If there is a data table we should ask user if we really want to 
destroy it
+// and switch to data ranges.
+ChartModel& rModel = dynamic_cast(*xChartDoc.get());
+if ( rModel.hasInternalDataProvider() )
 {
+// Check if we will able to create data provider later
+Reference< lang::XServiceInfo > xParentServiceInfo( 
rModel.getParent(), uno::UNO_QUERY );
+if ( !xParentServiceInfo.is() || 
!xParentServiceInfo->supportsService("com.sun.star.chart2.XDataProviderCreator")
 )
+return;
+
 SolarMutexGuard aSolarGuard;
-ScopedVclPtrInstance< ::chart::DataSourceDialog > aDlg( 
m_pChartWindow, xChartDoc, m_xCC );
-if( aDlg->Execute() == RET_OK )
+
+ScopedVclPtrInstance< MessageDialog > aQueryBox( m_pChartWindow, 
SchResId( STR_DLG_REMOVE_DATA_TABLE ), VCL_MESSAGE_QUESTION, 
VCL_BUTTONS_YES_NO);
+
+// If "No" then just return
+if (aQueryBox->Execute() == RET_NO)
+return;
+
+// Remove data table
+rModel.removeDataProviders();
+
+// Ask parent document to create new data provider
+css::uno::Reference< com::sun::star::chart2::XDataProviderCreator > 
xCreatorDoc(
+rModel.getParent(), uno::UNO_QUERY );
+OSL_ENSURE( xCreatorDoc.is(), "Invalid XDataProviderCreator" );
+
+if ( xCreatorDoc.is() )
 {
-