Blame SOURCES/0023-fdo-79676-Initialize-with-a-default-chart-only-from-.patch

f085be
From 0e3826d08d7a7d54dd532319fb584008eb0e24c8 Mon Sep 17 00:00:00 2001
f085be
From: Kohei Yoshida <kohei.yoshida@collabora.com>
f085be
Date: Mon, 9 Jun 2014 14:32:53 -0400
f085be
Subject: [PATCH 023/137] fdo#79676: Initialize with a default chart only from
f085be
 the UI.
f085be
f085be
When creating an embedded chart object during import, we don't want to
f085be
create a default chart which would only mess up the chart data.
f085be
f085be
With this change, ChartModel::initNew() is a no-op.
f085be
f085be
(cherry picked from commit c5539bb585370f095cb6c09e38a7dd005d237295)
f085be
Signed-off-by: Andras Timar <andras.timar@collabora.com>
f085be
f085be
Conflicts:
f085be
	chart2/source/model/main/ChartModel_Persistence.cxx
f085be
	sc/source/ui/drawfunc/fuins2.cxx
f085be
	sw/source/uibase/table/tablemgr.cxx
f085be
f085be
Change-Id: Id29659c3885ec1e06bed26d2c851123fb63072cc
f085be
(cherry picked from commit 1eccdc5c39587d4019cb4c88f8483b1fe14d5dda)
f085be
Signed-off-by: Andras Timar <andras.timar@collabora.com>
f085be
---
f085be
 chart2/inc/ChartModel.hxx                           |  4 ++++
f085be
 chart2/source/model/main/ChartModel.cxx             |  6 ++++++
f085be
 chart2/source/model/main/ChartModel_Persistence.cxx | 16 ++++++++++------
f085be
 offapi/com/sun/star/chart2/XChartDocument.idl       |  4 ++++
f085be
 sc/source/ui/drawfunc/fuins2.cxx                    |  5 +++++
f085be
 sd/source/ui/func/fuinsert.cxx                      | 10 ++++++++++
f085be
 sw/source/ui/table/tablemgr.cxx                     |  8 ++++++++
f085be
 7 files changed, 47 insertions(+), 6 deletions(-)
f085be
f085be
diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx
f085be
index c8f992a..028ce0e 100644
f085be
--- a/chart2/inc/ChartModel.hxx
f085be
+++ b/chart2/inc/ChartModel.hxx
f085be
@@ -221,6 +221,8 @@ private:
f085be
     void impl_adjustAdditionalShapesPositionAndSize(
f085be
         const ::com::sun::star::awt::Size& aVisualAreaSize );
f085be
 
f085be
+    void insertDefaultChart();
f085be
+
f085be
 public:
f085be
     //no default constructor
f085be
     ChartModel(::com::sun::star::uno::Reference<
f085be
@@ -432,6 +434,8 @@ public:
f085be
         getPageBackground()
f085be
             throw (::com::sun::star::uno::RuntimeException);
f085be
 
f085be
+    virtual void SAL_CALL createDefaultChart() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
f085be
+
f085be
     // ____ XDataReceiver (public API) ____
f085be
     virtual void SAL_CALL
f085be
         attachDataProvider( const ::com::sun::star::uno::Reference<
f085be
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
f085be
index c29a10e..170019f 100644
f085be
--- a/chart2/source/model/main/ChartModel.cxx
f085be
+++ b/chart2/source/model/main/ChartModel.cxx
f085be
@@ -947,6 +947,12 @@ uno::Reference< beans::XPropertySet > SAL_CALL ChartModel::getPageBackground()
f085be
     return m_xPageBackground;
f085be
 }
f085be
 
f085be
+void SAL_CALL ChartModel::createDefaultChart()
f085be
+    throw (css::uno::RuntimeException, std::exception)
f085be
+{
f085be
+    insertDefaultChart();
f085be
+}
f085be
+
f085be
 // ____ XTitled ____
f085be
 uno::Reference< chart2::XTitle > SAL_CALL ChartModel::getTitleObject()
f085be
     throw (uno::RuntimeException)
f085be
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx
f085be
index d964ced..5284ad2 100644
f085be
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
f085be
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
f085be
@@ -380,12 +380,7 @@ void ChartModel::impl_store(
f085be
     }
f085be
 }
f085be
 
f085be
-// frame::XLoadable
f085be
-void SAL_CALL ChartModel::initNew()
f085be
-    throw (frame::DoubleInitializationException,
f085be
-           io::IOException,
f085be
-           uno::Exception,
f085be
-           uno::RuntimeException)
f085be
+void ChartModel::insertDefaultChart()
f085be
 {
f085be
     lockControllers();
f085be
     createInternalDataProvider( sal_False );
f085be
@@ -486,6 +481,15 @@ void SAL_CALL ChartModel::initNew()
f085be
 #endif
f085be
 }
f085be
 
f085be
+// frame::XLoadable
f085be
+void SAL_CALL ChartModel::initNew()
f085be
+    throw (frame::DoubleInitializationException,
f085be
+           io::IOException,
f085be
+           uno::Exception,
f085be
+           uno::RuntimeException)
f085be
+{
f085be
+}
f085be
+
f085be
 void SAL_CALL ChartModel::load(
f085be
     const Sequence< beans::PropertyValue >& rMediaDescriptor )
f085be
     throw (frame::DoubleInitializationException,
f085be
diff --git a/offapi/com/sun/star/chart2/XChartDocument.idl b/offapi/com/sun/star/chart2/XChartDocument.idl
f085be
index 217d7fa..0055cbb 100644
f085be
--- a/offapi/com/sun/star/chart2/XChartDocument.idl
f085be
+++ b/offapi/com/sun/star/chart2/XChartDocument.idl
f085be
@@ -123,6 +123,10 @@ interface XChartDocument : ::com::sun::star::frame::XModel
f085be
         XDiagram::getWall().

f085be
      */
f085be
     com::sun::star::beans::XPropertySet getPageBackground();
f085be
+
f085be
+    /** Creates a default chart type for a brand-new chart object.
f085be
+     */
f085be
+    void createDefaultChart();
f085be
 };
f085be
 
f085be
 } ; // chart2
f085be
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
f085be
index 9db9ac9..787b58b 100644
f085be
--- a/sc/source/ui/drawfunc/fuins2.cxx
f085be
+++ b/sc/source/ui/drawfunc/fuins2.cxx
f085be
@@ -55,6 +55,7 @@
f085be
 #include <com/sun/star/beans/PropertyValue.hpp>
f085be
 #include <com/sun/star/chart2/data/XDataProvider.hpp>
f085be
 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
f085be
+#include <com/sun/star/chart2/XChartDocument.hpp>
f085be
 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
f085be
 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
f085be
 #include <com/sun/star/lang/XInitialization.hpp>
f085be
@@ -502,6 +503,10 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
f085be
         if( xCompSupp.is())
f085be
             xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
f085be
 
f085be
+        uno::Reference<chart2::XChartDocument> xChartDoc(xReceiver, uno::UNO_QUERY);
f085be
+        if (xChartDoc.is())
f085be
+            xChartDoc->createDefaultChart();
f085be
+
f085be
         // lock the model to suppress any internal updates
f085be
         uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY );
f085be
         if( xChartModel.is() )
f085be
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
f085be
index 886be34..1606c33 100644
f085be
--- a/sd/source/ui/func/fuinsert.cxx
f085be
+++ b/sd/source/ui/func/fuinsert.cxx
f085be
@@ -25,6 +25,7 @@
f085be
 #include <toolkit/helper/vclunohelper.hxx>
f085be
 #include <svx/svxdlg.hxx>
f085be
 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
f085be
+#include <com/sun/star/embed/XComponentSupplier.hpp>
f085be
 #include <com/sun/star/embed/Aspects.hpp>
f085be
 #include <com/sun/star/beans/XPropertySet.hpp>
f085be
 #include <com/sun/star/chart2/XChartDocument.hpp>
f085be
@@ -274,6 +275,15 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
f085be
                 GetEmbeddedObjectContainer().CreateEmbeddedObject( aName.GetByteSequence(), aObjName );
f085be
         if ( xObj.is() )
f085be
         {
f085be
+            uno::Reference<embed::XComponentSupplier> xCompSupp(xObj, uno::UNO_QUERY);
f085be
+            if (xCompSupp.is())
f085be
+            {
f085be
+                // Create default chart type.
f085be
+                uno::Reference<chart2::XChartDocument> xChartDoc(xCompSupp->getComponent(), uno::UNO_QUERY);
f085be
+                if (xChartDoc.is())
f085be
+                    xChartDoc->createDefaultChart();
f085be
+            }
f085be
+
f085be
             sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
f085be
 
f085be
             MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
f085be
diff --git a/sw/source/ui/table/tablemgr.cxx b/sw/source/ui/table/tablemgr.cxx
f085be
index 947e3dd..26871ee 100644
f085be
--- a/sw/source/ui/table/tablemgr.cxx
f085be
+++ b/sw/source/ui/table/tablemgr.cxx
f085be
@@ -21,6 +21,7 @@
f085be
 #include <com/sun/star/chart/ChartDataRowSource.hpp>
f085be
 #include <com/sun/star/chart2/data/XDataProvider.hpp>
f085be
 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
f085be
+#include <com/sun/star/chart2/XChartDocument.hpp>
f085be
 #include <com/sun/star/beans/PropertyState.hpp>
f085be
 
f085be
 #include <sot/storage.hxx>
f085be
@@ -243,7 +244,14 @@ uno::Reference< frame::XModel > SwTableFUNC::InsertChart(
f085be
         {
f085be
             xChartModel.set( xCompSupp->getComponent(), uno::UNO_QUERY );
f085be
             if( xChartModel.is() )
f085be
+            {
f085be
+                // Create a default chart type.
f085be
+                uno::Reference<chart2::XChartDocument> xChartDoc(xChartModel, uno::UNO_QUERY);
f085be
+                if (xChartDoc.is())
f085be
+                    xChartDoc->createDefaultChart();
f085be
+
f085be
                 xChartModel->lockControllers(); //#i79578# don't request a new replacement image for charts to often - block change notifications
f085be
+            }
f085be
         }
f085be
 
f085be
         // set the table name at the OLE-node
f085be
-- 
f085be
1.9.3
f085be