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); 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) : 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.SetStyle(maLbSettings.GetStyle() | WB_CLIPCHILDREN | WB_FORCE_MAKEVISIBLE);
maLbSettings.SetHighlightRange(); maLbSettings.SetHighlightRange();
maLbSettings.SetSelectHdl(LINK(this, ScCalcOptionsDialog, SettingsSelHdl)); Link aLink = LINK(this, ScCalcOptionsDialog, SettingsSelHdl);
maLbSettings.SetDoubleClickHdl(LINK(this, ScCalcOptionsDialog, SettingsDoubleClickHdl)); maLbSettings.SetSelectHdl(aLink);
maLbOptionEdit.SetSelectHdl(aLink);
FillOptionsList(); FillOptionsList();
FreeResource(); FreeResource();
@@ -90,18 +126,28 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(Window* pParent, const ScCalcConfig& rC
ScCalcOptionsDialog::~ScCalcOptionsDialog() {} ScCalcOptionsDialog::~ScCalcOptionsDialog() {}
const ScCalcConfig& ScCalcOptionsDialog::GetConfig() const
{
return maConfig;
}
void ScCalcOptionsDialog::FillOptionsList() void ScCalcOptionsDialog::FillOptionsList()
{ {
maLbSettings.SetUpdateMode(false); maLbSettings.SetUpdateMode(false);
maLbSettings.Clear();
SvLBoxTreeList* pModel = maLbSettings.GetModel(); 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); maLbSettings.SetUpdateMode(true);
} }
@@ -112,27 +158,47 @@ void ScCalcOptionsDialog::SelectionChanged()
{ {
// Formula syntax for INDIRECT function. // Formula syntax for INDIRECT function.
maLbOptionEdit.Clear(); maLbOptionEdit.Clear();
maLbOptionEdit.InsertEntry(rtl::OUString("Use formula syntax"));
maLbOptionEdit.InsertEntry(rtl::OUString("Calc A1")); maLbOptionEdit.InsertEntry(rtl::OUString("Calc A1"));
maLbOptionEdit.InsertEntry(rtl::OUString("Excel A1")); maLbOptionEdit.InsertEntry(rtl::OUString("Excel A1"));
maLbOptionEdit.InsertEntry(rtl::OUString("Excel R1C1")); 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); 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(); if (pCtrl == &maLbSettings)
return 0; SelectionChanged();
} else if (pCtrl == &maLbOptionEdit)
ListOptionValueChanged();
IMPL_LINK_NOARG(ScCalcOptionsDialog, SettingsDoubleClickHdl)
{
EditOption();
return 0; return 0;
} }

View File

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

View File

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

View File

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