diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-05-16 20:22:00 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-05-17 06:48:23 +0200 |
commit | 01f29d865e62f6a5371f4459c66f035e56326f5b (patch) | |
tree | 66260297ac70796694e01bb2444793d426b7d4fc /sc | |
parent | c35dc39928824fc258080dd1ba2eb0569559e544 (diff) |
fix incorrect databar length calculation
Change-Id: I8d6fda8b78daa228fff62f2af8f5f14c7aa03312
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/colorscale.cxx | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 35d0cf7fe40c..d9876eba0b9f 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -892,8 +892,12 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const } else if (mpFormatData->meAxisPosition == databar::AUTOMATIC) { - double nMaxNegative = 0; - double nMinPositive = 0; + // if auto is used we may need to adjust it + // for the length calculation + if (mpFormatData->mpLowerLimit->GetType() == COLORSCALE_AUTO && nMin > 0) + nMin = 0; + if (mpFormatData->mpUpperLimit->GetType() == COLORSCALE_MAX && nMax < 0) + nMax = 0; //calculate the zero position first if(nMin < 0) @@ -908,27 +912,20 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const else pInfo->mnZero = 0; - // if max or min is used we may need to adjust it - // for the length calculation - if (mpFormatData->mpLowerLimit->GetType() == COLORSCALE_MIN && nMin > 0) - nMinPositive = nMin; - if (mpFormatData->mpUpperLimit->GetType() == COLORSCALE_MAX && nMax < 0) - nMaxNegative = nMax; - //calculate the length if(nValue < 0) { if (nValue < nMin) pInfo->mnLength = -100; else - pInfo->mnLength = -100 * (nValue-nMaxNegative)/(nMin-nMaxNegative); + pInfo->mnLength = -100 * (nValue-nMax)/(nMin-nMax); } else { if ( nValue > nMax ) pInfo->mnLength = 100; else - pInfo->mnLength = (nValue-nMinPositive)/(nMax-nMinPositive)*100; + pInfo->mnLength = 100 * (nValue-nMin)/(nMax-nMin); } } else if( mpFormatData->meAxisPosition == databar::MIDDLE) |