kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0005-bnc-881025-Mark-axis-a-percent-axis-only-when-all-da.patch

f085be
From c1ed90d187eac6abae9f7e50137b20d2ce93f7ff Mon Sep 17 00:00:00 2001
f085be
From: Kohei Yoshida <kohei.yoshida@collabora.com>
f085be
Date: Mon, 7 Jul 2014 16:38:29 -0400
f085be
Subject: [PATCH 005/137] bnc#881025: Mark axis a percent axis only when all
f085be
 data series are percent.
f085be
f085be
(cherry picked from commit b8c444a46b2f41dae673c6118d84276be0e6c87d)
f085be
Signed-off-by: Andras Timar <andras.timar@collabora.com>
f085be
f085be
Conflicts:
f085be
	oox/inc/drawingml/chart/axisconverter.hxx
f085be
f085be
Change-Id: I302cc1e5b164b2ce9999087293b034ec930951af
f085be
(cherry picked from commit 3997f7b8e5f07312466e66f6bcf0a4ac1c8c5a39)
f085be
Signed-off-by: Andras Timar <andras.timar@collabora.com>
f085be
---
f085be
 include/oox/drawingml/chart/axisconverter.hxx    | 10 +++----
f085be
 oox/source/drawingml/chart/axisconverter.cxx     | 38 +++++++++++++++++++-----
f085be
 oox/source/drawingml/chart/plotareaconverter.cxx |  6 ++--
f085be
 3 files changed, 38 insertions(+), 16 deletions(-)
f085be
f085be
diff --git a/include/oox/drawingml/chart/axisconverter.hxx b/include/oox/drawingml/chart/axisconverter.hxx
f085be
index e107057..f2df756 100644
f085be
--- a/include/oox/drawingml/chart/axisconverter.hxx
f085be
+++ b/include/oox/drawingml/chart/axisconverter.hxx
f085be
@@ -45,12 +45,10 @@ public:
f085be
     virtual             ~AxisConverter();
f085be
 
f085be
     /** Creates a chart2 axis and inserts it into the passed coordinate system. */
f085be
-    void                convertFromModel(
f085be
-                            const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >& rxCoordSystem,
f085be
-                            TypeGroupConverter& rTypeGroup,
f085be
-                            const AxisModel* pCrossingAxis,
f085be
-                            sal_Int32 nAxesSetIdx,
f085be
-                            sal_Int32 nAxisIdx );
f085be
+    void convertFromModel(
f085be
+        const css::uno::Reference<css::chart2::XCoordinateSystem>& rxCoordSystem,
f085be
+        RefVector<TypeGroupConverter>& rTypeGroups, const AxisModel* pCrossingAxis,
f085be
+        sal_Int32 nAxesSetIdx, sal_Int32 nAxisIdx );
f085be
 };
f085be
 
f085be
 // ============================================================================
f085be
diff --git a/oox/source/drawingml/chart/axisconverter.cxx b/oox/source/drawingml/chart/axisconverter.cxx
f085be
index f290992..d30595d 100644
f085be
--- a/oox/source/drawingml/chart/axisconverter.cxx
f085be
+++ b/oox/source/drawingml/chart/axisconverter.cxx
f085be
@@ -107,6 +107,26 @@ sal_Int32 lclGetTickMark( sal_Int32 nToken )
f085be
     return NONE;
f085be
 }
f085be
 
f085be
+/**
f085be
+ * The groups is of percent type only when all of its members are of percent
f085be
+ * type.
f085be
+ */
f085be
+bool isPercent( const RefVector<TypeGroupConverter>& rTypeGroups )
f085be
+{
f085be
+    if (rTypeGroups.empty())
f085be
+        return false;
f085be
+
f085be
+    RefVector<TypeGroupConverter>::const_iterator it = rTypeGroups.begin(), itEnd = rTypeGroups.end();
f085be
+    for (; it != itEnd; ++it)
f085be
+    {
f085be
+        TypeGroupConverter& rConv = **it;
f085be
+        if (!rConv.isPercent())
f085be
+            return false;
f085be
+    }
f085be
+
f085be
+    return true;
f085be
+}
f085be
+
f085be
 } // namespace
f085be
 
f085be
 // ============================================================================
f085be
@@ -120,16 +140,20 @@ AxisConverter::~AxisConverter()
f085be
 {
f085be
 }
f085be
 
f085be
-void AxisConverter::convertFromModel( const Reference< XCoordinateSystem >& rxCoordSystem,
f085be
-        TypeGroupConverter& rTypeGroup, const AxisModel* pCrossingAxis, sal_Int32 nAxesSetIdx, sal_Int32 nAxisIdx )
f085be
+void AxisConverter::convertFromModel(
f085be
+    const Reference< XCoordinateSystem >& rxCoordSystem,
f085be
+    RefVector<TypeGroupConverter>& rTypeGroups, const AxisModel* pCrossingAxis, sal_Int32 nAxesSetIdx, sal_Int32 nAxisIdx )
f085be
 {
f085be
+    if (rTypeGroups.empty())
f085be
+        return;
f085be
+
f085be
     Reference< XAxis > xAxis;
f085be
     try
f085be
     {
f085be
         namespace cssc = ::com::sun::star::chart;
f085be
         namespace cssc2 = ::com::sun::star::chart2;
f085be
 
f085be
-        const TypeGroupInfo& rTypeInfo = rTypeGroup.getTypeInfo();
f085be
+        const TypeGroupInfo& rTypeInfo = rTypeGroups.front()->getTypeInfo();
f085be
         ObjectFormatter& rFormatter = getFormatter();
f085be
 
f085be
         // create the axis object (always)
f085be
@@ -189,7 +213,7 @@ void AxisConverter::convertFromModel( const Reference< XCoordinateSystem >& rxCo
f085be
                         currently). */
f085be
                     aScaleData.AxisType = (bDateAxis && !mrModel.mbAuto) ? cssc2::AxisType::DATE : cssc2::AxisType::CATEGORY;
f085be
                     aScaleData.AutoDateAxis = mrModel.mbAuto;
f085be
-                    aScaleData.Categories = rTypeGroup.createCategorySequence();
f085be
+                    aScaleData.Categories = rTypeGroups.front()->createCategorySequence();
f085be
                 }
f085be
                 else
f085be
                 {
f085be
@@ -199,11 +223,11 @@ void AxisConverter::convertFromModel( const Reference< XCoordinateSystem >& rxCo
f085be
             break;
f085be
             case API_Y_AXIS:
f085be
                 OSL_ENSURE( mrModel.mnTypeId == C_TOKEN( valAx ), "AxisConverter::convertFromModel - unexpected axis model type (must: c:valAx)" );
f085be
-                aScaleData.AxisType = rTypeGroup.isPercent() ? cssc2::AxisType::PERCENT : cssc2::AxisType::REALNUMBER;
f085be
+                aScaleData.AxisType = isPercent(rTypeGroups) ? cssc2::AxisType::PERCENT : cssc2::AxisType::REALNUMBER;
f085be
             break;
f085be
             case API_Z_AXIS:
f085be
                 OSL_ENSURE( mrModel.mnTypeId == C_TOKEN( serAx ), "AxisConverter::convertFromModel - unexpected axis model type (must: c:serAx)" );
f085be
-                OSL_ENSURE( rTypeGroup.isDeep3dChart(), "AxisConverter::convertFromModel - series axis not supported by this chart type" );
f085be
+                OSL_ENSURE( rTypeGroups.front()->isDeep3dChart(), "AxisConverter::convertFromModel - series axis not supported by this chart type" );
f085be
                 aScaleData.AxisType = cssc2::AxisType::SERIES;
f085be
             break;
f085be
         }
f085be
@@ -330,7 +354,7 @@ void AxisConverter::convertFromModel( const Reference< XCoordinateSystem >& rxCo
f085be
         // axis title ---------------------------------------------------------
f085be
 
f085be
         // in radar charts, title objects may exist, but are not shown
f085be
-        if( mrModel.mxTitle.is() && (rTypeGroup.getTypeInfo().meTypeCategory != TYPECATEGORY_RADAR) )
f085be
+        if( mrModel.mxTitle.is() && (rTypeGroups.front()->getTypeInfo().meTypeCategory != TYPECATEGORY_RADAR) )
f085be
         {
f085be
             Reference< XTitled > xTitled( xAxis, UNO_QUERY_THROW );
f085be
             TitleConverter aTitleConv( *this, *mrModel.mxTitle );
f085be
diff --git a/oox/source/drawingml/chart/plotareaconverter.cxx b/oox/source/drawingml/chart/plotareaconverter.cxx
f085be
index ff67b5f..eaa51e0 100644
f085be
--- a/oox/source/drawingml/chart/plotareaconverter.cxx
f085be
+++ b/oox/source/drawingml/chart/plotareaconverter.cxx
f085be
@@ -171,15 +171,15 @@ void AxesSetConverter::convertFromModel( const Reference< XDiagram >& rxDiagram,
f085be
             ModelRef< AxisModel > xYAxis = lclGetOrCreateAxis( mrModel.maAxes, API_Y_AXIS, C_TOKEN( valAx ) );
f085be
 
f085be
             AxisConverter aXAxisConv( *this, *xXAxis );
f085be
-            aXAxisConv.convertFromModel( xCoordSystem, rFirstTypeGroup, xYAxis.get(), nAxesSetIdx, API_X_AXIS );
f085be
+            aXAxisConv.convertFromModel( xCoordSystem, aTypeGroups, xYAxis.get(), nAxesSetIdx, API_X_AXIS );
f085be
             AxisConverter aYAxisConv( *this, *xYAxis );
f085be
-            aYAxisConv.convertFromModel( xCoordSystem, rFirstTypeGroup, xXAxis.get(), nAxesSetIdx, API_Y_AXIS );
f085be
+            aYAxisConv.convertFromModel( xCoordSystem, aTypeGroups, xXAxis.get(), nAxesSetIdx, API_Y_AXIS );
f085be
 
f085be
             if( rFirstTypeGroup.isDeep3dChart() )
f085be
             {
f085be
                 ModelRef< AxisModel > xZAxis = lclGetOrCreateAxis( mrModel.maAxes, API_Z_AXIS, C_TOKEN( serAx ) );
f085be
                 AxisConverter aZAxisConv( *this, *xZAxis );
f085be
-                aZAxisConv.convertFromModel( xCoordSystem, rFirstTypeGroup, 0, nAxesSetIdx, API_Z_AXIS );
f085be
+                aZAxisConv.convertFromModel( xCoordSystem, aTypeGroups, 0, nAxesSetIdx, API_Z_AXIS );
f085be
             }
f085be
 
f085be
             // convert all chart type groups, this converts all series data and formatting
f085be
-- 
f085be
1.9.3
f085be