[Libreoffice-commits] core.git: include/oox oox/source

Caolán McNamara caolanm at redhat.com
Thu Sep 3 08:09:54 PDT 2015


 include/oox/export/chartexport.hxx |   29 ++++++++++++++++++-----------
 oox/source/export/chartexport.cxx  |   35 ++++++++++++++++++++---------------
 2 files changed, 38 insertions(+), 26 deletions(-)

New commits:
commit 90ea1221856340860c406357e274000771b5b127
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Sep 3 15:07:49 2015 +0100

    convert Axis constants to an enum and hilight suspicious absence
    
    that compiler warnings then shows (which I saw manually in the first place)
    of AXIS_SECONDARY_X
    
    Change-Id: I873623141020633ea73f14f5c93322c2346b8efb

diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx
index c043fd7..da434b1 100644
--- a/include/oox/export/chartexport.hxx
+++ b/include/oox/export/chartexport.hxx
@@ -64,18 +64,25 @@ namespace com { namespace sun { namespace star {
 
 namespace oox { namespace drawingml {
 
-const sal_Int32  AXIS_PRIMARY_X = 1;
-const sal_Int32  AXIS_PRIMARY_Y = 2;
-const sal_Int32  AXIS_PRIMARY_Z = 3;
-const sal_Int32  AXIS_SECONDARY_X = 4;
-const sal_Int32  AXIS_SECONDARY_Y = 5;
+enum AxesType
+{
+    AXIS_PRIMARY_X = 1,
+    AXIS_PRIMARY_Y = 2,
+    AXIS_PRIMARY_Z = 3,
+    AXIS_SECONDARY_X = 4,
+    AXIS_SECONDARY_Y = 5
+};
 
 struct AxisIdPair{
-    sal_Int32 nAxisType;
+    AxesType nAxisType;
     sal_Int32 nAxisId;
     sal_Int32 nCrossAx;
 
-    AxisIdPair( sal_Int32 nType, sal_Int32 nId, sal_Int32 nAx ): nAxisType( nType ),nAxisId( nId ),nCrossAx( nAx ) {}
+    AxisIdPair(AxesType nType, sal_Int32 nId, sal_Int32 nAx)
+        : nAxisType(nType)
+        , nAxisId(nId)
+        , nCrossAx(nAx)
+    {}
 };
 
 class OOX_DLLPUBLIC ChartExport : public DrawingML {
@@ -145,14 +152,14 @@ private:
     void exportHiLowLines();
     void exportUpDownBars(css::uno::Reference< css::chart2::XChartType > xChartType );
 
-    void exportAllSeries(css::uno::Reference<css::chart2::XChartType> xChartType, sal_Int32& nAttachedAxis);
+    void exportAllSeries(css::uno::Reference<css::chart2::XChartType> xChartType, AxesType& rAttachedAxis);
     void exportSeries(css::uno::Reference< css::chart2::XChartType > xChartType,
-            css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries> >& rSeriesSeq, sal_Int32& nAttachedAxis );
+            css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries> >& rSeriesSeq, AxesType& rAttachedAxis );
     void exportCandleStickSeries(
         const css::uno::Sequence<
             css::uno::Reference<
                 css::chart2::XDataSeries > > & aSeriesSeq,
-        bool bJapaneseCandleSticks, sal_Int32& nAttachedAxis );
+        bool bJapaneseCandleSticks, AxesType& rAttachedAxis );
     void exportSeriesText(
         const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq );
     void exportSeriesCategory(
@@ -186,7 +193,7 @@ private:
         sal_Int32 nAxisType,
         const char* sAxisPos,
         const AxisIdPair& rAxisIdPair );
-    void exportAxesId( sal_Int32 nAttachedAxis );
+    void exportAxesId(AxesType nAttachedAxis);
     void exportView3D();
     bool isDeep3dChart();
 
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 14eb613..3c0fcaf 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -119,7 +119,7 @@ namespace oox { namespace drawingml {
 
 namespace {
 
-sal_Int32 translateFromChart2AxisIndexToOox(sal_Int32 nIndex)
+AxesType translateFromChart2AxisIndexToOox(sal_Int32 nIndex)
 {
     assert(nIndex == 0 || nIndex == 1);
     if (nIndex == 1)
@@ -1533,7 +1533,7 @@ void ChartExport::exportAreaChart( Reference< chart2::XChartType > xChartType )
             FSEND );
 
     exportGrouping( );
-    sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
+    AxesType nAttachedAxis = AXIS_PRIMARY_Y;
     exportAllSeries( xChartType, nAttachedAxis );
     exportAxesId( nAttachedAxis );
 
@@ -1566,7 +1566,7 @@ void ChartExport::exportBarChart( Reference< chart2::XChartType > xChartType )
             XML_val, varyColors,
             FSEND );
 
-    sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
+    AxesType nAttachedAxis = AXIS_PRIMARY_Y;
     exportAllSeries( xChartType, nAttachedAxis );
 
     Reference< XPropertySet > xTypeProp( xChartType, uno::UNO_QUERY );
@@ -1642,7 +1642,7 @@ void ChartExport::exportBubbleChart( Reference< chart2::XChartType > xChartType
             XML_val, varyColors,
             FSEND );
 
-    sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
+    AxesType nAttachedAxis = AXIS_PRIMARY_Y;
     exportAllSeries( xChartType, nAttachedAxis );
 
     pFS->singleElement(FSNS(XML_c, XML_bubble3D),
@@ -1660,7 +1660,7 @@ void ChartExport::exportDoughnutChart( Reference< chart2::XChartType > xChartTyp
     pFS->startElement( FSNS( XML_c, XML_doughnutChart ),
             FSEND );
 
-    sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
+    AxesType nAttachedAxis = AXIS_PRIMARY_Y;
     exportAllSeries( xChartType, nAttachedAxis );
     // firstSliceAng
     exportFirstSliceAng( );
@@ -1734,7 +1734,7 @@ void ChartExport::exportLineChart( Reference< chart2::XChartType > xChartType )
 
         exportGrouping( );
         // TODO: show marker symbol in series?
-        sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
+        AxesType nAttachedAxis = AXIS_PRIMARY_Y;
         exportSeries( xChartType, *itr, nAttachedAxis );
 
         // show marker?
@@ -1779,7 +1779,7 @@ void ChartExport::exportPieChart( Reference< chart2::XChartType > xChartType )
             XML_val, varyColors,
             FSEND );
 
-    sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
+    AxesType nAttachedAxis = AXIS_PRIMARY_Y;
     exportAllSeries( xChartType, nAttachedAxis );
 
     if( !mbIs3DChart )
@@ -1807,7 +1807,7 @@ void ChartExport::exportRadarChart( Reference< chart2::XChartType > xChartType)
     pFS->singleElement( FSNS( XML_c, XML_radarStyle ),
             XML_val, radarStyle,
             FSEND );
-    sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
+    AxesType nAttachedAxis = AXIS_PRIMARY_Y;
     exportAllSeries( xChartType, nAttachedAxis );
     exportAxesId( nAttachedAxis );
 
@@ -1848,7 +1848,7 @@ void ChartExport::exportScatterChart( Reference< chart2::XChartType > xChartType
                 FSEND );
 
         // FIXME: should export xVal and yVal
-        sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
+        AxesType nAttachedAxis = AXIS_PRIMARY_Y;
         exportSeries( xChartType, *itr, nAttachedAxis );
         exportAxesId( nAttachedAxis );
 
@@ -1862,7 +1862,7 @@ void ChartExport::exportStockChart( Reference< chart2::XChartType > xChartType )
     pFS->startElement( FSNS( XML_c, XML_stockChart ),
             FSEND );
 
-    sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
+    AxesType nAttachedAxis = AXIS_PRIMARY_Y;
 
     bool bJapaneseCandleSticks = false;
     Reference< beans::XPropertySet > xCTProp( xChartType, uno::UNO_QUERY );
@@ -1961,14 +1961,14 @@ void ChartExport::exportSurfaceChart( Reference< chart2::XChartType > xChartType
         nTypeId = XML_surface3DChart;
     pFS->startElement( FSNS( XML_c, nTypeId ),
             FSEND );
-    sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y;
+    AxesType nAttachedAxis = AXIS_PRIMARY_Y;
     exportAllSeries( xChartType, nAttachedAxis );
     exportAxesId( nAttachedAxis );
 
     pFS->endElement( FSNS( XML_c, nTypeId ) );
 }
 
-void ChartExport::exportAllSeries(Reference<chart2::XChartType> xChartType, sal_Int32& rAttachedAxis)
+void ChartExport::exportAllSeries(Reference<chart2::XChartType> xChartType, AxesType& rAttachedAxis)
 {
     Reference< chart2::XDataSeriesContainer > xDSCnt( xChartType, uno::UNO_QUERY );
     if( ! xDSCnt.is())
@@ -1980,7 +1980,7 @@ void ChartExport::exportAllSeries(Reference<chart2::XChartType> xChartType, sal_
 }
 
 void ChartExport::exportSeries( Reference<chart2::XChartType> xChartType,
-        Sequence<Reference<chart2::XDataSeries> >& rSeriesSeq, sal_Int32& rAttachedAxis )
+        Sequence<Reference<chart2::XDataSeries> >& rSeriesSeq, AxesType& rAttachedAxis )
 {
     OUString aLabelRole = xChartType->getRoleOfSequenceForSeriesLabel();
     OUString aChartType( xChartType->getChartType());
@@ -2181,7 +2181,7 @@ void ChartExport::exportSeries( Reference<chart2::XChartType> xChartType,
 void ChartExport::exportCandleStickSeries(
     const Sequence< Reference< chart2::XDataSeries > > & aSeriesSeq,
     bool /*bJapaneseCandleSticks*/,
-    sal_Int32& rAttachedAxis )
+    AxesType& rAttachedAxis )
 {
     for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx )
     {
@@ -2568,6 +2568,11 @@ void ChartExport::exportAxis(const AxisIdPair& rAxisIdPair)
             sAxPos = "b";
             break;
         }
+        case AXIS_SECONDARY_X:
+        {
+            //TODO: suspicously absent
+            break;
+        }
         case AXIS_SECONDARY_Y:
         {
             Reference< css::chart::XTwoAxisYSupplier > xAxisTwoYSupp( mxDiagram, uno::UNO_QUERY );
@@ -3179,7 +3184,7 @@ void ChartExport::exportDataPoints(
     }
 }
 
-void ChartExport::exportAxesId( sal_Int32 nAttachedAxis )
+void ChartExport::exportAxesId(AxesType nAttachedAxis)
 {
     sal_Int32 nAxisIdx = lcl_generateRandomValue();
     sal_Int32 nAxisIdy = lcl_generateRandomValue();


More information about the Libreoffice-commits mailing list