[Libreoffice-commits] core.git: Branch 'feature/perfwork' - 4 commits - chart2/source

Kohei Yoshida kohei.yoshida at collabora.com
Mon Oct 13 16:42:09 PDT 2014


 chart2/source/view/axes/Tickmarks.cxx        |    6 -
 chart2/source/view/axes/VAxisProperties.cxx  |   48 ++++----
 chart2/source/view/axes/VAxisProperties.hxx  |   17 ++
 chart2/source/view/axes/VCartesianAxis.cxx   |  102 +++++++++--------
 chart2/source/view/axes/VCartesianAxis.hxx   |    4 
 chart2/source/view/axes/VPolarRadiusAxis.cxx |    6 -
 chart2/source/view/main/ChartView.cxx        |  155 ++++++++++++++++-----------
 7 files changed, 192 insertions(+), 146 deletions(-)

New commits:
commit a7b70511e2ba26b56c8f80ac6b3b0c0bd5630118
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Oct 13 19:32:15 2014 -0400

    More on documenting the methods.
    
    Change-Id: Ibdbc1b26521e56de5dcba1b9572bb0221fc0fff5

diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index c0e133c..5b290b0 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -255,11 +255,23 @@ public:
      * largest axis label text object prior to calling this method.
      *
      * The new axis scaling data will be stored in the VCoordinateSystem
-     * objects.
+     * objects.  The label alignment direction for each axis will also get
+     * determined during this process, and stored in VAxis.
      */
     void doAutoScaling( ChartModel& rModel );
+
+    /**
+     * After auto-scaling is performed, call this method to set the explicit
+     * scaling and increment data to all relevant VAxis objects.
+     */
     void updateScalesAndIncrementsOnAxes();
+
+    /**
+     * After auto-scaling is performed, call this method to set the explicit
+     * scaling data to all the plotters.
+     */
     void setScalesFromCooSysToPlotter();
+
     void setNumberFormatsFromAxes();
     drawing::Direction3D getPreferredAspectRatio();
 
commit 16e84295b39ffcaa519b24656de3601678df1c39
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Oct 13 15:24:33 2014 -0400

    Scope level reduction & explain what the max axis index really is.
    
    The concept of axis index and dimension index is quite confusing in the
    chart2 code....
    
    Change-Id: I035af0a225396bd5394089d6f584f78dcaf0ad31

diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 542a24f..c0e133c 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -276,7 +276,15 @@ private:
     SeriesPlottersType m_aSeriesPlotterList;
     std::vector< VCoordinateSystem* >& m_rVCooSysList;
     ::std::map< uno::Reference< XAxis >, AxisUsage > m_aAxisUsageList;
+
+    /**
+     * Max axis index of all dimensions.  Currently this can be either 0 or 1
+     * since we only support primary and secondary axes per dimension.  The
+     * value of 0 means all dimensions have only primary axis, while 1 means
+     * at least one dimension has a secondary axis.
+     */
     sal_Int32 m_nMaxAxisIndex;
+
     bool m_bChartTypeUsesShiftedCategoryPositionPerDefault;
     sal_Int32 m_nDefaultDateNumberFormat;
 };
