Get the sub dialog functional.

Change-Id: Ib3311f64417b68cf94505aeb7f8b153cf5fcdbff
This commit is contained in:
Kohei Yoshida
2012-05-30 00:19:30 -04:00
parent 7dd9054bde
commit ef3fd657ba
4 changed files with 90 additions and 23 deletions

View File

@@ -62,6 +62,41 @@ void OptionString::Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 /*nFlags*/,
rDev.SetFont(aOldFont);
}
rtl::OUString toString(formula::FormulaGrammar::AddressConvention eConv)
{
switch (eConv)
{
case formula::FormulaGrammar::CONV_OOO:
return rtl::OUString("Calc A1");
case formula::FormulaGrammar::CONV_XL_A1:
return rtl::OUString ("Excel A1");
case formula::FormulaGrammar::CONV_XL_R1C1:
return rtl::OUString("Excel R1C1");
case formula::FormulaGrammar::CONV_UNSPECIFIED:
default:
;
}
return rtl::OUString("Use formula syntax");
}
formula::FormulaGrammar::AddressConvention toAddressConvention(sal_uInt16 nPos)
{
switch (nPos)
{
case 1:
return formula::FormulaGrammar::CONV_OOO;
case 2:
return formula::FormulaGrammar::CONV_XL_A1;
case 3:
return formula::FormulaGrammar::CONV_XL_R1C1;
case 0:
default:
;
}
return formula::FormulaGrammar::CONV_UNSPECIFIED;
}
}
ScCalcOptionsDialog::ScCalcOptionsDialog(Window* pParent, const ScCalcConfig& rConfig) :
@@ -80,8 +115,9 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(Window* pParent, const ScCalcConfig& rC
maLbSettings.SetStyle(maLbSettings.GetStyle() | WB_CLIPCHILDREN | WB_FORCE_MAKEVISIBLE);
maLbSettings.SetHighlightRange();
maLbSettings.SetSelectHdl(LINK(this, ScCalcOptionsDialog, SettingsSelHdl));
maLbSettings.SetDoubleClickHdl(LINK(this, ScCalcOptionsDialog, SettingsDoubleClickHdl));
Link aLink = LINK(this, ScCalcOptionsDialog, SettingsSelHdl);
maLbSettings.SetSelectHdl(aLink);
maLbOptionEdit.SetSelectHdl(aLink);
FillOptionsList();
FreeResource();
@@ -90,18 +126,28 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(Window* pParent, const ScCalcConfig& rC
ScCalcOptionsDialog::~ScCalcOptionsDialog() {}
const ScCalcConfig& ScCalcOptionsDialog::GetConfig() const
{
return maConfig;
}
void ScCalcOptionsDialog::FillOptionsList()
{
maLbSettings.SetUpdateMode(false);
maLbSettings.Clear();
SvLBoxTreeList* pModel = maLbSettings.GetModel();
SvLBoxEntry* pEntry = new SvLBoxEntry;
pEntry->AddItem(new SvLBoxString(pEntry, 0, rtl::OUString()));
pEntry->AddItem(new SvLBoxContextBmp(pEntry, 0, Image(), Image(), 0));
OptionString* pItem = new OptionString(maCaptionIndirectSyntax, "Calc A1");
pEntry->AddItem(pItem);
pModel->Insert(pEntry);
{
// Syntax for INDIRECT function.
SvLBoxEntry* pEntry = new SvLBoxEntry;
pEntry->AddItem(new SvLBoxString(pEntry, 0, rtl::OUString()));
pEntry->AddItem(new SvLBoxContextBmp(pEntry, 0, Image(), Image(), 0));
OptionString* pItem = new OptionString(
maCaptionIndirectSyntax, toString(maConfig.meIndirectRefSyntax));
pEntry->AddItem(pItem);
pModel->Insert(pEntry);
}
maLbSettings.SetUpdateMode(true);
}
@@ -112,27 +158,47 @@ void ScCalcOptionsDialog::SelectionChanged()
{
// Formula syntax for INDIRECT function.
maLbOptionEdit.Clear();
maLbOptionEdit.InsertEntry(rtl::OUString("Use formula syntax"));
maLbOptionEdit.InsertEntry(rtl::OUString("Calc A1"));
maLbOptionEdit.InsertEntry(rtl::OUString("Excel A1"));
maLbOptionEdit.InsertEntry(rtl::OUString("Excel R1C1"));
maLbOptionEdit.SelectEntryPos(0);
switch (maConfig.meIndirectRefSyntax)
{
case formula::FormulaGrammar::CONV_OOO:
maLbOptionEdit.SelectEntryPos(1);
break;
case formula::FormulaGrammar::CONV_XL_A1:
maLbOptionEdit.SelectEntryPos(2);
break;
case formula::FormulaGrammar::CONV_XL_R1C1:
maLbOptionEdit.SelectEntryPos(3);
break;
case formula::FormulaGrammar::CONV_UNSPECIFIED:
default:
maLbOptionEdit.SelectEntryPos(0);
}
maFtAnnotation.SetText(maDescIndirectSyntax);
}
}
void ScCalcOptionsDialog::EditOption()
void ScCalcOptionsDialog::ListOptionValueChanged()
{
if (true)
{
// Formula syntax for INDIRECT function.
sal_uInt16 nPos = maLbOptionEdit.GetSelectEntryPos();
maConfig.meIndirectRefSyntax = toAddressConvention(nPos);
FillOptionsList();
}
}
IMPL_LINK_NOARG(ScCalcOptionsDialog, SettingsSelHdl)
IMPL_LINK(ScCalcOptionsDialog, SettingsSelHdl, Control*, pCtrl)
{
SelectionChanged();
return 0;
}
if (pCtrl == &maLbSettings)
SelectionChanged();
else if (pCtrl == &maLbOptionEdit)
ListOptionValueChanged();
IMPL_LINK_NOARG(ScCalcOptionsDialog, SettingsDoubleClickHdl)
{
EditOption();
return 0;
}

View File

@@ -42,13 +42,14 @@ public:
ScCalcOptionsDialog(Window* pParent, const ScCalcConfig& rConfig);
virtual ~ScCalcOptionsDialog();
DECL_LINK( SettingsSelHdl, void* );
DECL_LINK( SettingsDoubleClickHdl, void* );
DECL_LINK( SettingsSelHdl, Control* );
const ScCalcConfig& GetConfig() const;
private:
void FillOptionsList();
void SelectionChanged();
void EditOption();
void ListOptionValueChanged();
private:
SvxCheckListBox maLbSettings;

View File

@@ -54,8 +54,8 @@ ModalDialog RID_SCDLG_FORMULA_CALCOPTIONS
ListBox LB_OPTION_EDIT
{
Pos = MAP_APPFONT ( 50 , 82 ) ;
Size = MAP_APPFONT ( 60, 46 ) ;
Pos = MAP_APPFONT ( 50, 82 ) ;
Size = MAP_APPFONT ( 100, 46 ) ;
TabStop = TRUE ;
DropDown = TRUE ;
};

View File

@@ -144,7 +144,7 @@ void ScTpFormulaOptions::LaunchCustomCalcSettings()
ScCalcOptionsDialog aDlg(this, maCurrentConfig);
if (aDlg.Execute() == RET_OK)
{
maCurrentConfig = aDlg.GetConfig();
}
}