[Libreoffice-commits] .: 2 commits - oox/source sc/inc sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Sun May 20 15:27:54 PDT 2012
oox/source/token/tokens.txt | 1 +
sc/inc/colorscale.hxx | 16 ++++++++++++++--
sc/source/core/data/colorscale.cxx | 33 +++++++++++++++++++++++++--------
sc/source/filter/oox/extlstcontext.cxx | 17 +++++++++--------
4 files changed, 49 insertions(+), 18 deletions(-)
New commits:
commit 09938f698b0a45ce1b3977995fc944274f048566
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Mon May 21 00:24:51 2012 +0200
support fixed axis in the middle of the cell
Change-Id: I1f6dca8434282d161dac3f86da6b4c75aac29a02
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 0f72475..0dbb876 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -72,12 +72,24 @@ public:
void SetPercent(bool bPercent);
};
+namespace databar
+{
+
+enum ScAxisPostion
+{
+ NONE,
+ AUTOMATIC,
+ MIDDLE
+};
+
+}
+
struct ScDataBarFormatData
{
ScDataBarFormatData():
mbGradient(true),
mbNeg(true),
- mbSameDirection(false) {}
+ meAxisPosition(databar::AUTOMATIC) {}
/**
* Color for all Positive Values and if mbNeg == false also for negative ones
@@ -110,7 +122,7 @@ struct ScDataBarFormatData
*
* Default is false
*/
- bool mbSameDirection;
+ databar::ScAxisPostion meAxisPosition;
boost::scoped_ptr<ScColorScaleEntry> mpUpperLimit;
boost::scoped_ptr<ScColorScaleEntry> mpLowerLimit;
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 8364cd1..70b4872 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -679,10 +679,11 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
double nMin = getMin(nValMin, nValMax);
double nMax = getMax(nValMin, nValMax);
+
double nValue = mpDoc->GetValue(rAddr);
ScDataBarInfo* pInfo = new ScDataBarInfo();
- if(mpFormatData->mbSameDirection || nMin > 0)
+ if(mpFormatData->meAxisPosition == databar::NONE)
{
if(nValue <= nMin)
{
@@ -701,16 +702,32 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
}
else
{
+ double nMinPositive = 0;
+ double nMaxNegative = 0;
//calculate the zero position first
- if(nMin < 0)
+ if(mpFormatData->meAxisPosition == databar::AUTOMATIC)
{
- if(nMax < 0)
- pInfo->mnZero = 100;
- else
+ if(nMin < 0)
{
- pInfo->mnZero = -100*nMin/(nMax-nMin);
+ if(nMax < 0)
+ pInfo->mnZero = 100;
+ else
+ {
+ pInfo->mnZero = -100*nMin/(nMax-nMin);
+ }
}
+ else
+ pInfo->mnZero = 0;
+
+ // if max or min is used we may need to adjust it
+ // for the length calculation
+ if (mpFormatData->mpLowerLimit->GetMin() && nMin > 0)
+ nMinPositive = nMin;
+ if (mpFormatData->mpUpperLimit->GetMax() && nMax < 0)
+ nMaxNegative = nMax;
}
+ else if( mpFormatData->meAxisPosition == databar::MIDDLE)
+ pInfo->mnZero = 50;
//calculate the length
if(nValue < 0)
@@ -718,14 +735,14 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
if (nValue < nMin)
pInfo->mnLength = -100;
else
- pInfo->mnLength = -100 * nValue/nMin;
+ pInfo->mnLength = -100 * (nValue-nMaxNegative)/(nMin-nMaxNegative);
}
else
{
if ( nValue > nMax )
pInfo->mnLength = 100;
else
- pInfo->mnLength = nValue/nMax*100;
+ pInfo->mnLength = (nValue-nMinPositive)/(nMax-nMinPositive)*100;
}
}
diff --git a/sc/source/filter/oox/extlstcontext.cxx b/sc/source/filter/oox/extlstcontext.cxx
index 02113ea..d8c2d1f 100644
--- a/sc/source/filter/oox/extlstcontext.cxx
+++ b/sc/source/filter/oox/extlstcontext.cxx
@@ -69,11 +69,11 @@ void ExtCfRuleContext::importDataBar( const AttributeList& rAttribs )
rtl::OUString aAxisPosition = rAttribs.getString( XML_axisPosition, "automatic" );
if( aAxisPosition == "none" )
- pDataBar->mbSameDirection = true;
+ pDataBar->meAxisPosition = databar::NONE;
else if( aAxisPosition == "middle" )
- pDataBar->mbSameDirection = false;
+ pDataBar->meAxisPosition = databar::MIDDLE;
else
- pDataBar->mbSameDirection = false;
+ pDataBar->meAxisPosition = databar::AUTOMATIC;
pDataBar->mbNeg = !rAttribs.getBool( XML_negativeBarColorSameAsPositive, false );
}
commit f6442313dc0aea603d3d5adca39614428a4bc854
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun May 20 22:25:40 2012 +0200
more on correct import of data bars from Excel2010
http://msdn.microsoft.com/en-us/library/documentformat.openxml.office2010.excel.databar.aspx
Change-Id: I6d76cd888b723718e5a2beedfb5223fb6c0d0ba2
diff --git a/oox/source/token/tokens.txt b/oox/source/token/tokens.txt
index 4c84cb0..5bbaa62 100644
--- a/oox/source/token/tokens.txt
+++ b/oox/source/token/tokens.txt
@@ -3423,6 +3423,7 @@ ndxf
neCell
negativeInteger
negativeFillColor
+negativeBarColorSameAsPositive
neq
never
new
diff --git a/sc/source/filter/oox/extlstcontext.cxx b/sc/source/filter/oox/extlstcontext.cxx
index 4b7a79f..02113ea 100644
--- a/sc/source/filter/oox/extlstcontext.cxx
+++ b/sc/source/filter/oox/extlstcontext.cxx
@@ -67,14 +67,15 @@ void ExtCfRuleContext::importDataBar( const AttributeList& rAttribs )
ScDataBarFormatData* pDataBar = static_cast<ScDataBarFormatData*>(mpTarget);
pDataBar->mbGradient = rAttribs.getBool( XML_gradient, true );
- if(rAttribs.hasAttribute(XML_axisPosition))
- {
- rtl::OUString aAxisPosition = rAttribs.getString( XML_axisPosition, rtl::OUString() );
- if( aAxisPosition == "none" )
- {
- pDataBar->mbSameDirection = true;
- }
- }
+ rtl::OUString aAxisPosition = rAttribs.getString( XML_axisPosition, "automatic" );
+ if( aAxisPosition == "none" )
+ pDataBar->mbSameDirection = true;
+ else if( aAxisPosition == "middle" )
+ pDataBar->mbSameDirection = false;
+ else
+ pDataBar->mbSameDirection = false;
+
+ pDataBar->mbNeg = !rAttribs.getBool( XML_negativeBarColorSameAsPositive, false );
}
namespace {
More information about the Libreoffice-commits
mailing list