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

Balazs Varga (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 26 06:51:08 UTC 2019


 chart2/source/view/main/ChartView.cxx  |   18 ++++++++++++++++--
 sw/qa/extras/layout/data/tdf124796.odt |binary
 sw/qa/extras/layout/layout.cxx         |   24 ++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 2 deletions(-)

New commits:
commit 2ec293ab590c440fe7e36f5b7fcbef4cbfe5133c
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Thu Apr 25 15:00:55 2019 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Fri Apr 26 08:50:10 2019 +0200

    tdf#124796 Fix chart primary Y axis scaling
    
    Re-scale the primary Y axis if the secondary axis
    is deleted and the dataseries still attached to the
    secondary axis.
    
    Change-Id: I6e7958766d23a74569ce8529ddf1bdafa89f1870
    Reviewed-on: https://gerrit.libreoffice.org/71302
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 8b0548f909ee..d165ccb05251 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -441,6 +441,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(
     bool bConnectBars = false;
     bool bGroupBarsPerAxis = true;
     bool bIncludeHiddenCells = true;
+    bool bSecondaryYaxisVisible = true;
     sal_Int32 nStartingAngle = 90;
     sal_Int32 n3DRelativeHeight = 100;
     try
@@ -479,7 +480,19 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(
     {
         uno::Reference< XCoordinateSystem > xCooSys( aCooSysList[nCS] );
         VCoordinateSystem* pVCooSys = addCooSysToList(m_rVCooSysList,xCooSys,rChartModel);
-
+        // Let's check whether the secondary Y axis is visible
+        try
+        {
+            Reference< beans::XPropertySet > xAxisProp(xCooSys->getAxisByDimension(1, 1), uno::UNO_QUERY);
+            if (xAxisProp.is())
+            {
+                xAxisProp->getPropertyValue("Show") >>= bSecondaryYaxisVisible;
+            }
+        }
+        catch (const lang::IndexOutOfBoundsException& e)
+        {
+            SAL_WARN("chart2", "Exception caught. " << e);
+        }
         //iterate through all chart types in the current coordinate system
         uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
         OSL_ASSERT( xChartTypeContainer.is());
@@ -563,7 +576,8 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(
 
                 //ignore secondary axis for charttypes that do not support them
                 if( pSeries->getAttachedAxisIndex() != MAIN_AXIS_INDEX &&
-                    !ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimensionCount ) )
+                  ( !ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimensionCount ) ||
+                    !bSecondaryYaxisVisible ) )
                 {
                     pSeries->setAttachedAxisIndex(MAIN_AXIS_INDEX);
                 }
diff --git a/sw/qa/extras/layout/data/tdf124796.odt b/sw/qa/extras/layout/data/tdf124796.odt
new file mode 100644
index 000000000000..2a8d2c816ad1
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf124796.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 91705c8e18d9..c17adf1bba92 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2340,6 +2340,30 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf122800)
     // This failed, if the textarray length of the first axis label not 22.
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf124796)
+{
+    SwDoc* pDoc = createDoc("tdf124796.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);
+
+    // This failed, if the minimum value of Y axis is not -10.
+    assertXPathContent(
+        pXmlDoc,
+        "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[5]/text",
+        "-10");
+
+    // This failed, if the maximum value of Y axis is not 15.
+    assertXPathContent(
+        pXmlDoc,
+        "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[10]/text",
+        "15");
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116925)
 {
     SwDoc* pDoc = createDoc("tdf116925.docx");


More information about the Libreoffice-commits mailing list