diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2019-06-04 10:11:29 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-06-04 11:37:23 +0200 |
commit | a2554ac1f0173b0904032f4f8a70bb2231d0d934 (patch) | |
tree | 33343727cb09d0edc1de0df12f18cf59f3c150a5 | |
parent | d160bca0dcb80f1b517b79221d5c3a43bbad8639 (diff) |
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>
-rw-r--r-- | chart2/source/view/axes/VCartesianAxis.cxx | 43 |
1 files changed, 21 insertions, 22 deletions
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; } |