@@ -778,85 +786,85 @@ void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries( ChartModel&
                 continue;
 
             uno::Reference< XDiagram > xDiagram( rModel.getFirstDiagram() );
-            if( xDiagram.is() )
+            if (!xDiagram.is())
+                continue;
+
+            bool bSeriesAttachedToThisAxis = false;
+            sal_Int32 nAttachedAxisIndex = -1;
             {
-                bool bSeriesAttachedToThisAxis = false;
-                sal_Int32 nAttachedAxisIndex = -1;
+                ::std::vector< Reference< XDataSeries > > aSeriesVector( DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+                ::std::vector< Reference< XDataSeries > >::const_iterator aIter = aSeriesVector.begin();
+                for( ; aIter != aSeriesVector.end(); ++aIter )
                 {
-                    ::std::vector< Reference< XDataSeries > > aSeriesVector( DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
-                    ::std::vector< Reference< XDataSeries > >::const_iterator aIter = aSeriesVector.begin();
-                    for( ; aIter != aSeriesVector.end(); ++aIter )
+                    sal_Int32 nCurrentIndex = DataSeriesHelper::getAttachedAxisIndex( *aIter );
+                    if( nAxisIndex == nCurrentIndex )
                     {
-                        sal_Int32 nCurrentIndex = DataSeriesHelper::getAttachedAxisIndex( *aIter );
-                        if( nAxisIndex == nCurrentIndex )
-                        {
-                            bSeriesAttachedToThisAxis = true;
-                            break;
-                        }
-                        else if( nAttachedAxisIndex<0 || nAttachedAxisIndex>nCurrentIndex )
-                            nAttachedAxisIndex=nCurrentIndex;
+                        bSeriesAttachedToThisAxis = true;
+                        break;
                     }
+                    else if( nAttachedAxisIndex<0 || nAttachedAxisIndex>nCurrentIndex )
+                        nAttachedAxisIndex=nCurrentIndex;
                 }
+            }
 
-                if( !bSeriesAttachedToThisAxis && nAttachedAxisIndex >= 0 )
-                {
-                    for( size_t nC = 0; nC < aVCooSysList_Y.size(); ++nC )
-                    {
-                        aVCooSysList_Y[nC]->prepareAutomaticAxisScaling( rAxisUsage.aAutoScaling, 1, nAttachedAxisIndex );
+            if (bSeriesAttachedToThisAxis || nAttachedAxisIndex < 0)
+                continue;
 
-                        ExplicitScaleData aExplicitScaleSource = aVCooSysList_Y[nC]->getExplicitScale( 1,nAttachedAxisIndex );
-                        ExplicitIncrementData aExplicitIncrementSource = aVCooSysList_Y[nC]->getExplicitIncrement( 1,nAttachedAxisIndex );
+            for( size_t nC = 0; nC < aVCooSysList_Y.size(); ++nC )
+            {
+                aVCooSysList_Y[nC]->prepareAutomaticAxisScaling( rAxisUsage.aAutoScaling, 1, nAttachedAxisIndex );
 
-                        ExplicitScaleData aExplicitScaleDest = aVCooSysList_Y[nC]->getExplicitScale( 1,nAxisIndex );;
-                        ExplicitIncrementData aExplicitIncrementDest = aVCooSysList_Y[nC]->getExplicitIncrement( 1,nAxisIndex );;
+                ExplicitScaleData aExplicitScaleSource = aVCooSysList_Y[nC]->getExplicitScale( 1,nAttachedAxisIndex );
+                ExplicitIncrementData aExplicitIncrementSource = aVCooSysList_Y[nC]->getExplicitIncrement( 1,nAttachedAxisIndex );
 
-                        aExplicitScaleDest.Orientation = aExplicitScaleSource.Orientation;
-                        aExplicitScaleDest.Scaling = aExplicitScaleSource.Scaling;
-                        aExplicitScaleDest.AxisType = aExplicitScaleSource.AxisType;
+                ExplicitScaleData aExplicitScaleDest = aVCooSysList_Y[nC]->getExplicitScale( 1,nAxisIndex );;
+                ExplicitIncrementData aExplicitIncrementDest = aVCooSysList_Y[nC]->getExplicitIncrement( 1,nAxisIndex );;
 
-                        aExplicitIncrementDest.BaseValue = aExplicitIncrementSource.BaseValue;
+                aExplicitScaleDest.Orientation = aExplicitScaleSource.Orientation;
+                aExplicitScaleDest.Scaling = aExplicitScaleSource.Scaling;
+                aExplicitScaleDest.AxisType = aExplicitScaleSource.AxisType;
 
-                        ScaleData aScale( rAxisUsage.aAutoScaling.getScale() );
-                        if( !aScale.Minimum.hasValue() )
-                        {
-                            bool bNewMinOK = true;
-                            double fMax=0.0;
-                            if( aScale.Maximum >>= fMax )
-                                bNewMinOK = (aExplicitScaleSource.Minimum <= fMax);
-                            if( bNewMinOK )
-                                aExplicitScaleDest.Minimum = aExplicitScaleSource.Minimum;
-                        }
-                        else
-                            aExplicitIncrementDest.BaseValue = aExplicitScaleDest.Minimum;
+                aExplicitIncrementDest.BaseValue = aExplicitIncrementSource.BaseValue;
 
-                        if( !aScale.Maximum.hasValue() )
-                        {
-                            bool bNewMaxOK = true;
-                            double fMin=0.0;
-                            if( aScale.Minimum >>= fMin )
-                                bNewMaxOK = (fMin <= aExplicitScaleSource.Maximum);
-                            if( bNewMaxOK )
-                                aExplicitScaleDest.Maximum = aExplicitScaleSource.Maximum;
-                        }
-                        if( !aScale.Origin.hasValue() )
-                            aExplicitScaleDest.Origin = aExplicitScaleSource.Origin;
+                ScaleData aScale( rAxisUsage.aAutoScaling.getScale() );
+                if( !aScale.Minimum.hasValue() )
+                {
+                    bool bNewMinOK = true;
+                    double fMax=0.0;
+                    if( aScale.Maximum >>= fMax )
+                        bNewMinOK = (aExplicitScaleSource.Minimum <= fMax);
+                    if( bNewMinOK )
+                        aExplicitScaleDest.Minimum = aExplicitScaleSource.Minimum;
+                }
+                else
+                    aExplicitIncrementDest.BaseValue = aExplicitScaleDest.Minimum;
 
-                        if( !aScale.IncrementData.Distance.hasValue() )
-                            aExplicitIncrementDest.Distance = aExplicitIncrementSource.Distance;
+                if( !aScale.Maximum.hasValue() )
+                {
+                    bool bNewMaxOK = true;
+                    double fMin=0.0;
+                    if( aScale.Minimum >>= fMin )
+                        bNewMaxOK = (fMin <= aExplicitScaleSource.Maximum);
+                    if( bNewMaxOK )
+                        aExplicitScaleDest.Maximum = aExplicitScaleSource.Maximum;
+                }
+                if( !aScale.Origin.hasValue() )
+                    aExplicitScaleDest.Origin = aExplicitScaleSource.Origin;
 
-                        bool bAutoMinorInterval = true;
-                        if( aScale.IncrementData.SubIncrements.getLength() )
-                            bAutoMinorInterval = !( aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() );
-                        if( bAutoMinorInterval )
-                        {
-                            if( !aExplicitIncrementDest.SubIncrements.empty() && !aExplicitIncrementSource.SubIncrements.empty() )
-                                aExplicitIncrementDest.SubIncrements[0].IntervalCount =
-                                    aExplicitIncrementSource.SubIncrements[0].IntervalCount;
-                        }
+                if( !aScale.IncrementData.Distance.hasValue() )
+                    aExplicitIncrementDest.Distance = aExplicitIncrementSource.Distance;
 
-                        aVCooSysList_Y[nC]->setExplicitScaleAndIncrement( 1, nAxisIndex, aExplicitScaleDest, aExplicitIncrementDest );
-                    }
+                bool bAutoMinorInterval = true;
+                if( aScale.IncrementData.SubIncrements.getLength() )
+                    bAutoMinorInterval = !( aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() );
+                if( bAutoMinorInterval )
+                {
+                    if( !aExplicitIncrementDest.SubIncrements.empty() && !aExplicitIncrementSource.SubIncrements.empty() )
+                        aExplicitIncrementDest.SubIncrements[0].IntervalCount =
+                            aExplicitIncrementSource.SubIncrements[0].IntervalCount;
                 }
+
+                aVCooSysList_Y[nC]->setExplicitScaleAndIncrement( 1, nAxisIndex, aExplicitScaleDest, aExplicitIncrementDest );
             }
         }
     }
commit fa799191e14b1a0a9983a22662b96388a3a44055
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Oct 13 15:11:51 2014 -0400

    Explain what doAutoScaling() does.
    
    Change-Id: I15ca9ca0c3a22094f0a969adf2b3f1145d116052

diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 4ace1b4..542a24f 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -248,6 +248,15 @@ public:
 
     void initializeCooSysAndSeriesPlotter( ChartModel& rModel );
     void initAxisUsageList(const Date& rNullDate);
+
+    /**
+     * Perform automatic axis scaling and determine the amount and spacing of
+     * increments.  It assumes that the caller has determined the size of the
+     * largest axis label text object prior to calling this method.
+     *
+     * The new axis scaling data will be stored in the VCoordinateSystem
+     * objects.
+     */
     void doAutoScaling( ChartModel& rModel );
     void updateScalesAndIncrementsOnAxes();
     void setScalesFromCooSysToPlotter();
commit 2f243540b579f80513e4e147d4bd12bdd1e15bdb
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Oct 13 14:56:11 2014 -0400

    Make VCartesianAxis::get2DAxisMainLine() truly const method.
    
    No internal state gets modified by this method now.
    
    Change-Id: I10475ad3483cb3a92e41208e1a55a6b925c10223

diff --git a/chart2/source/view/axes/Tickmarks.cxx b/chart2/source/view/axes/Tickmarks.cxx
index 9942753..a8cd9a5 100644
--- a/chart2/source/view/axes/Tickmarks.cxx
+++ b/chart2/source/view/axes/Tickmarks.cxx
@@ -237,7 +237,7 @@ B2DVector TickFactory2D::getDistanceAxisTickToText( const AxisProperties& rAxisP
         || ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END == rAxisProperties.m_eLabelPos )
         bFarAwayLabels = true;
 
-    double fInnerDirectionSign = rAxisProperties.m_fInnerDirectionSign;
+    double fInnerDirectionSign = rAxisProperties.maLabelAlignment.mfInnerTickDirection;
     if( fInnerDirectionSign==0.0 )
         fInnerDirectionSign = 1.0;
 
@@ -269,11 +269,11 @@ B2DVector TickFactory2D::getDistanceAxisTickToText( const AxisProperties& rAxisP
     }
 
     B2DVector aLabelDirection(aStart);
-    if( rAxisProperties.m_fInnerDirectionSign != rAxisProperties.m_fLabelDirectionSign )
+    if (rAxisProperties.maLabelAlignment.mfInnerTickDirection != rAxisProperties.maLabelAlignment.mfLabelDirection)
         aLabelDirection = aEnd;
 
     B2DVector aOrthoLabelDirection(aOrthoDirection);
-    if( rAxisProperties.m_fInnerDirectionSign != rAxisProperties.m_fLabelDirectionSign )
+    if (rAxisProperties.maLabelAlignment.mfInnerTickDirection != rAxisProperties.maLabelAlignment.mfLabelDirection)
         aOrthoLabelDirection*=-1.0;
     aOrthoLabelDirection.normalize();
     if( bIncludeSpaceBetweenTickAndText )
diff --git a/chart2/source/view/axes/VAxisProperties.cxx b/chart2/source/view/axes/VAxisProperties.cxx
index da04616..4672b47 100644
--- a/chart2/source/view/axes/VAxisProperties.cxx
+++ b/chart2/source/view/axes/VAxisProperties.cxx
@@ -30,11 +30,16 @@
 #include <com/sun/star/drawing/LineStyle.hpp>
 #include <com/sun/star/text/WritingMode2.hpp>
 
-namespace chart
-{
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::chart2;
 
+namespace chart {
+
+AxisLabelAlignment::AxisLabelAlignment() :
+    mfLabelDirection(1.0),
+    mfInnerTickDirection(1.0),
+    meAlignment(LABEL_ALIGN_RIGHT_TOP) {}
+
 sal_Int32 lcl_calcTickLengthForDepth(sal_Int32 nDepth,sal_Int32 nTickmarkStyle)
 {
     sal_Int32 nWidth = AXIS2D_TICKLENGTH; //@maybefuturetodo this length could be offered by the model
@@ -112,7 +117,7 @@ TickmarkProperties AxisProperties::makeTickmarkProperties(
         nTickmarkStyle = m_nMinorTickmarks;
     }
 
-    if( m_fInnerDirectionSign == 0.0 )
+    if (maLabelAlignment.mfInnerTickDirection == 0.0)
     {
         if( nTickmarkStyle != 0 )
             nTickmarkStyle = 3; //inner and outer tickmarks
@@ -128,7 +133,7 @@ TickmarkProperties AxisProperties::makeTickmarkProperties(
 TickmarkProperties AxisProperties::makeTickmarkPropertiesForComplexCategories(
     sal_Int32 nTickLength, sal_Int32 nTickStartDistanceToAxis, sal_Int32 /*nTextLevel*/ ) const
 {
-    sal_Int32 nTickmarkStyle = (m_fLabelDirectionSign==m_fInnerDirectionSign) ? 2/*outside*/ : 1/*inside*/;
+    sal_Int32 nTickmarkStyle = (maLabelAlignment.mfLabelDirection == maLabelAlignment.mfInnerTickDirection) ? 2/*outside*/ : 1/*inside*/;
 
     TickmarkProperties aTickmarkProperties;
     aTickmarkProperties.Length = nTickLength;// + nTextLevel*( lcl_calcTickLengthForDepth(0,nTickmarkStyle) );
@@ -158,9 +163,6 @@ AxisProperties::AxisProperties( const uno::Reference< XAxis >& xAxisModel
     , m_eTickmarkPos( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS )
     , m_bCrossingAxisHasReverseDirection(false)
     , m_bCrossingAxisIsCategoryAxes(false)
-    , m_fLabelDirectionSign(1.0)
-    , m_fInnerDirectionSign(1.0)
-    , m_aLabelAlignment(LABEL_ALIGN_RIGHT_TOP)
     , m_bDisplayLabels( true )
     , m_nNumberFormatKey(0)
     , m_nMajorTickmarks(1)
@@ -184,9 +186,7 @@ AxisProperties::AxisProperties( const AxisProperties& rAxisProperties )
     , m_eLabelPos( rAxisProperties.m_eLabelPos )
     , m_bCrossingAxisHasReverseDirection( rAxisProperties.m_bCrossingAxisHasReverseDirection )
     , m_bCrossingAxisIsCategoryAxes( rAxisProperties.m_bCrossingAxisIsCategoryAxes )
-    , m_fLabelDirectionSign( rAxisProperties.m_fLabelDirectionSign )
-    , m_fInnerDirectionSign( rAxisProperties.m_fInnerDirectionSign )
-    , m_aLabelAlignment( rAxisProperties.m_aLabelAlignment )
+    , maLabelAlignment( rAxisProperties.maLabelAlignment )
     , m_bDisplayLabels( rAxisProperties.m_bDisplayLabels )
     , m_nNumberFormatKey( rAxisProperties.m_nNumberFormatKey )
     , m_nMajorTickmarks( rAxisProperties.m_nMajorTickmarks )
@@ -208,7 +208,7 @@ AxisProperties::AxisProperties( const AxisProperties& rAxisProperties )
 LabelAlignment lcl_getLabelAlignmentForZAxis( const AxisProperties& rAxisProperties )
 {
     LabelAlignment aRet( LABEL_ALIGN_RIGHT );
-    if( rAxisProperties.m_fLabelDirectionSign<0 )
+    if (rAxisProperties.maLabelAlignment.mfLabelDirection < 0)
         aRet = LABEL_ALIGN_LEFT;
     return aRet;
 }
@@ -216,7 +216,7 @@ LabelAlignment lcl_getLabelAlignmentForZAxis( const AxisProperties& rAxisPropert
 LabelAlignment lcl_getLabelAlignmentForYAxis( const AxisProperties& rAxisProperties )
 {
     LabelAlignment aRet( LABEL_ALIGN_RIGHT );
-    if( rAxisProperties.m_fLabelDirectionSign<0 )
+    if (rAxisProperties.maLabelAlignment.mfLabelDirection < 0)
         aRet = LABEL_ALIGN_LEFT;
     return aRet;
 }
@@ -224,7 +224,7 @@ LabelAlignment lcl_getLabelAlignmentForYAxis( const AxisProperties& rAxisPropert
 LabelAlignment lcl_getLabelAlignmentForXAxis( const AxisProperties& rAxisProperties )
 {
     LabelAlignment aRet( LABEL_ALIGN_BOTTOM );
-    if( rAxisProperties.m_fLabelDirectionSign<0 )
+    if (rAxisProperties.maLabelAlignment.mfLabelDirection < 0)
         aRet = LABEL_ALIGN_TOP;
     return aRet;
 }
@@ -290,35 +290,35 @@ void AxisProperties::init( bool bCartesian )
             m_bComplexCategories = true;
 
         if( ::com::sun::star::chart::ChartAxisPosition_END == m_eCrossoverType )
-            m_fInnerDirectionSign = m_bCrossingAxisHasReverseDirection ? 1 : -1;
+            maLabelAlignment.mfInnerTickDirection = m_bCrossingAxisHasReverseDirection ? 1.0 : -1.0;
         else
-            m_fInnerDirectionSign = m_bCrossingAxisHasReverseDirection ? -1 : 1;
+            maLabelAlignment.mfInnerTickDirection = m_bCrossingAxisHasReverseDirection ? -1.0 : 1.0;
 
         if( ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS == m_eLabelPos )
-            m_fLabelDirectionSign = m_fInnerDirectionSign;
+            maLabelAlignment.mfLabelDirection = maLabelAlignment.mfInnerTickDirection;
         else if( ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS_OTHER_SIDE == m_eLabelPos )
-            m_fLabelDirectionSign = -m_fInnerDirectionSign;
+            maLabelAlignment.mfLabelDirection = -maLabelAlignment.mfInnerTickDirection;
         else if( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START == m_eLabelPos )
-            m_fLabelDirectionSign = m_bCrossingAxisHasReverseDirection ? -1 : 1;
+            maLabelAlignment.mfLabelDirection = m_bCrossingAxisHasReverseDirection ? -1 : 1;
         else if( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END == m_eLabelPos )
-            m_fLabelDirectionSign = m_bCrossingAxisHasReverseDirection ? 1 : -1;
+            maLabelAlignment.mfLabelDirection = m_bCrossingAxisHasReverseDirection ? 1 : -1;
 
         if( m_nDimensionIndex==2 )
-            m_aLabelAlignment = lcl_getLabelAlignmentForZAxis(*this);
+            maLabelAlignment.meAlignment = lcl_getLabelAlignmentForZAxis(*this);
         else
         {
             bool bIsYAxisPosition = (m_nDimensionIndex==1 && !m_bSwapXAndY)
                 || (m_nDimensionIndex==0 && m_bSwapXAndY);
             if( bIsYAxisPosition )
             {
-                m_fLabelDirectionSign*=-1;
-                m_fInnerDirectionSign*=-1;
+                maLabelAlignment.mfLabelDirection *= -1.0;
+                maLabelAlignment.mfInnerTickDirection *= -1.0;
             }
 
             if( bIsYAxisPosition )
-                m_aLabelAlignment = lcl_getLabelAlignmentForYAxis(*this);
+                maLabelAlignment.meAlignment = lcl_getLabelAlignmentForYAxis(*this);
             else
-                m_aLabelAlignment = lcl_getLabelAlignmentForXAxis(*this);
+                maLabelAlignment.meAlignment = lcl_getLabelAlignmentForXAxis(*this);
         }
     }
 
diff --git a/chart2/source/view/axes/VAxisProperties.hxx b/chart2/source/view/axes/VAxisProperties.hxx
index b43f97b..7495c21 100644
--- a/chart2/source/view/axes/VAxisProperties.hxx
+++ b/chart2/source/view/axes/VAxisProperties.hxx
@@ -84,6 +84,16 @@ struct AxisLabelProperties SAL_FINAL
     bool getIsStaggered() const;
 };
 
+struct AxisLabelAlignment
+{
+    double mfLabelDirection; /// which direction the labels are to be drawn.
+    double mfInnerTickDirection; /// which direction the inner tickmarks are to be drawn.
+
+    LabelAlignment meAlignment;
+
+    AxisLabelAlignment();
+};
+
 struct AxisProperties SAL_FINAL
 {
     css::uno::Reference<css::chart2::XAxis> m_xAxisModel;
@@ -102,11 +112,8 @@ struct AxisProperties SAL_FINAL
     bool        m_bCrossingAxisHasReverseDirection;
     bool        m_bCrossingAxisIsCategoryAxes;
 
-    //this direction is used to indicate in which direction the labels are to be drawn
-    double          m_fLabelDirectionSign;
-    //this direction is used to indicate in which direction inner tickmarks are to be drawn
-    double          m_fInnerDirectionSign;
-    LabelAlignment  m_aLabelAlignment;
+    AxisLabelAlignment maLabelAlignment;
+
     bool            m_bDisplayLabels;
 
     sal_Int32       m_nNumberFormatKey;
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index 67226f2..8d30d96 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -98,7 +98,7 @@ Reference< drawing::XShape > createSingleLabel(
                     ->createText( xTarget, aLabel, rPropNames, rPropValues, aATransformation );
 
     LabelPositionHelper::correctPositionForRotation( xShape2DText
-        , rAxisProperties.m_aLabelAlignment, rAxisLabelProperties.fRotationAngleDegree, rAxisProperties.m_bComplexCategories );
+        , rAxisProperties.maLabelAlignment.meAlignment, rAxisLabelProperties.fRotationAngleDegree, rAxisProperties.m_bComplexCategories );
 
     return xShape2DText;
 }
@@ -649,7 +649,7 @@ bool VCartesianAxis::createTextShapes(
         , nLimitedSpaceForText, bLimitedHeight );
     LabelPositionHelper::doDynamicFontResize( aPropValues, aPropNames, xProps
         , m_aAxisLabelProperties.m_aFontReferenceSize );
-    LabelPositionHelper::changeTextAdjustment( aPropValues, aPropNames, m_aAxisProperties.m_aLabelAlignment );
+    LabelPositionHelper::changeTextAdjustment( aPropValues, aPropNames, m_aAxisProperties.maLabelAlignment.meAlignment );
 
     uno::Any* pColorAny = PropertyMapper::getValuePointer(aPropValues,aPropNames,"CharColor");
     sal_Int32 nColor = Color( COL_AUTO ).GetColor();
@@ -922,7 +922,8 @@ struct lcl_GreaterYPos : ::std::binary_function< VCartesianAxis::ScreenPosAndLog
     }
 };
 
-void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, double fCrossesOtherAxis )
+void VCartesianAxis::get2DAxisMainLine(
+    B2DVector& rStart, B2DVector& rEnd, AxisLabelAlignment& rAlignment, double fCrossesOtherAxis ) const
 {
     //m_aAxisProperties might get updated and changed here because
     //    the label alignmant and inner direction sign depends exactly of the choice of the axis line position which is made here in this method
@@ -1011,23 +1012,23 @@ void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, doub
 
                 if( fabs(fDeltaY) > fabs(fDeltaX)  )
                 {
-                    m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_LEFT;
+                    rAlignment.meAlignment = LABEL_ALIGN_LEFT;
                     //choose most left positions
                     ::std::sort( aPosList.begin(), aPosList.end(), lcl_LessXPos() );
-                    m_aAxisProperties.m_fLabelDirectionSign = fDeltaY<0 ? -1 : 1;
+                    rAlignment.mfLabelDirection = (fDeltaY < 0) ? -1.0 : 1.0;
                 }
                 else
                 {
-                    m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_BOTTOM;
+                    rAlignment.meAlignment = LABEL_ALIGN_BOTTOM;
                     //choose most bottom positions
                     ::std::sort( aPosList.begin(), aPosList.end(), lcl_GreaterYPos() );
-                    m_aAxisProperties.m_fLabelDirectionSign = fDeltaX<0 ? -1 : 1;
+                    rAlignment.mfLabelDirection = (fDeltaX < 0) ? -1.0 : 1.0;
                 }
                 ScreenPosAndLogicPos aBestPos( aPosList[0] );
                 fYStart = fYEnd = aBestPos.fLogicY;
                 fZStart = fZEnd = aBestPos.fLogicZ;
                 if( !m_pPosHelper->isMathematicalOrientationX() )
-                    m_aAxisProperties.m_fLabelDirectionSign *= -1;
+                    rAlignment.mfLabelDirection *= -1.0;
             }
         }//end 3D x axis
     }
@@ -1065,23 +1066,23 @@ void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, doub
 
                 if( fabs(fDeltaY) > fabs(fDeltaX)  )
                 {
-                    m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_LEFT;
+                    rAlignment.meAlignment = LABEL_ALIGN_LEFT;
                     //choose most left positions
                     ::std::sort( aPosList.begin(), aPosList.end(), lcl_LessXPos() );
-                    m_aAxisProperties.m_fLabelDirectionSign = fDeltaY<0 ? -1 : 1;
+                    rAlignment.mfLabelDirection = (fDeltaY < 0) ? -1.0 : 1.0;
                 }
                 else
                 {
-                    m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_BOTTOM;
+                    rAlignment.meAlignment = LABEL_ALIGN_BOTTOM;
                     //choose most bottom positions
                     ::std::sort( aPosList.begin(), aPosList.end(), lcl_GreaterYPos() );
-                    m_aAxisProperties.m_fLabelDirectionSign = fDeltaX<0 ? -1 : 1;
+                    rAlignment.mfLabelDirection = (fDeltaX < 0) ? -1.0 : 1.0;
                 }
                 ScreenPosAndLogicPos aBestPos( aPosList[0] );
                 fXStart = fXEnd = aBestPos.fLogicX;
                 fZStart = fZEnd = aBestPos.fLogicZ;
                 if( !m_pPosHelper->isMathematicalOrientationY() )
-                    m_aAxisProperties.m_fLabelDirectionSign *= -1;
+                    rAlignment.mfLabelDirection *= -1.0;
             }
         }//end 3D y axis
     }
@@ -1150,21 +1151,21 @@ void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, doub
                 if( !::rtl::math::approxEqual( fDeltaX, 0.0 ) ) // prefer left-right alignments
                 {
                     if( aBestPos.aScreenPos.getX() > aNotSoGoodPos.aScreenPos.getX() )
-                        m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_RIGHT;
+                        rAlignment.meAlignment = LABEL_ALIGN_RIGHT;
                     else
-                         m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_LEFT;
+                         rAlignment.meAlignment = LABEL_ALIGN_LEFT;
                 }
                 else
                 {
                     if( aBestPos.aScreenPos.getY() > aNotSoGoodPos.aScreenPos.getY() )
-                        m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_BOTTOM;
+                        rAlignment.meAlignment = LABEL_ALIGN_BOTTOM;
                     else
-                         m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_TOP;
+                        rAlignment.meAlignment = LABEL_ALIGN_TOP;
                 }
 
-                m_aAxisProperties.m_fLabelDirectionSign = fDeltaX<0 ? -1 : 1;
+                rAlignment.mfLabelDirection = (fDeltaX < 0) ? -1.0 : 1.0;
                 if( !m_pPosHelper->isMathematicalOrientationZ() )
-                    m_aAxisProperties.m_fLabelDirectionSign *= -1;
+                    rAlignment.mfLabelDirection *= -1.0;
 
                 fXStart = fXEnd = aBestPos.fLogicX;
                 fYStart = fYEnd = aBestPos.fLogicY;
@@ -1176,7 +1177,7 @@ void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, doub
     rEnd = getScreenPosition( fXEnd, fYEnd, fZEnd );
 
     if(3==m_nDimension && !AxisHelper::isAxisPositioningEnabled() )
-        m_aAxisProperties.m_fInnerDirectionSign = m_aAxisProperties.m_fLabelDirectionSign;//to behave like before
+        rAlignment.mfInnerTickDirection = rAlignment.mfLabelDirection;//to behave like before
 
     if(3==m_nDimension && AxisHelper::isAxisPositioningEnabled() )
     {
@@ -1187,54 +1188,54 @@ void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, doub
         {
             if( m_eLeftWallPos != CuboidPlanePosition_Left )
             {
-                m_aAxisProperties.m_fLabelDirectionSign *= -1.0;
-                m_aAxisProperties.m_fInnerDirectionSign *= -1.0;
+                rAlignment.mfLabelDirection *= -1.0;
+                rAlignment.mfInnerTickDirection *= -1.0;
             }
 
-            m_aAxisProperties.m_aLabelAlignment =
-                ( m_aAxisProperties.m_fLabelDirectionSign<0 ) ?
+            rAlignment.meAlignment =
+                (rAlignment.mfLabelDirection < 0) ?
                     LABEL_ALIGN_LEFT :  LABEL_ALIGN_RIGHT;
 
             if( ( fDeltaY<0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) ||
                 ( fDeltaY>0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) )
-                m_aAxisProperties.m_aLabelAlignment =
-                    ( m_aAxisProperties.m_aLabelAlignment==LABEL_ALIGN_RIGHT ) ?
-                        LABEL_ALIGN_LEFT :  LABEL_ALIGN_RIGHT;
+                rAlignment.meAlignment =
+                    (rAlignment.meAlignment == LABEL_ALIGN_RIGHT) ?
+                        LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
         }
         else if( fabs(fDeltaY) > fabs(fDeltaX) )
         {
             if( m_eBackWallPos != CuboidPlanePosition_Back )
             {
-                m_aAxisProperties.m_fLabelDirectionSign *= -1.0;
-                m_aAxisProperties.m_fInnerDirectionSign *= -1.0;
+                rAlignment.mfLabelDirection *= -1.0;
+                rAlignment.mfInnerTickDirection *= -1.0;
             }
 
-            m_aAxisProperties.m_aLabelAlignment =
-                ( m_aAxisProperties.m_fLabelDirectionSign<0 ) ?
-                    LABEL_ALIGN_LEFT :  LABEL_ALIGN_RIGHT;
+            rAlignment.meAlignment =
+                (rAlignment.mfLabelDirection < 0) ?
+                    LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
 
             if( ( fDeltaY<0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) ||
                 ( fDeltaY>0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) )
-                m_aAxisProperties.m_aLabelAlignment =
-                    ( m_aAxisProperties.m_aLabelAlignment==LABEL_ALIGN_RIGHT ) ?
+                rAlignment.meAlignment =
+                    (rAlignment.meAlignment == LABEL_ALIGN_RIGHT) ?
                         LABEL_ALIGN_LEFT :  LABEL_ALIGN_RIGHT;
         }
         else
         {
             if( m_eBackWallPos != CuboidPlanePosition_Back )
             {
-                m_aAxisProperties.m_fLabelDirectionSign *= -1.0;
-                m_aAxisProperties.m_fInnerDirectionSign *= -1.0;
+                rAlignment.mfLabelDirection *= -1.0;
+                rAlignment.mfInnerTickDirection *= -1.0;
             }
 
-            m_aAxisProperties.m_aLabelAlignment =
-                ( m_aAxisProperties.m_fLabelDirectionSign<0 ) ?
+            rAlignment.meAlignment =
+                (rAlignment.mfLabelDirection < 0) ?
                     LABEL_ALIGN_TOP : LABEL_ALIGN_BOTTOM;
 
             if( ( fDeltaX>0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) ||
                 ( fDeltaX<0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) )
-                m_aAxisProperties.m_aLabelAlignment =
-                    ( m_aAxisProperties.m_aLabelAlignment==LABEL_ALIGN_TOP ) ?
+                rAlignment.meAlignment =
+                    (rAlignment.meAlignment == LABEL_ALIGN_TOP) ?
                         LABEL_ALIGN_BOTTOM : LABEL_ALIGN_TOP;
         }
     }
@@ -1247,11 +1248,14 @@ TickFactory* VCartesianAxis::createTickFactory()
 
 TickFactory2D* VCartesianAxis::createTickFactory2D()
 {
+    AxisLabelAlignment aLabelAlign;
     B2DVector aStart, aEnd;
-    get2DAxisMainLine( aStart, aEnd, getAxisIntersectionValue() );
+    get2DAxisMainLine(aStart, aEnd, aLabelAlign, getAxisIntersectionValue());
+    m_aAxisProperties.maLabelAlignment = aLabelAlign;
 
     B2DVector aLabelLineStart, aLabelLineEnd;
-    get2DAxisMainLine( aLabelLineStart, aLabelLineEnd, getLabelLineIntersectionValue() );
+    get2DAxisMainLine(aLabelLineStart, aLabelLineEnd, aLabelAlign, getLabelLineIntersectionValue());
+    m_aAxisProperties.maLabelAlignment = aLabelAlign;
 
     return new TickFactory2D( m_aScale, m_aIncrement, aStart, aEnd, aLabelLineStart-aStart );
 }
@@ -1297,7 +1301,9 @@ sal_Int32 VCartesianAxis::estimateMaximumAutoMainIncrementCount()
         return nRet;
 
     B2DVector aStart, aEnd;
-    this->get2DAxisMainLine( aStart, aEnd, getAxisIntersectionValue() );
+    AxisLabelAlignment aLabelAlign;
+    get2DAxisMainLine(aStart, aEnd, aLabelAlign, getAxisIntersectionValue());
+    m_aAxisProperties.maLabelAlignment = aLabelAlign;
 
     sal_Int32 nMaxHeight = static_cast<sal_Int32>(fabs(aEnd.getY()-aStart.getY()));
     sal_Int32 nMaxWidth = static_cast<sal_Int32>(fabs(aEnd.getX()-aStart.getX()));
@@ -1516,7 +1522,7 @@ void VCartesianAxis::updatePositions()
 
                 //correctPositionForRotation
                 LabelPositionHelper::correctPositionForRotation( xShape2DText
-                    , m_aAxisProperties.m_aLabelAlignment, fRotationAngleDegree, m_aAxisProperties.m_bComplexCategories );
+                    , m_aAxisProperties.maLabelAlignment.meAlignment, fRotationAngleDegree, m_aAxisProperties.m_bComplexCategories );
             }
         }
     }
@@ -1538,7 +1544,7 @@ void VCartesianAxis::createTickMarkLineShapes( TickInfoArrayType& rTickInfos, co
             continue;
 
         bool bTicksAtLabels = ( m_aAxisProperties.m_eTickmarkPos != ::com::sun::star::chart::ChartAxisMarkPosition_AT_AXIS );
-        double fInnerDirectionSign = m_aAxisProperties.m_fInnerDirectionSign;
+        double fInnerDirectionSign = m_aAxisProperties.maLabelAlignment.mfInnerTickDirection;
         if( bTicksAtLabels && m_aAxisProperties.m_eLabelPos == ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END )
             fInnerDirectionSign *= -1.0;
         bTicksAtLabels = bTicksAtLabels || bOnlyAtLabels;
@@ -1548,7 +1554,7 @@ void VCartesianAxis::createTickMarkLineShapes( TickInfoArrayType& rTickInfos, co
         //add ticks at axis (without lables):
         if( !bOnlyAtLabels && m_aAxisProperties.m_eTickmarkPos == ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS )
             rTickFactory2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue
-                , m_aAxisProperties.m_fInnerDirectionSign, rTickmarkProperties, !bTicksAtLabels );
+                , m_aAxisProperties.maLabelAlignment.mfInnerTickDirection, rTickmarkProperties, !bTicksAtLabels );
     }
     aPoints.realloc(nN);
     m_pShapeFactory->createLine2D( m_xGroupShape_Shapes, aPoints
@@ -1641,7 +1647,9 @@ void VCartesianAxis::createShapes()
             if (!rtl::math::isNan(fExtraLineCrossesOtherAxis))
             {
                 B2DVector aStart, aEnd;
-                this->get2DAxisMainLine( aStart, aEnd, fExtraLineCrossesOtherAxis );
+                AxisLabelAlignment aLabelAlign;
+                get2DAxisMainLine(aStart, aEnd, aLabelAlign, fExtraLineCrossesOtherAxis);
+                m_aAxisProperties.maLabelAlignment = aLabelAlign;
                 drawing::PointSequenceSequence aPoints( lcl_makePointSequence(aStart,aEnd) );
                 Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
                         m_xGroupShape_Shapes, aPoints, &m_aAxisProperties.m_aLineProperties );
diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx
index 0bbeb43..e3f26a8 100644
--- a/chart2/source/view/axes/VCartesianAxis.hxx
+++ b/chart2/source/view/axes/VCartesianAxis.hxx
@@ -71,7 +71,9 @@ public:
      */
     double getExtraLineIntersectionValue() const;
 
-    void        get2DAxisMainLine( ::basegfx::B2DVector& rStart, ::basegfx::B2DVector& rEnd, double fCrossesOtherAxis );
+    void get2DAxisMainLine(
+        basegfx::B2DVector& rStart, basegfx::B2DVector& rEnd, AxisLabelAlignment& rLabelAlignment,
+        double fCrossesOtherAxis ) const;
 
     //Layout interface for cartesian axes:
 
diff --git a/chart2/source/view/axes/VPolarRadiusAxis.cxx b/chart2/source/view/axes/VPolarRadiusAxis.cxx
index 6db58e8..f5d9992 100644
--- a/chart2/source/view/axes/VPolarRadiusAxis.cxx
+++ b/chart2/source/view/axes/VPolarRadiusAxis.cxx
@@ -35,10 +35,10 @@ VPolarRadiusAxis::VPolarRadiusAxis( const AxisProperties& rAxisProperties
             , sal_Int32 nDimensionCount )
             : VPolarAxis( rAxisProperties, xNumberFormatsSupplier, 1/*nDimensionIndex*/, nDimensionCount )
 {
-    m_aAxisProperties.m_fLabelDirectionSign=0.0;
-    m_aAxisProperties.m_fInnerDirectionSign=0.0;
+    m_aAxisProperties.maLabelAlignment.mfLabelDirection = 0.0;
+    m_aAxisProperties.maLabelAlignment.mfInnerTickDirection = 0.0;
+    m_aAxisProperties.maLabelAlignment.meAlignment = LABEL_ALIGN_RIGHT;
     m_aAxisProperties.m_bIsMainAxis=false;
-    m_aAxisProperties.m_aLabelAlignment=LABEL_ALIGN_RIGHT;
     m_aAxisProperties.init();
 
     m_apAxisWithLabels.reset( new VCartesianAxis(


More information about the Libreoffice-commits mailing list