[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - chart2/qa oox/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Mar 5 07:56:32 UTC 2019


 chart2/qa/extras/chart2import.cxx              |   20 ++++++++++++++++++++
 chart2/qa/extras/data/docx/testTdf122226.docx  |binary
 oox/source/drawingml/chart/seriesconverter.cxx |    6 +++++-
 3 files changed, 25 insertions(+), 1 deletion(-)

New commits:
commit 592c6893156615695b7f95f53d71624a87650bf6
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Fri Feb 8 11:24:07 2019 +0100
Commit:     Bartosz Kosiorek <gang65 at poczta.onet.pl>
CommitDate: Tue Mar 5 08:56:08 2019 +0100

    tdf#122226 OOXML Chart Import: data label separator
    
    Set the data label separator to "new line" if there is not
    present explicit point separator and the "percentage format
    wins over number value format". In MS-Office (2007/2010/2013/2016)
    the defult separator is the "new line" in that case, any other
    case the separator is a semicolon.
    (cherry picked from commit de73efb96fbb1d268caea0f41acbe20a234ec59f)
    (cherry picked from commit 42fd10b0ab6c6f65ba6394f9ae216c0f13973221)
    
    Change-Id: I9ee0fb9f98fc1bb322892616af50954f4f8db0f9
    Reviewed-on: https://gerrit.libreoffice.org/67758
    Tested-by: Jenkins
    Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>

diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index aa46fbae8503..b429a3e7f20f 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -106,6 +106,7 @@ public:
     void testTdf109858(); // Pie chart label placement settings(XLSX)
 
     void testTdf111173();
+    void testTdf122226();
 
     void testInternalDataProvider();
 
@@ -177,6 +178,7 @@ public:
     CPPUNIT_TEST(testTdf90510);
     CPPUNIT_TEST(testTdf109858);
     CPPUNIT_TEST(testTdf111173);
+    CPPUNIT_TEST(testTdf122226);
 
     CPPUNIT_TEST(testInternalDataProvider);
 
@@ -1440,6 +1442,24 @@ void Chart2ImportTest::testTdf111173()
     uno::Reference< chart::XChartDocument > xChart1Doc( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW );
 }
 
+void Chart2ImportTest::testTdf122226()
+{
+    load( "/chart2/qa/extras/data/docx/", "testTdf122226.docx" );
+    uno::Reference< chart2::XChartDocument > xChartDoc ( getChartDocFromWriter(0), uno::UNO_QUERY);
+    CPPUNIT_ASSERT( xChartDoc.is() );
+
+    css::uno::Reference<chart2::XDiagram> xDiagram(xChartDoc->getFirstDiagram(), UNO_QUERY_THROW);
+    Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
+    uno::Reference<beans::XPropertySet> xPropertySet(xDataSeries->getDataPointByIndex(0), uno::UNO_QUERY_THROW);
+    CPPUNIT_ASSERT(xPropertySet.is());
+
+    uno::Any aAny = xPropertySet->getPropertyValue( "LabelSeparator" );
+    CPPUNIT_ASSERT( aAny.hasValue() );
+    OUString nLabelSeparator;
+    CPPUNIT_ASSERT( aAny >>= nLabelSeparator );
+    CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data labels should be separated into new lines", OUString("\n"), nLabelSeparator );
+}
+
 void Chart2ImportTest::testTdf115107()
 {
     load("/chart2/qa/extras/data/pptx/", "tdf115107.pptx");
diff --git a/chart2/qa/extras/data/docx/testTdf122226.docx b/chart2/qa/extras/data/docx/testTdf122226.docx
new file mode 100755
index 000000000000..7205525a7615
Binary files /dev/null and b/chart2/qa/extras/data/docx/testTdf122226.docx differ
diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx
index 716a0b234bdd..01e1d72562c5 100644
--- a/oox/source/drawingml/chart/seriesconverter.cxx
+++ b/oox/source/drawingml/chart/seriesconverter.cxx
@@ -182,7 +182,11 @@ void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatt
         convertTextProperty(rPropSet, rFormatter, rDataLabel.mxTextProp);
 
         // data label separator (do not overwrite series separator, if no explicit point separator is present)
-        if( bDataSeriesLabel || rDataLabel.moaSeparator.has() )
+        // Set the data label separator to "new line" if the value is shown as percentage with a category name,
+        // just like in MS-Office. In any other case the default separator will be a semicolon.
+        if( bShowPercent && !bShowValue && ( bDataSeriesLabel || rDataLabel.moaSeparator.has() ) )
+            rPropSet.setProperty( PROP_LabelSeparator, rDataLabel.moaSeparator.get( "\n" ) );
+        else if( bDataSeriesLabel || rDataLabel.moaSeparator.has() )
             rPropSet.setProperty( PROP_LabelSeparator, rDataLabel.moaSeparator.get( "; " ) );
 
         // data label placement (do not overwrite series placement, if no explicit point placement is present)


More information about the Libreoffice-commits mailing list