[Libreoffice-commits] core.git: 5 commits - chart2/qa chart2/source include/xmloff xmloff/inc xmloff/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Sat Apr 5 09:37:57 PDT 2014
chart2/qa/extras/chart2export.cxx | 24 ++++++++++++++++++++
chart2/qa/extras/charttest.hxx | 31 +++++++++++++++++++++++---
chart2/qa/extras/data/ods/labelString.ods |binary
chart2/source/tools/AxisHelper.cxx | 20 ++++++++++------
include/xmloff/xmltoken.hxx | 1
xmloff/inc/SchXMLImport.hxx | 1
xmloff/source/chart/SchXMLExport.cxx | 28 ++++++++++++++++++++---
xmloff/source/chart/SchXMLImport.cxx | 1
xmloff/source/chart/SchXMLSeries2Context.cxx | 19 +++++++++++-----
xmloff/source/chart/SchXMLSeries2Context.hxx | 1
xmloff/source/chart/SchXMLTools.cxx | 32 +++++++++++++++++++++++++++
xmloff/source/chart/SchXMLTools.hxx | 5 ++++
xmloff/source/core/xmltoken.cxx | 1
13 files changed, 143 insertions(+), 21 deletions(-)
New commits:
commit c47bbfce2deea8bda80f06c961be531aee4b23ce
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat Apr 5 18:33:07 2014 +0200
add test for fdo#64722, cp#1000058
Change-Id: Idccff4629b8af84e59d52fb3135e9217d3564cb9
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index ead4350..fa1c90c 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -55,6 +55,7 @@ public:
void testEmbeddingsOleObjectGrabBag();
void testGapWidthXLSX();
void testSmoothedLines();
+ void testLabelStringODS();
CPPUNIT_TEST_SUITE(Chart2ExportTest);
CPPUNIT_TEST(test);
@@ -82,6 +83,7 @@ public:
CPPUNIT_TEST(testEmbeddingsOleObjectGrabBag);
CPPUNIT_TEST(testGapWidthXLSX);
CPPUNIT_TEST(testSmoothedLines);
+ CPPUNIT_TEST(testLabelStringODS);
CPPUNIT_TEST_SUITE_END();
protected:
@@ -782,6 +784,28 @@ void Chart2ExportTest::testSmoothedLines()
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[1]/c:smooth", "val", "0");
}
+void Chart2ExportTest::testLabelStringODS()
+{
+ load("/chart2/qa/extras/data/ods/", "labelString.ods");
+
+ uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent );
+ Reference< chart2::data::XDataSequence > xLabelSeq =
+ getLabelDataSequenceFromDoc(xChartDoc);
+ CPPUNIT_ASSERT(xLabelSeq.is());
+
+ OUString aLabelString = xLabelSeq->getSourceRangeRepresentation();
+ CPPUNIT_ASSERT_EQUAL(OUString("\"LabelName\""), aLabelString);
+
+ reload("calc8");
+
+ xChartDoc = getChartDocFromSheet( 0, mxComponent );
+ xLabelSeq = getLabelDataSequenceFromDoc(xChartDoc);
+ CPPUNIT_ASSERT(xLabelSeq.is());
+
+ aLabelString = xLabelSeq->getSourceRangeRepresentation();
+ CPPUNIT_ASSERT_EQUAL(OUString("\"LabelName\""), aLabelString);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx
index 73b5748..471346c 100644
--- a/chart2/qa/extras/charttest.hxx
+++ b/chart2/qa/extras/charttest.hxx
@@ -35,6 +35,8 @@
#include <com/sun/star/chart2/XChartTypeContainer.hpp>
#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
+#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
+#include <com/sun/star/chart2/data/XDataSource.hpp>
#include <com/sun/star/chart/XChartDataArray.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
#include <com/sun/star/chart/XChartDocument.hpp>
@@ -213,6 +215,29 @@ Reference< chart2::XDataSeries > getDataSeriesFromDoc( uno::Reference< chart2::X
return xSeries;
}
+Reference< chart2::data::XDataSequence > getLabelDataSequenceFromDoc(
+ Reference< chart2::XChartDocument > xChartDoc,
+ sal_Int32 nDataSeries = 0, sal_Int32 nChartType = 0, sal_Int32 nCooSys = 0 )
+{
+ Reference< chart2::XDataSeries > xDataSeries =
+ getDataSeriesFromDoc( xChartDoc, nDataSeries, nChartType, nCooSys );
+ CPPUNIT_ASSERT(xDataSeries.is());
+ Reference< chart2::data::XDataSource > xDataSource( xDataSeries, uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > xDataSequences =
+ xDataSource->getDataSequences();
+ for(sal_Int32 i = 0; i < xDataSequences.getLength(); ++i)
+ {
+ Reference< chart2::data::XDataSequence> xLabelSeq = xDataSequences[i]->getLabel();
+ if(!xLabelSeq.is())
+ continue;
+
+ return xLabelSeq;
+ }
+
+ CPPUNIT_FAIL("no Label sequence found");
+ return Reference< chart2::data::XDataSequence > ();
+}
+
uno::Sequence < OUString > getWriterChartColumnDescriptions( Reference< lang::XComponent > mxComponent )
{
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/chart2/qa/extras/data/ods/labelString.ods b/chart2/qa/extras/data/ods/labelString.ods
new file mode 100644
index 0000000..2b7e03c
Binary files /dev/null and b/chart2/qa/extras/data/ods/labelString.ods differ
commit 6052c282400029f550f5e8ec938f1137edcd1e96
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat Apr 5 17:18:53 2014 +0200
rename variable
Change-Id: I6ac553172a7c017010d4efa42224f25e2d5537da
diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx
index 900fe45..73b5748 100644
--- a/chart2/qa/extras/charttest.hxx
+++ b/chart2/qa/extras/charttest.hxx
@@ -202,10 +202,10 @@ Reference< chart2::XDataSeries > getDataSeriesFromDoc( uno::Reference< chart2::X
sal_Int32 nDataSeries, sal_Int32 nChartType = 0, sal_Int32 nCooSys = 0 )
{
Reference< chart2::XChartType > xChartType = getChartTypeFromDoc( xChartDoc, nChartType, nCooSys );
- Reference< chart2::XDataSeriesContainer > xDataSequenceContainer( xChartType, UNO_QUERY_THROW );
- CPPUNIT_ASSERT ( xDataSequenceContainer.is() );
+ Reference< chart2::XDataSeriesContainer > xDataSeriesContainer( xChartType, UNO_QUERY_THROW );
+ CPPUNIT_ASSERT ( xDataSeriesContainer.is() );
- Sequence< Reference< chart2::XDataSeries > > xSeriesSequence( xDataSequenceContainer->getDataSeries() );
+ Sequence< Reference< chart2::XDataSeries > > xSeriesSequence( xDataSeriesContainer->getDataSeries() );
CPPUNIT_ASSERT( xSeriesSequence.getLength() > nDataSeries );
Reference< chart2::XDataSeries > xSeries = xSeriesSequence[nDataSeries];
commit 89bbc9286778df711f786f50c27f65315b29c39a
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat Apr 5 16:49:39 2014 +0200
export label names that are strings, fdo#64722, cp#1000058
Change-Id: Id72e9778c70db02b942326c6f8b5f448acb28b41
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index c934912..9e206d8 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -1066,6 +1066,7 @@ namespace xmloff { namespace token {
XML_LABEL_CELL_RANGE_ADDRESS,
XML_LABEL_RANGE,
XML_LABEL_RANGES,
+ XML_LABEL_STRING,
XML_LAMBDA,
XML_LANDSCAPE,
XML_LANGUAGE,
diff --git a/xmloff/inc/SchXMLImport.hxx b/xmloff/inc/SchXMLImport.hxx
index 173788a..8b6286d 100644
--- a/xmloff/inc/SchXMLImport.hxx
+++ b/xmloff/inc/SchXMLImport.hxx
@@ -140,6 +140,7 @@ enum SchXMLSeriesAttrMap
{
XML_TOK_SERIES_CELL_RANGE,
XML_TOK_SERIES_LABEL_ADDRESS,
+ XML_TOK_SERIES_LABEL_STRING,
XML_TOK_SERIES_ATTACHED_AXIS,
XML_TOK_SERIES_STYLE_NAME,
XML_TOK_SERIES_CHART_CLASS
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 859e4a5..bd17360 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -2553,6 +2553,14 @@ namespace
//no doubles and no texts
return false;
}
+
+ bool isString(const OUString& rString)
+ {
+ if(rString.startsWith("\"") && rString.endsWith("\""))
+ return true;
+
+ return false;
+ }
}
void SchXMLExportHelper_Impl::exportSeries(
@@ -2720,10 +2728,21 @@ void SchXMLExportHelper_Impl::exportSeries(
modifyLabelRange = true;
if (modifyLabelRange)
aRange = "label " + OUString::number(aRange.copy( OUString("label").getLength()).toInt32() - 1);
- mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS,
- lcl_ConvertRange(
- aRange,
- xNewDoc ));
+
+ OUString aXMLRange = lcl_ConvertRange( aRange, xNewDoc );
+ if(aXMLRange.isEmpty() && !aRange.isEmpty())
+ {
+ // might just be a string
+ bool bIsString = isString(aRange);
+ if(bIsString)
+ {
+ mrExport.AddAttribute( XML_NAMESPACE_LO_EXT,
+ XML_LABEL_STRING, aRange );
+ }
+ }
+ else
+ mrExport.AddAttribute( XML_NAMESPACE_CHART,
+ XML_LABEL_CELL_ADDRESS, aXMLRange );
}
if( xLabelSeq.is() || xValuesSeq.is() )
aSeriesLabelValuesPair = tLabelValuesDataPair( xLabelSeq, xValuesSeq );
@@ -3138,6 +3157,7 @@ void SchXMLExportHelper_Impl::exportCandleStickSeries(
Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY );
//@todo: export data points
+ //TODO: moggi: same code three times
// open
if( bJapaneseCandleSticks )
{
diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx
index 3a3dc51..042dcba 100644
--- a/xmloff/source/chart/SchXMLImport.cxx
+++ b/xmloff/source/chart/SchXMLImport.cxx
@@ -339,6 +339,7 @@ const SvXMLTokenMap& SchXMLImportHelper::GetSeriesAttrTokenMap()
{
{ XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, XML_TOK_SERIES_CELL_RANGE },
{ XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, XML_TOK_SERIES_LABEL_ADDRESS },
+ { XML_NAMESPACE_LO_EXT, XML_LABEL_STRING, XML_TOK_SERIES_LABEL_STRING },
{ XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_TOK_SERIES_ATTACHED_AXIS },
{ XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_SERIES_STYLE_NAME },
{ XML_NAMESPACE_CHART, XML_CLASS, XML_TOK_SERIES_CHART_CLASS },
diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx
index 795effb..54dcd57 100644
--- a/xmloff/source/chart/SchXMLSeries2Context.cxx
+++ b/xmloff/source/chart/SchXMLSeries2Context.cxx
@@ -308,6 +308,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
bool bHasRange = false;
OUString aSeriesLabelRange;
+ OUString aSeriesLabelString;
for( sal_Int16 i = 0; i < nAttrCount; i++ )
{
@@ -325,6 +326,9 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
case XML_TOK_SERIES_LABEL_ADDRESS:
aSeriesLabelRange = aValue;
break;
+ case XML_TOK_SERIES_LABEL_STRING:
+ aSeriesLabelString = aValue;
+ break;
case XML_TOK_SERIES_ATTACHED_AXIS:
{
sal_Int32 nNumOfAxes = mrAxes.size();
@@ -442,6 +446,12 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
SchXMLTools::CreateDataSequence( aSeriesLabelRange, mxNewDoc );
xLabeledSeq->setLabel( xLabelSequence );
}
+ else if( !aSeriesLabelString.isEmpty() )
+ {
+ Reference< chart2::data::XDataSequence > xLabelSequence =
+ SchXMLTools::CreateDataSequenceWithoutConvert( aSeriesLabelString, mxNewDoc );
+ xLabeledSeq->setLabel( xLabelSequence );
+ }
// Note: Even if we have no label, we have to register the label
// for creation, because internal data always has labels. If
diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx
index 8e86b91..e37ed83 100644
--- a/xmloff/source/chart/SchXMLTools.cxx
+++ b/xmloff/source/chart/SchXMLTools.cxx
@@ -424,6 +424,38 @@ Reference< chart2::data::XDataSequence > CreateDataSequence(
return xRet;
}
+Reference< chart2::data::XDataSequence > CreateDataSequenceWithoutConvert(
+ const OUString & rRange,
+ const Reference< chart2::XChartDocument >& xChartDoc )
+{
+ Reference< chart2::data::XDataSequence > xRet;
+
+ if( !xChartDoc.is() )
+ {
+ SAL_WARN("xmloff.chart", "need a chart document" );
+ return xRet;
+ }
+
+ Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() );
+ if( !xDataProvider.is() )
+ {
+ SAL_WARN("xmloff.chart", "need a data provider" );
+ return xRet;
+ }
+
+ try
+ {
+ xRet.set( xDataProvider->createDataSequenceByRangeRepresentation( rRange ) );
+ SchXMLTools::setXMLRangePropertyAtDataSequence( xRet, rRange );
+ }
+ catch( const lang::IllegalArgumentException & )
+ {
+ SAL_WARN("xmloff.chart", "could not create data sequence" );
+ }
+
+ return xRet;
+}
+
void CreateCategories(
const uno::Reference< chart2::data::XDataProvider > & xDataProvider,
const uno::Reference< chart2::XChartDocument > & xNewDoc,
diff --git a/xmloff/source/chart/SchXMLTools.hxx b/xmloff/source/chart/SchXMLTools.hxx
index 0b6f49a..ed21ea2 100644
--- a/xmloff/source/chart/SchXMLTools.hxx
+++ b/xmloff/source/chart/SchXMLTools.hxx
@@ -86,6 +86,11 @@ namespace SchXMLTools
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartDocument >& xChartDoc );
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > CreateDataSequenceWithoutConvert(
+ const OUString& rRange,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XChartDocument >& xChartDoc );
+
void CreateCategories(
const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > & xDataProvider,
const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xNewDoc,
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index c28b850..09027cd 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -1071,6 +1071,7 @@ namespace xmloff { namespace token {
TOKEN( "label-cell-range-address", XML_LABEL_CELL_RANGE_ADDRESS ),
TOKEN( "label-range", XML_LABEL_RANGE ),
TOKEN( "label-ranges", XML_LABEL_RANGES ),
+ TOKEN( "label-string", XML_LABEL_STRING ),
TOKEN( "lambda", XML_LAMBDA ),
TOKEN( "landscape", XML_LANDSCAPE ),
TOKEN( "language", XML_LANGUAGE ),
commit 2c59f12e5a9b062f91d6f0b85d4b6196728c689c
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat Apr 5 15:34:38 2014 +0200
no need for member variable and bool variable
Change-Id: I58dc22fdec3db8280506a92fe16065cc5482c357
diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx
index bbea32e..795effb 100644
--- a/xmloff/source/chart/SchXMLSeries2Context.cxx
+++ b/xmloff/source/chart/SchXMLSeries2Context.cxx
@@ -307,7 +307,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
mnAttachedAxis = 1;
bool bHasRange = false;
- bool bHasLabelRange = false;
+ OUString aSeriesLabelRange;
for( sal_Int16 i = 0; i < nAttrCount; i++ )
{
@@ -323,8 +323,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
bHasRange = true;
break;
case XML_TOK_SERIES_LABEL_ADDRESS:
- m_aSeriesLabelRange = aValue;
- bHasLabelRange = true;
+ aSeriesLabelRange = aValue;
break;
case XML_TOK_SERIES_ATTACHED_AXIS:
{
@@ -437,10 +436,10 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
tSchXMLIndexWithPart( m_rGlobalSeriesImportInfo.nCurrentDataIndex, SCH_XML_PART_VALUES ), xLabeledSeq ));
// label
- if( bHasLabelRange && !m_aSeriesLabelRange.isEmpty() )
+ if( !aSeriesLabelRange.isEmpty() )
{
Reference< chart2::data::XDataSequence > xLabelSequence =
- SchXMLTools::CreateDataSequence( m_aSeriesLabelRange, mxNewDoc );
+ SchXMLTools::CreateDataSequence( aSeriesLabelRange, mxNewDoc );
xLabeledSeq->setLabel( xLabelSequence );
}
diff --git a/xmloff/source/chart/SchXMLSeries2Context.hxx b/xmloff/source/chart/SchXMLSeries2Context.hxx
index a4974ce..ee78f4c 100644
--- a/xmloff/source/chart/SchXMLSeries2Context.hxx
+++ b/xmloff/source/chart/SchXMLSeries2Context.hxx
@@ -64,7 +64,6 @@ private:
OUString maGlobalChartTypeName;
OUString maSeriesChartTypeName;
OUString m_aSeriesRange;
- OUString m_aSeriesLabelRange;
bool m_bHasDomainContext;
tSchXMLLSequencesPerIndex & mrLSequencesPerIndex;
tSchXMLLSequencesPerIndex maPostponedSequences;
commit 291bf3b84f423217959b38b46a16055947c9e84e
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat Apr 5 02:50:40 2014 +0200
prevent excessive exceptions
They hide the interesting parts that I'm interested in and are always
thrown so let us avoid them
Change-Id: I532a3fe678de7d3ac0776db23363df5d35c793eb
diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx
index 4b372ca..65c297fb 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -597,14 +597,18 @@ Reference< XAxis > AxisHelper::getAxis( sal_Int32 nDimensionIndex, sal_Int32 nAx
, const Reference< XCoordinateSystem >& xCooSys )
{
Reference< XAxis > xRet;
- try
- {
- if( xCooSys.is() )
- xRet.set( xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ) );
- }
- catch( const uno::Exception & )
- {
- }
+ if(!xCooSys.is())
+ return xRet;
+
+ if(nDimensionIndex >= xCooSys->getDimension())
+ return xRet;
+
+ if(nAxisIndex > xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex))
+ return xRet;
+
+ assert(nAxisIndex >= 0);
+ assert(nDimensionIndex >= 0);
+ xRet.set( xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ) );
return xRet;
}
More information about the Libreoffice-commits
mailing list