diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-07-29 12:23:12 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-07-29 20:28:29 +0200 |
commit | d73e8c0df224dec52ac60ac278947f4633d6405b (patch) | |
tree | 64fea2cc81e4ad965fa598af2d0bc84cb56829d3 | |
parent | 741db80a08e98b7832c2e3be3b23d535037e836c (diff) |
weld ScTpFormulaOptions
Change-Id: I8d45dfc745dbb7f90346028eb29a432309db0845
Reviewed-on: https://gerrit.libreoffice.org/76547
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sc/source/ui/inc/tpformula.hxx | 47 | ||||
-rw-r--r-- | sc/source/ui/optdlg/tpformula.cxx | 205 | ||||
-rw-r--r-- | sc/uiconfig/scalc/ui/optformula.ui | 9 |
3 files changed, 119 insertions, 142 deletions
diff --git a/sc/source/ui/inc/tpformula.hxx b/sc/source/ui/inc/tpformula.hxx index 53e8496d38e7..dd7ec5ced453 100644 --- a/sc/source/ui/inc/tpformula.hxx +++ b/sc/source/ui/inc/tpformula.hxx @@ -21,58 +21,38 @@ #define INCLUDED_SC_SOURCE_UI_INC_TPFORMULA_HXX #include <sfx2/tabdlg.hxx> -#include <vcl/lstbox.hxx> -#include <vcl/button.hxx> #include <calcconfig.hxx> #include <docoptio.hxx> -class Edit; - class ScTpFormulaOptions : public SfxTabPage { friend class VclPtr<ScTpFormulaOptions>; public: using SfxTabPage::DeactivatePage; - static VclPtr<SfxTabPage> Create (TabPageParent pParent, const SfxItemSet* rCoreSet); + static VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet* rCoreSet); virtual bool FillItemSet(SfxItemSet* rCoreSet) override; virtual void Reset( const SfxItemSet* rCoreSet ) override; virtual DeactivateRC DeactivatePage(SfxItemSet* pSet ) override; private: - explicit ScTpFormulaOptions(vcl::Window* pParent, const SfxItemSet& rCoreSet); + explicit ScTpFormulaOptions(TabPageParent pParent, const SfxItemSet& rCoreSet); virtual ~ScTpFormulaOptions() override; - virtual void dispose() override; void ResetSeparators(); - void OnFocusSeparatorInput(Edit* pEdit); + void OnFocusSeparatorInput(weld::Entry* pEdit); void UpdateCustomCalcRadioButtons(bool bDefault); void LaunchCustomCalcSettings(); bool IsValidSeparator(const OUString& rSep) const; bool IsValidSeparatorSet() const; - DECL_LINK( ButtonHdl, Button*, void ); - DECL_LINK( SepModifyHdl, Edit&, void ); - DECL_LINK( SepEditOnFocusHdl, Control&, void ); + DECL_LINK( ButtonHdl, weld::Button&, void ); + DECL_LINK( SepModifyHdl, weld::Entry&, void ); + DECL_LINK( SepEditOnFocusHdl, weld::Widget&, void ); private: - VclPtr<ListBox> mpLbFormulaSyntax; - VclPtr<CheckBox> mpCbEnglishFuncName; - - VclPtr<RadioButton> mpBtnCustomCalcDefault; - VclPtr<RadioButton> mpBtnCustomCalcCustom; - VclPtr<PushButton> mpBtnCustomCalcDetails; - - VclPtr<Edit> mpEdSepFuncArg; - VclPtr<Edit> mpEdSepArrayCol; - VclPtr<Edit> mpEdSepArrayRow; - VclPtr<PushButton> mpBtnSepReset; - - VclPtr<ListBox> mpLbOOXMLRecalcOptions; - VclPtr<ListBox> mpLbODFRecalcOptions; - /** Stores old separator value of currently focused separator edit box. This value is used to revert undesired value change. */ OUString maOldSepValue; @@ -84,6 +64,21 @@ private: ScDocOptions maCurrentDocOptions; sal_Unicode mnDecSep; + + std::unique_ptr<weld::ComboBox> mxLbFormulaSyntax; + std::unique_ptr<weld::CheckButton> mxCbEnglishFuncName; + + std::unique_ptr<weld::RadioButton> mxBtnCustomCalcDefault; + std::unique_ptr<weld::RadioButton> mxBtnCustomCalcCustom; + std::unique_ptr<weld::Button> mxBtnCustomCalcDetails; + + std::unique_ptr<weld::Entry> mxEdSepFuncArg; + std::unique_ptr<weld::Entry> mxEdSepArrayCol; + std::unique_ptr<weld::Entry> mxEdSepArrayRow; + std::unique_ptr<weld::Button> mxBtnSepReset; + + std::unique_ptr<weld::ComboBox> mxLbOOXMLRecalcOptions; + std::unique_ptr<weld::ComboBox> mxLbODFRecalcOptions; }; #endif diff --git a/sc/source/ui/optdlg/tpformula.cxx b/sc/source/ui/optdlg/tpformula.cxx index fff31c327635..abdd14a99f3f 100644 --- a/sc/source/ui/optdlg/tpformula.cxx +++ b/sc/source/ui/optdlg/tpformula.cxx @@ -31,42 +31,40 @@ #include <unotools/localedatawrapper.hxx> - -ScTpFormulaOptions::ScTpFormulaOptions(vcl::Window* pParent, const SfxItemSet& rCoreAttrs) : - SfxTabPage(pParent, "OptFormula", "modules/scalc/ui/optformula.ui", &rCoreAttrs), - mnDecSep(0) +ScTpFormulaOptions::ScTpFormulaOptions(TabPageParent pParent, const SfxItemSet& rCoreAttrs) + : SfxTabPage(pParent, "modules/scalc/ui/optformula.ui", "OptFormula", &rCoreAttrs) + , mnDecSep(0) + , mxLbFormulaSyntax(m_xBuilder->weld_combo_box("formulasyntax")) + , mxCbEnglishFuncName(m_xBuilder->weld_check_button("englishfuncname")) + , mxBtnCustomCalcDefault(m_xBuilder->weld_radio_button("calcdefault")) + , mxBtnCustomCalcCustom(m_xBuilder->weld_radio_button("calccustom")) + , mxBtnCustomCalcDetails(m_xBuilder->weld_button("details")) + , mxEdSepFuncArg(m_xBuilder->weld_entry("function")) + , mxEdSepArrayCol(m_xBuilder->weld_entry("arraycolumn")) + , mxEdSepArrayRow(m_xBuilder->weld_entry("arrayrow")) + , mxBtnSepReset(m_xBuilder->weld_button("reset")) + , mxLbOOXMLRecalcOptions(m_xBuilder->weld_combo_box("ooxmlrecalc")) + , mxLbODFRecalcOptions(m_xBuilder->weld_combo_box("odfrecalc")) { - get(mpLbFormulaSyntax, "formulasyntax"); - get(mpCbEnglishFuncName, "englishfuncname"); - get(mpBtnCustomCalcDefault, "calcdefault"); - get(mpBtnCustomCalcCustom, "calccustom"); - get(mpBtnCustomCalcDetails, "details"); - get(mpEdSepFuncArg, "function"); - get(mpEdSepArrayCol, "arraycolumn"); - get(mpEdSepArrayRow, "arrayrow"); - get(mpBtnSepReset, "reset"); - get(mpLbOOXMLRecalcOptions, "ooxmlrecalc"); - get(mpLbODFRecalcOptions, "odfrecalc"); - - mpLbFormulaSyntax->InsertEntry(ScResId(SCSTR_FORMULA_SYNTAX_CALC_A1)); - mpLbFormulaSyntax->InsertEntry(ScResId(SCSTR_FORMULA_SYNTAX_XL_A1)); - mpLbFormulaSyntax->InsertEntry(ScResId(SCSTR_FORMULA_SYNTAX_XL_R1C1)); - - Link<Button*,void> aLink2 = LINK( this, ScTpFormulaOptions, ButtonHdl ); - mpBtnSepReset->SetClickHdl(aLink2); - mpBtnCustomCalcDefault->SetClickHdl(aLink2); - mpBtnCustomCalcCustom->SetClickHdl(aLink2); - mpBtnCustomCalcDetails->SetClickHdl(aLink2); - - Link<Edit&,void> aLink = LINK( this, ScTpFormulaOptions, SepModifyHdl ); - mpEdSepFuncArg->SetModifyHdl(aLink); - mpEdSepArrayCol->SetModifyHdl(aLink); - mpEdSepArrayRow->SetModifyHdl(aLink); - - Link<Control&,void> aLink3 = LINK( this, ScTpFormulaOptions, SepEditOnFocusHdl ); - mpEdSepFuncArg->SetGetFocusHdl(aLink3); - mpEdSepArrayCol->SetGetFocusHdl(aLink3); - mpEdSepArrayRow->SetGetFocusHdl(aLink3); + mxLbFormulaSyntax->append_text(ScResId(SCSTR_FORMULA_SYNTAX_CALC_A1)); + mxLbFormulaSyntax->append_text(ScResId(SCSTR_FORMULA_SYNTAX_XL_A1)); + mxLbFormulaSyntax->append_text(ScResId(SCSTR_FORMULA_SYNTAX_XL_R1C1)); + + Link<weld::Button&,void> aLink2 = LINK( this, ScTpFormulaOptions, ButtonHdl ); + mxBtnSepReset->connect_clicked(aLink2); + mxBtnCustomCalcDefault->connect_clicked(aLink2); + mxBtnCustomCalcCustom->connect_clicked(aLink2); + mxBtnCustomCalcDetails->connect_clicked(aLink2); + + Link<weld::Entry&,void> aLink = LINK( this, ScTpFormulaOptions, SepModifyHdl ); + mxEdSepFuncArg->connect_changed(aLink); + mxEdSepArrayCol->connect_changed(aLink); + mxEdSepArrayRow->connect_changed(aLink); + + Link<weld::Widget&,void> aLink3 = LINK( this, ScTpFormulaOptions, SepEditOnFocusHdl ); + mxEdSepFuncArg->connect_focus_in(aLink3); + mxEdSepArrayCol->connect_focus_in(aLink3); + mxEdSepArrayRow->connect_focus_in(aLink3); // Get the decimal separator for current locale. OUString aSep = ScGlobal::GetpLocaleData()->getNumDecimalSep(); @@ -78,59 +76,40 @@ ScTpFormulaOptions::ScTpFormulaOptions(vcl::Window* pParent, const SfxItemSet& r ScTpFormulaOptions::~ScTpFormulaOptions() { - disposeOnce(); -} - -void ScTpFormulaOptions::dispose() -{ - mpLbFormulaSyntax.clear(); - mpCbEnglishFuncName.clear(); - mpBtnCustomCalcDefault.clear(); - mpBtnCustomCalcCustom.clear(); - mpBtnCustomCalcDetails.clear(); - mpEdSepFuncArg.clear(); - mpEdSepArrayCol.clear(); - mpEdSepArrayRow.clear(); - mpBtnSepReset.clear(); - mpLbOOXMLRecalcOptions.clear(); - mpLbODFRecalcOptions.clear(); - SfxTabPage::dispose(); } void ScTpFormulaOptions::ResetSeparators() { OUString aFuncArg, aArrayCol, aArrayRow; ScFormulaOptions::GetDefaultFormulaSeparators(aFuncArg, aArrayCol, aArrayRow); - mpEdSepFuncArg->SetText(aFuncArg); - mpEdSepArrayCol->SetText(aArrayCol); - mpEdSepArrayRow->SetText(aArrayRow); + mxEdSepFuncArg->set_text(aFuncArg); + mxEdSepArrayCol->set_text(aArrayCol); + mxEdSepArrayRow->set_text(aArrayRow); } -void ScTpFormulaOptions::OnFocusSeparatorInput(Edit* pEdit) +void ScTpFormulaOptions::OnFocusSeparatorInput(weld::Entry* pEdit) { if (!pEdit) return; // Make sure the entire text is selected. - sal_Int32 nLen = pEdit->GetText().getLength(); - Selection aSel(0, static_cast<sal_uInt16>(nLen)); - pEdit->SetSelection(aSel); - maOldSepValue = pEdit->GetText(); + pEdit->select_region(0, -1); + maOldSepValue = pEdit->get_text(); } void ScTpFormulaOptions::UpdateCustomCalcRadioButtons(bool bDefault) { if (bDefault) { - mpBtnCustomCalcDefault->Check(); - mpBtnCustomCalcCustom->Check(false); - mpBtnCustomCalcDetails->Disable(); + mxBtnCustomCalcDefault->set_active(true); + mxBtnCustomCalcCustom->set_active(false); + mxBtnCustomCalcDetails->set_sensitive(false); } else { - mpBtnCustomCalcDefault->Check(false); - mpBtnCustomCalcCustom->Check(); - mpBtnCustomCalcDetails->Enable(); + mxBtnCustomCalcDefault->set_active(false); + mxBtnCustomCalcCustom->set_active(true); + mxBtnCustomCalcDetails->set_sensitive(true); } } @@ -185,76 +164,76 @@ bool ScTpFormulaOptions::IsValidSeparator(const OUString& rSep) const bool ScTpFormulaOptions::IsValidSeparatorSet() const { // Make sure the column and row separators are different. - OUString aColStr = mpEdSepArrayCol->GetText(); - OUString aRowStr = mpEdSepArrayRow->GetText(); + OUString aColStr = mxEdSepArrayCol->get_text(); + OUString aRowStr = mxEdSepArrayRow->get_text(); return aColStr != aRowStr; } -IMPL_LINK( ScTpFormulaOptions, ButtonHdl, Button*, pBtn, void ) +IMPL_LINK( ScTpFormulaOptions, ButtonHdl, weld::Button&, rBtn, void ) { - if (pBtn == mpBtnSepReset) + if (&rBtn == mxBtnSepReset.get()) ResetSeparators(); - else if (pBtn == mpBtnCustomCalcDefault) + else if (&rBtn == mxBtnCustomCalcDefault.get()) UpdateCustomCalcRadioButtons(true); - else if (pBtn == mpBtnCustomCalcCustom) + else if (&rBtn == mxBtnCustomCalcCustom.get()) UpdateCustomCalcRadioButtons(false); - else if (pBtn == mpBtnCustomCalcDetails) + else if (&rBtn == mxBtnCustomCalcDetails.get()) LaunchCustomCalcSettings(); } -IMPL_LINK( ScTpFormulaOptions, SepModifyHdl, Edit&, rEdit, void ) +IMPL_LINK( ScTpFormulaOptions, SepModifyHdl, weld::Entry&, rEdit, void ) { - OUString aStr = rEdit.GetText(); + OUString aStr = rEdit.get_text(); if (aStr.getLength() > 1) { // In case the string is more than one character long, only grab the // first character. aStr = aStr.copy(0, 1); - rEdit.SetText(aStr); + rEdit.set_text(aStr); } if ((!IsValidSeparator(aStr) || !IsValidSeparatorSet()) && !maOldSepValue.isEmpty()) // Invalid separator. Restore the old value. - rEdit.SetText(maOldSepValue); + rEdit.set_text(maOldSepValue); OnFocusSeparatorInput(&rEdit); } -IMPL_LINK( ScTpFormulaOptions, SepEditOnFocusHdl, Control&, rControl, void ) +IMPL_LINK( ScTpFormulaOptions, SepEditOnFocusHdl, weld::Widget&, rControl, void ) { - OnFocusSeparatorInput(static_cast<Edit*>(&rControl)); + OnFocusSeparatorInput(dynamic_cast<weld::Entry*>(&rControl)); } VclPtr<SfxTabPage> ScTpFormulaOptions::Create(TabPageParent pParent, const SfxItemSet* rCoreSet) { - return VclPtr<ScTpFormulaOptions>::Create(pParent.pParent, *rCoreSet); + return VclPtr<ScTpFormulaOptions>::Create(pParent, *rCoreSet); } bool ScTpFormulaOptions::FillItemSet(SfxItemSet* rCoreSet) { bool bRet = false; ScFormulaOptions aOpt; - bool bEnglishFuncName = mpCbEnglishFuncName->IsChecked(); - sal_Int16 aSyntaxPos = mpLbFormulaSyntax->GetSelectedEntryPos(); - OUString aSep = mpEdSepFuncArg->GetText(); - OUString aSepArrayCol = mpEdSepArrayCol->GetText(); - OUString aSepArrayRow = mpEdSepArrayRow->GetText(); - sal_Int16 nOOXMLRecalcMode = mpLbOOXMLRecalcOptions->GetSelectedEntryPos(); - sal_Int16 nODFRecalcMode = mpLbODFRecalcOptions->GetSelectedEntryPos(); - - if (mpBtnCustomCalcDefault->IsChecked()) + bool bEnglishFuncName = mxCbEnglishFuncName->get_active(); + sal_Int16 aSyntaxPos = mxLbFormulaSyntax->get_active(); + OUString aSep = mxEdSepFuncArg->get_text(); + OUString aSepArrayCol = mxEdSepArrayCol->get_text(); + OUString aSepArrayRow = mxEdSepArrayRow->get_text(); + sal_Int16 nOOXMLRecalcMode = mxLbOOXMLRecalcOptions->get_active(); + sal_Int16 nODFRecalcMode = mxLbODFRecalcOptions->get_active(); + + if (mxBtnCustomCalcDefault->get_active()) { // When Default is selected, reset all the calc config settings to default. maCurrentConfig.reset(); } - if ( mpLbFormulaSyntax->GetSavedValue() != aSyntaxPos - || mpCbEnglishFuncName->GetSavedValue() != (bEnglishFuncName ? 1 : 0) - || mpEdSepFuncArg->GetSavedValue() != aSep - || mpEdSepArrayCol->GetSavedValue() != aSepArrayCol - || mpEdSepArrayRow->GetSavedValue() != aSepArrayRow - || mpLbOOXMLRecalcOptions->GetSavedValue() != nOOXMLRecalcMode - || mpLbODFRecalcOptions->GetSavedValue() != nODFRecalcMode + if ( mxLbFormulaSyntax->get_saved_value() != mxLbFormulaSyntax->get_text(aSyntaxPos) + || mxCbEnglishFuncName->get_saved_state() != (bEnglishFuncName ? 1 : 0) + || mxEdSepFuncArg->get_saved_value() != aSep + || mxEdSepArrayCol->get_saved_value() != aSepArrayCol + || mxEdSepArrayRow->get_saved_value() != aSepArrayRow + || mxLbOOXMLRecalcOptions->get_saved_value() != mxLbOOXMLRecalcOptions->get_text(nOOXMLRecalcMode) + || mxLbODFRecalcOptions->get_saved_value() != mxLbODFRecalcOptions->get_text(nODFRecalcMode) || maSavedConfig != maCurrentConfig || maSavedDocOptions != maCurrentDocOptions ) { @@ -308,31 +287,31 @@ void ScTpFormulaOptions::Reset(const SfxItemSet* rCoreSet) switch (eGram) { case ::formula::FormulaGrammar::GRAM_NATIVE: - mpLbFormulaSyntax->SelectEntryPos(0); + mxLbFormulaSyntax->set_active(0); break; case ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1: - mpLbFormulaSyntax->SelectEntryPos(1); + mxLbFormulaSyntax->set_active(1); break; case ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1: - mpLbFormulaSyntax->SelectEntryPos(2); + mxLbFormulaSyntax->set_active(2); break; default: - mpLbFormulaSyntax->SelectEntryPos(0); + mxLbFormulaSyntax->set_active(0); } - mpLbFormulaSyntax->SaveValue(); + mxLbFormulaSyntax->save_value(); ScRecalcOptions eOOXMLRecalc = aOpt.GetOOXMLRecalcOptions(); - mpLbOOXMLRecalcOptions->SelectEntryPos(static_cast<sal_uInt16>(eOOXMLRecalc)); - mpLbOOXMLRecalcOptions->SaveValue(); + mxLbOOXMLRecalcOptions->set_active(static_cast<sal_uInt16>(eOOXMLRecalc)); + mxLbOOXMLRecalcOptions->save_value(); ScRecalcOptions eODFRecalc = aOpt.GetODFRecalcOptions(); - mpLbODFRecalcOptions->SelectEntryPos(static_cast<sal_uInt16>(eODFRecalc)); - mpLbODFRecalcOptions->SaveValue(); + mxLbODFRecalcOptions->set_active(static_cast<sal_uInt16>(eODFRecalc)); + mxLbODFRecalcOptions->save_value(); // english function name. - mpCbEnglishFuncName->Check( aOpt.GetUseEnglishFuncName() ); - mpCbEnglishFuncName->SaveValue(); + mxCbEnglishFuncName->set_active( aOpt.GetUseEnglishFuncName() ); + mxCbEnglishFuncName->save_state(); // Separators OUString aSep = aOpt.GetFormulaSepArg(); @@ -342,13 +321,13 @@ void ScTpFormulaOptions::Reset(const SfxItemSet* rCoreSet) if (aSep.getLength() == 1 && aSepArrayRow.getLength() == 1 && aSepArrayCol.getLength() == 1) { // Each separator must be one character long. - mpEdSepFuncArg->SetText(aSep); - mpEdSepArrayCol->SetText(aSepArrayCol); - mpEdSepArrayRow->SetText(aSepArrayRow); + mxEdSepFuncArg->set_text(aSep); + mxEdSepArrayCol->set_text(aSepArrayCol); + mxEdSepArrayRow->set_text(aSepArrayRow); - mpEdSepFuncArg->SaveValue(); - mpEdSepArrayCol->SaveValue(); - mpEdSepArrayRow->SaveValue(); + mxEdSepFuncArg->save_value(); + mxEdSepArrayCol->save_value(); + mxEdSepArrayRow->save_value(); } else ResetSeparators(); diff --git a/sc/uiconfig/scalc/ui/optformula.ui b/sc/uiconfig/scalc/ui/optformula.ui index 0804854bdec0..8b8f2a8dfa6f 100644 --- a/sc/uiconfig/scalc/ui/optformula.ui +++ b/sc/uiconfig/scalc/ui/optformula.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> +<!-- Generated with glade 3.22.1 --> <interface domain="sc"> <requires lib="gtk+" version="3.18"/> <object class="GtkGrid" id="OptFormula"> @@ -47,7 +47,7 @@ <property name="hexpand">True</property> <property name="column_spacing">12</property> <child> - <object class="GtkComboBox" id="formulasyntax"> + <object class="GtkComboBoxText" id="formulasyntax"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> @@ -222,8 +222,8 @@ <property name="receives_default">False</property> <property name="use_underline">True</property> <property name="xalign">0</property> + <property name="active">True</property> <property name="draw_indicator">True</property> - <property name="group">calccustom</property> </object> <packing> <property name="left_attach">0</property> @@ -357,6 +357,7 @@ <object class="GtkEntry" id="function"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="width_chars">5</property> <property name="max_width_chars">1</property> </object> @@ -369,6 +370,7 @@ <object class="GtkEntry" id="arraycolumn"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="width_chars">5</property> <property name="max_width_chars">1</property> </object> @@ -381,6 +383,7 @@ <object class="GtkEntry" id="arrayrow"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="width_chars">5</property> <property name="max_width_chars">1</property> </object> |