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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Dec 7 12:39:46 UTC 2018


 chart2/source/view/charttypes/VSeriesPlotter.cxx |   21 ++++++++++++++++++++-
 chart2/source/view/inc/LegendEntryProvider.hxx   |    4 +++-
 chart2/source/view/inc/VSeriesPlotter.hxx        |    4 +++-
 chart2/source/view/main/VLegend.cxx              |    2 +-
 sw/qa/extras/layout/data/tdf114163.odt           |binary
 sw/qa/extras/layout/layout.cxx                   |   20 ++++++++++++++++++++
 6 files changed, 47 insertions(+), 4 deletions(-)

New commits:
commit 40144617ce05d7eff86eeb8a412c6991fe0b819e
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Wed Dec 5 16:00:09 2018 +0100
Commit:     Bartosz Kosiorek <gang65 at poczta.onet.pl>
CommitDate: Fri Dec 7 13:39:22 2018 +0100

    tdf#114163 Chart: fix order of legend names
    
    Respecting the axis direction in case of
    normal/stacked/percent stacked Bar chart and
    the legend names will be in the right order.
    
    Change-Id: If782393a33e48dae32f919d137e1d1148a85b0b0
    Reviewed-on: https://gerrit.libreoffice.org/64632
    Tested-by: Jenkins
    Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>

diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index ee76f7351d93..a79fadcc974b 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -40,6 +40,7 @@
 #include <DateHelper.hxx>
 #include <DiagramHelper.hxx>
 #include <defines.hxx>
+#include <ChartModel.hxx>
 
 //only for creation: @todo remove if all plotter are uno components and instantiated via servicefactory
 #include "BarChart.hxx"
@@ -66,6 +67,7 @@
 #include <basegfx/vector/b2dvector.hxx>
 #include <com/sun/star/drawing/LineStyle.hpp>
 #include <com/sun/star/util/XCloneable.hpp>
+#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
 
 #include <com/sun/star/style/ParagraphAdjust.hpp>
 #include <com/sun/star/drawing/XShapes.hpp>
@@ -2188,12 +2190,26 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntries(
             , const Reference< drawing::XShapes >& xTarget
             , const Reference< lang::XMultiServiceFactory >& xShapeFactory
             , const Reference< uno::XComponentContext >& xContext
+            , ChartModel& rModel
             )
 {
     std::vector< ViewLegendEntry > aResult;
 
     if( xTarget.is() )
     {
+        uno::Reference< XCoordinateSystemContainer > xCooSysCnt( rModel.getFirstDiagram(), uno::UNO_QUERY );
+        Reference< chart2::XCoordinateSystem > xCooSys(xCooSysCnt->getCoordinateSystems()[0]);
+        Reference< beans::XPropertySet > xProp( xCooSys, uno::UNO_QUERY );
+        bool bSwapXAndY = false;
+
+        if( xProp.is()) try
+        {
+            xProp->getPropertyValue( "SwapXAndYAxis" ) >>= bSwapXAndY;
+        }
+        catch( const uno::Exception& )
+        {
+        }
+
         //iterate through all series
         bool bBreak = false;
         bool bFirstSeries = true;
@@ -2234,7 +2250,10 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntries(
                         StackingDirection eStackingDirection( pSeries->getStackingDirection() );
                         bReverse = ( eStackingDirection == StackingDirection_Y_STACKING );
 
-                        //todo: respect direction of axis in future
+                        if( bSwapXAndY )
+                        {
+                            bReverse = !bReverse;
+                        }
                     }
 
                     if (bReverse)
diff --git a/chart2/source/view/inc/LegendEntryProvider.hxx b/chart2/source/view/inc/LegendEntryProvider.hxx
index 3ad8a94b8832..aff7a5d84116 100644
--- a/chart2/source/view/inc/LegendEntryProvider.hxx
+++ b/chart2/source/view/inc/LegendEntryProvider.hxx
@@ -25,6 +25,7 @@
 #include <com/sun/star/uno/Sequence.h>
 #include <vector>
 
+namespace chart { class ChartModel; }
 namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } } } }
 namespace com { namespace sun { namespace star { namespace chart2 { class XFormattedString2; } } } }
 namespace com { namespace sun { namespace star { namespace drawing { class XShape; } } } }
