[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.2' - 2 commits - chart2/inc chart2/source offapi/com qadevOOo/runner sc/source sd/source sfx2/qa sw/source

Kohei Yoshida kohei.yoshida at collabora.com
Tue Jun 10 07:51:34 PDT 2014


 chart2/inc/ChartModel.hxx                           |    4 ++++
 chart2/source/model/main/ChartModel.cxx             |    6 ++++++
 chart2/source/model/main/ChartModel_Persistence.cxx |   16 ++++++++++------
 offapi/com/sun/star/chart2/XChartDocument.idl       |    4 ++++
 qadevOOo/runner/util/SOfficeFactory.java            |    9 +++++++--
 sc/source/ui/drawfunc/fuins2.cxx                    |    5 +++++
 sd/source/ui/func/fuinsert.cxx                      |   10 ++++++++++
 sfx2/qa/complex/sfx2/undo/ChartDocumentTest.java    |    4 ++++
 sw/source/ui/table/tablemgr.cxx                     |    8 ++++++++
 9 files changed, 58 insertions(+), 8 deletions(-)

New commits:
commit 90ffbc8582ec1a6edc647b8ab222e60e6dedc66f
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Jun 10 09:36:54 2014 -0400

    fdo#79676: Fix the Java UNO API test with regard to chart tests.
    
    The Java tests rely on the "undocumented" behavior that, when loading an empty
    chart document, the chart automaticallly created a "default chart" which is a
    column chart with many of its properties filled.  Unfortunately this behavior
    caused ugly side effects when loading documents with charts via flat ODF
    filter.
    
    I believe fixing the test this way is the right fix.
    
    Change-Id: If3e6c8979da9d0731346ebeedc23c0d3363e83fd
    (cherry picked from commit d44b58beed743871df03909e7d9545e488f3d7c8)

diff --git a/qadevOOo/runner/util/SOfficeFactory.java b/qadevOOo/runner/util/SOfficeFactory.java
index 2a0f0ed..f464ea8 100644
--- a/qadevOOo/runner/util/SOfficeFactory.java
+++ b/qadevOOo/runner/util/SOfficeFactory.java
@@ -225,7 +225,12 @@ public class SOfficeFactory {
 
         if (oDoc != null) {
             DesktopTools.bringWindowToFront(oDoc);
-            return UnoRuntime.queryInterface(XChartDocument.class, oDoc);
+            XChartDocument xChartDoc = UnoRuntime.queryInterface(XChartDocument.class, oDoc);
+            // Create a default chart which many chart tests rely on.
+            com.sun.star.chart2.XChartDocument xCD2 =
+                UnoRuntime.queryInterface(com.sun.star.chart2.XChartDocument.class, oDoc);
+            xCD2.createDefaultChart();
+            return xChartDoc;
         } else {
             return null;
         }
@@ -616,4 +621,4 @@ public class SOfficeFactory {
         }
         return null;
     } // finish queryXServiceInfo
-}
\ No newline at end of file
+}
diff --git a/sfx2/qa/complex/sfx2/undo/ChartDocumentTest.java b/sfx2/qa/complex/sfx2/undo/ChartDocumentTest.java
index 3eb7d4e..75981d7 100644
--- a/sfx2/qa/complex/sfx2/undo/ChartDocumentTest.java
+++ b/sfx2/qa/complex/sfx2/undo/ChartDocumentTest.java
@@ -74,6 +74,10 @@ public class ChartDocumentTest implements DocumentTest
 
         // retrieve the chart model
         XChartDocument chartDoc = UnoRuntime.queryInterface( XChartDocument.class, shapeProps.getPropertyValue( "Model" ) );
+        // insert default chart for the test to use.
+        com.sun.star.chart2.XChartDocument xCD2 =
+            UnoRuntime.queryInterface(com.sun.star.chart2.XChartDocument.class, chartDoc);
+        xCD2.createDefaultChart();
         m_chartDocument = new OfficeDocument( i_orb, chartDoc );
 
         // actually activate the object
commit 1eccdc5c39587d4019cb4c88f8483b1fe14d5dda
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Jun 9 14:32:53 2014 -0400

    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.
    
    (cherry picked from commit c5539bb585370f095cb6c09e38a7dd005d237295)
    
    Conflicts:
    	chart2/source/model/main/ChartModel_Persistence.cxx
    	sc/source/ui/drawfunc/fuins2.cxx
    	sw/source/uibase/table/tablemgr.cxx
    
    Change-Id: Id29659c3885ec1e06bed26d2c851123fb63072cc

diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx
index c8f992a..028ce0e 100644
--- a/chart2/inc/ChartModel.hxx
+++ b/chart2/inc/ChartModel.hxx
@@ -221,6 +221,8 @@ private:
     void impl_adjustAdditionalShapesPositionAndSize(
         const ::com::sun::star::awt::Size& aVisualAreaSize );
 
+    void insertDefaultChart();
+
 public:
     //no default constructor
     ChartModel(::com::sun::star::uno::Reference<
@@ -432,6 +434,8 @@ public:
         getPageBackground()
             throw (::com::sun::star::uno::RuntimeException);
 
+    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 c29a10e..170019f 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -947,6 +947,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)
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx
index d964ced..5284ad2 100644
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -380,12 +380,7 @@ void ChartModel::impl_store(
     }
 }
 
-// frame::XLoadable
-void SAL_CALL ChartModel::initNew()
-    throw (frame::DoubleInitializationException,
-           io::IOException,
-           uno::Exception,
-           uno::RuntimeException)
+void ChartModel::insertDefaultChart()
 {
     lockControllers();
     createInternalDataProvider( sal_False );
@@ -486,6 +481,15 @@ void SAL_CALL ChartModel::initNew()
 #endif
 }
 
+// frame::XLoadable
+void SAL_CALL ChartModel::initNew()
+    throw (frame::DoubleInitializationException,
+           io::IOException,
+           uno::Exception,
+           uno::RuntimeException)
+{
+}
+
 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 217d7fa..0055cbb 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 3060fda..3471cdd 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/ui/dialogs/XExecutableDialog.hpp>
 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
@@ -502,6 +503,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 9f50702..15eb9f1 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>
@@ -274,6 +275,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/ui/table/tablemgr.cxx b/sw/source/ui/table/tablemgr.cxx
index 947e3dd..26871ee 100644
--- a/sw/source/ui/table/tablemgr.cxx
+++ b/sw/source/ui/table/tablemgr.cxx
@@ -21,6 +21,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>
@@ -243,7 +244,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


More information about the Libreoffice-commits mailing list