[Libreoffice-commits] core.git: chart2/source sw/qa

Balazs Varga (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 12 14:55:19 UTC 2019


 chart2/source/tools/UncachedDataSequence.cxx |   13 +++++++++++--
 sw/qa/extras/layout/data/tdf75659.docx       |binary
 sw/qa/extras/layout/layout.cxx               |   25 +++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 2 deletions(-)

New commits:
commit 007bf60611e2ba5a65ffabe80dbb0e279fcb9f26
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Tue Jun 11 13:26:50 2019 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Wed Jun 12 16:54:03 2019 +0200

    tdf#75659 Chart: fix empty legend at not available legend names
    
    by using localized versions of "Unnamed Series 1" etc.
    
    Note: OOXML files don't contain the default or fallback legend names
    used by MSO in this case, so the original empty string replacement
    of the missing names resulted bad chart import.
    
    Change-Id: I2897c70d9003e1ab3241dd569de0d79821d896b1
    Reviewed-on: https://gerrit.libreoffice.org/73817
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Tested-by: László Németh <nemeth at numbertext.org>

diff --git a/chart2/source/tools/UncachedDataSequence.cxx b/chart2/source/tools/UncachedDataSequence.cxx
index b9721490b7e7..ca3a9280c452 100644
--- a/chart2/source/tools/UncachedDataSequence.cxx
+++ b/chart2/source/tools/UncachedDataSequence.cxx
@@ -23,6 +23,8 @@
 
 #include <cppuhelper/supportsservice.hxx>
 #include <algorithm>
+#include <strings.hrc>
+#include <ResId.hxx>
 #include <com/sun/star/chart2/XInternalDataProvider.hpp>
 #include <tools/diagnose_ex.h>
 
@@ -209,8 +211,15 @@ OUString SAL_CALL UncachedDataSequence::getSourceRangeRepresentation()
 
 Sequence< OUString > SAL_CALL UncachedDataSequence::generateLabel( chart2::data::LabelOrigin )
 {
-    // auto-generated label is an empty string
-    return Sequence< OUString >(1);
+    // auto-generated label
+    sal_Int32 nSeries = m_aSourceRepresentation.toInt32() + 1;
+    OUString aResString(::chart::SchResId(STR_DATA_UNNAMED_SERIES_WITH_INDEX));
+    const OUString aReplacementStr("%NUMBER");
+    sal_Int32 nIndex = aResString.indexOf(aReplacementStr);
+    OUString aName;
+    if( nIndex != -1 )
+        aName = aResString.replaceAt(nIndex, aReplacementStr.getLength(), OUString::number(nSeries));
+    return Sequence< OUString >( &aName, 1 );
 }
 
 ::sal_Int32 SAL_CALL UncachedDataSequence::getNumberFormatKeyByIndex( ::sal_Int32 )
diff --git a/sw/qa/extras/layout/data/tdf75659.docx b/sw/qa/extras/layout/data/tdf75659.docx
new file mode 100644
index 000000000000..a3cde330f8f5
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf75659.docx differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 1175d25ef573..325c0ef49e64 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2327,6 +2327,31 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf125335)
     // This failed, if the legend first label is not "Data3". The legend position is bottom.
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf75659)
+{
+    SwDoc* pDoc = createDoc("tdf75659.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;
+    xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
+    CPPUNIT_ASSERT(pXmlDoc);
+
+    assertXPathContent(pXmlDoc,
+                       "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[17]/text",
+                       "Unnamed Series 1");
+
+    assertXPathContent(pXmlDoc,
+                       "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[18]/text",
+                       "Unnamed Series 2");
+
+    assertXPathContent(pXmlDoc,
+                       "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[19]/text",
+                       "Unnamed Series 3");
+    // These failed, if the legend names are empty strings.
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf108021)
 {
     SwDoc* pDoc = createDoc("tdf108021.odt");


More information about the Libreoffice-commits mailing list