summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-10-10 06:06:23 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-10-10 06:49:19 +0200
commit2757c7450de3369872a247cf4876bb1723cc48fa (patch)
tree4bdf7366e8fea812b14caaaa135b552e2f2e4700 /sc
parent8816aa1b8301bce189ee4582fa1b8f04864726a4 (diff)
unify the list box entry handling a bit
Change-Id: Ia42e56dd21567ac65ca952dc66471cfb326a9e1c
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/colorscale.hxx9
-rw-r--r--sc/source/ui/condformat/colorformat.cxx66
-rw-r--r--sc/source/ui/condformat/condformatdlgentry.cxx61
-rw-r--r--sc/source/ui/src/colorformat.src2
4 files changed, 39 insertions, 99 deletions
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 7ee92ce09c6e..92f88f3359b4 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -45,15 +45,18 @@ class ScFormulaCell;
class ScTokenArray;
struct ScDataBarInfo;
+// don't change the order
+// they are also used in the dialog to determine the position
+// in the list box
enum ScColorScaleEntryType
{
- COLORSCALE_VALUE,
+ COLORSCALE_AUTO,
COLORSCALE_MIN,
COLORSCALE_MAX,
- COLORSCALE_PERCENT,
COLORSCALE_PERCENTILE,
+ COLORSCALE_VALUE,
+ COLORSCALE_PERCENT,
COLORSCALE_FORMULA,
- COLORSCALE_AUTO,
};
class SC_DLLPUBLIC ScColorScaleEntry
diff --git a/sc/source/ui/condformat/colorformat.cxx b/sc/source/ui/condformat/colorformat.cxx
index 7dfa918d6e3b..963137d1e28a 100644
--- a/sc/source/ui/condformat/colorformat.cxx
+++ b/sc/source/ui/condformat/colorformat.cxx
@@ -69,62 +69,26 @@ ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow, ScDocument* pDoc):
namespace {
-void SetType(const ScColorScaleEntry* pEntry, ListBox& aLstBox)
+void SetType(const ScColorScaleEntry* pEntry, ListBox& rLstBox)
{
- switch(pEntry->GetType())
- {
- case COLORSCALE_AUTO:
- aLstBox.SelectEntryPos(0);
- break;
- case COLORSCALE_MIN:
- aLstBox.SelectEntryPos(1);
- break;
- case COLORSCALE_MAX:
- aLstBox.SelectEntryPos(2);
- break;
- case COLORSCALE_PERCENTILE:
- aLstBox.SelectEntryPos(3);
- break;
- case COLORSCALE_PERCENT:
- aLstBox.SelectEntryPos(4);
- break;
- case COLORSCALE_FORMULA:
- aLstBox.SelectEntryPos(6);
- break;
- case COLORSCALE_VALUE:
- aLstBox.SelectEntryPos(5);
- break;
- }
+ rLstBox.SelectEntryPos(pEntry->GetType());
}
void GetType(const ListBox& rLstBox, const Edit& rEd, ScColorScaleEntry* pEntry, SvNumberFormatter* pNumberFormatter )
{
double nVal = 0;
sal_uInt32 nIndex = 0;
+ pEntry->SetType(static_cast<ScColorScaleEntryType>(rLstBox.GetSelectEntryPos()));
switch(rLstBox.GetSelectEntryPos())
{
- case 0:
- pEntry->SetType(COLORSCALE_AUTO);
- break;
- case 1:
- pEntry->SetType(COLORSCALE_MIN);
- break;
- case 2:
- pEntry->SetType(COLORSCALE_MAX);
- break;
- case 3:
- pEntry->SetType(COLORSCALE_PERCENTILE);
- pNumberFormatter->IsNumberFormat( rEd.GetText(), nIndex, nVal );
- pEntry->SetValue(nVal);
- break;
- case 4:
- pEntry->SetType(COLORSCALE_PERCENT);
- pNumberFormatter->IsNumberFormat( rEd.GetText(), nIndex, nVal );
- pEntry->SetValue(nVal);
+ case COLORSCALE_AUTO:
+ case COLORSCALE_MIN:
+ case COLORSCALE_MAX:
break;
- case 5:
+ case COLORSCALE_PERCENTILE:
+ case COLORSCALE_VALUE:
+ case COLORSCALE_PERCENT:
pNumberFormatter->IsNumberFormat( rEd.GetText(), nIndex, nVal );
- pEntry->SetType(COLORSCALE_VALUE);
pEntry->SetValue(nVal);
break;
case 6:
@@ -288,10 +252,10 @@ IMPL_LINK_NOARG( ScDataBarSettingsDlg, OkBtnHdl )
//check that min < max
bool bWarn = false;
sal_Int32 nSelectMin = maLbTypeMin.GetSelectEntryPos();
- if( nSelectMin == 1 || nSelectMin == 7)
+ if( nSelectMin == COLORSCALE_MIN )
bWarn = true;
sal_Int32 nSelectMax = maLbTypeMax.GetSelectEntryPos();
- if( nSelectMax == 0 || nSelectMax == 6 )
+ if( nSelectMax == COLORSCALE_MAX )
bWarn = true;
if(!bWarn && maLbTypeMin.GetSelectEntryPos() == maLbTypeMax.GetSelectEntryPos())
@@ -327,14 +291,14 @@ IMPL_LINK_NOARG( ScDataBarSettingsDlg, OkBtnHdl )
IMPL_LINK_NOARG( ScDataBarSettingsDlg, TypeSelectHdl )
{
sal_Int32 nSelectMin = maLbTypeMin.GetSelectEntryPos();
- if( nSelectMin == 0 || nSelectMin == 1 || nSelectMin == 6 || nSelectMin == 7)
+ if( nSelectMin <= COLORSCALE_MAX)
maEdMin.Disable();
else
{
maEdMin.Enable();
if(!maEdMin.GetText().Len())
{
- if(nSelectMin == 2 || nSelectMin == 3)
+ if(nSelectMin == COLORSCALE_PERCENTILE || nSelectMin == COLORSCALE_PERCENT)
maEdMin.SetText(rtl::OUString::valueOf(static_cast<sal_Int32>(50)));
else
maEdMin.SetText(rtl::OUString::valueOf(static_cast<sal_Int32>(0)));
@@ -342,14 +306,14 @@ IMPL_LINK_NOARG( ScDataBarSettingsDlg, TypeSelectHdl )
}
sal_Int32 nSelectMax = maLbTypeMax.GetSelectEntryPos();
- if(nSelectMax == 0 || nSelectMax == 1 || nSelectMax == 6 || nSelectMax == 7)
+ if(nSelectMax <= COLORSCALE_MAX)
maEdMax.Disable();
else
{
maEdMax.Enable();
if(!maEdMax.GetText().Len())
{
- if(nSelectMax == 2 || nSelectMax == 3)
+ if(nSelectMax == COLORSCALE_PERCENTILE || nSelectMax == COLORSCALE_PERCENT)
maEdMax.SetText(rtl::OUString::valueOf(static_cast<sal_Int32>(50)));
else
maEdMax.SetText(rtl::OUString::valueOf(static_cast<sal_Int32>(0)));
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index c25223879696..14b7bd430a6b 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -515,29 +515,19 @@ namespace {
void SetColorScaleEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Edit& rEdit, ColorListBox& rLbCol )
{
+ rLbType.SelectEntryPos(rEntry.GetType());
switch(rEntry.GetType())
{
case COLORSCALE_MIN:
- rLbType.SelectEntryPos(1);
- break;
case COLORSCALE_MAX:
- rLbType.SelectEntryPos(2);
break;
case COLORSCALE_PERCENTILE:
- rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
- rLbType.SelectEntryPos(3);
- break;
+ case COLORSCALE_VALUE:
case COLORSCALE_PERCENT:
rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
- rLbType.SelectEntryPos(5);
break;
case COLORSCALE_FORMULA:
rEdit.SetText(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
- rLbType.SelectEntryPos(6);
- break;
- case COLORSCALE_VALUE:
- rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
- rLbType.SelectEntryPos(4);
break;
case COLORSCALE_AUTO:
abort();
@@ -558,33 +548,23 @@ void SetColorScaleEntry( ScColorScaleEntry* pEntry, const ListBox& rType, const
if(!bDataBar)
++nPos;
+ pEntry->SetType(static_cast<ScColorScaleEntryType>(nPos));
switch(nPos)
{
- case 1:
- pEntry->SetType(COLORSCALE_MIN);
- break;
- case 2:
- pEntry->SetType(COLORSCALE_MAX);
+ case COLORSCALE_AUTO:
+ case COLORSCALE_MIN:
+ case COLORSCALE_MAX:
break;
- case 3:
- pEntry->SetType(COLORSCALE_PERCENTILE);
- pEntry->SetValue(nVal);
break;
- case 4:
- pEntry->SetType(COLORSCALE_VALUE);
- pEntry->SetValue(nVal);
break;
- case 5:
- pEntry->SetType(COLORSCALE_PERCENT);
+ case COLORSCALE_PERCENTILE:
+ case COLORSCALE_VALUE:
+ case COLORSCALE_PERCENT:
pEntry->SetValue(nVal);
break;
- case 6:
- pEntry->SetType(COLORSCALE_FORMULA);
+ case COLORSCALE_FORMULA:
pEntry->SetFormula(rValue.GetText(), pDoc, rPos);
break;
- case 0:
- pEntry->SetType(COLORSCALE_AUTO);
- break;
default:
break;
}
@@ -724,7 +704,7 @@ IMPL_LINK( ScColorScale2FrmtEntry, EntryTypeHdl, ListBox*, pBox )
{
bool bEnableEdit = true;
sal_Int32 nPos = pBox->GetSelectEntryPos();
- if(nPos == 0 || nPos == 1)
+ if(nPos < 2)
{
bEnableEdit = false;
}
@@ -895,7 +875,7 @@ IMPL_LINK( ScColorScale3FrmtEntry, EntryTypeHdl, ListBox*, pBox )
{
bool bEnableEdit = true;
sal_Int32 nPos = pBox->GetSelectEntryPos();
- if(nPos == 0 || nPos == 1)
+ if(nPos < 2)
{
bEnableEdit = false;
}
@@ -936,32 +916,24 @@ namespace {
void SetDataBarEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Edit& rEdit )
{
+ rLbType.SelectEntryPos(rEntry.GetType());
switch(rEntry.GetType())
{
+ case COLORSCALE_AUTO:
case COLORSCALE_MIN:
- rLbType.SelectEntryPos(1);
- break;
case COLORSCALE_MAX:
- rLbType.SelectEntryPos(2);
break;
case COLORSCALE_PERCENTILE:
rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
- rLbType.SelectEntryPos(3);
break;
case COLORSCALE_PERCENT:
rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
- rLbType.SelectEntryPos(5);
break;
case COLORSCALE_FORMULA:
rEdit.SetText(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
- rLbType.SelectEntryPos(6);
break;
case COLORSCALE_VALUE:
rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
- rLbType.SelectEntryPos(4);
- break;
- case COLORSCALE_AUTO:
- rLbType.SelectEntryPos(0);
break;
}
}
@@ -990,6 +962,7 @@ ScDataBarFrmtEntry::ScDataBarFrmtEntry( Window* pParent, ScDocument* pDoc, const
{
maLbDataBarMinType.SelectEntryPos(0);
maLbDataBarMaxType.SelectEntryPos(0);
+ DataBarTypeSelectHdl(NULL);
}
Init();
@@ -1052,13 +1025,13 @@ void ScDataBarFrmtEntry::SetInactive()
IMPL_LINK_NOARG( ScDataBarFrmtEntry, DataBarTypeSelectHdl )
{
sal_Int32 nSelectPos = maLbDataBarMinType.GetSelectEntryPos();
- if(nSelectPos == 0 || nSelectPos == 1)
+ if(nSelectPos <= COLORSCALE_MAX)
maEdDataBarMin.Disable();
else
maEdDataBarMin.Enable();
nSelectPos = maLbDataBarMaxType.GetSelectEntryPos();
- if(nSelectPos == 0 || nSelectPos == 1)
+ if(nSelectPos <= COLORSCALE_MAX)
maEdDataBarMax.Disable();
else
maEdDataBarMax.Enable();
diff --git a/sc/source/ui/src/colorformat.src b/sc/source/ui/src/colorformat.src
index dd702e100b95..2cc585283e62 100644
--- a/sc/source/ui/src/colorformat.src
+++ b/sc/source/ui/src/colorformat.src
@@ -138,8 +138,8 @@ ModalDialog RID_SCDLG_DATABAR
"Minimum";
"Maximum";
"Percentile";
- "Percent";
"Value";
+ "Percent";
"Formula";
};
};