Kaydet (Commit) c35dc399 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

little refactoring in databar code

Change-Id: Icf2943604106440ff0b1979ebe10497f01fea784
üst 598f0e26
...@@ -890,66 +890,64 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const ...@@ -890,66 +890,64 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
} }
pInfo->mnZero = 0; pInfo->mnZero = 0;
} }
else else if (mpFormatData->meAxisPosition == databar::AUTOMATIC)
{ {
double nMinPositive = 0;
double nMaxNegative = 0; double nMaxNegative = 0;
double nMinPositive = 0;
//calculate the zero position first //calculate the zero position first
if(mpFormatData->meAxisPosition == databar::AUTOMATIC) if(nMin < 0)
{ {
if(nMin < 0) if(nMax < 0)
pInfo->mnZero = 100;
else
{ {
if(nMax < 0) pInfo->mnZero = -100*nMin/(nMax-nMin);
pInfo->mnZero = 100;
else
{
pInfo->mnZero = -100*nMin/(nMax-nMin);
}
} }
else }
pInfo->mnZero = 0; else
pInfo->mnZero = 0;
// if max or min is used we may need to adjust it // if max or min is used we may need to adjust it
// for the length calculation // for the length calculation
if (mpFormatData->mpLowerLimit->GetType() == COLORSCALE_MIN && nMin > 0) if (mpFormatData->mpLowerLimit->GetType() == COLORSCALE_MIN && nMin > 0)
nMinPositive = nMin; nMinPositive = nMin;
if (mpFormatData->mpUpperLimit->GetType() == COLORSCALE_MAX && nMax < 0) if (mpFormatData->mpUpperLimit->GetType() == COLORSCALE_MAX && nMax < 0)
nMaxNegative = nMax; nMaxNegative = nMax;
//calculate the length //calculate the length
if(nValue < 0) if(nValue < 0)
{ {
if (nValue < nMin) if (nValue < nMin)
pInfo->mnLength = -100; pInfo->mnLength = -100;
else
pInfo->mnLength = -100 * (nValue-nMaxNegative)/(nMin-nMaxNegative);
}
else else
{ pInfo->mnLength = -100 * (nValue-nMaxNegative)/(nMin-nMaxNegative);
if ( nValue > nMax )
pInfo->mnLength = 100;
else
pInfo->mnLength = (nValue-nMinPositive)/(nMax-nMinPositive)*100;
}
} }
else if( mpFormatData->meAxisPosition == databar::MIDDLE) else
{ {
pInfo->mnZero = 50; if ( nValue > nMax )
double nAbsMax = std::max(std::abs(nMin), std::abs(nMax)); pInfo->mnLength = 100;
if (nValue < 0)
{
if (nValue < nMin)
pInfo->mnLength = -nMaxLength;
else
pInfo->mnLength = nMaxLength * (nValue/nAbsMax);
}
else else
{ pInfo->mnLength = (nValue-nMinPositive)/(nMax-nMinPositive)*100;
if (nValue > nMax) }
pInfo->mnLength = nMaxLength; }
else else if( mpFormatData->meAxisPosition == databar::MIDDLE)
pInfo->mnLength = nMaxLength * (nValue/nAbsMax); {
} pInfo->mnZero = 50;
double nAbsMax = std::max(std::abs(nMin), std::abs(nMax));
if (nValue < 0)
{
if (nValue < nMin)
pInfo->mnLength = -nMaxLength;
else
pInfo->mnLength = nMaxLength * (nValue/nAbsMax);
}
else
{
if (nValue > nMax)
pInfo->mnLength = nMaxLength;
else
pInfo->mnLength = nMaxLength * (nValue/nAbsMax);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment