Related: tdf#48041 Chart: vertical value axis labels

Do not duplicate vertical axis labels and gridlines
if same value labels follow each other, because of
the number format and rounding.
Supplement of commit: 7f373a4c88961348f35e4f990182628488878efe

Change-Id: I7a5d8196d4f16024c279fa4417a0c8809fb8aec7
Reviewed-on: https://gerrit.libreoffice.org/73432
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index 99eb1b0..a70551b 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -1554,33 +1554,32 @@ sal_Int32 VCartesianAxis::estimateMaximumAutoMainIncrementCount()
    sal_Int32 nSingleNeeded = m_nMaximumTextHeightSoFar;
    sal_Int32 nMaxSameLabel = 0;

    // tdf#48041: do not duplicate the value labels because of rounding
    if (m_aAxisProperties.m_nAxisType != css::chart2::AxisType::DATE)
    {
        FixedNumberFormatter aFixedNumberFormatterTest(m_xNumberFormatsSupplier, m_aAxisLabelProperties.nNumberFormatKey);
        OUString sPreviousValueLabel;
        sal_Int32 nSameLabel = 0;
        for (sal_Int32 nLabel = 0; nLabel < static_cast<sal_Int32>(m_aAllTickInfos[0].size()); ++nLabel)
        {
            Color nColor = COL_AUTO;
            bool bHasColor = false;
            OUString sValueLabel = aFixedNumberFormatterTest.getFormattedString(m_aAllTickInfos[0][nLabel].fScaledTickValue, nColor, bHasColor);
            if (sValueLabel == sPreviousValueLabel)
            {
                nSameLabel++;
                if (nSameLabel > nMaxSameLabel)
                    nMaxSameLabel = nSameLabel;
            }
            else
                nSameLabel = 0;
            sPreviousValueLabel = sValueLabel;
        }
    }
    //for horizontal axis:
    if( (m_nDimensionIndex == 0 && !m_aAxisProperties.m_bSwapXAndY)
        || (m_nDimensionIndex == 1 && m_aAxisProperties.m_bSwapXAndY) )
    {
        if (m_aAxisProperties.m_nAxisType != css::chart2::AxisType::DATE)
        {
            // tdf#48041: do not duplicate the value labels because of rounding
            FixedNumberFormatter aFixedNumberFormatterTest(m_xNumberFormatsSupplier, m_aAxisLabelProperties.nNumberFormatKey);
            OUString sPreviousValueLabel;
            sal_Int32 nSameLabel = 0;
            for (sal_Int32 nLabel = 0; nLabel < static_cast<sal_Int32>(m_aAllTickInfos[0].size()); ++nLabel)
            {
                Color nColor = COL_AUTO;
                bool bHasColor = false;
                OUString sValueLabel = aFixedNumberFormatterTest.getFormattedString(m_aAllTickInfos[0][nLabel].fScaledTickValue, nColor, bHasColor);
                if (sValueLabel == sPreviousValueLabel)
                {
                    nSameLabel++;
                    if (nSameLabel > nMaxSameLabel)
                        nMaxSameLabel = nSameLabel;
                }
                else
                    nSameLabel = 0;
                sPreviousValueLabel = sValueLabel;
            }
        }

        nTotalAvailable = nMaxWidth;
        nSingleNeeded = m_nMaximumTextWidthSoFar;
    }