summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-03-24 14:42:36 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-03-24 16:01:58 +0100
commit7d1fa5fb8ef2067c406eadbdfb0dbca37d4627bf (patch)
tree514875b08eff1618cf2401c35b83a39274afa2c2
parent0dc9317d52850b4271876ad18fa651b2f3c25bff (diff)
add minLength and maxLength support to databars
Change-Id: Idbbc4b64b616ead6ef880340064623b9a5c0ff51
-rw-r--r--sc/inc/colorscale.hxx14
-rw-r--r--sc/source/core/data/colorscale.cxx8
-rw-r--r--sc/source/filter/excel/xecontent.cxx2
-rw-r--r--sc/source/filter/oox/condformatbuffer.cxx2
4 files changed, 23 insertions, 3 deletions
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 06c3c80c7faa..5b6f6e59b00f 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -101,6 +101,8 @@ struct SC_DLLPUBLIC ScDataBarFormatData
mbGradient(true),
mbNeg(true),
meAxisPosition(databar::AUTOMATIC),
+ mnMinLength(0),
+ mnMaxLength(100),
mbOnlyBar(false){}
ScDataBarFormatData(const ScDataBarFormatData& r):
@@ -109,6 +111,8 @@ struct SC_DLLPUBLIC ScDataBarFormatData
mbGradient(r.mbGradient),
mbNeg(r.mbNeg),
meAxisPosition(r.meAxisPosition),
+ mnMinLength(r.mnMinLength),
+ mnMaxLength(r.mnMaxLength),
mbOnlyBar(r.mbOnlyBar)
{
if(r.mpNegativeColor)
@@ -157,6 +161,16 @@ struct SC_DLLPUBLIC ScDataBarFormatData
* Default is false
*/
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
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 9de8919294b2..f56756335ba9 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -838,6 +838,8 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
double nValMax = getMaxValue();
double nMin = getMin(nValMin, nValMax);
double nMax = getMax(nValMin, nValMax);
+ double nMinLength = mpFormatData->mnMinLength;
+ double nMaxLength = mpFormatData->mnMaxLength;
double nValue = mpDoc->GetValue(rAddr);
@@ -846,16 +848,16 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
{
if(nValue <= nMin)
{
- pInfo->mnLength = 0;
+ pInfo->mnLength = nMinLength;
}
else if(nValue >= nMax)
{
- pInfo->mnLength = 100;
+ pInfo->mnLength = nMaxLength;
}
else
{
double nDiff = nMax - nMin;
- pInfo->mnLength = (nValue - nMin)/nDiff*100.0;
+ pInfo->mnLength = nMinLength + (nValue - nMin)/nDiff * (nMaxLength-nMinLength);
}
pInfo->mnZero = 0;
}
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 17140e04b762..ca71cf96a1b1 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -1300,6 +1300,8 @@ void XclExpDataBar::SaveXml( XclExpXmlStream& rStrm )
rWorksheet->startElement( XML_dataBar,
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 );
mpCfvoLowerLimit->SaveXml(rStrm);
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index 511e02e0e90f..9fa0b1432118 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -273,6 +273,8 @@ void DataBarRule::importCfvo( const AttributeList& rAttribs )
void DataBarRule::importAttribs( const AttributeList& rAttribs )
{
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 )