summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2020-08-29 13:44:37 +0200
committerGabor Kelemen <kelemen.gabor2@nisz.hu>2021-02-18 13:42:30 +0100
commit359760c34373ea89876a9dd656e465e836a0d38d (patch)
tree609237932367aecc3b54b139bcdadef5b88492aa
parent47c4921dca9f911fa3744e4c78d0e8c72afccf6c (diff)
tdf#136061 Chart ODF/OOXML: fix missing custom labels
by UNO extensions ShowCustomLabel in DataPointLabel.idl and CUSTOM in ChartDataCaption.idl, fixing OOXML/ODF import/export. We should display custom data label even if DataPointLabel is disabled (e.g. category name and/or value fields are not displayed). Note: import of the embedded chart of the DOCX unit test document uses also ODF format in the background, testing also the extension of the native file format. Change-Id: I73e21f1e69fddec9f3b4163c46b6582cd1c74b5d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101640 Tested-by: Jenkins Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> (cherry picked from commit 0d2340998415fb4b2f794054c62ef61c83e32155) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111135 Tested-by: Gabor Kelemen <kelemen.gabor2@nisz.hu> Reviewed-by: Gabor Kelemen <kelemen.gabor2@nisz.hu>
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx4
-rw-r--r--chart2/source/controller/main/ChartController_Tools.cxx1
-rw-r--r--chart2/source/model/main/DataPointProperties.cxx3
-rw-r--r--chart2/source/tools/DataSeriesHelper.cxx6
-rw-r--r--chart2/source/view/main/VDataSeries.cxx2
-rw-r--r--offapi/com/sun/star/chart/ChartDataCaption.idl8
-rw-r--r--offapi/com/sun/star/chart2/DataPointLabel.idl7
-rw-r--r--oox/source/drawingml/chart/seriesconverter.cxx12
-rw-r--r--sc/source/filter/excel/xichart.cxx2
-rw-r--r--sw/qa/extras/layout/data/tdf136061.docxbin0 -> 25928 bytes
-rw-r--r--sw/qa/extras/layout/layout.cxx14
-rw-r--r--xmloff/source/chart/SchXMLSeries2Context.cxx2
12 files changed, 49 insertions, 12 deletions
diff --git a/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx
index f55540f67db8..c786c1b3913c 100644
--- a/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx
+++ b/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx
@@ -71,7 +71,7 @@ sal_Int32 lcl_LabelToCaption( const chart2::DataPointLabel& rLabel )
chart2::DataPointLabel lcl_CaptionToLabel( sal_Int32 nCaption )
{
- chart2::DataPointLabel aLabel(false,false,false,false);
+ chart2::DataPointLabel aLabel(false,false,false,false,false);
if( nCaption & css::chart::ChartDataCaption::VALUE )
aLabel.ShowNumber = true;
@@ -81,6 +81,8 @@ chart2::DataPointLabel lcl_CaptionToLabel( sal_Int32 nCaption )
aLabel.ShowCategoryName = true;
if( nCaption & css::chart::ChartDataCaption::SYMBOL )
aLabel.ShowLegendSymbol = true;
+ if( nCaption & css::chart::ChartDataCaption::CUSTOM )
+ aLabel.ShowCustomLabel = true;
return aLabel;
}
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index c6024350430d..bf2b97f5773b 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -760,6 +760,7 @@ bool ChartController::executeDispatch_Delete()
aLabel.ShowNumberInPercent = false;
aLabel.ShowCategoryName = false;
aLabel.ShowLegendSymbol = false;
+ aLabel.ShowCustomLabel = false;
if( aObjectType == OBJECTTYPE_DATA_LABELS )
{
uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( aCID, getModel() ));
diff --git a/chart2/source/model/main/DataPointProperties.cxx b/chart2/source/model/main/DataPointProperties.cxx
index dba488fdd924..dcc343002ffb 100644
--- a/chart2/source/model/main/DataPointProperties.cxx
+++ b/chart2/source/model/main/DataPointProperties.cxx
@@ -515,7 +515,8 @@ void DataPointProperties::AddDefaultsToMap(
false, // ShowNumber
false, // ShowNumberInPercent
false, // ShowCategoryName
- false // ShowLegendSymbol
+ false, // ShowLegendSymbol
+ false // ShowCustomLabel
));
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_TEXT_WORD_WRAP, false );
diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx
index c90a356bf2ee..c5fd3e43fb2f 100644
--- a/chart2/source/tools/DataSeriesHelper.cxx
+++ b/chart2/source/tools/DataSeriesHelper.cxx
@@ -170,6 +170,7 @@ void lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( const Reference< chart2::
{
aLabel.ShowNumberInPercent = false;
aLabel.ShowCategoryName = false;
+ aLabel.ShowCustomLabel = false;
}
xPointProp->setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabel));
}
@@ -747,7 +748,7 @@ bool hasDataLabelsAtPoints( const Reference< chart2::XDataSeries >& xSeries )
{
DataPointLabel aLabel;
if( xPointProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel )
- bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName;
+ bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName || aLabel.ShowCustomLabel;
if( bRet )
break;
}
@@ -785,7 +786,7 @@ bool hasDataLabelAtPoint( const Reference< chart2::XDataSeries >& xSeries, sal_I
{
DataPointLabel aLabel;
if( xProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel )
- bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName;
+ bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName || aLabel.ShowCustomLabel;
}
}
}
@@ -835,6 +836,7 @@ void deleteDataLabelsFromPoint( const Reference< beans::XPropertySet >& xPointPr
aLabel.ShowNumber = false;
aLabel.ShowNumberInPercent = false;
aLabel.ShowCategoryName = false;
+ aLabel.ShowCustomLabel = false;
xPointProp->setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabel));
}
}
diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx
index 91388d1c2eda..db93d255fe21 100644
--- a/chart2/source/view/main/VDataSeries.cxx
+++ b/chart2/source/view/main/VDataSeries.cxx
@@ -996,7 +996,7 @@ DataPointLabel* VDataSeries::getDataPointLabelIfLabel( sal_Int32 index ) const
{
DataPointLabel* pLabel = getDataPointLabel( index );
if( !pLabel || (!pLabel->ShowNumber && !pLabel->ShowNumberInPercent
- && !pLabel->ShowCategoryName ) )
+ && !pLabel->ShowCategoryName && !pLabel->ShowCustomLabel ) )
return nullptr;
return pLabel;
}
diff --git a/offapi/com/sun/star/chart/ChartDataCaption.idl b/offapi/com/sun/star/chart/ChartDataCaption.idl
index c0b589a2efe9..fb5da8034961 100644
--- a/offapi/com/sun/star/chart/ChartDataCaption.idl
+++ b/offapi/com/sun/star/chart/ChartDataCaption.idl
@@ -68,6 +68,14 @@ published constants ChartDataCaption
/** The symbol of data column/row is additionally displayed in the caption.
*/
const long SYMBOL = 16;
+
+
+ /** The caption contains a custom text, which belongs
+ to a data point label.
+
+ @since LibreOffice 7.1
+ */
+ const long CUSTOM = 32;
};
diff --git a/offapi/com/sun/star/chart2/DataPointLabel.idl b/offapi/com/sun/star/chart2/DataPointLabel.idl
index 5963e8dd93b2..f16245c8797a 100644
--- a/offapi/com/sun/star/chart2/DataPointLabel.idl
+++ b/offapi/com/sun/star/chart2/DataPointLabel.idl
@@ -57,6 +57,13 @@ struct DataPointLabel
caption.
*/
boolean ShowLegendSymbol;
+
+ /** The caption contains a custom label text, which belongs
+ to a data point label.
+
+ @since LibreOffice 7.1
+ */
+ boolean ShowCustomLabel;
};
diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx
index 47e2f643b900..484619326f20 100644
--- a/oox/source/drawingml/chart/seriesconverter.cxx
+++ b/oox/source/drawingml/chart/seriesconverter.cxx
@@ -109,7 +109,7 @@ void convertTextProperty(PropertySet& rPropSet, ObjectFormatter& rFormatter,
void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatter,
DataLabelModelBase& rDataLabel, const TypeGroupConverter& rTypeGroup,
- bool bDataSeriesLabel, bool bHasInternalData, bool bMSO2007Doc )
+ bool bDataSeriesLabel, bool bCustomLabelField, bool bHasInternalData, bool bMSO2007Doc )
{
const TypeGroupInfo& rTypeInfo = rTypeGroup.getTypeInfo();
@@ -141,7 +141,7 @@ void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatt
// type of attached label
if( bHasAnyElement || rDataLabel.mbDeleted )
{
- DataPointLabel aPointLabel( bShowValue, bShowPercent, bShowCateg, bShowSymbol );
+ DataPointLabel aPointLabel( bShowValue, bShowPercent, bShowCateg, bShowSymbol, bCustomLabelField );
rPropSet.setProperty( PROP_Label, aPointLabel );
}
@@ -277,8 +277,8 @@ void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDat
bool bHasInternalData = getChartDocument()->hasInternalDataProvider();
PropertySet aPropSet( rxDataSeries->getDataPointByIndex( mrModel.mnIndex ) );
- lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, false, bHasInternalData, bMSO2007Doc );
-
+ bool bCustomLabelField = mrModel.mxText && mrModel.mxText->mxTextBody && !mrModel.mxText->mxTextBody->getParagraphs().empty();
+ lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, false, bCustomLabelField, bHasInternalData, bMSO2007Doc );
const TypeGroupInfo& rTypeInfo = rTypeGroup.getTypeInfo();
bool bIsPie = rTypeInfo.meTypeCategory == TYPECATEGORY_PIE;
@@ -296,7 +296,7 @@ void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDat
importFillProperties(aPropSet, *mrModel.mxShapeProp, getFilter().getGraphicHelper(),
rHelper);
}
- if( mrModel.mxText && mrModel.mxText->mxTextBody && !mrModel.mxText->mxTextBody->getParagraphs().empty() )
+ if( bCustomLabelField )
{
css::uno::Reference< XComponentContext > xContext = getComponentContext();
uno::Sequence< css::uno::Reference< XDataPointCustomLabelField > > aSequence;
@@ -411,7 +411,7 @@ void DataLabelsConverter::convertFromModel( const Reference< XDataSeries >& rxDa
bool bMSO2007Doc = getFilter().isMSO2007Document();
bool bHasInternalData = getChartDocument()->hasInternalDataProvider();
- lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, true, bHasInternalData, bMSO2007Doc );
+ lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, true, false, bHasInternalData, bMSO2007Doc );
if (mrModel.mxShapeProp)
{
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index 38a1f84d173b..af917bc95121 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -1099,7 +1099,7 @@ void XclImpChText::ConvertDataLabel( ScfPropertySet& rPropSet, const XclChTypeIn
bool bShowSymbol = bShowAny && ::get_flag( maData.mnFlags, EXC_CHTEXT_SHOWSYMBOL );
// create API struct for label values, set API label separator
- cssc2::DataPointLabel aPointLabel( bShowValue, bShowPercent, bShowCateg, bShowSymbol );
+ cssc2::DataPointLabel aPointLabel( bShowValue, bShowPercent, bShowCateg, bShowSymbol, false );
rPropSet.SetProperty( EXC_CHPROP_LABEL, aPointLabel );
OUString aSep = mxLabelProps ? mxLabelProps->maSeparator : OUString('\n');
if( aSep.isEmpty() )
diff --git a/sw/qa/extras/layout/data/tdf136061.docx b/sw/qa/extras/layout/data/tdf136061.docx
new file mode 100644
index 000000000000..c91e3438ffbf
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf136061.docx
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 7dca4acd2314..11bdd07c9771 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3105,6 +3105,20 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf134146)
assertXPath(pXmlDoc, "//textarray", 14);
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf136061)
+{
+ SwDoc* pDoc = createDoc("tdf136061.docx");
+ SwDocShell* pShell = pDoc->GetDocShell();
+
+ // Dump the rendering of the first page as an XML file.
+ std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
+ MetafileXmlDump dumper;
+ xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
+ CPPUNIT_ASSERT(pXmlDoc);
+ // This failed, if the custom text of data label is missing.
+ assertXPathContent(pXmlDoc, "//textarray[16]/text", "Customlabel");
+}
+
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116925)
{
SwDoc* pDoc = createDoc("tdf116925.docx");
diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx
index eb743022fd3e..ffb75d8d65f1 100644
--- a/xmloff/source/chart/SchXMLSeries2Context.cxx
+++ b/xmloff/source/chart/SchXMLSeries2Context.cxx
@@ -37,6 +37,7 @@
#include <com/sun/star/chart/ChartAxisAssign.hpp>
#include <com/sun/star/chart/ChartSymbolType.hpp>
+#include <com/sun/star/chart/ChartDataCaption.hpp>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
#include <com/sun/star/chart/XChartDocument.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -1143,6 +1144,7 @@ void SchXMLSeries2Context::setStylesToDataPoints( SeriesDefaultsAndStyles& rSeri
}
}
xPointProp->setPropertyValue("CustomLabelFields", uno::Any(xLabels));
+ xPointProp->setPropertyValue("DataCaption", uno::Any(chart::ChartDataCaption::CUSTOM));
}
if( seriesStyle.mCustomLabelPos[0] != 0.0 || seriesStyle.mCustomLabelPos[1] != 0.0 )