@@ -75,7 +76,8 @@ public:
             const css::uno::Reference< css::beans::XPropertySet >& xTextProperties,
             const css::uno::Reference< css::drawing::XShapes >& xTarget,
             const css::uno::Reference< css::lang::XMultiServiceFactory >& xShapeFactory,
-            const css::uno::Reference< css::uno::XComponentContext >& xContext
+            const css::uno::Reference< css::uno::XComponentContext >& xContext,
+            ChartModel& rModel
                 ) = 0;
 
 protected:
diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx
index e181c7590a71..445411523359 100644
--- a/chart2/source/view/inc/VSeriesPlotter.hxx
+++ b/chart2/source/view/inc/VSeriesPlotter.hxx
@@ -33,6 +33,7 @@ namespace com { namespace sun { namespace star { namespace chart2 { class XChart
 
 namespace chart { class ExplicitCategoriesProvider; }
 namespace chart { struct ExplicitScaleData; }
+namespace chart { class ChartModel; }
 
 namespace com { namespace sun { namespace star {
     namespace util {
@@ -197,7 +198,8 @@ public:
             const css::uno::Reference< css::beans::XPropertySet >& xTextProperties,
             const css::uno::Reference< css::drawing::XShapes >& xTarget,
             const css::uno::Reference< css::lang::XMultiServiceFactory >& xShapeFactory,
-            const css::uno::Reference< css::uno::XComponentContext >& xContext
+            const css::uno::Reference< css::uno::XComponentContext >& xContext,
+            ChartModel& rModel
                 ) override;
 
     virtual LegendSymbolStyle getLegendSymbolStyle();
diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx
index 52a4f78fd8c9..d201a2c72756 100644
--- a/chart2/source/view/main/VLegend.cxx
+++ b/chart2/source/view/main/VLegend.cxx
@@ -949,7 +949,7 @@ void VLegend::createShapes(
                 {
                     std::vector<ViewLegendEntry> aNewEntries = pLegendEntryProvider->createLegendEntries(
                                                                     aMaxSymbolExtent, eExpansion, xLegendProp,
-                                                                    xLegendContainer, m_xShapeFactory, m_xContext);
+                                                                    xLegendContainer, m_xShapeFactory, m_xContext, mrModel);
                     aViewEntries.insert( aViewEntries.end(), aNewEntries.begin(), aNewEntries.end() );
                 }
             }
diff --git a/sw/qa/extras/layout/data/tdf114163.odt b/sw/qa/extras/layout/data/tdf114163.odt
new file mode 100755
index 000000000000..cf22e1160b2c
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf114163.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 304f14b40398..4ac2f6ce555e 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -40,6 +40,7 @@ public:
     void testRedlineTables();
     void testRedlineCharAttributes();
     void testTdf116830();
+    void testTdf114163();
     void testTdf116925();
     void testTdf117028();
     void testTdf106390();
@@ -73,6 +74,7 @@ public:
     CPPUNIT_TEST(testRedlineTables);
     CPPUNIT_TEST(testRedlineCharAttributes);
     CPPUNIT_TEST(testTdf116830);
+    CPPUNIT_TEST(testTdf114163);
     CPPUNIT_TEST(testTdf116925);
     CPPUNIT_TEST(testTdf117028);
     CPPUNIT_TEST(testTdf106390);
@@ -2299,6 +2301,24 @@ void SwLayoutWriter::testTdf116830()
     assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/rect", 1);
 }
 
+void SwLayoutWriter::testTdf114163()
+{
+    SwDoc* pDoc = createDoc("tdf114163.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 = dumper.dumpAndParse(*xMetaFile);
+    CPPUNIT_ASSERT(pXmlDoc);
+
+    assertXPathContent(
+        pXmlDoc,
+        "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[12]/text",
+        "Data3");
+    // This failed, if the legend first label is not "Data3".
+}
+
 void SwLayoutWriter::testTdf116925()
 {
     SwDoc* pDoc = createDoc("tdf116925.docx");


More information about the Libreoffice-commits mailing list