chart2/CppunitTest_chart2_export.mk | 16 +++ chart2/qa/extras/chart2export.cxx | 34 ++++++++ chart2/qa/extras/charttest.hxx | 93 ++++++++++++++++++++++ chart2/qa/extras/data/odt/scatter-plot-labels.odt |binary sc/inc/unonames.hxx | 2 sc/source/ui/unoobj/chart2uno.cxx | 14 +++ sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 5 - xmloff/source/chart/SchXMLExport.cxx | 41 +++++---- 8 files changed, 184 insertions(+), 21 deletions(-)
New commits: commit 6e31feb0f09f2dc9a9cd10e77ef884e000e1b32b Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Thu Jun 12 11:24:30 2014 -0400 fdo#77506: More reliable way to determine label strings. Not beautiful, but doable. Change-Id: I6f3b00d620e7d7d19cc05ec4239deeb14d0d5201 (cherry picked from commit a2a1a59a448420a858724371c4a339f75ebe8c1e) diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index ca7a28c..aaead41 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -654,6 +654,8 @@ #define SC_UNONAME_INCLUDEHIDDENCELLS "IncludeHiddenCells" #define SC_UNONAME_HIDDENVALUES "HiddenValues" #define SC_UNONAME_USE_INTERNAL_DATA_PROVIDER "UseInternalDataProvider" +#define SC_UNONAME_HAS_STRING_LABEL "HasStringLabel" +#define SC_UNONAME_TIME_BASED "TimeBased" // Solver #define SC_UNONAME_TIMEOUT "Timeout" diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 4792d86..3b2b1ba 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -3530,10 +3530,22 @@ uno::Any SAL_CALL ScChart2DataSequence::getPropertyValue(const OUString& rProper BuildDataCache(); aRet <<= m_aHiddenValues; } - else if (rPropertyName == "TimeBased") + else if (rPropertyName == SC_UNONAME_TIME_BASED) { aRet <<= mbTimeBased; } + else if (rPropertyName == SC_UNONAME_HAS_STRING_LABEL) + { + // Read-only property. It returns whether or not the label value is a + // direct user input, rather than an indirect reference. + bool bHasStringLabel = false; + if (m_pTokens->size() == 1) + { + const ScToken& rToken = *(*m_pTokens)[0]; + bHasStringLabel = rToken.GetType() == formula::svString; + } + aRet <<= bHasStringLabel; + } else throw beans::UnknownPropertyException(); // TODO: support optional properties diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index cfd0c1f..dfa4d0dc 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -2572,7 +2572,6 @@ void SchXMLExportHelper_Impl::exportSeries( OUString aFirstXDomainRange; OUString aFirstYDomainRange; - bool modifyLabelRange = false; std::vector< XMLPropertyState > aPropertyStates; @@ -2718,28 +2717,36 @@ void SchXMLExportHelper_Impl::exportSeries( // #i75297# allow empty series, export empty range to have all ranges on import mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, OUString()); - if( xLabelSeq.is()) { - OUString aRange = xLabelSeq->getSourceRangeRepresentation(); - if ( nSeriesIdx == 0 && aRange.equalsAscii("label 1")) - modifyLabelRange = true; - if (modifyLabelRange) - aRange = "label " + OUString::number(aRange.copy( OUString("label").getLength()).toInt32() - 1); - - OUString aXMLRange = lcl_ConvertRange( aRange, xNewDoc ); - if(aXMLRange.isEmpty() && !aRange.isEmpty()) + if (xLabelSeq.is()) + { + // Check if the label is direct string value rather than a reference. + bool bHasString = false; + uno::Reference<beans::XPropertySet> xLSProp(xLabelSeq, uno::UNO_QUERY); + if (xLSProp.is()) { - // might just be a string - bool bIsString = isString(aRange); - if(bIsString) + try { - mrExport.AddAttribute( XML_NAMESPACE_LO_EXT, - XML_LABEL_STRING, aRange ); + xLSProp->getPropertyValue("HasStringLabel") >>= bHasString; } + catch (const beans::UnknownPropertyException&) {} + } + + OUString aRange = xLabelSeq->getSourceRangeRepresentation(); + + if (bHasString) + { + mrExport.AddAttribute( + XML_NAMESPACE_LO_EXT, XML_LABEL_STRING, aRange); } else - mrExport.AddAttribute( XML_NAMESPACE_CHART, - XML_LABEL_CELL_ADDRESS, aXMLRange ); + { + mrExport.AddAttribute( + XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, + lcl_ConvertRange( + xLabelSeq->getSourceRangeRepresentation(), xNewDoc)); + } } + if( xLabelSeq.is() || xValuesSeq.is() ) aSeriesLabelValuesPair = tLabelValuesDataPair( xLabelSeq, xValuesSeq ); commit 1f090934e9ddffe0c7c1aa491688a45e9ab0b08e Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Thu Jun 12 11:21:40 2014 -0400 fdo#77506: Enable this check. Change-Id: Ib4ad7c1a1583b9fde1a06dc8e355442f10bb9bec (cherry picked from commit 10f8d24540a4145af3ec629f7eb724849ca53d22) diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index 2d4713e..21a9ece 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -739,13 +739,11 @@ void Chart2ExportTest::testScatterPlotLabels() xCT = getChartTypeFromDoc(xChartDoc, 0, 0); CPPUNIT_ASSERT(xCT.is()); -#if 0 aLabels = getDataSeriesLabelsFromChartType(xCT); CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size()); CPPUNIT_ASSERT_EQUAL(OUString("a"), aLabels[0][0].get<OUString>()); CPPUNIT_ASSERT_EQUAL(OUString("b"), aLabels[1][0].get<OUString>()); CPPUNIT_ASSERT_EQUAL(OUString("c"), aLabels[2][0].get<OUString>()); -#endif } void Chart2ExportTest::testErrorBarDataRangeODS() diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx index 72af75a..7e260cc 100644 --- a/chart2/qa/extras/charttest.hxx +++ b/chart2/qa/extras/charttest.hxx @@ -298,7 +298,6 @@ std::vector<uno::Sequence<uno::Any> > getDataSeriesLabelsFromChartType( const Re Reference<chart2::XDataSeriesContainer> xDSCont(xCT, uno::UNO_QUERY); CPPUNIT_ASSERT(xDSCont.is()); Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aDataSeriesSeq.getLength()); std::vector<uno::Sequence<uno::Any> > aRet; for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i) commit 021aa5dff47712af36fffe7025b258355bf19a6c Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Wed Jun 11 15:36:36 2014 -0400 This assumption doesn't hold on all build environments. Change-Id: Ie1f56aed91e7cbfc59e254a111991f958e9a1607 (cherry picked from commit 61ad374e723d57d1bafb4131d6b78cca42a504ed) diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index a24c3ab..90d2680 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -2134,7 +2134,10 @@ DECLARE_OOXMLIMPORT_TEST(testFdo78883, "fdo78883.docx") uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); xCursor->jumpToLastPage(); - CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage()); + + // Check to make sure the document loaded. Note that the page number may + // be 1 or 2 depending on the environment. + CPPUNIT_ASSERT(xCursor->getPage() > sal_Int16(0)); } DECLARE_OOXMLIMPORT_TEST(testBnc875718, "bnc875718.docx") commit bd591a9480a769199e19e8c737e8645de5306ef8 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Wed Jun 11 11:45:14 2014 -0400 fdo#77506: (finally) write a unit test for this. I've switched from using a Draw document to Writer document due to some instability with Draw instance in our cppunit run. The bug is reproducible either way. The test is disabled for now, since the bug has yet to be fixed. (cherry picked from commit 56ca1b76963c44318a4f5577e15cfa5e7e1cd2a2) Conflicts: chart2/qa/extras/chart2export.cxx Change-Id: I49e0417e1ecbc70f40aab8531237ae98ae58bdd3 diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index 8ad51b6..2d4713e 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -83,7 +83,7 @@ public: CPPUNIT_TEST(testShapeFollowedByChart); CPPUNIT_TEST(testPieChartDataLabels); CPPUNIT_TEST(testSeriesIdxOrder); -// CPPUNIT_TEST(testScatterPlotLabels); TODO : This test crashes for some unknown reason. + CPPUNIT_TEST(testScatterPlotLabels); CPPUNIT_TEST(testErrorBarDataRangeODS); CPPUNIT_TEST(testChartCrash); CPPUNIT_TEST(testPieChartRotation); @@ -716,43 +716,36 @@ void Chart2ExportTest::testSeriesIdxOrder() void Chart2ExportTest::testScatterPlotLabels() { - load("/chart2/qa/extras/data/odg/", "scatter-plot-labels.odg"); - Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY); + load("/chart2/qa/extras/data/odt/", "scatter-plot-labels.odt"); + Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); CPPUNIT_ASSERT(xChartDoc.is()); Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0, 0); CPPUNIT_ASSERT(xCT.is()); - OUString aLabelRole = xCT->getRoleOfSequenceForSeriesLabel(); + // Make sure the original chart has 'a', 'b', 'c' as its data labels. + std::vector<uno::Sequence<uno::Any> > aLabels = getDataSeriesLabelsFromChartType(xCT); + CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size()); + CPPUNIT_ASSERT_EQUAL(OUString("a"), aLabels[0][0].get<OUString>()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), aLabels[1][0].get<OUString>()); + CPPUNIT_ASSERT_EQUAL(OUString("c"), aLabels[2][0].get<OUString>()); - Reference<chart2::XDataSeriesContainer> xDSCont(xCT, uno::UNO_QUERY); - CPPUNIT_ASSERT(xDSCont.is()); - Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aDataSeriesSeq.getLength()); + // Reload the doc and check again. The labels should not change. + reload("writer8"); - for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i) - { - uno::Reference<chart2::data::XDataSource> xDSrc(aDataSeriesSeq[i], uno::UNO_QUERY); - CPPUNIT_ASSERT(xDSrc.is()); - uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > aDataSeqs = xDSrc->getDataSequences(); - for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j) - { - Reference<chart2::data::XDataSequence> xValues = aDataSeqs[j]->getValues(); - CPPUNIT_ASSERT(xValues.is()); - Reference<beans::XPropertySet> xPropSet(xValues, uno::UNO_QUERY); - if (!xPropSet.is()) - continue; - - OUString aRoleName; - xPropSet->getPropertyValue("Role") >>= aRoleName; - if (aRoleName == aLabelRole) - { - // TODO : Check the data series labels. - } - } - } + xChartDoc.set(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + xCT = getChartTypeFromDoc(xChartDoc, 0, 0); + CPPUNIT_ASSERT(xCT.is()); - CPPUNIT_ASSERT(false); +#if 0 + aLabels = getDataSeriesLabelsFromChartType(xCT); + CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size()); + CPPUNIT_ASSERT_EQUAL(OUString("a"), aLabels[0][0].get<OUString>()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), aLabels[1][0].get<OUString>()); + CPPUNIT_ASSERT_EQUAL(OUString("c"), aLabels[2][0].get<OUString>()); +#endif } void Chart2ExportTest::testErrorBarDataRangeODS() diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx index 0b90f76..72af75a 100644 --- a/chart2/qa/extras/charttest.hxx +++ b/chart2/qa/extras/charttest.hxx @@ -64,6 +64,8 @@ public: uno::Reference<chart::XChartDocument> getChartDocFromDrawImpress( sal_Int32 nPage, sal_Int32 nShape ); + uno::Reference<chart::XChartDocument> getChartDocFromWriter( sal_Int32 nShape ); + virtual void setUp() SAL_OVERRIDE; virtual void tearDown() SAL_OVERRIDE; @@ -289,6 +291,46 @@ uno::Sequence < OUString > getWriterChartColumnDescriptions( Reference< lang::XC return seriesList; } +std::vector<uno::Sequence<uno::Any> > getDataSeriesLabelsFromChartType( const Reference<chart2::XChartType>& xCT ) +{ + OUString aLabelRole = xCT->getRoleOfSequenceForSeriesLabel(); + + Reference<chart2::XDataSeriesContainer> xDSCont(xCT, uno::UNO_QUERY); + CPPUNIT_ASSERT(xDSCont.is()); + Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aDataSeriesSeq.getLength()); + + std::vector<uno::Sequence<uno::Any> > aRet; + for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i) + { + uno::Reference<chart2::data::XDataSource> xDSrc(aDataSeriesSeq[i], uno::UNO_QUERY); + CPPUNIT_ASSERT(xDSrc.is()); + uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > aDataSeqs = xDSrc->getDataSequences(); + for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j) + { + Reference<chart2::data::XDataSequence> xValues = aDataSeqs[j]->getValues(); + CPPUNIT_ASSERT(xValues.is()); + Reference<beans::XPropertySet> xPropSet(xValues, uno::UNO_QUERY); + if (!xPropSet.is()) + continue; + + OUString aRoleName; + xPropSet->getPropertyValue("Role") >>= aRoleName; + if (aRoleName == aLabelRole) + { + Reference<chart2::data::XLabeledDataSequence> xLabel = aDataSeqs[j]; + CPPUNIT_ASSERT(xLabel.is()); + Reference<chart2::data::XDataSequence> xDS2 = xLabel->getLabel(); + CPPUNIT_ASSERT(xDS2.is()); + uno::Sequence<uno::Any> aData = xDS2->getData(); + aRet.push_back(aData); + } + } + } + + return aRet; +} + uno::Reference< chart::XChartDocument > ChartTest::getChartDocFromImpress( const char* pDir, const char* pName ) { mxComponent = loadFromDesktop(getURLFromSrc(pDir) + OUString::createFromAscii(pName), "com.sun.star.comp.Draw.PresentationDocument"); @@ -334,6 +376,25 @@ uno::Reference<chart::XChartDocument> ChartTest::getChartDocFromDrawImpress( return xChartDoc; } +uno::Reference<chart::XChartDocument> ChartTest::getChartDocFromWriter( sal_Int32 nShape ) +{ + Reference<drawing::XDrawPageSupplier> xPageSupp(mxComponent, uno::UNO_QUERY); + CPPUNIT_ASSERT(xPageSupp.is()); + + Reference<drawing::XDrawPage> xPage = xPageSupp->getDrawPage(); + CPPUNIT_ASSERT(xPage.is()); + + Reference<beans::XPropertySet> xShapeProps(xPage->getByIndex(nShape), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShapeProps.is()); + + Reference<frame::XModel> xDocModel; + xShapeProps->getPropertyValue("Model") >>= xDocModel; + CPPUNIT_ASSERT(xDocModel.is()); + + uno::Reference<chart::XChartDocument> xChartDoc(xDocModel, uno::UNO_QUERY); + return xChartDoc; +} + uno::Sequence < OUString > ChartTest::getImpressChartColumnDescriptions( const char* pDir, const char* pName ) { uno::Reference< chart::XChartDocument > xChartDoc = getChartDocFromImpress( pDir, pName ); diff --git a/chart2/qa/extras/data/odg/scatter-plot-labels.odg b/chart2/qa/extras/data/odg/scatter-plot-labels.odg deleted file mode 100644 index af0dfee..0000000 Binary files a/chart2/qa/extras/data/odg/scatter-plot-labels.odg and /dev/null differ diff --git a/chart2/qa/extras/data/odt/scatter-plot-labels.odt b/chart2/qa/extras/data/odt/scatter-plot-labels.odt new file mode 100644 index 0000000..ab8f243 Binary files /dev/null and b/chart2/qa/extras/data/odt/scatter-plot-labels.odt differ commit 41cfc01a5676d237438a543c467821359dd5550a Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Tue Jun 10 21:16:44 2014 -0400 Remove this. Change-Id: Ie2c64d3254dba35ba3fcb1af2566de84b8b300e2 (cherry picked from commit 7d10da2174eac4afd189ee2e9bfb031d315763c1) diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index 297950b..8ad51b6 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -725,9 +725,6 @@ void Chart2ExportTest::testScatterPlotLabels() OUString aLabelRole = xCT->getRoleOfSequenceForSeriesLabel(); - fprintf(stdout, "Chart2ExportTest::testScatterPlotLabels: label role = '%s\n", - rtl::OUStringToOString(aLabelRole, RTL_TEXTENCODING_UTF8).getStr()); - Reference<chart2::XDataSeriesContainer> xDSCont(xCT, uno::UNO_QUERY); CPPUNIT_ASSERT(xDSCont.is()); Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries(); commit 796c05c22285798dfd15bddf805e07d7907f710a Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Tue Jun 10 19:46:37 2014 -0400 New unit test for Draw document with chart. Disabled due to weird crash. No idea why it crashes whatsoever.... Change-Id: Ic46d5a98f21cacb03adb3bc0d6da239bde5d8ce2 (cherry picked from commit 81d2c208a4e6f9df87e2ee70c6e6da146742178a) diff --git a/chart2/CppunitTest_chart2_export.mk b/chart2/CppunitTest_chart2_export.mk index 7a32da0..55127d7 100644 --- a/chart2/CppunitTest_chart2_export.mk +++ b/chart2/CppunitTest_chart2_export.mk @@ -13,7 +13,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,chart2_export)) $(eval $(call gb_CppunitTest_use_externals,chart2_export, \ boost_headers \ - libxml2 \ + libxml2 \ )) $(eval $(call gb_CppunitTest_add_exception_objects,chart2_export, \ @@ -21,6 +21,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,chart2_export, \ )) $(eval $(call gb_CppunitTest_use_libraries,chart2_export, \ + $(call gb_Helper_optional,AVMEDIA,avmedia) \ basegfx \ comphelper \ cppu \ @@ -31,12 +32,15 @@ $(eval $(call gb_CppunitTest_use_libraries,chart2_export, \ forui \ i18nlangtag \ msfilter \ + vcl \ oox \ sal \ salhelper \ sax \ sb \ sc \ + sw \ + sd \ sfx \ sot \ svl \ @@ -50,7 +54,6 @@ $(eval $(call gb_CppunitTest_use_libraries,chart2_export, \ unotest \ utl \ vbahelper \ - vcl \ xo \ sw \ $(gb_UWINAPI) \ @@ -69,15 +72,20 @@ $(eval $(call gb_CppunitTest_use_ure,chart2_export)) $(eval $(call gb_CppunitTest_use_components,chart2_export,\ basic/util/sb \ + animations/source/animcore/animcore \ chart2/source/controller/chartcontroller \ chart2/source/chartcore \ comphelper/util/comphelp \ configmgr/source/configmgr \ + dtrans/util/mcnttype \ dbaccess/util/dba \ embeddedobj/util/embobj \ eventattacher/source/evtatt \ filter/source/config/cache/filterconfig1 \ + filter/source/odfflatxml/odfflatxml \ filter/source/storagefilterdetect/storagefd \ + filter/source/xmlfilteradaptor/xmlfa \ + filter/source/xmlfilterdetect/xmlfd \ forms/util/frm \ framework/util/fwk \ i18npool/util/i18npool \ @@ -92,6 +100,9 @@ $(eval $(call gb_CppunitTest_use_components,chart2_export,\ sw/util/sw \ sw/util/swd \ sw/util/msword \ + sd/util/sd \ + sd/util/sdfilt \ + sd/util/sdd \ $(if $(filter TRUE,$(DISABLE_SCRIPTING)),, \ sc/util/vbaobj) \ scaddins/source/analysis/analysis \ @@ -114,6 +125,7 @@ $(eval $(call gb_CppunitTest_use_components,chart2_export,\ unoxml/source/service/unoxml \ writerfilter/util/writerfilter \ xmloff/util/xo \ + xmlscript/util/xmlscript \ )) $(eval $(call gb_CppunitTest_use_configuration,chart2_export)) diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index 4443b06..297950b 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -50,6 +50,7 @@ public: void testShapeFollowedByChart(); void testPieChartDataLabels(); void testSeriesIdxOrder(); + void testScatterPlotLabels(); void testErrorBarDataRangeODS(); void testChartCrash(); void testPieChartRotation(); @@ -82,6 +83,7 @@ public: CPPUNIT_TEST(testShapeFollowedByChart); CPPUNIT_TEST(testPieChartDataLabels); CPPUNIT_TEST(testSeriesIdxOrder); +// CPPUNIT_TEST(testScatterPlotLabels); TODO : This test crashes for some unknown reason. CPPUNIT_TEST(testErrorBarDataRangeODS); CPPUNIT_TEST(testChartCrash); CPPUNIT_TEST(testPieChartRotation); @@ -712,6 +714,50 @@ void Chart2ExportTest::testSeriesIdxOrder() assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:order[1]", "val", "1"); } +void Chart2ExportTest::testScatterPlotLabels() +{ + load("/chart2/qa/extras/data/odg/", "scatter-plot-labels.odg"); + Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + Reference<chart2::XChartType> xCT = getChartTypeFromDoc(xChartDoc, 0, 0); + CPPUNIT_ASSERT(xCT.is()); + + OUString aLabelRole = xCT->getRoleOfSequenceForSeriesLabel(); + + fprintf(stdout, "Chart2ExportTest::testScatterPlotLabels: label role = '%s\n", + rtl::OUStringToOString(aLabelRole, RTL_TEXTENCODING_UTF8).getStr()); + + Reference<chart2::XDataSeriesContainer> xDSCont(xCT, uno::UNO_QUERY); + CPPUNIT_ASSERT(xDSCont.is()); + Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aDataSeriesSeq.getLength()); + + for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i) + { + uno::Reference<chart2::data::XDataSource> xDSrc(aDataSeriesSeq[i], uno::UNO_QUERY); + CPPUNIT_ASSERT(xDSrc.is()); + uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > aDataSeqs = xDSrc->getDataSequences(); + for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j) + { + Reference<chart2::data::XDataSequence> xValues = aDataSeqs[j]->getValues(); + CPPUNIT_ASSERT(xValues.is()); + Reference<beans::XPropertySet> xPropSet(xValues, uno::UNO_QUERY); + if (!xPropSet.is()) + continue; + + OUString aRoleName; + xPropSet->getPropertyValue("Role") >>= aRoleName; + if (aRoleName == aLabelRole) + { + // TODO : Check the data series labels. + } + } + } + + CPPUNIT_ASSERT(false); +} + void Chart2ExportTest::testErrorBarDataRangeODS() { load("/chart2/qa/extras/data/ods/", "ErrorBarRange.ods"); diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx index 1bb38f5..0b90f76 100644 --- a/chart2/qa/extras/charttest.hxx +++ b/chart2/qa/extras/charttest.hxx @@ -62,6 +62,8 @@ public: uno::Reference< chart::XChartDocument > getChartDocFromImpress( const char* pDir, const char* pName ); + uno::Reference<chart::XChartDocument> getChartDocFromDrawImpress( sal_Int32 nPage, sal_Int32 nShape ); + virtual void setUp() SAL_OVERRIDE; virtual void tearDown() SAL_OVERRIDE; @@ -89,6 +91,10 @@ void ChartTest::load( const OUString& aDir, const OUString& aName ) { maServiceName = "com.sun.star.text.TextDocument"; } + else if (extension == "odg") + { + maServiceName = "com.sun.star.drawing.DrawingDocument"; + } mxComponent = loadFromDesktop(getURLFromSrc(aDir) + aName, maServiceName); CPPUNIT_ASSERT(mxComponent.is()); @@ -301,6 +307,33 @@ uno::Reference< chart::XChartDocument > ChartTest::getChartDocFromImpress( const return xChartDoc; } +uno::Reference<chart::XChartDocument> ChartTest::getChartDocFromDrawImpress( + sal_Int32 nPage, sal_Int32 nShape ) +{ + uno::Reference<chart::XChartDocument> xEmpty; + + uno::Reference<drawing::XDrawPagesSupplier> xPages(mxComponent, uno::UNO_QUERY); + if (!xPages.is()) + return xEmpty; + + uno::Reference<drawing::XDrawPage> xPage( + xPages->getDrawPages()->getByIndex(nPage), uno::UNO_QUERY_THROW); + if (!xPage.is()) + return xEmpty; + + uno::Reference<beans::XPropertySet> xShapeProps(xPage->getByIndex(nShape), uno::UNO_QUERY); + if (!xShapeProps.is()) + return xEmpty; + + uno::Reference<frame::XModel> xDocModel; + xShapeProps->getPropertyValue("Model") >>= xDocModel; + if (!xDocModel.is()) + return xEmpty; + + uno::Reference<chart::XChartDocument> xChartDoc(xDocModel, uno::UNO_QUERY); + return xChartDoc; +} + uno::Sequence < OUString > ChartTest::getImpressChartColumnDescriptions( const char* pDir, const char* pName ) { uno::Reference< chart::XChartDocument > xChartDoc = getChartDocFromImpress( pDir, pName ); diff --git a/chart2/qa/extras/data/odg/scatter-plot-labels.odg b/chart2/qa/extras/data/odg/scatter-plot-labels.odg new file mode 100644 index 0000000..af0dfee Binary files /dev/null and b/chart2/qa/extras/data/odg/scatter-plot-labels.odg differ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits