[Libreoffice-commits] core.git: 3 commits - chart2/CppunitTest_chart2_exporttest.mk chart2/Module_chart2.mk chart2/qa oox/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Wed May 1 11:31:26 PDT 2013
chart2/CppunitTest_chart2_exporttest.mk | 119 ++++++++++++++++++++++
chart2/Module_chart2.mk | 2
chart2/qa/extras/chart2export.cxx | 99 ++++++++++++++++++
chart2/qa/extras/charttest.hxx | 23 ++++
chart2/qa/extras/data/ods/error_bar.ods |binary
chart2/qa/extras/data/ods/simple_export_chart.ods |binary
oox/source/export/chartexport.cxx | 5
7 files changed, 246 insertions(+), 2 deletions(-)
New commits:
commit 3dc2f24a5db4b116802dd70cd2b6765ea9c63b6e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed May 1 20:22:08 2013 +0200
we need to exclude scatter chart for data label export for now
Excel does not like our data label export and removes the charts during
import. I could not figure out what is wrong as the files are valid.
Change-Id: I92458803a48bff1436e7c47ca29d27e487c0642b
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 660455d..11a79fc 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -1527,7 +1527,10 @@ void ChartExport::exportSeries( Reference< chart2::XChartType > xChartType, sal_
}
// export data labels
- exportDataLabels( uno::Reference< beans::XPropertySet >( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ), nSeriesLength );
+ // Excel does not like our current data label export
+ // for scatter charts
+ if( eChartType != chart::TYPEID_SCATTER )
+ exportDataLabels( uno::Reference< beans::XPropertySet >( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ), nSeriesLength );
// export data points
exportDataPoints( uno::Reference< beans::XPropertySet >( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ), nSeriesLength );
commit 6ed88e6d4d61394aed2acd45777f8f037da53d58
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed May 1 20:18:58 2013 +0200
add test for ooxml error bar export
Change-Id: I87f99c8d47770181c3f29c70f1f91a1f3dd421b5
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index d17416f..ca7105c 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -9,13 +9,20 @@
#include "charttest.hxx"
+#include <com/sun/star/chart/ErrorBarStyle.hpp>
+
+using uno::Reference;
+using beans::XPropertySet;
+
class Chart2ExportTest : public ChartTest
{
public:
void test();
+ void testErrorBarXLSX();
CPPUNIT_TEST_SUITE(Chart2ExportTest);
CPPUNIT_TEST(test);
+ CPPUNIT_TEST(testErrorBarXLSX);
CPPUNIT_TEST_SUITE_END();
private:
@@ -27,6 +34,64 @@ void Chart2ExportTest::test()
reload("Calc Office Open XML");
}
+namespace {
+
+void testErrorBar( Reference< XPropertySet > xErrorBar )
+{
+ sal_Int32 nErrorBarStyle;
+ xErrorBar->getPropertyValue("ErrorBarStyle") >>= nErrorBarStyle;
+ CPPUNIT_ASSERT_EQUAL(nErrorBarStyle, chart::ErrorBarStyle::RELATIVE);
+ bool bShowPositive, bShowNegative;
+ xErrorBar->getPropertyValue("ShowPositiveError") >>= bShowPositive;
+ CPPUNIT_ASSERT(bShowPositive);
+ xErrorBar->getPropertyValue("ShowNegativeError") >>= bShowNegative;
+ CPPUNIT_ASSERT(bShowNegative);
+ double nVal;
+ xErrorBar->getPropertyValue("PositiveError") >>= nVal;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(nVal, 10.0, 1e-10);
+}
+
+}
+
+// improve the test
+void Chart2ExportTest::testErrorBarXLSX()
+{
+ load("/chart2/qa/extras/data/ods/", "error_bar.ods");
+ {
+ // make sure the ODS import was successful
+ uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ Reference< chart2::XDataSeries > xDataSeries = getDataSeriesFromDoc( xChartDoc, 0 );
+ CPPUNIT_ASSERT( xDataSeries.is() );
+
+ Reference< beans::XPropertySet > xPropSet( xDataSeries, UNO_QUERY_THROW );
+ CPPUNIT_ASSERT( xPropSet.is() );
+
+ // test that y error bars are there
+ Reference< beans::XPropertySet > xErrorBarYProps;
+ xPropSet->getPropertyValue("ErrorBarY") >>= xErrorBarYProps;
+ testErrorBar(xErrorBarYProps);
+ }
+
+ reload("Calc Office Open XML");
+ {
+ uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ Reference< chart2::XDataSeries > xDataSeries = getDataSeriesFromDoc( xChartDoc, 0 );
+ CPPUNIT_ASSERT( xDataSeries.is() );
+
+ Reference< beans::XPropertySet > xPropSet( xDataSeries, UNO_QUERY_THROW );
+ CPPUNIT_ASSERT( xPropSet.is() );
+
+ // test that y error bars are there
+ Reference< beans::XPropertySet > xErrorBarYProps;
+ xPropSet->getPropertyValue("ErrorBarY") >>= xErrorBarYProps;
+ testErrorBar(xErrorBarYProps);
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/ods/error_bar.ods b/chart2/qa/extras/data/ods/error_bar.ods
new file mode 100644
index 0000000..9c3adbb
Binary files /dev/null and b/chart2/qa/extras/data/ods/error_bar.ods differ
commit 14c2ab30201d97f733375b4e3e88e5919701be25
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed May 1 19:30:04 2013 +0200
add export test for charts
Change-Id: I176f7967d37f3032057758d9aaa5f39c46d29c3d
diff --git a/chart2/CppunitTest_chart2_exporttest.mk b/chart2/CppunitTest_chart2_exporttest.mk
new file mode 100644
index 0000000..0c0e025
--- /dev/null
+++ b/chart2/CppunitTest_chart2_exporttest.mk
@@ -0,0 +1,119 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,chart2_export))
+
+$(eval $(call gb_CppunitTest_use_external,chart2_export,boost_headers))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,chart2_export, \
+ chart2/qa/extras/chart2export \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,chart2_export, \
+ avmedia \
+ basegfx \
+ comphelper \
+ cppu \
+ cppuhelper \
+ drawinglayer \
+ editeng \
+ fileacc \
+ for \
+ forui \
+ i18nlangtag \
+ msfilter \
+ oox \
+ sal \
+ salhelper \
+ sax \
+ sb \
+ sc \
+ sfx \
+ sot \
+ svl \
+ svt \
+ svx \
+ svxcore \
+ test \
+ tl \
+ tk \
+ ucbhelper \
+ unotest \
+ utl \
+ vbahelper \
+ vcl \
+ xo \
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_set_include,chart2_export,\
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,chart2_export,\
+ offapi \
+ udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,chart2_export))
+
+$(eval $(call gb_CppunitTest_use_components,chart2_export,\
+ basic/util/sb \
+ chart2/source/controller/chartcontroller \
+ chart2/source/chartcore \
+ comphelper/util/comphelp \
+ configmgr/source/configmgr \
+ dbaccess/util/dba \
+ embeddedobj/util/embobj \
+ eventattacher/source/evtatt \
+ fileaccess/source/fileacc \
+ filter/source/config/cache/filterconfig1 \
+ forms/util/frm \
+ framework/util/fwk \
+ i18npool/util/i18npool \
+ linguistic/source/lng \
+ oox/util/oox \
+ package/source/xstor/xstor \
+ package/util/package2 \
+ sax/source/expatwrap/expwrap \
+ sax/source/fastparser/fastsax \
+ sc/util/sc \
+ sc/util/scd \
+ sc/util/scfilt \
+ $(if $(filter TRUE,$(DISABLE_SCRIPTING)),, \
+ sc/util/vbaobj) \
+ scaddins/source/analysis/analysis \
+ scaddins/source/datefunc/date \
+ scripting/source/basprov/basprov \
+ scripting/util/scriptframe \
+ sfx2/util/sfx \
+ sot/util/sot \
+ svl/source/fsstor/fsstorage \
+ svl/util/svl \
+ svtools/util/svt \
+ svx/util/svx \
+ toolkit/util/tk \
+ ucb/source/core/ucb1 \
+ ucb/source/ucp/file/ucpfile1 \
+ ucb/source/ucp/tdoc/ucptdoc1 \
+ unotools/util/utl \
+ unoxml/source/rdf/unordf \
+ unoxml/source/service/unoxml \
+ xmloff/util/xo \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,chart2_export))
+
+$(eval $(call gb_CppunitTest_use_filter_configuration,chart2_export))
+
+$(eval $(call gb_CppunitTest_use_unittest_configuration,chart2_export))
+
+# vim: set noet sw=4 ts=4:
diff --git a/chart2/Module_chart2.mk b/chart2/Module_chart2.mk
index 13e9f3b..3dacc4c 100644
--- a/chart2/Module_chart2.mk
+++ b/chart2/Module_chart2.mk
@@ -17,7 +17,7 @@ $(eval $(call gb_Module_add_targets,chart2,\
))
$(eval $(call gb_Module_add_slowcheck_targets,chart2,\
- CppunitTest_chart2_importtest \
+ CppunitTest_chart2_exporttest \
))
$(eval $(call gb_Module_add_subsequentcheck_targets,chart2,\
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
new file mode 100644
index 0000000..d17416f
--- /dev/null
+++ b/chart2/qa/extras/chart2export.cxx
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "charttest.hxx"
+
+class Chart2ExportTest : public ChartTest
+{
+public:
+ void test();
+
+ CPPUNIT_TEST_SUITE(Chart2ExportTest);
+ CPPUNIT_TEST(test);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+};
+
+void Chart2ExportTest::test()
+{
+ load("/chart2/qa/extras/data/ods/", "simple_export_chart.ods");
+ reload("Calc Office Open XML");
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx
index e4968f1..8fe76e2 100644
--- a/chart2/qa/extras/charttest.hxx
+++ b/chart2/qa/extras/charttest.hxx
@@ -22,6 +22,10 @@
#include <com/sun/star/table/XTableChart.hpp>
#include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#include <unotools/tempfile.hxx>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/XDiagram.hpp>
@@ -30,6 +34,8 @@
#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
+#include <iostream>
+
using namespace com::sun::star;
using namespace com::sun::star::uno;
@@ -37,6 +43,7 @@ class ChartTest : public test::BootstrapFixture, public unotest::MacrosTest
{
public:
void load( const char* pDir, const char* pName );
+ void reload( const OUString& rFilterName );
virtual void setUp();
virtual void tearDown();
@@ -50,6 +57,22 @@ void ChartTest::load( const char* pDir, const char* pName )
CPPUNIT_ASSERT(mxComponent.is());
}
+void ChartTest::reload(const OUString& rFilterName)
+{
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aArgs(1);
+ aArgs[0].Name = "FilterName";
+ aArgs[0].Value <<= rFilterName;
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ xStorable->storeToURL(aTempFile.GetURL(), aArgs);
+ uno::Reference<lang::XComponent> xComponent(xStorable, uno::UNO_QUERY);
+ xComponent->dispose();
+ mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.sheet.SpreadsheetDocument");
+ std::cout << aTempFile.GetURL();
+ CPPUNIT_ASSERT(mxComponent.is());
+}
+
void ChartTest::setUp()
{
test::BootstrapFixture::setUp();
diff --git a/chart2/qa/extras/data/ods/simple_export_chart.ods b/chart2/qa/extras/data/ods/simple_export_chart.ods
new file mode 100644
index 0000000..b944c36
Binary files /dev/null and b/chart2/qa/extras/data/ods/simple_export_chart.ods differ
More information about the Libreoffice-commits
mailing list