summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-08-11 13:02:48 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-08-13 12:34:17 +0200
commitc6a8eb06027765640a5d1113866903454892d134 (patch)
treeebaedaa2d00d074ebe5b9c53d73ef34f78476d7e /sc
parentc8218367a0f52206591a5048848fa5292405b6c3 (diff)
use an enum instead of several flags
Change-Id: I93c7483c6ba91671515025cc3b365a68c45a395c
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/colorscale.hxx27
-rw-r--r--sc/source/core/data/colorscale.cxx205
-rw-r--r--sc/source/filter/excel/xecontent.cxx23
-rw-r--r--sc/source/filter/oox/condformatbuffer.cxx11
-rw-r--r--sc/source/filter/xml/xmlcondformat.cxx9
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx34
-rw-r--r--sc/source/ui/condformat/colorformat.cxx47
-rw-r--r--sc/source/ui/condformat/condformatdlg.cxx105
8 files changed, 224 insertions, 237 deletions
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 24aa2ea3c027..f1b8d41d8c60 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -42,17 +42,24 @@ class ScFormulaCell;
class ScTokenArray;
struct ScDataBarInfo;
+enum ScColorScaleEntryType
+{
+ COLORSCALE_VALUE,
+ COLORSCALE_MIN,
+ COLORSCALE_MAX,
+ COLORSCALE_PERCENT,
+ COLORSCALE_PERCENTILE,
+ COLORSCALE_FORMULA
+};
+
class SC_DLLPUBLIC ScColorScaleEntry
{
private:
double mnVal;
Color maColor;
boost::scoped_ptr<ScFormulaCell> mpCell;
+ ScColorScaleEntryType meType;
- bool mbMin;
- bool mbMax;
- bool mbPercent;
- bool mbPercentile;
public:
ScColorScaleEntry(double nVal, const Color& rCol);
ScColorScaleEntry();
@@ -69,19 +76,11 @@ public:
void UpdateReference( UpdateRefMode eUpdateRefMode,
const ScRange& rRange, SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
- bool GetMin() const;
- bool GetMax() const;
- bool GetPercent() const;
- bool GetPercentile() const;
- bool HasFormula() const;
const ScTokenArray* GetFormula() const;
rtl::OUString GetFormula( formula::FormulaGrammar::Grammar eGrammar ) const;
- void SetMin(bool bMin);
- void SetMax(bool bMax);
- void SetPercent(bool bPercent);
- void SetPercentile(bool bPercentile);
- void SetHasValue();
+ ScColorScaleEntryType GetType() const;
+ void SetType( ScColorScaleEntryType eType );
};
namespace databar
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 38f061aed9b2..e429068a89e9 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -34,10 +34,7 @@
ScColorScaleEntry::ScColorScaleEntry():
mnVal(0),
mpCell(NULL),
- mbMin(false),
- mbMax(false),
- mbPercent(false),
- mbPercentile(false)
+ meType(COLORSCALE_VALUE)
{
}
@@ -45,10 +42,7 @@ ScColorScaleEntry::ScColorScaleEntry(double nVal, const Color& rCol):
mnVal(nVal),
maColor(rCol),
mpCell(NULL),
- mbMin(false),
- mbMax(false),
- mbPercent(false),
- mbPercentile(false)
+ meType(COLORSCALE_VALUE)
{
}
@@ -56,10 +50,7 @@ ScColorScaleEntry::ScColorScaleEntry(const ScColorScaleEntry& rEntry):
mnVal(rEntry.mnVal),
maColor(rEntry.maColor),
mpCell(),
- mbMin(rEntry.mbMin),
- mbMax(rEntry.mbMax),
- mbPercent(rEntry.mbPercent),
- mbPercentile(rEntry.mbPercentile)
+ meType(rEntry.meType)
{
}
@@ -67,10 +58,7 @@ ScColorScaleEntry::ScColorScaleEntry(ScDocument* pDoc, const ScColorScaleEntry&
mnVal(rEntry.mnVal),
maColor(rEntry.maColor),
mpCell(),
- mbMin(rEntry.mbMin),
- mbMax(rEntry.mbMax),
- mbPercent(rEntry.mbPercent),
- mbPercentile(rEntry.mbPercentile)
+ meType(rEntry.meType)
{
if(rEntry.mpCell)
{
@@ -197,58 +185,16 @@ void ScColorScaleFormat::AddEntry( ScColorScaleEntry* pEntry )
maColorScales.push_back( pEntry );
}
-bool ScColorScaleEntry::GetMin() const
+void ScColorScaleEntry::SetType( ScColorScaleEntryType eType )
{
- return mbMin;
+ meType = eType;
+ if(eType != COLORSCALE_FORMULA)
+ mpCell.reset();
}
-bool ScColorScaleEntry::GetMax() const
+ScColorScaleEntryType ScColorScaleEntry::GetType() const
{
- return mbMax;
-}
-
-bool ScColorScaleEntry::GetPercent() const
-{
- return mbPercent;
-}
-
-bool ScColorScaleEntry::GetPercentile() const
-{
- return mbPercentile;
-}
-
-bool ScColorScaleEntry::HasFormula() const
-{
- return mpCell;
-}
-
-void ScColorScaleEntry::SetMin(bool bMin)
-{
- mbMin = bMin;
-}
-
-void ScColorScaleEntry::SetMax(bool bMax)
-{
- mbMax = bMax;
-}
-
-void ScColorScaleEntry::SetPercent(bool bPercent)
-{
- mbPercent = bPercent;
-}
-
-void ScColorScaleEntry::SetPercentile(bool bPercentile)
-{
- mbPercentile = bPercentile;
-}
-
-void ScColorScaleEntry::SetHasValue()
-{
- mbPercentile = false;
- mbPercent = false;
- mbMin = false;
- mbMax = false;
- mpCell.reset();
+ return meType;
}
namespace {
@@ -352,7 +298,7 @@ double ScColorScaleFormat::GetMinValue() const
{
const_iterator itr = maColorScales.begin();
- if(!itr->GetMin())
+ if(itr->GetType() != COLORSCALE_MIN)
return itr->GetValue();
else
{
@@ -364,7 +310,7 @@ double ScColorScaleFormat::GetMaxValue() const
{
ColorScaleEntries::const_reverse_iterator itr = maColorScales.rbegin();
- if(!itr->GetMax())
+ if(itr->GetType() != COLORSCALE_MAX)
return itr->GetValue();
else
{
@@ -460,29 +406,29 @@ double GetPercentile( std::vector<double>& rArray, double fPercentile )
double ScColorScaleFormat::CalcValue(double nMin, double nMax, ScColorScaleFormat::const_iterator& itr) const
{
- if(itr->GetPercent())
- {
- return nMin + (nMax-nMin)*(itr->GetValue()/100);
- }
- else if(itr->GetMin())
- {
- return nMin;
- }
- else if(itr->GetMax())
+ switch(itr->GetType())
{
- return nMax;
- }
- else if(itr->GetPercentile())
- {
- std::vector<double> aValues;
- getValues(aValues);
- if(aValues.size() == 1)
- return aValues[0];
- else
+ case COLORSCALE_PERCENT:
+ return nMin + (nMax-nMin)*(itr->GetValue()/100);
+ case COLORSCALE_MIN:
+ return nMin;
+ case COLORSCALE_MAX:
+ return nMax;
+ case COLORSCALE_PERCENTILE:
{
- double fPercentile = itr->GetValue()/100.0;
- return GetPercentile(aValues, fPercentile);
+ std::vector<double> aValues;
+ getValues(aValues);
+ if(aValues.size() == 1)
+ return aValues[0];
+ else
+ {
+ double fPercentile = itr->GetValue()/100.0;
+ return GetPercentile(aValues, fPercentile);
+ }
}
+
+ default:
+ break;
}
return itr->GetValue();
@@ -559,14 +505,18 @@ bool ScColorScaleFormat::CheckEntriesForRel(const ScRange& rRange) const
bool bNeedUpdate = false;
for(const_iterator itr = begin(); itr != end(); ++itr)
{
- if(itr->GetMin() || itr->GetMax())
+ ScColorScaleEntryType eType = itr->GetType();
+ switch(eType)
{
- bNeedUpdate = true;
- break;
+ case COLORSCALE_MIN:
+ case COLORSCALE_MAX:
+ bNeedUpdate = true;
+ break;
+ case COLORSCALE_FORMULA:
+ return true;
+ default:
+ break;
}
-
- if(itr->HasFormula())
- return true;
}
// TODO: check also if the changed value is the new min/max
@@ -661,14 +611,15 @@ namespace {
bool NeedUpdate(ScColorScaleEntry* pEntry)
{
- if(pEntry->GetMin())
- return true;
-
- if(pEntry->GetMax())
- return true;
-
- if(pEntry->GetFormula())
- return true;
+ switch(pEntry->GetType())
+ {
+ case COLORSCALE_MIN:
+ case COLORSCALE_MAX:
+ case COLORSCALE_FORMULA:
+ return true;
+ default:
+ return false;
+ }
return false;
}
@@ -704,16 +655,24 @@ void ScDataBarFormat::UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab)
double ScDataBarFormat::getMin(double nMin, double nMax) const
{
- if(mpFormatData->mpLowerLimit->GetMin())
- return nMin;
- else if(mpFormatData->mpLowerLimit->GetPercent())
- return nMin + (nMax-nMin)/100*mpFormatData->mpLowerLimit->GetValue();
- else if(mpFormatData->mpLowerLimit->GetPercentile())
+ switch(mpFormatData->mpLowerLimit->GetType())
{
- double fPercentile = mpFormatData->mpLowerLimit->GetValue()/100.0;
- std::vector<double> aValues;
- getValues(aValues);
- return GetPercentile(aValues, fPercentile);
+ case COLORSCALE_MIN:
+ return nMin;
+
+ case COLORSCALE_PERCENT:
+ return nMin + (nMax-nMin)/100*mpFormatData->mpLowerLimit->GetValue();
+
+ case COLORSCALE_PERCENTILE:
+ {
+ double fPercentile = mpFormatData->mpLowerLimit->GetValue()/100.0;
+ std::vector<double> aValues;
+ getValues(aValues);
+ return GetPercentile(aValues, fPercentile);
+ }
+
+ default:
+ break;
}
return mpFormatData->mpLowerLimit->GetValue();
@@ -721,16 +680,22 @@ double ScDataBarFormat::getMin(double nMin, double nMax) const
double ScDataBarFormat::getMax(double nMin, double nMax) const
{
- if(mpFormatData->mpUpperLimit->GetMax())
- return nMax;
- else if(mpFormatData->mpUpperLimit->GetPercent())
- return nMin + (nMax-nMin)/100*mpFormatData->mpUpperLimit->GetValue();
- else if(mpFormatData->mpLowerLimit->GetPercentile())
+ switch(mpFormatData->mpUpperLimit->GetType())
{
- double fPercentile = mpFormatData->mpLowerLimit->GetValue()/100.0;
- std::vector<double> aValues;
- getValues(aValues);
- return GetPercentile(aValues, fPercentile);
+ case COLORSCALE_MAX:
+ return nMax;
+ case COLORSCALE_PERCENT:
+ return nMin + (nMax-nMin)/100*mpFormatData->mpUpperLimit->GetValue();
+ case COLORSCALE_PERCENTILE:
+ {
+ double fPercentile = mpFormatData->mpLowerLimit->GetValue()/100.0;
+ std::vector<double> aValues;
+ getValues(aValues);
+ return GetPercentile(aValues, fPercentile);
+ }
+
+ default:
+ break;
}
return mpFormatData->mpUpperLimit->GetValue();
@@ -797,9 +762,9 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
// if max or min is used we may need to adjust it
// for the length calculation
- if (mpFormatData->mpLowerLimit->GetMin() && nMin > 0)
+ if (mpFormatData->mpLowerLimit->GetType() == COLORSCALE_MIN && nMin > 0)
nMinPositive = nMin;
- if (mpFormatData->mpUpperLimit->GetMax() && nMax < 0)
+ if (mpFormatData->mpUpperLimit->GetType() == COLORSCALE_MAX && nMax < 0)
nMaxNegative = nMax;
}
else if( mpFormatData->meAxisPosition == databar::MIDDLE)
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index bc7445b67062..0c28a59d6367 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -898,14 +898,19 @@ namespace {
rtl::OString getColorScaleType( const ScColorScaleEntry& rEntry )
{
- if (rEntry.GetMin())
- return "min";
- if(rEntry.GetMax())
- return "max";
- if(rEntry.GetPercent())
- return "percent";
- if(rEntry.HasFormula())
- return "formula";
+ switch(rEntry.GetType())
+ {
+ case COLORSCALE_MIN:
+ return "min";
+ case COLORSCALE_MAX:
+ return "max";
+ case COLORSCALE_PERCENT:
+ return "percent";
+ case COLORSCALE_FORMULA:
+ return "formula";
+ default:
+ break;
+ }
return "num";
}
@@ -917,7 +922,7 @@ void XclExpCfvo::SaveXml( XclExpXmlStream& rStrm )
sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
rtl::OString aValue;
- if(mrEntry.HasFormula())
+ if(mrEntry.GetType() == COLORSCALE_FORMULA)
{
rtl::OUString aFormula = XclXmlUtils::ToOUString( GetRoot().GetDoc(), maSrcPos, mrEntry.GetFormula()->Clone() );
aValue = rtl::OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8 );
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index b110df2b92f8..03d9ba17cf3b 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -232,16 +232,19 @@ ScColorScaleEntry* ConvertToModel( const ColorScaleRuleModelEntry& rEntry, ScDoc
ScColorScaleEntry* pEntry = new ScColorScaleEntry(rEntry.mnVal, rEntry.maColor);
if(rEntry.mbMin)
- pEntry->SetMin(true);
+ pEntry->SetType(COLORSCALE_MIN);
if(rEntry.mbMax)
- pEntry->SetMax(true);
+ pEntry->SetType(COLORSCALE_MAX);
if(rEntry.mbPercent)
- pEntry->SetPercent(true);
+ pEntry->SetType(COLORSCALE_PERCENT);
if(rEntry.mbPercentile)
- pEntry->SetPercentile(true);
+ pEntry->SetType(COLORSCALE_PERCENTILE);
if(!rEntry.maFormula.isEmpty())
+ {
+ pEntry->SetType(COLORSCALE_FORMULA);
pEntry->SetFormula(rEntry.maFormula, pDoc, rAddr, formula::FormulaGrammar::GRAM_ENGLISH_XL_A1);
+ }
return pEntry;
}
diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx
index 636e76af5300..d9b2fb9eaa7f 100644
--- a/sc/source/filter/xml/xmlcondformat.cxx
+++ b/sc/source/filter/xml/xmlcondformat.cxx
@@ -430,15 +430,16 @@ void setColorEntryType(const rtl::OUString& rType, ScColorScaleEntry* pEntry, co
ScXMLImport& rImport)
{
if(rType == "minimum")
- pEntry->SetMin(true);
+ pEntry->SetType(COLORSCALE_MIN);
else if(rType == "maximum")
- pEntry->SetMax(true);
+ pEntry->SetType(COLORSCALE_MAX);
else if(rType == "percentile")
- pEntry->SetPercentile(true);
+ pEntry->SetType(COLORSCALE_PERCENTILE);
else if(rType == "percent")
- pEntry->SetPercent(true);
+ pEntry->SetType(COLORSCALE_PERCENT);
else if(rType == "formula")
{
+ pEntry->SetType(COLORSCALE_FORMULA);
//position does not matter, only table is important
pEntry->SetFormula(rFormula, rImport.GetDocument(), ScAddress(0,0,rImport.GetTables().GetCurrentSheet()), formula::FormulaGrammar::GRAM_ODFF);
}
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index a3c769da2bdf..e97829a0d2a0 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3786,18 +3786,22 @@ namespace {
rtl::OUString getCondFormatEntryType(const ScColorScaleEntry& rEntry)
{
- if(rEntry.GetMin())
- return rtl::OUString("minimum");
- else if(rEntry.GetMax())
- return rtl::OUString("maximum");
- else if(rEntry.GetPercent())
- return rtl::OUString("percent");
- else if(rEntry.GetPercentile())
- return rtl::OUString("percentile");
- else if(rEntry.GetFormula())
- return rtl::OUString("formula");
- else
- return rtl::OUString("number");
+ switch(rEntry.GetType())
+ {
+ case COLORSCALE_MIN:
+ return rtl::OUString("minimum");
+ case COLORSCALE_MAX:
+ return rtl::OUString("maximum");
+ case COLORSCALE_PERCENT:
+ return rtl::OUString("percent");
+ case COLORSCALE_PERCENTILE:
+ return rtl::OUString("percentile");
+ case COLORSCALE_FORMULA:
+ return rtl::OUString("formula");
+ case COLORSCALE_VALUE:
+ return rtl::OUString("number");
+ }
+ return rtl::OUString();
}
}
@@ -3901,7 +3905,7 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
for(ScColorScaleFormat::const_iterator it = mrColorScale.begin();
it != mrColorScale.end(); ++it)
{
- if(it->HasFormula())
+ if(it->GetType() == COLORSCALE_FORMULA)
{
rtl::OUString sFormula = it->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, sFormula);
@@ -3962,7 +3966,7 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
SvXMLElementExport aElementDataBar(*this, XML_NAMESPACE_CALC_EXT, XML_DATA_BAR, true, true);
{
- if(pFormatData->mpLowerLimit->HasFormula())
+ if(pFormatData->mpLowerLimit->GetType() == COLORSCALE_FORMULA)
{
rtl::OUString sFormula = pFormatData->mpLowerLimit->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, sFormula);
@@ -3974,7 +3978,7 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
}
{
- if(pFormatData->mpUpperLimit->HasFormula())
+ if(pFormatData->mpUpperLimit->GetType() == COLORSCALE_FORMULA)
{
rtl::OUString sFormula = pFormatData->mpUpperLimit->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, sFormula);
diff --git a/sc/source/ui/condformat/colorformat.cxx b/sc/source/ui/condformat/colorformat.cxx
index daa14a816ee3..71f3bc71aa11 100644
--- a/sc/source/ui/condformat/colorformat.cxx
+++ b/sc/source/ui/condformat/colorformat.cxx
@@ -71,18 +71,27 @@ namespace {
void SetType(const ScColorScaleEntry* pEntry, ListBox& aLstBox)
{
- if(pEntry->GetMin())
- aLstBox.SelectEntryPos(0);
- else if(pEntry->GetMax())
- aLstBox.SelectEntryPos(1);
- else if(pEntry->GetPercentile())
- aLstBox.SelectEntryPos(2);
- else if(pEntry->GetPercent())
- aLstBox.SelectEntryPos(3);
- else if(pEntry->HasFormula())
- aLstBox.SelectEntryPos(5);
- else
- aLstBox.SelectEntryPos(4);
+ switch(pEntry->GetType())
+ {
+ case COLORSCALE_MIN:
+ aLstBox.SelectEntryPos(0);
+ break;
+ case COLORSCALE_MAX:
+ aLstBox.SelectEntryPos(1);
+ break;
+ case COLORSCALE_PERCENTILE:
+ aLstBox.SelectEntryPos(2);
+ break;
+ case COLORSCALE_PERCENT:
+ aLstBox.SelectEntryPos(3);
+ break;
+ case COLORSCALE_FORMULA:
+ aLstBox.SelectEntryPos(5);
+ break;
+ case COLORSCALE_VALUE:
+ aLstBox.SelectEntryPos(4);
+ break;
+ }
}
void GetType(const ListBox& rLstBox, const Edit& rEd, ScColorScaleEntry* pEntry, SvNumberFormatter* pNumberFormatter )
@@ -92,24 +101,24 @@ void GetType(const ListBox& rLstBox, const Edit& rEd, ScColorScaleEntry* pEntry,
switch(rLstBox.GetSelectEntryPos())
{
case 0:
- pEntry->SetMin(true);
+ pEntry->SetType(COLORSCALE_MIN);
break;
case 1:
- pEntry->SetMax(true);
+ pEntry->SetType(COLORSCALE_MAX);
break;
case 2:
- pEntry->SetPercentile(true);
+ pEntry->SetType(COLORSCALE_PERCENTILE);
pNumberFormatter->IsNumberFormat( rEd.GetText(), nIndex, nVal );
pEntry->SetValue(nVal);
break;
case 3:
- pEntry->SetPercent(true);
+ pEntry->SetType(COLORSCALE_PERCENT);
pNumberFormatter->IsNumberFormat( rEd.GetText(), nIndex, nVal );
pEntry->SetValue(nVal);
break;
case 4:
pNumberFormatter->IsNumberFormat( rEd.GetText(), nIndex, nVal );
- pEntry->SetHasValue();
+ pEntry->SetType(COLORSCALE_VALUE);
pEntry->SetValue(nVal);
break;
case 5:
@@ -119,9 +128,9 @@ void GetType(const ListBox& rLstBox, const Edit& rEd, ScColorScaleEntry* pEntry,
void SetValue( ScColorScaleEntry* pEntry, Edit& aEdit)
{
- if(pEntry->HasFormula())
+ if(pEntry->GetType() == COLORSCALE_FORMULA)
aEdit.SetText(pEntry->GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
- else if(!pEntry->GetMin() && !pEntry->GetMax())
+ else if(pEntry->GetType() != COLORSCALE_MIN && pEntry->GetType() != COLORSCALE_MAX)
aEdit.SetText(rtl::OUString::valueOf(pEntry->GetValue()));
else
aEdit.Disable();
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index cd850ac6a7ce..6b4270ac2c00 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -56,58 +56,59 @@ namespace {
void SetColorScaleEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Edit& rEdit, ColorListBox& rLbCol )
{
- if(rEntry.GetMin())
- rLbType.SelectEntryPos(0);
- else if(rEntry.GetMax())
- rLbType.SelectEntryPos(1);
- else if(rEntry.GetPercentile())
+ switch(rEntry.GetType())
{
- rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
- rLbType.SelectEntryPos(2);
- }
- else if(rEntry.GetPercent())
- {
- rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
- rLbType.SelectEntryPos(4);
- }
- else if(rEntry.HasFormula())
- {
- rEdit.SetText(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
- rLbType.SelectEntryPos(5);
- }
- else
- {
- rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
- rLbType.SelectEntryPos(3);
+ case COLORSCALE_MIN:
+ rLbType.SelectEntryPos(0);
+ break;
+ case COLORSCALE_MAX:
+ rLbType.SelectEntryPos(1);
+ break;
+ case COLORSCALE_PERCENTILE:
+ rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
+ rLbType.SelectEntryPos(2);
+ break;
+ case COLORSCALE_PERCENT:
+ rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
+ rLbType.SelectEntryPos(4);
+ break;
+ case COLORSCALE_FORMULA:
+ rEdit.SetText(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
+ rLbType.SelectEntryPos(5);
+ break;
+ case COLORSCALE_VALUE:
+ rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
+ rLbType.SelectEntryPos(3);
+ break;
}
rLbCol.SelectEntry(rEntry.GetColor());
}
void SetDataBarEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Edit& rEdit )
{
- if(rEntry.GetMin())
- rLbType.SelectEntryPos(0);
- else if(rEntry.GetMax())
- rLbType.SelectEntryPos(1);
- else if(rEntry.GetPercentile())
+ switch(rEntry.GetType())
{
- rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
- rLbType.SelectEntryPos(2);
- }
- else if(rEntry.GetPercent())
- {
- rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
- rLbType.SelectEntryPos(4);
- }
- else if(rEntry.HasFormula())
- {
- rEdit.SetText(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
- rLbType.SelectEntryPos(5);
- }
- else
- {
- rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
- rLbType.SelectEntryPos(3);
+ case COLORSCALE_MIN:
+ rLbType.SelectEntryPos(0);
+ break;
+ case COLORSCALE_MAX:
+ rLbType.SelectEntryPos(1);
+ case COLORSCALE_PERCENTILE:
+ rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
+ rLbType.SelectEntryPos(2);
+ break;
+ case COLORSCALE_PERCENT:
+ rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
+ rLbType.SelectEntryPos(4);
+ break;
+ case COLORSCALE_FORMULA:
+ rEdit.SetText(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
+ rLbType.SelectEntryPos(5);
+ break;
+ case COLORSCALE_VALUE:
+ rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
+ rLbType.SelectEntryPos(3);
+ break;
}
}
@@ -403,8 +404,8 @@ void ScCondFrmtEntry::Init()
mpDataBarData.reset(new ScDataBarFormatData());
mpDataBarData->mpUpperLimit.reset(new ScColorScaleEntry());
mpDataBarData->mpLowerLimit.reset(new ScColorScaleEntry());
- mpDataBarData->mpLowerLimit->SetMin(true);
- mpDataBarData->mpUpperLimit->SetMax(true);
+ mpDataBarData->mpLowerLimit->SetType(COLORSCALE_MIN);
+ mpDataBarData->mpUpperLimit->SetType(COLORSCALE_MAX);
mpDataBarData->maPositiveColor = COL_LIGHTBLUE;
}
@@ -702,24 +703,24 @@ void SetColorScaleEntry( ScColorScaleEntry* pEntry, const ListBox& rType, const
switch(rType.GetSelectEntryPos())
{
case 0:
- pEntry->SetMin(true);
+ pEntry->SetType(COLORSCALE_MIN);
break;
case 1:
- pEntry->SetMax(true);
+ pEntry->SetType(COLORSCALE_MAX);
break;
case 2:
- pEntry->SetPercentile(true);
+ pEntry->SetType(COLORSCALE_PERCENTILE);
pEntry->SetValue(nVal);
break;
case 3:
- pEntry->SetValue(nVal);
- pEntry->SetHasValue();
+ pEntry->SetType(COLORSCALE_VALUE);
break;
case 4:
- pEntry->SetPercent(true);
+ pEntry->SetType(COLORSCALE_PERCENT);
pEntry->SetValue(nVal);
break;
case 5:
+ pEntry->SetType(COLORSCALE_FORMULA);
pEntry->SetFormula(rValue.GetText(), pDoc, rPos);
break;
default: