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

add minLength and maxLength support to databars

Change-Id: Idbbc4b64b616ead6ef880340064623b9a5c0ff51
üst 0dc9317d
...@@ -101,6 +101,8 @@ struct SC_DLLPUBLIC ScDataBarFormatData ...@@ -101,6 +101,8 @@ struct SC_DLLPUBLIC ScDataBarFormatData
mbGradient(true), mbGradient(true),
mbNeg(true), mbNeg(true),
meAxisPosition(databar::AUTOMATIC), meAxisPosition(databar::AUTOMATIC),
mnMinLength(0),
mnMaxLength(100),
mbOnlyBar(false){} mbOnlyBar(false){}
ScDataBarFormatData(const ScDataBarFormatData& r): ScDataBarFormatData(const ScDataBarFormatData& r):
...@@ -109,6 +111,8 @@ struct SC_DLLPUBLIC ScDataBarFormatData ...@@ -109,6 +111,8 @@ struct SC_DLLPUBLIC ScDataBarFormatData
mbGradient(r.mbGradient), mbGradient(r.mbGradient),
mbNeg(r.mbNeg), mbNeg(r.mbNeg),
meAxisPosition(r.meAxisPosition), meAxisPosition(r.meAxisPosition),
mnMinLength(r.mnMinLength),
mnMaxLength(r.mnMaxLength),
mbOnlyBar(r.mbOnlyBar) mbOnlyBar(r.mbOnlyBar)
{ {
if(r.mpNegativeColor) if(r.mpNegativeColor)
...@@ -157,6 +161,16 @@ struct SC_DLLPUBLIC ScDataBarFormatData ...@@ -157,6 +161,16 @@ struct SC_DLLPUBLIC ScDataBarFormatData
* Default is false * Default is false
*/ */
databar::ScAxisPosition meAxisPosition; databar::ScAxisPosition meAxisPosition;
/**
* Minimal length of a databar in percent of cell length
* Value has to be in the range [0, 100)
*/
double mnMinLength;
/**
* Maximal length of a databar in percent of cell length
* Value has to be in the range (0, 100]
*/
double mnMaxLength;
/** /**
* If TRUE we only show the bar and not the value * If TRUE we only show the bar and not the value
......
...@@ -838,6 +838,8 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const ...@@ -838,6 +838,8 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
double nValMax = getMaxValue(); double nValMax = getMaxValue();
double nMin = getMin(nValMin, nValMax); double nMin = getMin(nValMin, nValMax);
double nMax = getMax(nValMin, nValMax); double nMax = getMax(nValMin, nValMax);
double nMinLength = mpFormatData->mnMinLength;
double nMaxLength = mpFormatData->mnMaxLength;
double nValue = mpDoc->GetValue(rAddr); double nValue = mpDoc->GetValue(rAddr);
...@@ -846,16 +848,16 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const ...@@ -846,16 +848,16 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
{ {
if(nValue <= nMin) if(nValue <= nMin)
{ {
pInfo->mnLength = 0; pInfo->mnLength = nMinLength;
} }
else if(nValue >= nMax) else if(nValue >= nMax)
{ {
pInfo->mnLength = 100; pInfo->mnLength = nMaxLength;
} }
else else
{ {
double nDiff = nMax - nMin; double nDiff = nMax - nMin;
pInfo->mnLength = (nValue - nMin)/nDiff*100.0; pInfo->mnLength = nMinLength + (nValue - nMin)/nDiff * (nMaxLength-nMinLength);
} }
pInfo->mnZero = 0; pInfo->mnZero = 0;
} }
......
...@@ -1300,6 +1300,8 @@ void XclExpDataBar::SaveXml( XclExpXmlStream& rStrm ) ...@@ -1300,6 +1300,8 @@ void XclExpDataBar::SaveXml( XclExpXmlStream& rStrm )
rWorksheet->startElement( XML_dataBar, rWorksheet->startElement( XML_dataBar,
XML_showValue, OString::number(!mrFormat.GetDataBarData()->mbOnlyBar), XML_showValue, OString::number(!mrFormat.GetDataBarData()->mbOnlyBar),
XML_minLength, OString::number(sal_uInt32(mrFormat.GetDataBarData()->mnMinLength)),
XML_maxLength, OString::number(sal_uInt32(mrFormat.GetDataBarData()->mnMaxLength)),
FSEND ); FSEND );
mpCfvoLowerLimit->SaveXml(rStrm); mpCfvoLowerLimit->SaveXml(rStrm);
......
...@@ -273,6 +273,8 @@ void DataBarRule::importCfvo( const AttributeList& rAttribs ) ...@@ -273,6 +273,8 @@ void DataBarRule::importCfvo( const AttributeList& rAttribs )
void DataBarRule::importAttribs( const AttributeList& rAttribs ) void DataBarRule::importAttribs( const AttributeList& rAttribs )
{ {
mxFormat->mbOnlyBar = !rAttribs.getBool( XML_showValue, true ); mxFormat->mbOnlyBar = !rAttribs.getBool( XML_showValue, true );
mxFormat->mnMinLength = rAttribs.getUnsigned( XML_minLength, 10);
mxFormat->mnMaxLength = rAttribs.getUnsigned( XML_maxLength, 90);
} }
void DataBarRule::SetData( ScDataBarFormat* pFormat, ScDocument* pDoc, const ScAddress& rAddr ) void DataBarRule::SetData( ScDataBarFormat* pFormat, ScDocument* pDoc, const ScAddress& rAddr )
......
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