summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-06-09 14:32:53 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-06-10 10:04:14 -0400
commit486bf19009d2c737dd7bb822f534aaa47dbe9d6e (patch)
treef3f1283d0bdd509cd9374136f0590a033caac6eb
parent713c639ce5ba6371e9c0d9ff51be7cf4c68d3d4c (diff)
fdo#79676: Initialize with a default chart only from the UI.
When creating an embedded chart object during import, we don't want to create a default chart which would only mess up the chart data. With this change, ChartModel::initNew() is a no-op. Change-Id: Id29659c3885ec1e06bed26d2c851123fb63072cc (cherry picked from commit c5539bb585370f095cb6c09e38a7dd005d237295)
-rw-r--r--chart2/inc/ChartModel.hxx4
-rw-r--r--chart2/source/model/main/ChartModel.cxx6
-rw-r--r--chart2/source/model/main/ChartModel_Persistence.cxx16
-rw-r--r--offapi/com/sun/star/chart2/XChartDocument.idl4
-rw-r--r--sc/source/ui/drawfunc/fuins2.cxx5
-rw-r--r--sd/source/ui/func/fuinsert.cxx10
-rw-r--r--sw/source/core/uibase/table/tablemgr.cxx8
7 files changed, 47 insertions, 6 deletions
diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx
index 9fb24fef2414..d8367ff31afa 100644
--- a/chart2/inc/ChartModel.hxx
+++ b/chart2/inc/ChartModel.hxx
@@ -223,6 +223,8 @@ private:
void impl_adjustAdditionalShapesPositionAndSize(
const ::com::sun::star::awt::Size& aVisualAreaSize );
+ void insertDefaultChart();
+
public:
//no default constructor
ChartModel(::com::sun::star::uno::Reference<
@@ -434,6 +436,8 @@ public:
getPageBackground()
throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual void SAL_CALL createDefaultChart() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
// ____ XDataReceiver (public API) ____
virtual void SAL_CALL
attachDataProvider( const ::com::sun::star::uno::Reference<
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index c61e83cf4f8b..504db8c6d605 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -958,6 +958,12 @@ uno::Reference< beans::XPropertySet > SAL_CALL ChartModel::getPageBackground()
return m_xPageBackground;
}
+void SAL_CALL ChartModel::createDefaultChart()
+ throw (css::uno::RuntimeException, std::exception)
+{
+ insertDefaultChart();
+}
+
// ____ XTitled ____
uno::Reference< chart2::XTitle > SAL_CALL ChartModel::getTitleObject()
throw (uno::RuntimeException, std::exception)
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx
index 80ddf7ae4fd4..d3bfec237609 100644
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -381,12 +381,7 @@ void ChartModel::impl_store(
}
}
-// frame::XLoadable
-void SAL_CALL ChartModel::initNew()
- throw (frame::DoubleInitializationException,
- io::IOException,
- uno::Exception,
- uno::RuntimeException, std::exception)
+void ChartModel::insertDefaultChart()
{
lockControllers();
createInternalDataProvider( sal_False );
@@ -487,6 +482,15 @@ void SAL_CALL ChartModel::initNew()
#endif
}
+// frame::XLoadable
+void SAL_CALL ChartModel::initNew()
+ throw (frame::DoubleInitializationException,
+ io::IOException,
+ uno::Exception,
+ uno::RuntimeException, std::exception)
+{
+}
+
void SAL_CALL ChartModel::load(
const Sequence< beans::PropertyValue >& rMediaDescriptor )
throw (frame::DoubleInitializationException,
diff --git a/offapi/com/sun/star/chart2/XChartDocument.idl b/offapi/com/sun/star/chart2/XChartDocument.idl
index 217d7fa38109..0055cbb83fd2 100644
--- a/offapi/com/sun/star/chart2/XChartDocument.idl
+++ b/offapi/com/sun/star/chart2/XChartDocument.idl
@@ -123,6 +123,10 @@ interface XChartDocument : ::com::sun::star::frame::XModel
XDiagram::getWall().</p>
*/
com::sun::star::beans::XPropertySet getPageBackground();
+
+ /** Creates a default chart type for a brand-new chart object.
+ */
+ void createDefaultChart();
};
} ; // chart2
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index 4e7b0dc6fe05..6af4fc8248ac 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -55,6 +55,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/chart2/data/XDataProvider.hpp>
#include <com/sun/star/chart2/data/XDataReceiver.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/X3DChartWindowProvider.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
@@ -504,6 +505,10 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView*
if( xCompSupp.is())
xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
+ uno::Reference<chart2::XChartDocument> xChartDoc(xReceiver, uno::UNO_QUERY);
+ if (xChartDoc.is())
+ xChartDoc->createDefaultChart();
+
// lock the model to suppress any internal updates
uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY );
if( xChartModel.is() )
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index 88eb7af439e2..c16e6fc0e62b 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -25,6 +25,7 @@
#include <toolkit/helper/vclunohelper.hxx>
#include <svx/svxdlg.hxx>
#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+#include <com/sun/star/embed/XComponentSupplier.hpp>
#include <com/sun/star/embed/Aspects.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
@@ -289,6 +290,15 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
GetEmbeddedObjectContainer().CreateEmbeddedObject( aName.GetByteSequence(), aObjName );
if ( xObj.is() )
{
+ uno::Reference<embed::XComponentSupplier> xCompSupp(xObj, uno::UNO_QUERY);
+ if (xCompSupp.is())
+ {
+ // Create default chart type.
+ uno::Reference<chart2::XChartDocument> xChartDoc(xCompSupp->getComponent(), uno::UNO_QUERY);
+ if (xChartDoc.is())
+ xChartDoc->createDefaultChart();
+ }
+
sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
diff --git a/sw/source/core/uibase/table/tablemgr.cxx b/sw/source/core/uibase/table/tablemgr.cxx
index 280f76d86f54..8f5ca04fc678 100644
--- a/sw/source/core/uibase/table/tablemgr.cxx
+++ b/sw/source/core/uibase/table/tablemgr.cxx
@@ -20,6 +20,7 @@
#include <com/sun/star/chart/ChartDataRowSource.hpp>
#include <com/sun/star/chart2/data/XDataProvider.hpp>
#include <com/sun/star/chart2/data/XDataReceiver.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/beans/PropertyState.hpp>
#include <sot/storage.hxx>
@@ -229,7 +230,14 @@ uno::Reference< frame::XModel > SwTableFUNC::InsertChart(
{
xChartModel.set( xCompSupp->getComponent(), uno::UNO_QUERY );
if( xChartModel.is() )
+ {
+ // Create a default chart type.
+ uno::Reference<chart2::XChartDocument> xChartDoc(xChartModel, uno::UNO_QUERY);
+ if (xChartDoc.is())
+ xChartDoc->createDefaultChart();
+
xChartModel->lockControllers(); //#i79578# don't request a new replacement image for charts to often - block change notifications
+ }
}
// set the table name at the OLE-node