summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chart2/qa/extras/chart2export.cxx16
-rwxr-xr-xchart2/qa/extras/data/docx/tdf123206.docxbin0 -> 24223 bytes
-rw-r--r--include/xmloff/xmltoken.hxx1
-rw-r--r--schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng9
-rw-r--r--xmloff/source/chart/SchXMLExport.cxx63
-rw-r--r--xmloff/source/chart/SchXMLPlotAreaContext.cxx9
-rw-r--r--xmloff/source/chart/SchXMLSeries2Context.cxx15
-rw-r--r--xmloff/source/chart/transporttypes.hxx1
-rw-r--r--xmloff/source/core/xmltoken.cxx1
-rw-r--r--xmloff/source/token/tokens.txt1
10 files changed, 107 insertions, 9 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 28bc0f34b53e..a7403e715cc4 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -136,6 +136,7 @@ public:
void testTdf121744();
void testTdf122031();
void testTdf115012();
+ void testTdf123206_customLabelText();
CPPUNIT_TEST_SUITE(Chart2ExportTest);
CPPUNIT_TEST(testErrorBarXLSX);
@@ -235,6 +236,8 @@ public:
CPPUNIT_TEST(testTdf121744);
CPPUNIT_TEST(testTdf122031);
CPPUNIT_TEST(testTdf115012);
+ CPPUNIT_TEST(testTdf123206_customLabelText);
+
CPPUNIT_TEST_SUITE_END();
protected:
@@ -2191,6 +2194,19 @@ void Chart2ExportTest::testTdf115012()
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:dispBlanksAs", "val", "zero");
}
+void Chart2ExportTest::testTdf123206_customLabelText()
+{
+ load("/chart2/qa/extras/data/docx/", "tdf123206.docx");
+
+ Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[2]/c:tx/c:rich/a:p/a:r/a:t", "kiscica");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/docx/tdf123206.docx b/chart2/qa/extras/data/docx/tdf123206.docx
new file mode 100755
index 000000000000..f47089fe3b1b
--- /dev/null
+++ b/chart2/qa/extras/data/docx/tdf123206.docx
Binary files differ
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 69ef7e889455..97748c0f9c30 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -533,6 +533,7 @@ namespace xmloff { namespace token {
XML_CUSTOM_ICONSET,
XML_CUSTOM_ICONSET_INDEX,
XML_CUSTOM_ICONSET_NAME,
+ XML_CUSTOM_LABEL_FIELD,
XML_CUT,
XML_CUT_OFFS,
XML_CX,
diff --git a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
index e5a0116bd029..32a3a85583a3 100644
--- a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
+++ b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
@@ -2348,4 +2348,13 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
</rng:optional>
</rng:define>
+ <!-- TODO no proposal -->
+ <rng:define name="chart-data-point-attlist" combine="interleave">
+ <rng:optional>
+ <rng:attribute name="loext:custom-label-field">
+ <rng:ref name="string"/>
+ </rng:attribute>
+ </rng:optional>
+ </rng:define>
+
</rng:grammar>
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 6507cb91b926..5f5bd225de1e 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -88,6 +88,7 @@
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
#include <com/sun/star/chart2/XChartTypeContainer.hpp>
#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
+#include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
#include <com/sun/star/chart2/data/XDataSource.hpp>
#include <com/sun/star/chart2/data/XDataSink.hpp>
#include <com/sun/star/chart2/data/XDataReceiver.hpp>
@@ -119,6 +120,19 @@ using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Any;
using ::std::vector;
+
+namespace
+{
+ struct SchXMLDataPointStruct
+ {
+ OUString maStyleName;
+ sal_Int32 mnRepeat;
+ OUString msCustomLabelText;
+
+ SchXMLDataPointStruct() : mnRepeat( 1 ) {}
+ };
+}
+
// class SchXMLExportHelper_Impl
class SchXMLExportHelper_Impl
@@ -273,6 +287,33 @@ public:
namespace
{
+OUString lcl_getCustomLabelField(sal_Int32 nDataPointIndex,
+ const uno::Reference< chart2::XDataSeries >& rSeries)
+{
+ if( !rSeries.is() )
+ return OUString{};
+
+ const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
+ if( nCurrentODFVersion <= SvtSaveOptions::ODFVER_012 )//do not export to ODF 1.2 or older
+ return OUString{};
+
+ // export custom label text
+ if(Reference<beans::XPropertySet> xLabels = rSeries->getDataPointByIndex(nDataPointIndex); xLabels.is())
+ {
+ if(Any aAny = xLabels->getPropertyValue("CustomLabelFields"); aAny.hasValue())
+ {
+ Sequence<uno::Reference<chart2::XDataPointCustomLabelField>> aCustomLabels;
+ aAny >>= aCustomLabels;
+ OUString sLabel;
+ // TODO export formatted string instead of simple characters
+ for(auto& aLabel : aCustomLabels)
+ sLabel += aLabel->getString();
+ return sLabel;
+ }
+ }
+ return OUString{};
+}
+
class lcl_MatchesRole
{
public:
@@ -951,14 +992,6 @@ bool lcl_exportDomainForThisSequence( const Reference< chart2::data::XDataSequen
} // anonymous namespace
-struct SchXMLDataPointStruct
-{
- OUString maStyleName;
- sal_Int32 mnRepeat;
-
- SchXMLDataPointStruct() : mnRepeat( 1 ) {}
-};
-
// class SchXMLExportHelper
SchXMLExportHelper::SchXMLExportHelper( SvXMLExport& rExport, SvXMLAutoStylePoolP& rASPool )
@@ -3287,6 +3320,8 @@ void SchXMLExportHelper_Impl::exportDataPoints(
SchXMLDataPointStruct aPoint;
aPoint.maStyleName = maAutoStyleNameQueue.front();
+ if(bExportNumFmt)
+ aPoint.msCustomLabelText = lcl_getCustomLabelField(nElement, xSeries);
maAutoStyleNameQueue.pop();
aDataPointVector.push_back( aPoint );
}
@@ -3315,6 +3350,7 @@ void SchXMLExportHelper_Impl::exportDataPoints(
{
SchXMLDataPointStruct aPoint;
aPoint.mnRepeat = nCurrIndex - nLastIndex - 1;
+ aPoint.msCustomLabelText = lcl_getCustomLabelField(nCurrIndex, xSeries);
aDataPointVector.push_back( aPoint );
}
@@ -3347,6 +3383,7 @@ void SchXMLExportHelper_Impl::exportDataPoints(
SAL_WARN_IF( maAutoStyleNameQueue.empty(), "xmloff.chart", "Autostyle queue empty!" );
SchXMLDataPointStruct aPoint;
aPoint.maStyleName = maAutoStyleNameQueue.front();
+ aPoint.msCustomLabelText = lcl_getCustomLabelField(nCurrIndex, xSeries);
maAutoStyleNameQueue.pop();
aDataPointVector.push_back( aPoint );
@@ -3362,6 +3399,7 @@ void SchXMLExportHelper_Impl::exportDataPoints(
// if we get here the property states are empty
SchXMLDataPointStruct aPoint;
+ aPoint.msCustomLabelText = lcl_getCustomLabelField(nCurrIndex, xSeries);
aDataPointVector.push_back( aPoint );
nLastIndex = nCurrIndex;
@@ -3391,10 +3429,13 @@ void SchXMLExportHelper_Impl::exportDataPoints(
{
aPoint = rPoint;
- if( aPoint.maStyleName == aLastPoint.maStyleName )
+ if( aPoint.maStyleName == aLastPoint.maStyleName && aPoint.msCustomLabelText.isEmpty() )
aPoint.mnRepeat += aLastPoint.mnRepeat;
else if( aLastPoint.mnRepeat > 0 )
{
+ // export custom label text
+ if(!aLastPoint.msCustomLabelText.isEmpty())
+ mrExport.AddAttribute( XML_NAMESPACE_LO_EXT, XML_CUSTOM_LABEL_FIELD, aLastPoint.msCustomLabelText);
// write last element
if( !aLastPoint.maStyleName.isEmpty() )
mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_STYLE_NAME, aLastPoint.maStyleName );
@@ -3410,6 +3451,10 @@ void SchXMLExportHelper_Impl::exportDataPoints(
// write last element if it hasn't been written in last iteration
if( aPoint.maStyleName == aLastPoint.maStyleName )
{
+ // export custom label text
+ if(!aLastPoint.msCustomLabelText.isEmpty())
+ mrExport.AddAttribute( XML_NAMESPACE_LO_EXT, XML_CUSTOM_LABEL_FIELD, aLastPoint.msCustomLabelText);
+
if( !aLastPoint.maStyleName.isEmpty() )
mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_STYLE_NAME, aLastPoint.maStyleName );
diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx
index 46fee917baf1..f94d3dea67a4 100644
--- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx
+++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx
@@ -618,6 +618,7 @@ void SchXMLDataPointContext::StartElement( const uno::Reference< xml::sax::XAttr
sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
OUString sAutoStyleName;
sal_Int32 nRepeat = 1;
+ OUString sCustomLabelField;
for( sal_Int16 i = 0; i < nAttrCount; i++ )
{
@@ -632,6 +633,13 @@ void SchXMLDataPointContext::StartElement( const uno::Reference< xml::sax::XAttr
else if( IsXMLToken( aLocalName, XML_REPEATED ) )
nRepeat = xAttrList->getValueByIndex( i ).toInt32();
}
+ else if( nPrefix == XML_NAMESPACE_LO_EXT)
+ {
+ if( IsXMLToken( aLocalName, XML_CUSTOM_LABEL_FIELD))
+ {
+ sCustomLabelField = xAttrList->getValueByIndex( i );
+ }
+ }
}
if( !sAutoStyleName.isEmpty())
@@ -640,6 +648,7 @@ void SchXMLDataPointContext::StartElement( const uno::Reference< xml::sax::XAttr
DataRowPointStyle::DATA_POINT,
m_xSeries, mrIndex, nRepeat, sAutoStyleName );
aStyle.mbSymbolSizeForSeriesIsMissingInFile = mbSymbolSizeForSeriesIsMissingInFile;
+ aStyle.msCustomLabelField = sCustomLabelField;
mrStyleVector.push_back( aStyle );
}
mrIndex += nRepeat;
diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx
index 93c9d2120fae..ba4379f5fcc2 100644
--- a/xmloff/source/chart/SchXMLSeries2Context.cxx
+++ b/xmloff/source/chart/SchXMLSeries2Context.cxx
@@ -32,6 +32,10 @@
#include <com/sun/star/chart2/data/XDataReceiver.hpp>
#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp>
+#include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
+#include <com/sun/star/chart2/DataPointCustomLabelFieldType.hpp>
+#include <com/sun/star/chart2/DataPointCustomLabelField.hpp>
+
#include <com/sun/star/chart/ChartAxisAssign.hpp>
#include <com/sun/star/chart/ChartSymbolType.hpp>
#include <com/sun/star/chart/XChartDocument.hpp>
@@ -1090,6 +1094,17 @@ void SchXMLSeries2Context::setStylesToDataPoints( SeriesDefaultsAndStyles& rSeri
if( seriesStyle.mbSymbolSizeForSeriesIsMissingInFile )
lcl_resetSymbolSizeForPointsIfNecessary( xPointProp, rImport, pPropStyleContext, pStylesCtxt );
}
+
+ if(!seriesStyle.msCustomLabelField.isEmpty())
+ {
+ Sequence< Reference<chart2::XDataPointCustomLabelField>> xLabels(1);
+ Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
+ Reference< chart2::XDataPointCustomLabelField > xCustomLabel = chart2::DataPointCustomLabelField::create(xContext);
+ xLabels[0] = xCustomLabel;
+ xCustomLabel->setString(seriesStyle.msCustomLabelField);
+ xCustomLabel->setFieldType(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT);
+ xPointProp->setPropertyValue("CustomLabelFields", uno::Any(xLabels));
+ }
}
catch( const uno::Exception & rEx )
{
diff --git a/xmloff/source/chart/transporttypes.hxx b/xmloff/source/chart/transporttypes.hxx
index 44d3bc3a7b22..6481cfb1c004 100644
--- a/xmloff/source/chart/transporttypes.hxx
+++ b/xmloff/source/chart/transporttypes.hxx
@@ -168,6 +168,7 @@ struct DataRowPointStyle
sal_Int32 m_nPointRepeat;
OUString msStyleName;
OUString msSeriesStyleNameForDonuts;
+ OUString msCustomLabelField;
sal_Int32 mnAttachedAxis;
bool mbSymbolSizeForSeriesIsMissingInFile;
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 1daa8897649d..deaf010a199e 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -534,6 +534,7 @@ namespace xmloff { namespace token {
TOKEN( "custom-iconset", XML_CUSTOM_ICONSET ),
TOKEN( "custom-iconset-index", XML_CUSTOM_ICONSET_INDEX ),
TOKEN( "custom-iconset-name", XML_CUSTOM_ICONSET_NAME ),
+ TOKEN( "custom-label-field", XML_CUSTOM_LABEL_FIELD ),
TOKEN( "cut", XML_CUT ),
TOKEN( "cut-offs", XML_CUT_OFFS ),
TOKEN( "cx", XML_CX ),
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index ce472bc62c7a..0441c34826d1 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -457,6 +457,7 @@ custom5
custom-iconset
custom-iconset-index
custom-iconset-name
+custom-label-field
cut
cut-offs
cx