chart2/source/view/main/VLegend.cxx    |    2 ++
 sw/qa/extras/layout/data/tdf123268.odt |binary
 sw/qa/extras/layout/layout.cxx         |   18 ++++++++++++++++++
 3 files changed, 20 insertions(+)

New commits:
commit 300e65cc47f3d6ae1563350757dbfadc080d7452
Author:     Tünde Tóth <tund...@gmail.com>
AuthorDate: Thu Feb 20 14:39:11 2020 +0100
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Fri Mar 6 10:42:25 2020 +0100

    tdf#123268 fix lost chart if all legend entries are hidden
    
    See also commit 19b2ed4dee1ec33ad55473d43bfcd0bfa194cbee
    (related tdf#51671, add UI options for new "hide legend entry" feature)
    
    Change-Id: If20ab167d867d2845fa414ba0bbc490bed09f61c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89123
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/chart2/source/view/main/VLegend.cxx 
b/chart2/source/view/main/VLegend.cxx
index 919dc57ddbf3..0fa0b3552d88 100644
--- a/chart2/source/view/main/VLegend.cxx
+++ b/chart2/source/view/main/VLegend.cxx
@@ -950,6 +950,8 @@ void VLegend::createShapes(
                     std::vector<ViewLegendEntry> aNewEntries = 
pLegendEntryProvider->createLegendEntries(
                                                                     
aMaxSymbolExtent, eExpansion, xLegendProp,
                                                                     
xLegendContainer, m_xShapeFactory, m_xContext, mrModel);
+                    if (aNewEntries.size() == 0)
+                        return;
                     aViewEntries.insert( aViewEntries.end(), 
aNewEntries.begin(), aNewEntries.end() );
                 }
             }
diff --git a/sw/qa/extras/layout/data/tdf123268.odt 
b/sw/qa/extras/layout/data/tdf123268.odt
new file mode 100644
index 000000000000..e68c8139f52c
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf123268.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 9e153c86e7b5..2fcc9f8da6f4 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2319,6 +2319,24 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf75659)
     // These failed, if the legend names are empty strings.
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf123268)
+{
+    SwDoc* pDoc = createDoc("tdf123268.odt");
+    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);
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 41
+    // - Actual  : 0
+    // i.e. the chart lost.
+    assertXPath(pXmlDoc, 
"/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/push",
+                41);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf115630)
 {
     SwDoc* pDoc = createDoc("tdf115630.docx");
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to