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

Balazs Varga (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 4 09:37:57 UTC 2019


 chart2/source/view/axes/VCartesianAxis.cxx |   43 ++++++++++++++---------------
 1 file changed, 21 insertions(+), 22 deletions(-)

New commits:
commit a2554ac1f0173b0904032f4f8a70bb2231d0d934
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Tue Jun 4 10:11:29 2019 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Tue Jun 4 11:37:23 2019 +0200

    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 at numbertext.org>

diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index 99eb1b085185..a70551bf8518 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;
 
-    //for horizontal axis:
-    if( (m_nDimensionIndex == 0 && !m_aAxisProperties.m_bSwapXAndY)
-        || (m_nDimensionIndex == 1 && m_aAxisProperties.m_bSwapXAndY) )
+    // tdf#48041: do not duplicate the value labels because of rounding
+    if (m_aAxisProperties.m_nAxisType != css::chart2::AxisType::DATE)
     {
-        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)
         {
-            // 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)
             {
-                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;
+                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) )
+    {
         nTotalAvailable = nMaxWidth;
         nSingleNeeded = m_nMaximumTextWidthSoFar;
     }


More information about the Libreoffice-commits mailing list