diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-05-01 15:46:06 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-05-07 13:08:13 +0200 |
commit | feecbabd01870ed83a04baa6cb13d7a8af832ac3 (patch) | |
tree | b3eac2bed9c5936287a04badea90a508be57f623 /formula | |
parent | d25fef637897bdf9e680700451e9207ac6aa7cbe (diff) |
weld FormulaDialog
drop xFocusWin hack, I don't see what gain it gives
Change-Id: I31952b5440797e6209ed1de6b546f1e4c0238d08
Reviewed-on: https://gerrit.libreoffice.org/71675
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'formula')
-rw-r--r-- | formula/source/ui/dlg/ControlHelper.hxx | 82 | ||||
-rw-r--r-- | formula/source/ui/dlg/formula.cxx | 974 | ||||
-rw-r--r-- | formula/source/ui/dlg/funcpage.cxx | 173 | ||||
-rw-r--r-- | formula/source/ui/dlg/funcpage.hxx | 45 | ||||
-rw-r--r-- | formula/source/ui/dlg/funcutl.cxx | 243 | ||||
-rw-r--r-- | formula/source/ui/dlg/parawin.cxx | 218 | ||||
-rw-r--r-- | formula/source/ui/dlg/parawin.hxx | 80 | ||||
-rw-r--r-- | formula/source/ui/dlg/structpg.cxx | 126 | ||||
-rw-r--r-- | formula/source/ui/dlg/structpg.hxx | 40 | ||||
-rw-r--r-- | formula/uiconfig/ui/formuladialog.ui | 103 | ||||
-rw-r--r-- | formula/uiconfig/ui/functionpage.ui | 49 | ||||
-rw-r--r-- | formula/uiconfig/ui/parameter.ui | 489 | ||||
-rw-r--r-- | formula/uiconfig/ui/structpage.ui | 51 |
13 files changed, 1267 insertions, 1406 deletions
diff --git a/formula/source/ui/dlg/ControlHelper.hxx b/formula/source/ui/dlg/ControlHelper.hxx index a5f975d64b65..8ec7d504279e 100644 --- a/formula/source/ui/dlg/ControlHelper.hxx +++ b/formula/source/ui/dlg/ControlHelper.hxx @@ -24,58 +24,28 @@ namespace formula { -// class EditBox -class EditBox : public Control -{ -private: - - VclPtr<MultiLineEdit> pMEdit; - Link<EditBox&,void> aSelChangedLink; - Selection aOldSel; - - DECL_LINK(ChangedHdl, void *, void); - -protected: - - virtual bool PreNotify( NotifyEvent& rNEvt ) override; - virtual void Resize() override; - virtual void GetFocus() override; - - -public: - EditBox( vcl::Window* pParent, WinBits nBits ); - - virtual ~EditBox() override; - virtual void dispose() override; - - MultiLineEdit* GetEdit() {return pMEdit;} - - void SetSelChangedHdl( const Link<EditBox&,void>& rLink ) { aSelChangedLink = rLink; } - - void UpdateOldSel(); -}; - +class ParaWin; // class ArgEdit -class ArgEdit : public RefEdit +class ArgEdit : public WeldRefEdit { public: - ArgEdit( vcl::Window* pParent, WinBits nBits ); - virtual ~ArgEdit() override; - virtual void dispose() override; + ArgEdit(std::unique_ptr<weld::Entry> xControl); - void Init( ArgEdit* pPrevEdit, ArgEdit* pNextEdit, - ScrollBar& rArgSlider, sal_uInt16 nArgCount ); + void Init(ArgEdit* pPrevEdit, ArgEdit* pNextEdit, + weld::ScrolledWindow& rArgSlider, + ParaWin& rParaWin, sal_uInt16 nArgCount); protected: - virtual void KeyInput( const KeyEvent& rKEvt ) override; + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); private: - VclPtr<ArgEdit> pEdPrev; - VclPtr<ArgEdit> pEdNext; - VclPtr<ScrollBar> pSlider; - sal_uInt16 nArgs; + ArgEdit* pEdPrev; + ArgEdit* pEdNext; + weld::ScrolledWindow* pSlider; + ParaWin* pParaWin; + sal_uInt16 nArgs; }; @@ -89,24 +59,24 @@ private: Link<ArgInput&,void> aEdFocusLink; Link<ArgInput&,void> aEdModifyLink; - VclPtr<FixedText> pFtArg; - VclPtr<PushButton> pBtnFx; - VclPtr<ArgEdit> pEdArg; - VclPtr<RefButton> pRefBtn; + weld::Label*pFtArg; + weld::Button* pBtnFx; + ArgEdit* pEdArg; + WeldRefButton* pRefBtn; - DECL_LINK( FxBtnClickHdl, Button*, void ); - DECL_LINK( FxBtnFocusHdl, Control&, void ); - DECL_LINK( EdFocusHdl, Control&, void ); - DECL_LINK( EdModifyHdl, Edit&, void ); + DECL_LINK( FxBtnClickHdl, weld::Button&, void ); + DECL_LINK( FxBtnFocusHdl, weld::Widget&, void ); + DECL_LINK( EdFocusHdl, WeldRefEdit&, void ); + DECL_LINK( EdModifyHdl, WeldRefEdit&, void ); public: ArgInput(); - void InitArgInput ( FixedText* pftArg, - PushButton* pbtnFx, - ArgEdit* pedArg, - RefButton* prefBtn); + void InitArgInput(weld::Label* pftArg, + weld::Button* pbtnFx, + ArgEdit* pedArg, + WeldRefButton* prefBtn); void SetArgName(const OUString &aArg); OUString GetArgName(); @@ -115,9 +85,9 @@ public: void SetArgVal(const OUString &aVal); OUString GetArgVal(); - void SetArgSelection (const Selection& rSel); + void SelectAll(); - ArgEdit* GetArgEdPtr() {return pEdArg;} + ArgEdit* GetArgEdPtr() { return pEdArg; } void SetFxClickHdl( const Link<ArgInput&,void>& rLink ) { aFxClickLink = rLink; } diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx index e7c5fede138d..73a8d30ed8ea 100644 --- a/formula/source/ui/dlg/formula.cxx +++ b/formula/source/ui/dlg/formula.cxx @@ -61,9 +61,6 @@ #include <map> // For tab page -#define TP_FUNCTION 1 -#define TP_STRUCT 2 - #define TOKEN_OPEN 0 #define TOKEN_CLOSE 1 #define TOKEN_SEP 2 @@ -75,9 +72,9 @@ using namespace ::com::sun::star; class FormulaDlg_Impl { public: - ::std::pair<RefButton*, RefEdit*> + static ::std::pair<RefButton*, RefEdit*> RefInputStartBefore( RefEdit* pEdit, RefButton* pButton ); - static ::std::pair<WeldRefButton*, WeldRefEdit*> + ::std::pair<WeldRefButton*, WeldRefEdit*> RefInputStartBefore( WeldRefEdit* pEdit, WeldRefButton* pButton ); void RefInputStartAfter(); void RefInputDoneAfter( bool bForced ); @@ -88,8 +85,8 @@ public: sal_Int32 GetFunctionPos(sal_Int32 nPos); void ClearAllParas(); - void MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, const FormulaToken* pFuncToken, - const FormulaToken* _pToken, long Count ); + void MakeTree(StructPage* _pTree, weld::TreeIter* pParent, const FormulaToken* pFuncToken, + const FormulaToken* _pToken, long Count); void fillTree(StructPage* _pTree); void UpdateTokenArray( const OUString& rStrExp); OUString RepairFormula(const OUString& aFormula); @@ -120,20 +117,22 @@ public: void UpdateParaWin( const Selection& _rSelection, const OUString& _sRefStr); void SetData( sal_Int32 nFStart, sal_Int32 nNextFStart, sal_Int32 nNextFEnd, sal_Int32& PrivStart, sal_Int32& PrivEnd); - void PreNotify( NotifyEvent const & rNEvt ); - RefEdit* GetCurrRefEdit(); + WeldRefEdit* GetCurrRefEdit(); const FormulaHelper& GetFormulaHelper() const { return m_aFormulaHelper;} void InitFormulaOpCodeMapper(); + void UpdateOldSel(); + void FormulaCursor(); + DECL_LINK( ModifyHdl, ParaWin&, void ); DECL_LINK( FxHdl, ParaWin&, void ); - DECL_LINK( MatrixHdl, Button*, void ); - DECL_LINK( FormulaHdl, Edit&, void); - DECL_LINK( FormulaCursorHdl, EditBox&, void ); - DECL_LINK( BtnHdl, Button*, void ); + DECL_LINK( MatrixHdl, weld::Button&, void ); + DECL_LINK( FormulaHdl, weld::TextView&, void); + DECL_LINK( FormulaCursorHdl, weld::TextView&, void ); + DECL_LINK( BtnHdl, weld::Button&, void ); DECL_LINK( DblClkHdl, FuncPage&, void ); DECL_LINK( FuncSelHdl, FuncPage&, void ); DECL_LINK( StructSelHdl, StructPage&, void ); @@ -148,44 +147,12 @@ public: mutable const sheet::FormulaOpCodeMapEntry* m_pFunctionOpCodesEnd; ::std::map<const FormulaToken*, sheet::FormulaToken> m_aTokenMap; IFormulaEditorHelper* m_pHelper; - VclPtr<Dialog> m_pParent; - VclPtr<TabControl> m_pTabCtrl; - VclPtr<VclVBox> m_pParaWinBox; - VclPtr<ParaWin> m_pParaWin; - VclPtr<FixedText> m_pFtHeadLine; - VclPtr<FixedText> m_pFtFuncName; - VclPtr<FixedText> m_pFtFuncDesc; - - VclPtr<FixedText> m_pFtEditName; - - VclPtr<FixedText> m_pFtResult; - VclPtr<Edit> m_pWndResult; - - VclPtr<FixedText> m_pFtFormula; - VclPtr<EditBox> m_pMEFormula; - - VclPtr<CheckBox> m_pBtnMatrix; - VclPtr<CancelButton> m_pBtnCancel; - - VclPtr<PushButton> m_pBtnBackward; - VclPtr<PushButton> m_pBtnForward; - VclPtr<OKButton> m_pBtnEnd; + weld::Dialog& m_rDialog; + weld::Builder& m_rParent; - VclPtr<RefEdit> m_pEdRef; - VclPtr<RefButton> m_pRefBtn; - - VclPtr<FixedText> m_pFtFormResult; - VclPtr<Edit> m_pWndFormResult; - - VclPtr<RefEdit> m_pTheRefEdit; - VclPtr<RefButton> m_pTheRefButton; - VclPtr<FuncPage> m_pFuncPage; - VclPtr<StructPage> m_pStructPage; OUString m_aOldFormula; bool m_bStructUpdate; - VclPtr<MultiLineEdit> m_pMEdit; bool m_bUserMatrixFlag; - Idle m_aIdle; const OUString m_aTitle1; const OUString m_aTitle2; @@ -194,7 +161,6 @@ public: OString m_aEditHelpId; OString m_aOldHelp; - bool m_bIsShutDown; bool m_bMakingTree; // in method of constructing tree bool m_bEditFlag; @@ -205,157 +171,172 @@ public: sal_Int32 m_nFuncExpStart; ///< current formula position for treeview results - FormulaDlg_Impl(Dialog* pParent - , bool _bSupportFunctionResult - , bool _bSupportResult - , bool _bSupportMatrix - , IFormulaEditorHelper* _pHelper - , const IFunctionManager* _pFunctionMgr - , IControlReferenceHandler* _pDlg); - ~FormulaDlg_Impl(); + int m_nSelectionStart; + int m_nSelectionEnd; -}; + WeldRefEdit* m_pTheRefEdit; + WeldRefButton* m_pTheRefButton; + + std::unique_ptr<weld::Notebook> m_xTabCtrl; + std::unique_ptr<weld::Container> m_xParaWinBox; + std::unique_ptr<ParaWin> m_xParaWin; + std::unique_ptr<weld::Label> m_xFtHeadLine; + std::unique_ptr<weld::Label> m_xFtFuncName; + std::unique_ptr<weld::Label> m_xFtFuncDesc; + + std::unique_ptr<weld::Label> m_xFtEditName; + + std::unique_ptr<weld::Label> m_xFtResult; + std::unique_ptr<weld::Entry> m_xWndResult; -FormulaDlg_Impl::FormulaDlg_Impl(Dialog* pParent - , bool _bSupportFunctionResult - , bool _bSupportResult - , bool _bSupportMatrix - , IFormulaEditorHelper* _pHelper - , const IFunctionManager* _pFunctionMgr - , IControlReferenceHandler* _pDlg) - : - m_pFunctionOpCodesEnd(nullptr), - m_pHelper (_pHelper), - m_pParent (pParent), - m_pTheRefEdit (nullptr), - m_pTheRefButton (nullptr), - m_pMEdit (nullptr), - m_bUserMatrixFlag(false), - m_aTitle1 ( ForResId( STR_TITLE1 ) ), - m_aTitle2 ( ForResId( STR_TITLE2 ) ), - m_aFormulaHelper(_pFunctionMgr), - m_bIsShutDown (false), - m_bMakingTree (false), - m_pFuncDesc (nullptr), - m_nArgs (0), - m_nFuncExpStart (0) -{ - pParent->get(m_pParaWinBox, "BOX"); - pParent->get(m_pTabCtrl, "tabs"); - pParent->get(m_pFtHeadLine, "headline"); - pParent->get(m_pFtFuncName, "funcname"); - pParent->get(m_pFtFuncDesc, "funcdesc"); - pParent->get(m_pFtEditName, "editname"); - pParent->get(m_pFtResult, "label2"); - pParent->get(m_pWndResult, "result"); - pParent->get(m_pFtFormula, "formula"); + std::unique_ptr<weld::Label> m_xFtFormula; + std::unique_ptr<weld::TextView> m_xMEdit; + std::unique_ptr<weld::CheckButton> m_xBtnMatrix; + std::unique_ptr<weld::Button> m_xBtnCancel; + + std::unique_ptr<weld::Button> m_xBtnBackward; + std::unique_ptr<weld::Button> m_xBtnForward; + std::unique_ptr<weld::Button> m_xBtnEnd; + + std::unique_ptr<weld::Label> m_xFtFormResult; + std::unique_ptr<weld::Entry> m_xWndFormResult; + + std::unique_ptr<WeldRefEdit> m_xEdRef; + std::unique_ptr<WeldRefButton> m_xRefBtn; + + std::unique_ptr<FuncPage> m_xFuncPage; + std::unique_ptr<StructPage> m_xStructPage; + + FormulaDlg_Impl(weld::Dialog& rDialog, + weld::Builder& rBuilder, + bool _bSupportFunctionResult, + bool _bSupportResult, + bool _bSupportMatrix, + IFormulaEditorHelper* _pHelper, + const IFunctionManager* _pFunctionMgr, + IControlReferenceHandler* _pDlg); + ~FormulaDlg_Impl(); +}; + +FormulaDlg_Impl::FormulaDlg_Impl(weld::Dialog& rDialog, + weld::Builder& rBuilder, + bool _bSupportFunctionResult, + bool _bSupportResult, + bool _bSupportMatrix, + IFormulaEditorHelper* _pHelper, + const IFunctionManager* _pFunctionMgr, + IControlReferenceHandler* _pDlg) + : m_pFunctionOpCodesEnd(nullptr) + , m_pHelper(_pHelper) + , m_rDialog(rDialog) + , m_rParent(rBuilder) + , m_bUserMatrixFlag(false) + , m_aTitle1( ForResId( STR_TITLE1 ) ) + , m_aTitle2( ForResId( STR_TITLE2 ) ) + , m_aFormulaHelper(_pFunctionMgr) + , m_bMakingTree(false) + , m_pFuncDesc(nullptr) + , m_nArgs(0) + , m_nFuncExpStart(0) + , m_nSelectionStart(-1) + , m_nSelectionEnd(-1) + , m_pTheRefEdit(nullptr) + , m_pTheRefButton(nullptr) + , m_xTabCtrl(rBuilder.weld_notebook("tabs")) + , m_xParaWinBox(rBuilder.weld_container("BOX")) + , m_xFtHeadLine(rBuilder.weld_label("headline")) + , m_xFtFuncName(rBuilder.weld_label("funcname")) + , m_xFtFuncDesc(rBuilder.weld_label("funcdesc")) + , m_xFtEditName(rBuilder.weld_label("editname")) + , m_xFtResult(rBuilder.weld_label("label2")) + , m_xWndResult(rBuilder.weld_entry("result")) + , m_xFtFormula(rBuilder.weld_label("formula")) + , m_xMEdit(rBuilder.weld_text_view("ed_formula")) + , m_xBtnMatrix(rBuilder.weld_check_button("array")) + , m_xBtnCancel(rBuilder.weld_button("cancel")) + , m_xBtnBackward(rBuilder.weld_button("back")) + , m_xBtnForward(rBuilder.weld_button("next")) + , m_xBtnEnd(rBuilder.weld_button("ok")) + , m_xFtFormResult(rBuilder.weld_label("label1")) + , m_xWndFormResult(rBuilder.weld_entry("formula_result")) + , m_xEdRef(new WeldRefEdit(rBuilder.weld_entry("ED_REF"))) + , m_xRefBtn(new WeldRefButton(rBuilder.weld_button("RB_REF"))) +{ //Space for two lines of text - m_pFtHeadLine->SetText("X\nX\n"); - long nHeight = m_pFtHeadLine->GetOptimalSize().Height(); - m_pFtHeadLine->set_height_request(nHeight); - m_pFtHeadLine->SetText(""); - - m_pFtFuncName->SetText("X\nX\n"); - nHeight = m_pFtFuncName->GetOptimalSize().Height(); - m_pFtFuncName->set_height_request(nHeight); - m_pFtFuncDesc->set_height_request(nHeight); - m_pFtFuncName->SetText(""); - - pParent->get(m_pMEFormula, "ed_formula"); - Size aSize(pParent->LogicToPixel(Size(203, 43), MapMode(MapUnit::MapAppFont))); - m_pMEFormula->set_height_request(aSize.Height()); - m_pMEFormula->set_width_request(aSize.Width()); - pParent->get(m_pBtnMatrix, "array"); - pParent->get(m_pBtnCancel, "cancel"); - pParent->get(m_pBtnBackward, "back"); - pParent->get(m_pBtnForward, "next"); - pParent->get(m_pBtnEnd, "ok"); - pParent->get(m_pFtFormResult, "label1"); - pParent->get(m_pWndFormResult, "formula_result"); - pParent->get(m_pEdRef, "ED_REF"); - m_pEdRef->SetReferences(_pDlg, m_pFtEditName); - pParent->get(m_pRefBtn, "RB_REF"); - m_pRefBtn->SetReferences(_pDlg, m_pEdRef); - - m_pParaWin = VclPtr<ParaWin>::Create(m_pParaWinBox, _pDlg); - m_pParaWin->Show(); - m_pParaWinBox->Hide(); - m_pFtEditName->Hide(); - m_pEdRef->Hide(); - m_pRefBtn->Hide(); - - m_pMEdit = m_pMEFormula->GetEdit(); - - m_pMEdit->SetAccessibleName(m_pFtFormula->GetText()); - - m_aEditHelpId = m_pMEdit->GetHelpId(); + m_xFtHeadLine->set_label("X\nX\n"); + auto nHeight = m_xFtHeadLine->get_preferred_size().Height(); + m_xFtHeadLine->set_size_request(-1, nHeight); + m_xFtHeadLine->set_label(""); + + m_xFtFuncName->set_label("X\nX\n"); + nHeight = m_xFtFuncName->get_preferred_size().Height(); + m_xFtFuncName->set_size_request(-1, nHeight); + m_xFtFuncDesc->set_size_request(-1, nHeight); + m_xFtFuncName->set_label(""); + + m_xMEdit->set_size_request(m_xMEdit->get_approximate_digit_width() * 62, + m_xMEdit->get_height_rows(5)); + + m_xEdRef->SetReferences(_pDlg, m_xFtEditName.get()); + m_xRefBtn->SetReferences(_pDlg, m_xEdRef.get()); + + m_xParaWin.reset(new ParaWin(m_xParaWinBox.get(), _pDlg)); + m_xParaWin->Show(); + m_xParaWinBox->hide(); + m_xFtEditName->hide(); + m_xEdRef->GetWidget()->hide(); + m_xRefBtn->GetWidget()->hide(); + + m_xMEdit->set_accessible_name(m_xFtFormula->get_label()); + + m_aEditHelpId = m_xMEdit->get_help_id(); m_bEditFlag =false; m_bStructUpdate =true; - m_pParaWin->SetArgModifiedHdl( LINK( this, FormulaDlg_Impl, ModifyHdl ) ); - m_pParaWin->SetFxHdl( LINK( this, FormulaDlg_Impl, FxHdl ) ); + m_xParaWin->SetArgModifiedHdl( LINK( this, FormulaDlg_Impl, ModifyHdl ) ); + m_xParaWin->SetFxHdl( LINK( this, FormulaDlg_Impl, FxHdl ) ); - m_pFuncPage = VclPtr<FuncPage>::Create( m_pTabCtrl, _pFunctionMgr); - m_pStructPage = VclPtr<StructPage>::Create( m_pTabCtrl); - m_pFuncPage->Hide(); - m_pStructPage->Hide(); - m_pTabCtrl->SetTabPage( TP_FUNCTION, m_pFuncPage); - m_pTabCtrl->SetTabPage( TP_STRUCT, m_pStructPage); + m_xFuncPage.reset(new FuncPage(m_xTabCtrl->get_page("function"), _pFunctionMgr)); + m_xStructPage.reset(new StructPage(m_xTabCtrl->get_page("struct"))); + m_xTabCtrl->set_current_page("function"); - m_aOldHelp = pParent->GetHelpId(); // HelpId from resource always for "Page 1" + m_aOldHelp = m_rDialog.get_help_id(); // HelpId from resource always for "Page 1" - m_pFtResult->Show( _bSupportResult ); - m_pWndResult->Show( _bSupportResult ); + m_xFtResult->set_visible( _bSupportResult ); + m_xWndResult->set_visible( _bSupportResult ); - m_pFtFormResult->Show( _bSupportFunctionResult ); - m_pWndFormResult->Show( _bSupportFunctionResult ); + m_xFtFormResult->set_visible( _bSupportFunctionResult ); + m_xWndFormResult->set_visible( _bSupportFunctionResult ); if ( _bSupportMatrix ) - m_pBtnMatrix->SetClickHdl( LINK( this, FormulaDlg_Impl, MatrixHdl ) ); + m_xBtnMatrix->connect_clicked( LINK( this, FormulaDlg_Impl, MatrixHdl ) ); else - m_pBtnMatrix->Hide(); + m_xBtnMatrix->hide(); - m_pBtnCancel ->SetClickHdl( LINK( this, FormulaDlg_Impl, BtnHdl ) ); - m_pBtnEnd ->SetClickHdl( LINK( this, FormulaDlg_Impl, BtnHdl ) ); - m_pBtnForward ->SetClickHdl( LINK( this, FormulaDlg_Impl, BtnHdl ) ); - m_pBtnBackward->SetClickHdl( LINK( this, FormulaDlg_Impl, BtnHdl ) ); + m_xBtnCancel->connect_clicked( LINK( this, FormulaDlg_Impl, BtnHdl ) ); + m_xBtnEnd->connect_clicked( LINK( this, FormulaDlg_Impl, BtnHdl ) ); + m_xBtnForward->connect_clicked( LINK( this, FormulaDlg_Impl, BtnHdl ) ); + m_xBtnBackward->connect_clicked( LINK( this, FormulaDlg_Impl, BtnHdl ) ); - m_pFuncPage->SetDoubleClickHdl( LINK( this, FormulaDlg_Impl, DblClkHdl ) ); - m_pFuncPage->SetSelectHdl( LINK( this, FormulaDlg_Impl, FuncSelHdl) ); - m_pStructPage->SetSelectionHdl( LINK( this, FormulaDlg_Impl, StructSelHdl ) ); - m_pMEdit->SetModifyHdl( LINK( this, FormulaDlg_Impl, FormulaHdl ) ); - m_pMEFormula->SetSelChangedHdl( LINK( this, FormulaDlg_Impl, FormulaCursorHdl ) ); + m_xFuncPage->SetDoubleClickHdl( LINK( this, FormulaDlg_Impl, DblClkHdl ) ); + m_xFuncPage->SetSelectHdl( LINK( this, FormulaDlg_Impl, FuncSelHdl) ); + m_xStructPage->SetSelectionHdl( LINK( this, FormulaDlg_Impl, StructSelHdl ) ); + m_xMEdit->connect_changed( LINK( this, FormulaDlg_Impl, FormulaHdl ) ); + m_xMEdit->connect_cursor_position( LINK( this, FormulaDlg_Impl, FormulaCursorHdl ) ); - vcl::Font aFntLight = m_pFtFormula->GetFont(); - aFntLight.SetTransparent( true ); + vcl::Font aFntLight = m_xFtFormula->get_font(); vcl::Font aFntBold = aFntLight; aFntBold.SetWeight( WEIGHT_BOLD ); - m_pParaWin->SetArgumentFonts( aFntBold, aFntLight); - - // function description for choosing a function is no longer in a different color - - m_pFtHeadLine->SetFont(aFntBold); - m_pFtFuncName->SetFont(aFntLight); - m_pFtFuncDesc->SetFont(aFntLight); + m_xParaWin->SetArgumentFonts( aFntBold, aFntLight); } FormulaDlg_Impl::~FormulaDlg_Impl() { - if (m_aIdle.IsActive()) - { - m_aIdle.ClearInvokeHandler(); - m_aIdle.Stop(); - } - m_bIsShutDown = true; // Set it in order to PreNotify not to save GetFocus. - - m_pTabCtrl->RemovePage(TP_FUNCTION); - m_pTabCtrl->RemovePage(TP_STRUCT); + m_xTabCtrl->remove_page("function"); + m_xTabCtrl->remove_page("struct"); - m_pStructPage.disposeAndClear(); - m_pFuncPage.disposeAndClear(); - m_pParaWin.disposeAndClear(); DeleteArgs(); } @@ -363,37 +344,23 @@ void FormulaDlg_Impl::StoreFormEditData(FormEditData* pData) { if (pData) // it won't be destroyed via Close { - pData->SetFStart(m_pMEdit->GetSelection().Min()); - pData->SetSelection(m_pMEdit->GetSelection()); + int nStartPos, nEndPos; + m_xMEdit->get_selection_bounds(nStartPos, nEndPos); + if (nStartPos > nEndPos) + std::swap(nStartPos, nEndPos); - if (m_pTabCtrl->GetCurPageId() == TP_FUNCTION) + pData->SetFStart(nStartPos); + pData->SetSelection(Selection(nStartPos, nEndPos)); + + if (m_xTabCtrl->get_current_page_ident() == "function") pData->SetMode( FormulaDlgMode::Formula ); else pData->SetMode( FormulaDlgMode::Edit ); - pData->SetUndoStr(m_pMEdit->GetText()); - pData->SetMatrixFlag(m_pBtnMatrix->IsChecked()); + pData->SetUndoStr(m_xMEdit->get_text()); + pData->SetMatrixFlag(m_xBtnMatrix->get_active()); } } - -void FormulaDlg_Impl::PreNotify( NotifyEvent const & rNEvt ) -{ - if (m_bIsShutDown) - return; - MouseNotifyEvent nSwitch = rNEvt.GetType(); - if (nSwitch != MouseNotifyEvent::GETFOCUS) - return; - vcl::Window* pWin = rNEvt.GetWindow(); - if (!pWin) - return; - if (m_aIdle.IsActive()) // will be destroyed via Close - return; - FormEditData* pData = m_pHelper->getFormEditData(); - if (!pData) - return; - pData->SetFocusWindow(pWin); -} - void FormulaDlg_Impl::InitFormulaOpCodeMapper() { if ( m_xOpCodeMapper.is() ) @@ -426,7 +393,7 @@ sal_Int32 FormulaDlg_Impl::GetFunctionPos(sal_Int32 nPos) const sal_Unicode sep = m_pHelper->getFunctionManager()->getSingleToken(IFunctionManager::eSep); sal_Int32 nFuncPos = SAL_MAX_INT32; - OUString aFormString = m_aFormulaHelper.GetCharClass()->uppercase(m_pMEdit->GetText()); + OUString aFormString = m_aFormulaHelper.GetCharClass()->uppercase(m_xMEdit->get_text()); const uno::Reference< sheet::XFormulaParser > xParser(m_pHelper->getFormulaParser()); const table::CellAddress aRefPos(m_pHelper->getReferencePosition()); @@ -450,7 +417,7 @@ sal_Int32 FormulaDlg_Impl::GetFunctionPos(sal_Int32 nPos) if ( !m_bUserMatrixFlag && FormulaCompiler::IsMatrixFunction(static_cast<OpCode>(eOp)) ) { - m_pBtnMatrix->Check(); + m_xBtnMatrix->set_active(true); } if (eOp == m_aSpecialOpCodes[sheet::FormulaMapGroupSpecialOffset::PUSH].Token.OpCode || @@ -508,7 +475,7 @@ sal_Int32 FormulaDlg_Impl::GetFunctionPos(sal_Int32 nPos) { if ( nBracketCount < 1 ) { - nFuncPos = m_pMEdit->GetText().getLength(); + nFuncPos = m_xMEdit->get_text().getLength(); } else if ( !bFlag ) { @@ -544,7 +511,7 @@ bool FormulaDlg_Impl::CalcValue( const OUString& rStrExp, OUString& rStrResult, bool bInput = Application::AnyInput( VclInputFlags::KEYBOARD ); if ( !bInput ) { - bResult = m_pHelper->calculateValue( rStrExp, rStrResult, bForceMatrixFormula || m_pBtnMatrix->IsChecked()); + bResult = m_pHelper->calculateValue( rStrExp, rStrResult, bForceMatrixFormula || m_xBtnMatrix->get_active()); } else bResult = false; @@ -560,7 +527,7 @@ void FormulaDlg_Impl::UpdateValues( bool bForceRecalcStruct ) bool bForceArray = false; // Only necessary if it's not a matrix formula anyway and matrix evaluation // is supported, i.e. the button is visible. - if (m_pBtnMatrix->IsVisible() && !m_pBtnMatrix->IsChecked()) + if (m_xBtnMatrix->get_visible() && !m_xBtnMatrix->get_active()) { std::unique_ptr<FormulaCompiler> pCompiler(m_pHelper->createCompiler(*m_pTokenArray)); // In the case of the reportdesign dialog there is no currently active @@ -586,20 +553,20 @@ void FormulaDlg_Impl::UpdateValues( bool bForceRecalcStruct ) OUString aStrResult; if (m_pFuncDesc && CalcValue( m_pFuncDesc->getFormula( m_aArguments), aStrResult, bForceArray)) - m_pWndResult->SetText( aStrResult ); + m_xWndResult->set_text( aStrResult ); if (m_bMakingTree) return; aStrResult.clear(); if ( CalcValue( m_pHelper->getCurrentFormula(), aStrResult ) ) - m_pWndFormResult->SetText( aStrResult ); + m_xWndFormResult->set_text( aStrResult ); else { aStrResult.clear(); - m_pWndFormResult->SetText( aStrResult ); + m_xWndFormResult->set_text( aStrResult ); } - CalcStruct( m_pMEdit->GetText(), bForceRecalcStruct); + CalcStruct( m_xMEdit->get_text(), bForceRecalcStruct); } void FormulaDlg_Impl::CalcStruct( const OUString& rStrExp, bool bForceRecalcStruct ) @@ -608,7 +575,7 @@ void FormulaDlg_Impl::CalcStruct( const OUString& rStrExp, bool bForceRecalcStru if ( !rStrExp.isEmpty() && (bForceRecalcStruct || m_aOldFormula != rStrExp) && m_bStructUpdate) { - m_pStructPage->ClearStruct(); + m_xStructPage->ClearStruct(); OUString aString = rStrExp; if (rStrExp[nLength-1] == '(') @@ -620,10 +587,10 @@ void FormulaDlg_Impl::CalcStruct( const OUString& rStrExp, bool bForceRecalcStru OUString aStrResult; if ( CalcValue( aString, aStrResult ) ) - m_pWndFormResult->SetText( aStrResult ); + m_xWndFormResult->set_text(aStrResult); UpdateTokenArray(aString); - fillTree(m_pStructPage); + fillTree(m_xStructPage.get()); m_aOldFormula = rStrExp; if (rStrExp[nLength-1] == '(') @@ -631,9 +598,8 @@ void FormulaDlg_Impl::CalcStruct( const OUString& rStrExp, bool bForceRecalcStru } } - -void FormulaDlg_Impl::MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, const FormulaToken* pFuncToken, - const FormulaToken* _pToken, long Count ) +void FormulaDlg_Impl::MakeTree(StructPage* _pTree, weld::TreeIter* pParent, const FormulaToken* pFuncToken, + const FormulaToken* _pToken, long Count) { if ( _pToken != nullptr && Count > 0 ) { @@ -655,7 +621,8 @@ void FormulaDlg_Impl::MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, co if ( nParas > 0 ) { - SvTreeListEntry* pEntry; + std::unique_ptr<weld::TreeIter> xEntry; + weld::TreeIter* pEntry; bool bCalcSubformula = false; OUString aTest = _pTree->GetEntryText(pParent); @@ -666,25 +633,29 @@ void FormulaDlg_Impl::MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, co } else { + xEntry = m_xStructPage->GetTlbStruct().make_iterator(); + if (eOp == ocBad) { - pEntry = _pTree->InsertEntry( aResult, pParent, STRUCT_ERROR, 0, _pToken); + _pTree->InsertEntry(aResult, pParent, STRUCT_ERROR, 0, _pToken, *xEntry); } else if (!((SC_OPCODE_START_BIN_OP <= eOp && eOp < SC_OPCODE_STOP_BIN_OP) || (SC_OPCODE_START_UN_OP <= eOp && eOp < SC_OPCODE_STOP_UN_OP))) { // Not a binary or unary operator. bCalcSubformula = true; - pEntry = _pTree->InsertEntry( aResult, pParent, STRUCT_FOLDER, 0, _pToken); + _pTree->InsertEntry(aResult, pParent, STRUCT_FOLDER, 0, _pToken, *xEntry); } else { /* TODO: question remains, why not sub calculate operators? */ - pEntry = _pTree->InsertEntry( aResult, pParent, STRUCT_FOLDER, 0, _pToken); + _pTree->InsertEntry(aResult, pParent, STRUCT_FOLDER, 0, _pToken, *xEntry); } + + pEntry = xEntry.get(); } - MakeTree( _pTree, pEntry, _pToken, m_pTokenArrayIterator->PrevRPN(), nParas); + MakeTree(_pTree, pEntry, _pToken, m_pTokenArrayIterator->PrevRPN(), nParas); if (bCalcSubformula) { @@ -704,9 +675,9 @@ void FormulaDlg_Impl::MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, co OUString aStr; if (CalcValue( aFormula, aStr, _pToken->IsInForceArray())) - m_pWndResult->SetText( aStr ); - aStr = m_pWndResult->GetText(); - m_pStructPage->GetTlbStruct()->SetEntryText( pEntry, aResult + " = " + aStr); + m_xWndResult->set_text( aStr ); + aStr = m_xWndResult->get_text(); + m_xStructPage->GetTlbStruct().set_text(*pEntry, aResult + " = " + aStr); } --Count; @@ -715,9 +686,10 @@ void FormulaDlg_Impl::MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, co } else { + std::unique_ptr<weld::TreeIter> xEntry(m_xStructPage->GetTlbStruct().make_iterator()); if (eOp == ocBad) { - _pTree->InsertEntry( aResult, pParent, STRUCT_ERROR, 0, _pToken); + _pTree->InsertEntry( aResult, pParent, STRUCT_ERROR, 0, _pToken, *xEntry); } else if (eOp == ocPush) { @@ -725,7 +697,7 @@ void FormulaDlg_Impl::MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, co // as array elements. Depending on parameter classification // a scalar value (non-array context) is calculated first. OUString aUnforcedResult; - bool bForceMatrix = (!m_pBtnMatrix->IsChecked() && + bool bForceMatrix = (!m_xBtnMatrix->get_active() && (_pToken->GetType() == svDoubleRef || _pToken->GetType() == svExternalDoubleRef)); if (bForceMatrix && pFuncToken) { @@ -765,14 +737,14 @@ void FormulaDlg_Impl::MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, co // Cell is a formula, print subformula. // With scalar values prints "A1:A3 = 2 {1;2;3}" _pTree->InsertEntry( aResult + " = " + aUnforcedResult + aCellResult, - pParent, STRUCT_END, 0, _pToken); + pParent, STRUCT_END, 0, _pToken, *xEntry); } else - _pTree->InsertEntry( aResult, pParent, STRUCT_END, 0, _pToken); + _pTree->InsertEntry(aResult, pParent, STRUCT_END, 0, _pToken, *xEntry); } else { - _pTree->InsertEntry( aResult, pParent, STRUCT_END, 0, _pToken); + _pTree->InsertEntry(aResult, pParent, STRUCT_END, 0, _pToken, *xEntry); } --Count; MakeTree( _pTree, pParent, _pToken, m_pTokenArrayIterator->PrevRPN(), Count); @@ -840,22 +812,21 @@ void FormulaDlg_Impl::FillDialog(bool bFlag) FillListboxes(); if (bFlag) { - m_pBtnBackward->Enable(bPrev); - m_pBtnForward->Enable(bNext); + m_xBtnBackward->set_sensitive(bPrev); + m_xBtnForward->set_sensitive(bNext); } OUString aStrResult; if ( CalcValue( m_pHelper->getCurrentFormula(), aStrResult ) ) - m_pWndFormResult->SetText( aStrResult ); + m_xWndFormResult->set_text( aStrResult ); else { aStrResult.clear(); - m_pWndFormResult->SetText( aStrResult ); + m_xWndFormResult->set_text( aStrResult ); } } - void FormulaDlg_Impl::FillListboxes() { // Switch between the "Pages" @@ -864,24 +835,24 @@ void FormulaDlg_Impl::FillListboxes() if ( m_pFuncDesc && m_pFuncDesc->getCategory() ) { // We'll never have more than int32 max categories so this is safe ... - if ( m_pFuncPage->GetCategory() != static_cast<sal_Int32>(m_pFuncDesc->getCategory()->getNumber() + 1) ) - m_pFuncPage->SetCategory(m_pFuncDesc->getCategory()->getNumber() + 1); + if ( m_xFuncPage->GetCategory() != static_cast<sal_Int32>(m_pFuncDesc->getCategory()->getNumber() + 1) ) + m_xFuncPage->SetCategory(m_pFuncDesc->getCategory()->getNumber() + 1); - sal_Int32 nPos = m_pFuncPage->GetFuncPos(m_pFuncDesc); + sal_Int32 nPos = m_xFuncPage->GetFuncPos(m_pFuncDesc); - m_pFuncPage->SetFunction(nPos); + m_xFuncPage->SetFunction(nPos); } else if ( pData ) { - m_pFuncPage->SetCategory( 1 ); - m_pFuncPage->SetFunction( LISTBOX_ENTRY_NOTFOUND ); + m_xFuncPage->SetCategory( 1 ); + m_xFuncPage->SetFunction( -1 ); } - FuncSelHdl(*m_pFuncPage); + FuncSelHdl(*m_xFuncPage); m_pHelper->setDispatcherLock( true ); // Activate Modal-Mode // HelpId for 1. page is the one from the resource - m_pParent->SetHelpId( m_aOldHelp ); + m_rDialog.set_help_id( m_aOldHelp ); } void FormulaDlg_Impl::FillControls( bool &rbNext, bool &rbPrev) @@ -907,16 +878,16 @@ void FormulaDlg_Impl::FillControls( bool &rbNext, bool &rbPrev) const bool bTestFlag = (pOldFuncDesc != m_pFuncDesc); if (bTestFlag) { - m_pFtHeadLine->Hide(); - m_pFtFuncName->Hide(); - m_pFtFuncDesc->Hide(); - m_pParaWin->SetFunctionDesc(m_pFuncDesc); - m_pFtEditName->SetText( m_pFuncDesc->getFunctionName() ); - m_pFtEditName->Show(); - m_pParaWinBox->Show(); + m_xFtHeadLine->hide(); + m_xFtFuncName->hide(); + m_xFtFuncDesc->hide(); + m_xParaWin->SetFunctionDesc(m_pFuncDesc); + m_xFtEditName->set_label( m_pFuncDesc->getFunctionName() ); + m_xFtEditName->show(); + m_xParaWinBox->show(); const OString aHelpId = m_pFuncDesc->getHelpId(); if ( !aHelpId.isEmpty() ) - m_pMEdit->SetHelpId(aHelpId); + m_xMEdit->set_help_id(aHelpId); } sal_Int32 nOldStart, nOldEnd; @@ -929,11 +900,11 @@ void FormulaDlg_Impl::FillControls( bool &rbNext, bool &rbPrev) m_aFuncSel.Max() = nNextFEnd; if (!m_bEditFlag) - m_pMEdit->SetText(m_pHelper->getCurrentFormula()); + m_xMEdit->set_text(m_pHelper->getCurrentFormula()); sal_Int32 PrivStart, PrivEnd; m_pHelper->getSelection( PrivStart, PrivEnd); if (!m_bEditFlag) - m_pMEdit->SetSelection( Selection( PrivStart, PrivEnd)); + m_xMEdit->select_region(PrivStart, PrivEnd); m_nArgs = m_pFuncDesc->getSuppressedArgumentCount(); sal_uInt16 nOffset = pData->GetOffset(); @@ -941,16 +912,22 @@ void FormulaDlg_Impl::FillControls( bool &rbNext, bool &rbPrev) // Concatenate the Edit's for Focus-Control if (bTestFlag) - m_pParaWin->SetArgumentOffset(nOffset); + m_xParaWin->SetArgumentOffset(nOffset); sal_uInt16 nActiv = 0; sal_Int32 nArgPos = m_aFormulaHelper.GetArgStart( aFormula, nFStart, 0 ); - sal_Int32 nEditPos = m_pMEdit->GetSelection().Min(); + + int nStartPos, nEndPos; + m_xMEdit->get_selection_bounds(nStartPos, nEndPos); + if (nStartPos > nEndPos) + std::swap(nStartPos, nEndPos); + + sal_Int32 nEditPos = nStartPos; bool bFlag = false; for (sal_Int32 i = 0; i < m_nArgs; i++) { sal_Int32 nLength = m_aArguments[i].getLength()+1; - m_pParaWin->SetArgument( i, m_aArguments[i]); + m_xParaWin->SetArgument( i, m_aArguments[i]); if (nArgPos <= nEditPos && nEditPos < nArgPos+nLength) { nActiv = i; @@ -958,25 +935,31 @@ void FormulaDlg_Impl::FillControls( bool &rbNext, bool &rbPrev) } nArgPos = nArgPos + nLength; } - m_pParaWin->UpdateParas(); + m_xParaWin->UpdateParas(); if (bFlag) { - m_pParaWin->SetActiveLine(nActiv); + m_xParaWin->SetActiveLine(nActiv); } UpdateValues(); } else { - m_pFtEditName->SetText(""); - m_pMEdit->SetHelpId( m_aEditHelpId ); + m_xFtEditName->set_label(""); + m_xMEdit->set_help_id(m_aEditHelpId); } // test if before/after are anymore functions sal_Int32 nTempStart = m_aFormulaHelper.GetArgStart( aFormula, nFStart, 0 ); rbNext = m_aFormulaHelper.GetNextFunc( aFormula, false, nTempStart ); - nTempStart = m_pMEdit->GetSelection().Min(); + + int nStartPos, nEndPos; + m_xMEdit->get_selection_bounds(nStartPos, nEndPos); + if (nStartPos > nEndPos) + std::swap(nStartPos, nEndPos); + + nTempStart = nStartPos; pData->SetFStart(nTempStart); rbPrev = m_aFormulaHelper.GetNextFunc( aFormula, true, nTempStart ); } @@ -986,20 +969,20 @@ void FormulaDlg_Impl::ClearAllParas() { DeleteArgs(); m_pFuncDesc = nullptr; - m_pParaWin->ClearAll(); - m_pWndResult->SetText(OUString()); - m_pFtFuncName->SetText(OUString()); - FuncSelHdl(*m_pFuncPage); + m_xParaWin->ClearAll(); + m_xWndResult->set_text(OUString()); + m_xFtFuncName->set_label(OUString()); + FuncSelHdl(*m_xFuncPage); - if (m_pFuncPage->IsVisible()) + if (m_xFuncPage->IsVisible()) { - m_pFtEditName->Hide(); - m_pParaWinBox->Hide(); + m_xFtEditName->hide(); + m_xParaWinBox->hide(); - m_pBtnForward->Enable(); //@new - m_pFtHeadLine->Show(); - m_pFtFuncName->Show(); - m_pFtFuncDesc->Show(); + m_xBtnForward->set_sensitive(true); //@new + m_xFtHeadLine->show(); + m_xFtFuncName->show(); + m_xFtFuncDesc->show(); } } @@ -1036,14 +1019,14 @@ void FormulaDlg_Impl::DoEnter(bool bOk) { // remove dummy arguments OUString aInputFormula = m_pHelper->getCurrentFormula(); - OUString aString = RepairFormula(m_pMEdit->GetText()); + OUString aString = RepairFormula(m_xMEdit->get_text()); m_pHelper->setSelection( 0, aInputFormula.getLength()); m_pHelper->setCurrentFormula(aString); } m_pHelper->switchBack(); - m_pHelper->dispatch( bOk, m_pBtnMatrix->IsChecked()); + m_pHelper->dispatch( bOk, m_xBtnMatrix->get_active()); // Clear data m_pHelper->deleteFormData(); @@ -1052,22 +1035,22 @@ void FormulaDlg_Impl::DoEnter(bool bOk) } -IMPL_LINK( FormulaDlg_Impl, BtnHdl, Button*, pBtn, void ) +IMPL_LINK(FormulaDlg_Impl, BtnHdl, weld::Button&, rBtn, void) { - if ( pBtn == m_pBtnCancel ) + if (&rBtn == m_xBtnCancel.get()) { DoEnter(false); // closes the Dialog } - else if ( pBtn == m_pBtnEnd ) + else if (&rBtn == m_xBtnEnd.get()) { DoEnter(true); // closes the Dialog } - else if ( pBtn == m_pBtnForward ) + else if (&rBtn == m_xBtnForward.get()) { const IFunctionDescription* pDesc; - sal_Int32 nSelFunc = m_pFuncPage->GetFunction(); - if (nSelFunc != LISTBOX_ENTRY_NOTFOUND) - pDesc = m_pFuncPage->GetFuncDesc( nSelFunc ); + sal_Int32 nSelFunc = m_xFuncPage->GetFunction(); + if (nSelFunc != -1) + pDesc = m_xFuncPage->GetFuncDesc( nSelFunc ); else { // Do not overwrite the selected formula expression, just edit the @@ -1075,61 +1058,60 @@ IMPL_LINK( FormulaDlg_Impl, BtnHdl, Button*, pBtn, void ) m_pFuncDesc = pDesc = nullptr; } - if (pDesc == m_pFuncDesc || !m_pFuncPage->IsVisible()) + if (pDesc == m_pFuncDesc || !m_xFuncPage->IsVisible()) EditNextFunc( true ); else { - DblClkHdl(*m_pFuncPage); //new - m_pBtnForward->Enable(false); //new + DblClkHdl(*m_xFuncPage); //new + m_xBtnForward->set_sensitive(false); //new } } - else if ( pBtn == m_pBtnBackward ) + else if (&rBtn == m_xBtnBackward.get()) { m_bEditFlag = false; - m_pBtnForward->Enable(); + m_xBtnForward->set_sensitive(true); EditNextFunc( false ); - m_pMEFormula->Invalidate(); - m_pMEFormula->Update(); } } - // Functions for 1. Page - // Handler for Listboxes IMPL_LINK_NOARG( FormulaDlg_Impl, DblClkHdl, FuncPage&, void) { - sal_Int32 nFunc = m_pFuncPage->GetFunction(); + sal_Int32 nFunc = m_xFuncPage->GetFunction(); // ex-UpdateLRUList - const IFunctionDescription* pDesc = m_pFuncPage->GetFuncDesc(nFunc); + const IFunctionDescription* pDesc = m_xFuncPage->GetFuncDesc(nFunc); m_pHelper->insertEntryToLRUList(pDesc); - OUString aFuncName = m_pFuncPage->GetSelFunctionName() + "()"; + OUString aFuncName = m_xFuncPage->GetSelFunctionName() + "()"; m_pHelper->setCurrentFormula(aFuncName); - m_pMEdit->ReplaceSelected(aFuncName); + m_xMEdit->replace_selection(aFuncName); - Selection aSel = m_pMEdit->GetSelection(); - aSel.Max() = aSel.Max()-1; - m_pMEdit->SetSelection(aSel); + int nStartPos, nEndPos; + m_xMEdit->get_selection_bounds(nStartPos, nEndPos); + if (nStartPos > nEndPos) + std::swap(nStartPos, nEndPos); - FormulaHdl(*m_pMEdit); + nEndPos = nEndPos - 1; + m_xMEdit->select_region(nStartPos, nEndPos); - aSel.Min() = aSel.Max(); - m_pMEdit->SetSelection(aSel); + FormulaHdl(*m_xMEdit); + + nStartPos = nEndPos; + m_xMEdit->select_region(nStartPos, nEndPos); if (m_nArgs == 0) { - BtnHdl(m_pBtnBackward); + BtnHdl(*m_xBtnBackward); } - m_pParaWin->SetEdFocus(); - m_pBtnForward->Enable(false); //@New + m_xParaWin->SetEdFocus(); + m_xBtnForward->set_sensitive(false); //@New } - // Functions for right Page void FormulaDlg_Impl::SetData( sal_Int32 nFStart, sal_Int32 nNextFStart, sal_Int32 nNextFEnd, sal_Int32& PrivStart, sal_Int32& PrivEnd) @@ -1140,14 +1122,14 @@ void FormulaDlg_Impl::SetData( sal_Int32 nFStart, sal_Int32 nNextFStart, sal_Int m_pHelper->getSelection( nFStart, nFEnd ); m_pHelper->setSelection( nNextFStart, nNextFEnd ); if (!m_bEditFlag) - m_pMEdit->SetText(m_pHelper->getCurrentFormula()); + m_xMEdit->set_text(m_pHelper->getCurrentFormula()); m_pHelper->getSelection( PrivStart, PrivEnd); if (!m_bEditFlag) { - m_pMEdit->SetSelection( Selection( PrivStart, PrivEnd)); - m_pMEFormula->UpdateOldSel(); + m_xMEdit->select_region(PrivStart, PrivEnd); + UpdateOldSel(); } FormEditData* pData = m_pHelper->getFormEditData(); @@ -1264,13 +1246,13 @@ void FormulaDlg_Impl::SaveArg( sal_uInt16 nEd ) if ( m_aArguments[i].isEmpty() ) m_aArguments[i] = " "; } - if (!m_pParaWin->GetArgument(nEd).isEmpty()) - m_aArguments[nEd] = m_pParaWin->GetArgument(nEd); + if (!m_xParaWin->GetArgument(nEd).isEmpty()) + m_aArguments[nEd] = m_xParaWin->GetArgument(nEd); sal_uInt16 nClearPos = nEd+1; for (sal_Int32 i = nEd+1; i < m_nArgs; i++) { - if ( !m_pParaWin->GetArgument(i).isEmpty() ) + if ( !m_xParaWin->GetArgument(i).isEmpty() ) { nClearPos = i+1; } @@ -1285,17 +1267,17 @@ void FormulaDlg_Impl::SaveArg( sal_uInt16 nEd ) IMPL_LINK( FormulaDlg_Impl, FxHdl, ParaWin&, rPtr, void ) { - if (&rPtr == m_pParaWin) + if (&rPtr == m_xParaWin.get()) { - m_pBtnForward->Enable(); //@ In order to be able to input another function. - m_pTabCtrl->SetCurPageId(TP_FUNCTION); + m_xBtnForward->set_sensitive(true); //@ In order to be able to input another function. + m_xTabCtrl->set_current_page("function"); OUString aUndoStr = m_pHelper->getCurrentFormula(); // it will be added before a ";" FormEditData* pData = m_pHelper->getFormEditData(); if (!pData) return; - sal_uInt16 nArgNo = m_pParaWin->GetActiveLine(); + sal_uInt16 nArgNo = m_xParaWin->GetActiveLine(); sal_uInt16 nEdFocus = nArgNo; SaveArg(nArgNo); @@ -1313,23 +1295,23 @@ IMPL_LINK( FormulaDlg_Impl, FxHdl, ParaWin&, rPtr, void ) ClearAllParas(); FillDialog(false); - m_pFuncPage->SetFocus(); //There Parawin is not visible anymore + m_xFuncPage->SetFocus(); //There Parawin is not visible anymore } } IMPL_LINK( FormulaDlg_Impl, ModifyHdl, ParaWin&, rPtr, void ) { - if (&rPtr == m_pParaWin) + if (&rPtr == m_xParaWin.get()) { - SaveArg(m_pParaWin->GetActiveLine()); + SaveArg(m_xParaWin->GetActiveLine()); UpdateValues(); UpdateSelection(); - CalcStruct(m_pMEdit->GetText()); + CalcStruct(m_xMEdit->get_text()); } } -IMPL_LINK_NOARG( FormulaDlg_Impl, FormulaHdl, Edit&, void) +IMPL_LINK_NOARG( FormulaDlg_Impl, FormulaHdl, weld::TextView&, void) { FormEditData* pData = m_pHelper->getFormEditData(); @@ -1338,48 +1320,50 @@ IMPL_LINK_NOARG( FormulaDlg_Impl, FormulaHdl, Edit&, void) m_bEditFlag = true; OUString aInputFormula = m_pHelper->getCurrentFormula(); - OUString aString = m_pMEdit->GetText(); + OUString aString = m_xMEdit->get_text(); - Selection aSel = m_pMEdit->GetSelection(); + int nStartPos, nEndPos; + m_xMEdit->get_selection_bounds(nStartPos, nEndPos); + if (nStartPos > nEndPos) + std::swap(nStartPos, nEndPos); if (aString.isEmpty()) // in case everything was cleared { aString += "="; - m_pMEdit->SetText(aString); - aSel .Min() = 1; - aSel .Max() = 1; - m_pMEdit->SetSelection(aSel); + m_xMEdit->set_text(aString); + nStartPos = 1; + nEndPos = 1; + m_xMEdit->select_region(nStartPos, nEndPos); } else if (aString[0]!='=') // in case it's replaced { aString = "=" + aString; - m_pMEdit->SetText(aString); - aSel .Min() += 1; - aSel .Max() += 1; - m_pMEdit->SetSelection(aSel); + m_xMEdit->set_text(aString); + nStartPos += 1; + nEndPos += 1; + m_xMEdit->select_region(nStartPos, nEndPos); } - m_pHelper->setSelection( 0, aInputFormula.getLength()); m_pHelper->setCurrentFormula(aString); - m_pHelper->setSelection( aSel.Min(), aSel.Max()); + m_pHelper->setSelection(nStartPos, nEndPos); - sal_Int32 nPos = aSel.Min()-1; + sal_Int32 nPos = nStartPos - 1; OUString aStrResult; if ( CalcValue( m_pHelper->getCurrentFormula(), aStrResult ) ) - m_pWndFormResult->SetText( aStrResult ); + m_xWndFormResult->set_text( aStrResult ); else { aStrResult.clear(); - m_pWndFormResult->SetText( aStrResult ); + m_xWndFormResult->set_text( aStrResult ); } CalcStruct(aString); nPos = GetFunctionPos(nPos); - if (nPos < aSel.Min()-1) + if (nPos < nStartPos - 1) { sal_Int32 nPos1 = aString.indexOf( '(', nPos); EditNextFunc( false, nPos1); @@ -1389,11 +1373,11 @@ IMPL_LINK_NOARG( FormulaDlg_Impl, FormulaHdl, Edit&, void) ClearAllParas(); } - m_pHelper->setSelection( aSel.Min(), aSel.Max()); + m_pHelper->setSelection(nStartPos, nEndPos); m_bEditFlag = false; } -IMPL_LINK_NOARG( FormulaDlg_Impl, FormulaCursorHdl, EditBox&, void) +void FormulaDlg_Impl::FormulaCursor() { FormEditData* pData = m_pHelper->getFormEditData(); if (!pData) @@ -1401,20 +1385,24 @@ IMPL_LINK_NOARG( FormulaDlg_Impl, FormulaCursorHdl, EditBox&, void) m_bEditFlag = true; - OUString aString = m_pMEdit->GetText(); + OUString aString = m_xMEdit->get_text(); + + int nStartPos, nEndPos; + m_xMEdit->get_selection_bounds(nStartPos, nEndPos); + if (nStartPos > nEndPos) + std::swap(nStartPos, nEndPos); - Selection aSel = m_pMEdit->GetSelection(); - m_pHelper->setSelection( aSel.Min(), aSel.Max()); + m_pHelper->setSelection(nStartPos, nEndPos); - if (aSel.Min() == 0) + if (nStartPos == 0) { - aSel.Min() = 1; - m_pMEdit->SetSelection(aSel); + nStartPos = 1; + m_xMEdit->select_region(nStartPos, nEndPos); } - if (aSel.Min() != aString.getLength()) + if (nStartPos != aString.getLength()) { - sal_Int32 nPos = aSel.Min(); + sal_Int32 nPos = nStartPos; sal_Int32 nFStart = GetFunctionPos(nPos - 1); @@ -1456,16 +1444,38 @@ IMPL_LINK_NOARG( FormulaDlg_Impl, FormulaCursorHdl, EditBox&, void) ClearAllParas(); } } - m_pHelper->setSelection( aSel.Min(), aSel.Max()); + m_pHelper->setSelection(nStartPos, nEndPos); m_bEditFlag = false; } +void FormulaDlg_Impl::UpdateOldSel() +{ + m_xMEdit->get_selection_bounds(m_nSelectionStart, m_nSelectionEnd); + if (m_nSelectionStart > m_nSelectionEnd) + std::swap(m_nSelectionStart, m_nSelectionEnd); +} + +IMPL_LINK_NOARG( FormulaDlg_Impl, FormulaCursorHdl, weld::TextView&, void) +{ + int nStartPos, nEndPos; + m_xMEdit->get_selection_bounds(nStartPos, nEndPos); + if (nStartPos > nEndPos) + std::swap(nStartPos, nEndPos); + + if (nStartPos != m_nSelectionStart || nEndPos != m_nSelectionEnd) + { + m_nSelectionStart = nStartPos; + m_nSelectionEnd = nEndPos; + FormulaCursor(); + } +} + void FormulaDlg_Impl::UpdateSelection() { m_pHelper->setSelection( m_aFuncSel.Min(), m_aFuncSel.Max()); m_pHelper->setCurrentFormula( m_pFuncDesc->getFormula( m_aArguments ) ); - m_pMEdit->SetText(m_pHelper->getCurrentFormula()); + m_xMEdit->set_text(m_pHelper->getCurrentFormula()); sal_Int32 PrivStart, PrivEnd; m_pHelper->getSelection( PrivStart, PrivEnd); m_aFuncSel.Min() = PrivStart; @@ -1473,10 +1483,10 @@ void FormulaDlg_Impl::UpdateSelection() m_nArgs = m_pFuncDesc->getSuppressedArgumentCount(); - OUString aFormula = m_pMEdit->GetText(); + OUString aFormula = m_xMEdit->get_text(); sal_Int32 nArgPos = m_aFormulaHelper.GetArgStart( aFormula, PrivStart, 0); - sal_uInt16 nPos = m_pParaWin->GetActiveLine(); + sal_uInt16 nPos = m_xParaWin->GetActiveLine(); if (nPos >= m_aArguments.size()) { SAL_WARN("formula.ui","FormulaDlg_Impl::UpdateSelection - shot in foot: nPos " << @@ -1493,41 +1503,48 @@ void FormulaDlg_Impl::UpdateSelection() } sal_Int32 nLength = (nPos < m_aArguments.size()) ? m_aArguments[nPos].getLength() : 0; - Selection aSel( nArgPos, nArgPos+nLength); - m_pHelper->setSelection( static_cast<sal_uInt16>(nArgPos),static_cast<sal_uInt16>(nArgPos+nLength)); - m_pMEdit->SetSelection(aSel); - m_pMEFormula->UpdateOldSel(); + m_pHelper->setSelection(nArgPos, nArgPos + nLength); + m_xMEdit->select_region(nArgPos, nArgPos + nLength); + UpdateOldSel(); } -::std::pair<RefButton*, RefEdit*> FormulaDlg_Impl::RefInputStartBefore( RefEdit* pEdit, RefButton* pButton ) +::std::pair<WeldRefButton*, WeldRefEdit*> FormulaDlg_Impl::RefInputStartBefore(WeldRefEdit* pEdit, WeldRefButton* pButton) { - //because its initially hidden, give it its optimal - //size so clicking the refbutton has an initial - //size to work when retro-fitting this to .ui - m_pEdRef->SetSizePixel(m_pEdRef->GetOptimalSize()); - m_pEdRef->Show(); m_pTheRefEdit = pEdit; m_pTheRefButton = pButton; + Selection aOrigSelection; + if (m_pTheRefEdit) + { + // grab selection before showing next widget in case the selection is blown away + // by it appearing + aOrigSelection = m_pTheRefEdit->GetSelection(); + } + + // because its initially hidden, give it its optimal size so clicking the + // refbutton has an initial size to work when retro-fitting this to .ui + m_xEdRef->GetWidget()->set_size_request(m_xEdRef->GetWidget()->get_preferred_size().Width(), -1); + m_xEdRef->GetWidget()->show(); + if ( m_pTheRefEdit ) { - m_pEdRef->SetRefString( m_pTheRefEdit->GetText() ); - m_pEdRef->SetSelection( m_pTheRefEdit->GetSelection() ); - m_pEdRef->SetHelpId( m_pTheRefEdit->GetHelpId() ); + m_xEdRef->SetRefString(m_pTheRefEdit->GetText()); + m_xEdRef->SetSelection(aOrigSelection); + m_xEdRef->GetWidget()->set_help_id(m_pTheRefEdit->GetWidget()->get_help_id()); } - m_pRefBtn->Show( pButton != nullptr ); + m_xRefBtn->GetWidget()->set_visible(pButton != nullptr); - ::std::pair<RefButton*, RefEdit*> aPair; - aPair.first = pButton ? m_pRefBtn.get() : nullptr; - aPair.second = m_pEdRef; + ::std::pair<WeldRefButton*, WeldRefEdit*> aPair; + aPair.first = pButton ? m_xRefBtn.get() : nullptr; + aPair.second = m_xEdRef.get(); return aPair; } -::std::pair<WeldRefButton*, WeldRefEdit*> FormulaDlg_Impl::RefInputStartBefore( WeldRefEdit* pEdit, WeldRefButton* pButton ) +::std::pair<RefButton*, RefEdit*> FormulaDlg_Impl::RefInputStartBefore( RefEdit* pEdit, RefButton* pButton ) { assert(!pEdit && !pButton); - ::std::pair<WeldRefButton*, WeldRefEdit*> aPair; + ::std::pair<RefButton*, RefEdit*> aPair; aPair.first = pButton; aPair.second = pEdit; return aPair; @@ -1535,105 +1552,109 @@ void FormulaDlg_Impl::UpdateSelection() void FormulaDlg_Impl::RefInputStartAfter() { - m_pRefBtn->SetEndImage(); + m_xRefBtn->SetEndImage(); - if ( m_pTheRefEdit ) + if (m_pTheRefEdit) { - OUString aStr = m_aTitle2 + " " + m_pFtEditName->GetText() + "( "; + OUString aStr = m_aTitle2 + " " + m_xFtEditName->get_label() + "( "; - if ( m_pParaWin->GetActiveLine() > 0 ) + if ( m_xParaWin->GetActiveLine() > 0 ) aStr += "...; "; - aStr += m_pParaWin->GetActiveArgName(); - if ( m_pParaWin->GetActiveLine() + 1 < m_nArgs ) + aStr += m_xParaWin->GetActiveArgName(); + if ( m_xParaWin->GetActiveLine() + 1 < m_nArgs ) aStr += "; ..."; aStr += " )"; - m_pParent->SetText( MnemonicGenerator::EraseAllMnemonicChars( aStr ) ); + m_rDialog.set_title(m_rDialog.strip_mnemonic(aStr)); } } void FormulaDlg_Impl::RefInputDoneAfter( bool bForced ) { - m_pRefBtn->SetStartImage(); - if ( bForced || !m_pRefBtn->IsVisible() ) + m_xRefBtn->SetStartImage(); + if (bForced || !m_xRefBtn->GetWidget()->get_visible()) { - m_pEdRef->Hide(); - m_pRefBtn->Hide(); + m_xEdRef->GetWidget()->hide(); + m_xRefBtn->GetWidget()->hide(); if ( m_pTheRefEdit ) { - m_pTheRefEdit->SetRefString( m_pEdRef->GetText() ); + m_pTheRefEdit->SetRefString( m_xEdRef->GetText() ); m_pTheRefEdit->GrabFocus(); if ( m_pTheRefButton ) m_pTheRefButton->SetStartImage(); - sal_uInt16 nPrivActiv = m_pParaWin->GetActiveLine(); - m_pParaWin->SetArgument( nPrivActiv, m_pEdRef->GetText() ); - ModifyHdl( *m_pParaWin ); + sal_uInt16 nPrivActiv = m_xParaWin->GetActiveLine(); + m_xParaWin->SetArgument( nPrivActiv, m_xEdRef->GetText() ); + ModifyHdl( *m_xParaWin ); m_pTheRefEdit = nullptr; } - m_pParent->SetText( m_aTitle1 ); + m_rDialog.set_title(m_aTitle1); } } -RefEdit* FormulaDlg_Impl::GetCurrRefEdit() +WeldRefEdit* FormulaDlg_Impl::GetCurrRefEdit() { - return m_pEdRef->IsVisible() ? m_pEdRef.get() : m_pParaWin->GetActiveEdit(); + return m_xEdRef->GetWidget()->get_visible() ? m_xEdRef.get() : m_xParaWin->GetActiveEdit(); } void FormulaDlg_Impl::Update() { FormEditData* pData = m_pHelper->getFormEditData(); - const OUString sExpression = m_pMEdit->GetText(); + const OUString sExpression = m_xMEdit->get_text(); m_aOldFormula.clear(); UpdateTokenArray(sExpression); - FormulaCursorHdl(*m_pMEFormula); + FormulaCursor(); CalcStruct(sExpression); if (pData->GetMode() == FormulaDlgMode::Formula) - m_pTabCtrl->SetCurPageId(TP_FUNCTION); + m_xTabCtrl->set_current_page("function"); else - m_pTabCtrl->SetCurPageId(TP_STRUCT); - m_pBtnMatrix->Check(pData->GetMatrixFlag()); + m_xTabCtrl->set_current_page("struct"); + m_xBtnMatrix->set_active(pData->GetMatrixFlag()); } void FormulaDlg_Impl::Update(const OUString& _sExp) { CalcStruct(_sExp); FillDialog(); - FuncSelHdl(*m_pFuncPage); + FuncSelHdl(*m_xFuncPage); } void FormulaDlg_Impl::SetMeText(const OUString& _sText) { FormEditData* pData = m_pHelper->getFormEditData(); - m_pMEdit->SetText(_sText); - m_pMEdit->SetSelection( pData->GetSelection()); - m_pMEFormula->UpdateOldSel(); + m_xMEdit->set_text(_sText); + auto aSelection = pData->GetSelection(); + m_xMEdit->select_region(aSelection.Min(), aSelection.Max()); + UpdateOldSel(); } FormulaDlgMode FormulaDlg_Impl::SetMeText( const OUString& _sText, sal_Int32 PrivStart, sal_Int32 PrivEnd, bool bMatrix, bool _bSelect, bool _bUpdate) { FormulaDlgMode eMode = FormulaDlgMode::Formula; if (!m_bEditFlag) - m_pMEdit->SetText(_sText); + m_xMEdit->set_text(_sText); if ( _bSelect || !m_bEditFlag ) - m_pMEdit->SetSelection( Selection( PrivStart, PrivEnd)); + m_xMEdit->select_region(PrivStart, PrivEnd); if ( _bUpdate ) { - m_pMEFormula->UpdateOldSel(); - m_pMEdit->Invalidate(); - m_pHelper->showReference(m_pMEdit->GetSelected()); + UpdateOldSel(); + int nStartPos, nEndPos; + m_xMEdit->get_selection_bounds(nStartPos, nEndPos); + if (nStartPos > nEndPos) + std::swap(nStartPos, nEndPos); + m_pHelper->showReference(m_xMEdit->get_text().copy(nStartPos, nEndPos - nStartPos)); eMode = FormulaDlgMode::Edit; - m_pBtnMatrix->Check( bMatrix ); + m_xBtnMatrix->set_active( bMatrix ); } // if ( _bUpdate ) return eMode; } bool FormulaDlg_Impl::CheckMatrix(OUString& aFormula) { - m_pMEdit->GrabFocus(); + m_xMEdit->grab_focus(); sal_Int32 nLen = aFormula.getLength(); bool bMatrix = nLen > 3 // Matrix-Formula && aFormula[0] == '{' @@ -1642,23 +1663,23 @@ bool FormulaDlg_Impl::CheckMatrix(OUString& aFormula) if ( bMatrix ) { aFormula = aFormula.copy( 1, aFormula.getLength()-2 ); - m_pBtnMatrix->Check( bMatrix ); - m_pBtnMatrix->Disable(); + m_xBtnMatrix->set_active( bMatrix ); + m_xBtnMatrix->set_sensitive(false); } // if ( bMatrix ) - m_pTabCtrl->SetCurPageId(TP_STRUCT); + m_xTabCtrl->set_current_page("struct"); return bMatrix; } IMPL_LINK_NOARG( FormulaDlg_Impl, StructSelHdl, StructPage&, void) { m_bStructUpdate = false; - if (m_pStructPage->IsVisible()) - m_pBtnForward->Enable(false); //@New + if (m_xStructPage->IsVisible()) + m_xBtnForward->set_sensitive(false); //@New m_bStructUpdate = true; } -IMPL_LINK_NOARG( FormulaDlg_Impl, MatrixHdl, Button*, void) +IMPL_LINK_NOARG( FormulaDlg_Impl, MatrixHdl, weld::Button&, void) { m_bUserMatrixFlag = true; UpdateValues(true); @@ -1666,78 +1687,78 @@ IMPL_LINK_NOARG( FormulaDlg_Impl, MatrixHdl, Button*, void) IMPL_LINK_NOARG( FormulaDlg_Impl, FuncSelHdl, FuncPage&, void) { - if ( (m_pFuncPage->GetFunctionEntryCount() > 0) - && (m_pFuncPage->GetFunction() != LISTBOX_ENTRY_NOTFOUND) ) + if ( (m_xFuncPage->GetFunctionEntryCount() > 0) + && (m_xFuncPage->GetFunction() != -1) ) { - const IFunctionDescription* pDesc = m_pFuncPage->GetFuncDesc( m_pFuncPage->GetFunction() ); + const IFunctionDescription* pDesc = m_xFuncPage->GetFuncDesc( m_xFuncPage->GetFunction() ); if (pDesc != m_pFuncDesc) - m_pBtnForward->Enable(); //new + m_xBtnForward->set_sensitive(true); //new if (pDesc) { pDesc->initArgumentInfo(); // full argument info is needed OUString aSig = pDesc->getSignature(); - m_pFtHeadLine->SetText( pDesc->getFunctionName() ); - m_pFtFuncName->SetText( aSig ); - m_pFtFuncDesc->SetText( pDesc->getDescription() ); + m_xFtHeadLine->set_label( pDesc->getFunctionName() ); + m_xFtFuncName->set_label( aSig ); + m_xFtFuncDesc->set_label( pDesc->getDescription() ); } } else { - m_pFtHeadLine->SetText( OUString() ); - m_pFtFuncName->SetText( OUString() ); - m_pFtFuncDesc->SetText( OUString() ); + m_xFtHeadLine->set_label( OUString() ); + m_xFtFuncName->set_label( OUString() ); + m_xFtFuncDesc->set_label( OUString() ); } } void FormulaDlg_Impl::UpdateParaWin( const Selection& _rSelection, const OUString& _sRefStr) { Selection theSel = _rSelection; - m_pEdRef->ReplaceSelected( _sRefStr ); + m_xEdRef->GetWidget()->replace_selection(_sRefStr); theSel.Max() = theSel.Min() + _sRefStr.getLength(); - m_pEdRef->SetSelection( theSel ); + m_xEdRef->SetSelection( theSel ); // Manual Update of the results' fields: - sal_uInt16 nPrivActiv = m_pParaWin->GetActiveLine(); - m_pParaWin->SetArgument( nPrivActiv, m_pEdRef->GetText()); - m_pParaWin->UpdateParas(); + sal_uInt16 nPrivActiv = m_xParaWin->GetActiveLine(); + m_xParaWin->SetArgument( nPrivActiv, m_xEdRef->GetText()); + m_xParaWin->UpdateParas(); - Edit* pEd = GetCurrRefEdit(); - if ( pEd != nullptr ) + WeldRefEdit* pEd = GetCurrRefEdit(); + if (pEd) pEd->SetSelection( theSel ); } bool FormulaDlg_Impl::UpdateParaWin(Selection& _rSelection) { OUString aStrEd; - Edit* pEd = GetCurrRefEdit(); - if (pEd != nullptr && m_pTheRefEdit == nullptr) + WeldRefEdit* pEd = GetCurrRefEdit(); + if (pEd && !m_pTheRefEdit) { _rSelection = pEd->GetSelection(); _rSelection.Justify(); aStrEd = pEd->GetText(); - m_pEdRef->SetRefString(aStrEd); - m_pEdRef->SetSelection( _rSelection ); + m_xEdRef->SetRefString(aStrEd); + m_xEdRef->SetSelection( _rSelection ); } else { - _rSelection = m_pEdRef->GetSelection(); + _rSelection = m_xEdRef->GetSelection(); _rSelection.Justify(); - aStrEd = m_pEdRef->GetText(); + aStrEd = m_xEdRef->GetText(); } return m_pTheRefEdit == nullptr; } void FormulaDlg_Impl::SetEdSelection() { - Edit* pEd = GetCurrRefEdit()/*aScParaWin.GetActiveEdit()*/; - if ( pEd ) + WeldRefEdit* pEd = GetCurrRefEdit()/*aScParaWin.GetActiveEdit()*/; + if (pEd) { - Selection theSel = m_pEdRef->GetSelection(); + Selection theSel = m_xEdRef->GetSelection(); // Edit may have the focus -> call ModifyHdl in addition // to what's happening in GetFocus pEd->GetModifyHdl().Call(*pEd); @@ -1746,24 +1767,18 @@ void FormulaDlg_Impl::SetEdSelection() } // if ( pEd ) } -FormulaModalDialog::FormulaModalDialog( vcl::Window* pParent - , IFunctionManager const * _pFunctionMgr - , IControlReferenceHandler* _pDlg ) - : ModalDialog(pParent, "FormulaDialog", "formula/ui/formuladialog.ui") - , m_pImpl(new FormulaDlg_Impl(this, false/*_bSupportFunctionResult*/, +FormulaModalDialog::FormulaModalDialog(weld::Window* pParent, + IFunctionManager const * _pFunctionMgr, + IControlReferenceHandler* _pDlg) + : GenericDialogController(pParent, "formula/ui/formuladialog.ui", "FormulaDialog") + , m_pImpl(new FormulaDlg_Impl(*m_xDialog, *m_xBuilder, false/*_bSupportFunctionResult*/, false/*_bSupportResult*/, false/*_bSupportMatrix*/, this, _pFunctionMgr, _pDlg)) { - SetText(m_pImpl->m_aTitle1); + m_xDialog->set_title(m_pImpl->m_aTitle1); } -FormulaModalDialog::~FormulaModalDialog() { disposeOnce(); } - -void FormulaModalDialog::dispose() -{ - m_pImpl.reset(); - ModalDialog::dispose(); -} +FormulaModalDialog::~FormulaModalDialog() { } void FormulaModalDialog::Update(const OUString& _sExp) { @@ -1785,12 +1800,12 @@ void FormulaModalDialog::Update() m_pImpl->Update(); } -::std::pair<RefButton*, RefEdit*> FormulaModalDialog::RefInputStartBefore( RefEdit* pEdit, RefButton* pButton ) +::std::pair<WeldRefButton*, WeldRefEdit*> FormulaModalDialog::RefInputStartBefore( WeldRefEdit* pEdit, WeldRefButton* pButton ) { return m_pImpl->RefInputStartBefore( pEdit, pButton ); } -::std::pair<WeldRefButton*, WeldRefEdit*> FormulaModalDialog::RefInputStartBefore( WeldRefEdit* pEdit, WeldRefButton* pButton ) +::std::pair<RefButton*, RefEdit*> FormulaModalDialog::RefInputStartBefore( RefEdit* pEdit, RefButton* pButton ) { return formula::FormulaDlg_Impl::RefInputStartBefore(pEdit, pButton); } @@ -1805,40 +1820,26 @@ void FormulaModalDialog::RefInputDoneAfter() m_pImpl->RefInputDoneAfter( true/*bForced*/ ); } -bool FormulaModalDialog::PreNotify( NotifyEvent& rNEvt ) -{ - if (m_pImpl) - m_pImpl->PreNotify( rNEvt ); - - return ModalDialog::PreNotify(rNEvt); -} - void FormulaModalDialog::StoreFormEditData(FormEditData* pData) { m_pImpl->StoreFormEditData(pData); } - // Initialisation / General functions for Dialog - -FormulaDlg::FormulaDlg( SfxBindings* pB, SfxChildWindow* pCW, - vcl::Window* pParent - , IFunctionManager const * _pFunctionMgr, IControlReferenceHandler* _pDlg ) : - SfxModelessDialog( pB, pCW, pParent, "FormulaDialog", "formula/ui/formuladialog.ui" ), - m_pImpl( new FormulaDlg_Impl(this, true/*_bSupportFunctionResult*/ - , true/*_bSupportResult*/ - , true/*_bSupportMatrix*/ - , this, _pFunctionMgr, _pDlg)) +FormulaDlg::FormulaDlg(SfxBindings* pB, SfxChildWindow* pCW, + weld::Window* pParent, + IFunctionManager const * _pFunctionMgr, IControlReferenceHandler* _pDlg) + : SfxModelessDialogController( pB, pCW, pParent, "formula/ui/formuladialog.ui", "FormulaDialog") + , m_pImpl(new FormulaDlg_Impl(*m_xDialog, *m_xBuilder, true/*_bSupportFunctionResult*/ + , true/*_bSupportResult*/ + , true/*_bSupportMatrix*/ + , this, _pFunctionMgr, _pDlg)) { - SetText(m_pImpl->m_aTitle1); + m_xDialog->set_title(m_pImpl->m_aTitle1); } -FormulaDlg::~FormulaDlg() {disposeOnce();} - -void FormulaDlg::dispose() +FormulaDlg::~FormulaDlg() { - m_pImpl.reset(); - SfxModelessDialog::dispose(); } void FormulaDlg::Update(const OUString& _sExp) @@ -1846,7 +1847,6 @@ void FormulaDlg::Update(const OUString& _sExp) m_pImpl->Update(_sExp); } - void FormulaDlg::SetMeText(const OUString& _sText) { m_pImpl->SetMeText(_sText); @@ -1864,14 +1864,12 @@ bool FormulaDlg::CheckMatrix(OUString& aFormula) OUString FormulaDlg::GetMeText() const { - return m_pImpl->m_pMEdit->GetText(); + return m_pImpl->m_xMEdit->get_text(); } void FormulaDlg::Update() { m_pImpl->Update(); - m_pImpl->m_aIdle.SetInvokeHandler( LINK( this, FormulaDlg, UpdateFocusHdl)); - m_pImpl->m_aIdle.Start(); } void FormulaDlg::DoEnter() @@ -1879,12 +1877,12 @@ void FormulaDlg::DoEnter() m_pImpl->DoEnter(false); } -::std::pair<RefButton*, RefEdit*> FormulaDlg::RefInputStartBefore( RefEdit* pEdit, RefButton* pButton ) +::std::pair<WeldRefButton*, WeldRefEdit*> FormulaDlg::RefInputStartBefore( WeldRefEdit* pEdit, WeldRefButton* pButton ) { return m_pImpl->RefInputStartBefore( pEdit, pButton ); } -::std::pair<WeldRefButton*, WeldRefEdit*> FormulaDlg::RefInputStartBefore( WeldRefEdit* pEdit, WeldRefButton* pButton ) +::std::pair<RefButton*, RefEdit*> FormulaDlg::RefInputStartBefore( RefEdit* pEdit, RefButton* pButton ) { return formula::FormulaDlg_Impl::RefInputStartBefore(pEdit, pButton); } @@ -1899,16 +1897,9 @@ void FormulaDlg::RefInputDoneAfter( bool bForced ) m_pImpl->RefInputDoneAfter( bForced ); } -bool FormulaDlg::PreNotify( NotifyEvent& rNEvt ) -{ - if (m_pImpl) - m_pImpl->PreNotify( rNEvt ); - return SfxModelessDialog::PreNotify(rNEvt); -} - void FormulaDlg::disableOk() { - m_pImpl->m_pBtnEnd->Disable(); + m_pImpl->m_xBtnEnd->set_sensitive(false); } void FormulaDlg::StoreFormEditData(FormEditData* pData) @@ -1935,9 +1926,9 @@ bool FormulaDlg::UpdateParaWin(Selection& _rSelection) return m_pImpl->UpdateParaWin(_rSelection); } -RefEdit* FormulaDlg::GetActiveEdit() +WeldRefEdit* FormulaDlg::GetActiveEdit() { - return m_pImpl->m_pParaWin->GetActiveEdit(); + return m_pImpl->m_xParaWin->GetActiveEdit(); } const FormulaHelper& FormulaDlg::GetFormulaHelper() const @@ -1950,17 +1941,6 @@ void FormulaDlg::SetEdSelection() m_pImpl->SetEdSelection(); } -IMPL_LINK_NOARG( FormulaDlg, UpdateFocusHdl, Timer *, void) -{ - FormEditData* pData = m_pImpl->m_pHelper->getFormEditData(); - if (!pData) - return; - // won't be destroyed via Close - VclPtr<vcl::Window> xWin(pData->GetFocusWindow()); - if (xWin && !xWin->IsDisposed()) - xWin->GrabFocus(); -} - void FormEditData::SaveValues() { Reset(); @@ -1972,7 +1952,6 @@ void FormEditData::Reset() nFStart = 0; nOffset = 0; bMatrix = false; - xFocusWin.clear(); aSelection.Min() = 0; aSelection.Max() = 0; aUndoStr.clear(); @@ -1985,7 +1964,6 @@ FormEditData& FormEditData::operator=( const FormEditData& r ) nOffset = r.nOffset; aUndoStr = r.aUndoStr; bMatrix = r.bMatrix ; - xFocusWin = r.xFocusWin; aSelection = r.aSelection; return *this; } diff --git a/formula/source/ui/dlg/funcpage.cxx b/formula/source/ui/dlg/funcpage.cxx index ce8c23da4eff..3cb0facba86c 100644 --- a/formula/source/ui/dlg/funcpage.cxx +++ b/formula/source/ui/dlg/funcpage.cxx @@ -23,6 +23,7 @@ #include <svl/stritem.hxx> #include <vcl/builderfactory.hxx> #include <vcl/event.hxx> +#include <vcl/svapp.hxx> #include <formula/IFunctionDescription.hxx> #include "funcpage.hxx" @@ -32,44 +33,26 @@ namespace formula { -FormulaListBox::FormulaListBox( vcl::Window* pParent, WinBits nBits ): - ListBox(pParent, nBits) -{} - -void FormulaListBox::KeyInput( const KeyEvent& rKEvt ) -{ - if(rKEvt.GetCharCode()==' ') - DoubleClick(); -} - -bool FormulaListBox::PreNotify( NotifyEvent& rNEvt ) +IMPL_LINK(FuncPage, KeyInputHdl, const KeyEvent&, rKEvt, bool) { - NotifyEvent aNotifyEvt=rNEvt; - - bool bResult = ListBox::PreNotify(rNEvt); - - MouseNotifyEvent nSwitch=aNotifyEvt.GetType(); - if(nSwitch==MouseNotifyEvent::KEYINPUT) + if (rKEvt.GetCharCode() == ' ') { - KeyInput(*aNotifyEvt.GetKeyEvent()); + aDoubleClickLink.Call(*this); + return true; } - return bResult; + return false; } -VCL_BUILDER_FACTORY_ARGS(FormulaListBox, WB_BORDER | WB_SORT) - -FuncPage::FuncPage(vcl::Window* pParent,const IFunctionManager* _pFunctionManager): - TabPage(pParent, "FunctionPage", "formula/ui/functionpage.ui"), - m_pFunctionManager(_pFunctionManager) +FuncPage::FuncPage(weld::Container* pParent, const IFunctionManager* _pFunctionManager) + : m_xBuilder(Application::CreateBuilder(pParent, "formula/ui/functionpage.ui")) + , m_xContainer(m_xBuilder->weld_container("FunctionPage")) + , m_xLbCategory(m_xBuilder->weld_combo_box("category")) + , m_xLbFunction(m_xBuilder->weld_tree_view("function")) + , m_xLbFunctionSearchString(m_xBuilder->weld_entry("search")) + , m_pFunctionManager(_pFunctionManager) { - get(m_pLbCategory, "category"); - get(m_pLbFunction, "function"); - get(m_plbFunctionSearchString, "search"); - m_pLbFunction->SetStyle(m_pLbFunction->GetStyle() | WB_SORT); - Size aSize(LogicToPixel(Size(86 , 162), MapMode(MapUnit::MapAppFont))); - m_pLbFunction->set_height_request(aSize.Height()); - m_pLbFunction->set_width_request(aSize.Width()); - m_aHelpId = m_pLbFunction->GetHelpId(); + m_xLbFunction->make_sorted(); + m_aHelpId = m_xLbFunction->get_help_id(); m_pFunctionManager->fillLastRecentlyUsedFunctions(aLRUList); @@ -77,30 +60,25 @@ FuncPage::FuncPage(vcl::Window* pParent,const IFunctionManager* _pFunctionManage for(sal_uInt32 j= 0; j < nCategoryCount; ++j) { const IFunctionCategory* pCategory = m_pFunctionManager->getCategory(j); - m_pLbCategory->SetEntryData(m_pLbCategory->InsertEntry(pCategory->getName()),const_cast<IFunctionCategory *>(pCategory)); + OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pCategory))); + m_xLbCategory->append(sId, pCategory->getName()); } - m_pLbCategory->SetDropDownLineCount(m_pLbCategory->GetEntryCount()); - m_pLbCategory->SelectEntryPos(1); - OUString searchStr = m_plbFunctionSearchString->GetText(); + m_xLbCategory->set_active(1); + OUString searchStr = m_xLbFunctionSearchString->get_text(); UpdateFunctionList(searchStr); - m_pLbCategory->SetSelectHdl( LINK( this, FuncPage, SelHdl ) ); - m_pLbFunction->SetSelectHdl( LINK( this, FuncPage, SelHdl ) ); - m_pLbFunction->SetDoubleClickHdl( LINK( this, FuncPage, DblClkHdl ) ); - m_plbFunctionSearchString->SetModifyHdl( LINK( this, FuncPage, ModifyHdl ) ); + // lock to its initial size + m_xLbFunction->set_size_request(m_xLbFunction->get_preferred_size().Width(), + m_xLbFunction->get_height_rows(15)); + m_xLbCategory->connect_changed( LINK( this, FuncPage, SelComboBoxHdl ) ); + m_xLbFunction->connect_changed( LINK( this, FuncPage, SelTreeViewHdl ) ); + m_xLbFunction->connect_row_activated( LINK( this, FuncPage, DblClkHdl ) ); + m_xLbFunction->connect_key_press( LINK( this, FuncPage, KeyInputHdl ) ); + m_xLbFunctionSearchString->connect_changed( LINK( this, FuncPage, ModifyHdl ) ); } FuncPage::~FuncPage() { - disposeOnce(); -} - -void FuncPage::dispose() -{ - m_pLbCategory.clear(); - m_pLbFunction.clear(); - m_plbFunctionSearchString.clear(); - TabPage::dispose(); } void FuncPage::impl_addFunctions(const IFunctionCategory* _pCategory) @@ -110,23 +88,24 @@ void FuncPage::impl_addFunctions(const IFunctionCategory* _pCategory) { TFunctionDesc pDesc(_pCategory->getFunction(i)); if (!pDesc->isHidden()) - m_pLbFunction->SetEntryData( - m_pLbFunction->InsertEntry(pDesc->getFunctionName() ),const_cast<IFunctionDescription *>(pDesc) ); + { + OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pDesc))); + m_xLbFunction->append(sId, pDesc->getFunctionName()); + } } } //aStr is non-empty when user types in the search box to search some function void FuncPage::UpdateFunctionList(const OUString& aStr) { + m_xLbFunction->clear(); + m_xLbFunction->freeze(); - m_pLbFunction->Clear(); - m_pLbFunction->SetUpdateMode( false ); - - const sal_Int32 nSelPos = m_pLbCategory->GetSelectedEntryPos(); + const sal_Int32 nSelPos = m_xLbCategory->get_active(); if (aStr.isEmpty() || nSelPos == 0) { - const IFunctionCategory* pCategory = static_cast<const IFunctionCategory*>(m_pLbCategory->GetEntryData(nSelPos)); + const IFunctionCategory* pCategory = reinterpret_cast<const IFunctionCategory*>(m_xLbCategory->get_id(nSelPos).toInt64()); if ( nSelPos > 0 ) { @@ -149,8 +128,8 @@ void FuncPage::UpdateFunctionList(const OUString& aStr) { if (elem) // may be null if a function is no longer available { - m_pLbFunction->SetEntryData( - m_pLbFunction->InsertEntry( elem->getFunctionName() ), const_cast<IFunctionDescription *>(elem) ); + OUString sId(OUString::number(reinterpret_cast<sal_Int64>(elem))); + m_xLbFunction->append(sId, elem->getFunctionName()); } } } @@ -164,10 +143,10 @@ void FuncPage::UpdateFunctionList(const OUString& aStr) const sal_uInt32 nCategoryCount = m_pFunctionManager->getCount(); // Category listbox holds additional entries for Last Used and All, so // the offset should be two but hard coded numbers are ugly.. - const sal_Int32 nCategoryOffset = m_pLbCategory->GetEntryCount() - nCategoryCount; + const sal_Int32 nCategoryOffset = m_xLbCategory->get_count() - nCategoryCount; // If a real category (not Last Used or All) is selected, list only // functions of that category. Else list all, LRU is handled above. - sal_Int32 nCatBeg = (nSelPos == LISTBOX_ENTRY_NOTFOUND ? -1 : nSelPos - nCategoryOffset); + sal_Int32 nCatBeg = (nSelPos == -1 ? -1 : nSelPos - nCategoryOffset); sal_uInt32 nCatEnd; if (nCatBeg < 0) { @@ -189,105 +168,105 @@ void FuncPage::UpdateFunctionList(const OUString& aStr) { if (!pDesc->isHidden()) { - m_pLbFunction->SetEntryData( - m_pLbFunction->InsertEntry( pDesc->getFunctionName()), - const_cast<IFunctionDescription *>(pDesc)); + OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pDesc))); + m_xLbFunction->append(sId, pDesc->getFunctionName()); } } } } } - m_pLbFunction->SetUpdateMode( true ); + m_xLbFunction->thaw(); // Ensure no function is selected so the Next button doesn't overwrite a // function that is not in the list with an arbitrary selected one. - m_pLbFunction->SetNoSelection(); + m_xLbFunction->unselect_all(); - if(IsVisible()) SelHdl(*m_pLbFunction); + if (IsVisible()) + SelTreeViewHdl(*m_xLbFunction); } -IMPL_LINK( FuncPage, SelHdl, ListBox&, rLb, void ) +IMPL_LINK_NOARG(FuncPage, SelComboBoxHdl, weld::ComboBox&, void) { - if(&rLb==m_pLbFunction) - { - const IFunctionDescription* pDesc = GetFuncDesc( GetFunction() ); - if ( pDesc ) - { - const OString sHelpId = pDesc->getHelpId(); - if ( !sHelpId.isEmpty() ) - m_pLbFunction->SetHelpId(sHelpId); - } - aSelectionLink.Call(*this); - } - else + OUString searchStr = m_xLbFunctionSearchString->get_text(); + m_xLbFunction->set_help_id(m_aHelpId); + UpdateFunctionList(searchStr); +} + +IMPL_LINK_NOARG(FuncPage, SelTreeViewHdl, weld::TreeView&, void) +{ + const IFunctionDescription* pDesc = GetFuncDesc( GetFunction() ); + if ( pDesc ) { - OUString searchStr = m_plbFunctionSearchString->GetText(); - m_pLbFunction->SetHelpId(m_aHelpId); - UpdateFunctionList(searchStr); + const OString sHelpId = pDesc->getHelpId(); + if ( !sHelpId.isEmpty() ) + m_xLbFunction->set_help_id(sHelpId); } + aSelectionLink.Call(*this); } -IMPL_LINK_NOARG(FuncPage, DblClkHdl, ListBox&, void) +IMPL_LINK_NOARG(FuncPage, DblClkHdl, weld::TreeView&, void) { aDoubleClickLink.Call(*this); } -IMPL_LINK_NOARG(FuncPage, ModifyHdl, Edit&, void) +IMPL_LINK_NOARG(FuncPage, ModifyHdl, weld::Entry&, void) { // While typing select All category. - m_pLbCategory->SelectEntryPos(1); - OUString searchStr = m_plbFunctionSearchString->GetText(); + m_xLbCategory->set_active(1); + OUString searchStr = m_xLbFunctionSearchString->get_text(); UpdateFunctionList(searchStr); } void FuncPage::SetCategory(sal_Int32 nCat) { - m_pLbCategory->SelectEntryPos(nCat); + m_xLbCategory->set_active(nCat); UpdateFunctionList(OUString()); } sal_Int32 FuncPage::GetFuncPos(const IFunctionDescription* _pDesc) { - return m_pLbFunction->GetEntryPos(_pDesc); + return m_xLbFunction->find_id(OUString::number(reinterpret_cast<sal_Int64>(_pDesc))); } void FuncPage::SetFunction(sal_Int32 nFunc) { - if (nFunc == LISTBOX_ENTRY_NOTFOUND) - m_pLbFunction->SetNoSelection(); + if (nFunc == -1) + m_xLbFunction->unselect_all(); else - m_pLbFunction->SelectEntryPos(nFunc); + m_xLbFunction->select(nFunc); } void FuncPage::SetFocus() { - m_pLbFunction->GrabFocus(); + m_xLbFunction->grab_focus(); } sal_Int32 FuncPage::GetCategory() { - return m_pLbCategory->GetSelectedEntryPos(); + return m_xLbCategory->get_active(); } sal_Int32 FuncPage::GetFunction() { - return m_pLbFunction->GetSelectedEntryPos(); + return m_xLbFunction->get_selected_index(); } sal_Int32 FuncPage::GetFunctionEntryCount() { - return m_pLbFunction->GetSelectedEntryCount(); + return m_xLbFunction->n_children(); } OUString FuncPage::GetSelFunctionName() const { - return m_pLbFunction->GetSelectedEntry(); + return m_xLbFunction->get_selected_text(); } const IFunctionDescription* FuncPage::GetFuncDesc( sal_Int32 nPos ) const { + if (nPos == -1) + return nullptr; // not pretty, but hopefully rare - return static_cast<const IFunctionDescription*>(m_pLbFunction->GetEntryData(nPos)); + return reinterpret_cast<const IFunctionDescription*>(m_xLbFunction->get_id(nPos).toInt64()); } } // formula diff --git a/formula/source/ui/dlg/funcpage.hxx b/formula/source/ui/dlg/funcpage.hxx index b4bccbc64199..1b5b92b6b2fb 100644 --- a/formula/source/ui/dlg/funcpage.hxx +++ b/formula/source/ui/dlg/funcpage.hxx @@ -37,49 +37,39 @@ class IFunctionDescription; class IFunctionManager; class IFunctionCategory; - -class FormulaListBox : public ListBox -{ -protected: - - virtual void KeyInput( const KeyEvent& rKEvt ) override; - virtual bool PreNotify( NotifyEvent& rNEvt ) override; - -public: - FormulaListBox( vcl::Window* pParent, WinBits nBits ); - -}; - - typedef const IFunctionDescription* TFunctionDesc; -class FuncPage final : public TabPage +class FuncPage final { private: + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Container> m_xContainer; + + std::unique_ptr<weld::ComboBox> m_xLbCategory; + std::unique_ptr<weld::TreeView> m_xLbFunction; + std::unique_ptr<weld::Entry> m_xLbFunctionSearchString; + Link<FuncPage&,void> aDoubleClickLink; Link<FuncPage&,void> aSelectionLink; - VclPtr<ListBox> m_pLbCategory; - VclPtr<FormulaListBox> m_pLbFunction; - VclPtr<Edit> m_plbFunctionSearchString; const IFunctionManager* m_pFunctionManager; ::std::vector< TFunctionDesc > aLRUList; OString m_aHelpId; - void impl_addFunctions(const IFunctionCategory* _pCategory); - DECL_LINK( SelHdl, ListBox&, void ); - DECL_LINK(DblClkHdl, ListBox&, void); - DECL_LINK(ModifyHdl, Edit&, void); - void UpdateFunctionList(const OUString&); + DECL_LINK(SelComboBoxHdl, weld::ComboBox&, void); + DECL_LINK(SelTreeViewHdl, weld::TreeView&, void); + DECL_LINK(DblClkHdl, weld::TreeView&, void); + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(ModifyHdl, weld::Entry&, void); + void UpdateFunctionList(const OUString&); public: - FuncPage( vcl::Window* pParent,const IFunctionManager* _pFunctionManager); - virtual ~FuncPage() override; - virtual void dispose() override; + FuncPage(weld::Container* pContainer, const IFunctionManager* _pFunctionManager); + ~FuncPage(); void SetCategory(sal_Int32 nCat); void SetFunction(sal_Int32 nFunc); @@ -96,6 +86,9 @@ public: void SetSelectHdl( const Link<FuncPage&,void>& rLink ) { aSelectionLink = rLink; } + void Show() { m_xContainer->show(); } + bool IsVisible() { return m_xContainer->get_visible(); } + void Hide() { m_xContainer->hide(); } }; } // formula diff --git a/formula/source/ui/dlg/funcutl.cxx b/formula/source/ui/dlg/funcutl.cxx index 698afeab405c..2aeb01ab0ae4 100644 --- a/formula/source/ui/dlg/funcutl.cxx +++ b/formula/source/ui/dlg/funcutl.cxx @@ -27,6 +27,7 @@ #include <formula/funcutl.hxx> #include <formula/IControlReferenceHandler.hxx> #include "ControlHelper.hxx" +#include "parawin.hxx" #include <strings.hrc> #include <bitmaps.hlst> #include <core_resource.hxx> @@ -36,41 +37,29 @@ namespace formula { // class ArgEdit -ArgEdit::ArgEdit( vcl::Window* pParent, WinBits nBits ) - : RefEdit( pParent, nullptr, nBits ), - pEdPrev ( nullptr ), - pEdNext ( nullptr ), - pSlider ( nullptr ), - nArgs ( 0 ) +ArgEdit::ArgEdit(std::unique_ptr<weld::Entry> xControl) + : WeldRefEdit(std::move(xControl)) + , pEdPrev(nullptr) + , pEdNext(nullptr) + , pSlider(nullptr) + , pParaWin(nullptr) + , nArgs(0) { } -ArgEdit::~ArgEdit() -{ - disposeOnce(); -} - -void ArgEdit::dispose() -{ - pEdPrev.clear(); - pEdNext.clear(); - pSlider.clear(); - RefEdit::dispose(); -} - -VCL_BUILDER_FACTORY_ARGS(ArgEdit, WB_BORDER) - -void ArgEdit::Init( ArgEdit* pPrevEdit, ArgEdit* pNextEdit, - ScrollBar& rArgSlider, sal_uInt16 nArgCount ) +void ArgEdit::Init(ArgEdit* pPrevEdit, ArgEdit* pNextEdit, + weld::ScrolledWindow& rArgSlider, + ParaWin& rParaWin, sal_uInt16 nArgCount) { pEdPrev = pPrevEdit; pEdNext = pNextEdit; pSlider = &rArgSlider; + pParaWin = &rParaWin; nArgs = nArgCount; } // Cursor control for Edit Fields in Argument Dialog -void ArgEdit::KeyInput( const KeyEvent& rKEvt ) +IMPL_LINK(ArgEdit, KeyInputHdl, const KeyEvent&, rKEvt, bool) { vcl::KeyCode aCode = rKEvt.GetKeyCode(); bool bUp = (aCode.GetCode() == KEY_UP); @@ -83,7 +72,7 @@ void ArgEdit::KeyInput( const KeyEvent& rKEvt ) if ( nArgs > 1 ) { ArgEdit* pEd = nullptr; - long nThumb = pSlider->GetThumbPos(); + int nThumb = pSlider->vadjustment_get_value(); bool bDoScroll = false; bool bChangeFocus = false; @@ -132,17 +121,17 @@ void ArgEdit::KeyInput( const KeyEvent& rKEvt ) if ( bDoScroll ) { - pSlider->SetThumbPos( nThumb ); - pSlider->GetEndScrollHdl().Call( pSlider ); + pSlider->vadjustment_set_value( nThumb ); + pParaWin->SliderMoved(); } else if ( bChangeFocus ) { pEd->GrabFocus(); } } + return true; } - else - RefEdit::KeyInput( rKEvt ); + return false; } // class ArgInput @@ -154,8 +143,8 @@ ArgInput::ArgInput() pRefBtn=nullptr; } -void ArgInput::InitArgInput( FixedText* pftArg, PushButton* pbtnFx, - ArgEdit* pedArg, RefButton* prefBtn) +void ArgInput::InitArgInput(weld::Label* pftArg, weld::Button* pbtnFx, + ArgEdit* pedArg, WeldRefButton* prefBtn) { pFtArg =pftArg; pBtnFx =pbtnFx; @@ -164,240 +153,124 @@ void ArgInput::InitArgInput( FixedText* pftArg, PushButton* pbtnFx, if(pBtnFx!=nullptr) { - pBtnFx->SetClickHdl ( LINK( this, ArgInput, FxBtnClickHdl ) ); - pBtnFx->SetGetFocusHdl( LINK( this, ArgInput, FxBtnFocusHdl ) ); + pBtnFx->connect_clicked( LINK( this, ArgInput, FxBtnClickHdl ) ); + pBtnFx->connect_focus_in( LINK( this, ArgInput, FxBtnFocusHdl ) ); } if(pEdArg!=nullptr) { pEdArg->SetGetFocusHdl ( LINK( this, ArgInput, EdFocusHdl ) ); pEdArg->SetModifyHdl ( LINK( this, ArgInput, EdModifyHdl ) ); } - } // Sets the Name for the Argument void ArgInput::SetArgName(const OUString &aArg) { - if(pFtArg !=nullptr) pFtArg->SetText(aArg ); + if (pFtArg) + pFtArg->set_label(aArg ); } // Returns the Name for the Argument OUString ArgInput::GetArgName() { OUString aPrivArgName; - if(pFtArg !=nullptr) - aPrivArgName=pFtArg->GetText(); - + if (pFtArg) + aPrivArgName = pFtArg->get_label(); return aPrivArgName; } //Sets the Name for the Argument -void ArgInput::SetArgNameFont (const vcl::Font &aFont) +void ArgInput::SetArgNameFont(const vcl::Font &aFont) { - if(pFtArg !=nullptr) pFtArg->SetFont(aFont); + if (pFtArg) + pFtArg->set_font(aFont); } //Sets up the Selection for the EditBox. -void ArgInput::SetArgSelection (const Selection& rSel ) +void ArgInput::SelectAll() { - if(pEdArg !=nullptr) pEdArg ->SetSelection(rSel ); + if (pEdArg) + pEdArg->SelectAll(); } //Sets the Value for the Argument void ArgInput::SetArgVal(const OUString &rVal) { - if(pEdArg != nullptr) - { - pEdArg ->SetRefString(rVal); - } + if (pEdArg) + pEdArg->SetRefString(rVal); } //Returns the Value for the Argument OUString ArgInput::GetArgVal() { OUString aResult; - if(pEdArg!=nullptr) - { + if (pEdArg) aResult=pEdArg->GetText(); - } return aResult; } //Hides the Controls void ArgInput::Hide() { - if ( pFtArg && pBtnFx && pEdArg && pRefBtn) + if (pFtArg && pBtnFx && pEdArg && pRefBtn) { - pFtArg->Hide(); - pBtnFx->Hide(); - pEdArg->Hide(); - pRefBtn->Hide(); + pFtArg->hide(); + pBtnFx->hide(); + pEdArg->GetWidget()->hide(); + pRefBtn->GetWidget()->hide(); } } //Casts the Controls again. void ArgInput::Show() { - if ( pFtArg && pBtnFx && pEdArg && pRefBtn) + if (pFtArg && pBtnFx && pEdArg && pRefBtn) { - pFtArg->Show(); - pBtnFx->Show(); - pEdArg->Show(); - pRefBtn->Show(); + pFtArg->show(); + pBtnFx->show(); + pEdArg->GetWidget()->show(); + pRefBtn->GetWidget()->show(); } } void ArgInput::UpdateAccessibleNames() { OUString aArgName(":"); - aArgName += pFtArg->GetText(); + aArgName += pFtArg->get_label(); - OUString aName = pBtnFx->GetQuickHelpText(); + OUString aName = pBtnFx->get_tooltip_text(); aName += aArgName; - pBtnFx->SetAccessibleName(aName); + pBtnFx->set_accessible_name(aName); - aName = pRefBtn->GetQuickHelpText(); + aName = pRefBtn->GetWidget()->get_tooltip_text(); aName += aArgName; - pRefBtn->SetAccessibleName(aName); + pRefBtn->GetWidget()->set_accessible_name(aName); } -IMPL_LINK( ArgInput, FxBtnClickHdl, Button*, pBtn, void ) +IMPL_LINK(ArgInput, FxBtnClickHdl, weld::Button&, rBtn, void) { - if(pBtn == pBtnFx) + if (&rBtn == pBtnFx) aFxClickLink.Call(*this); } -IMPL_LINK( ArgInput, FxBtnFocusHdl, Control&, rControl, void ) +IMPL_LINK( ArgInput, FxBtnFocusHdl, weld::Widget&, rControl, void ) { - if(&rControl == pBtnFx) + if (&rControl == pBtnFx) aFxFocusLink.Call(*this); } -IMPL_LINK( ArgInput, EdFocusHdl, Control&, rControl, void ) +IMPL_LINK( ArgInput, EdFocusHdl, WeldRefEdit&, rControl, void ) { - if(&rControl == pEdArg) + if (&rControl == pEdArg) aEdFocusLink.Call(*this); } -IMPL_LINK( ArgInput, EdModifyHdl, Edit&, rEdit, void ) +IMPL_LINK( ArgInput, EdModifyHdl, WeldRefEdit&, rEdit, void ) { - if(&rEdit == pEdArg) + if (&rEdit == pEdArg) aEdModifyLink.Call(*this); } -// class EditBox - -EditBox::EditBox( vcl::Window* pParent, WinBits nBits ) - :Control(pParent,nBits) -{ - WinBits nStyle=GetStyle(); - SetStyle( nStyle| WB_DIALOGCONTROL); - - pMEdit=VclPtr<MultiLineEdit>::Create(this,WB_LEFT | WB_VSCROLL | (nStyle & WB_TABSTOP) | - WB_NOBORDER | WB_NOHIDESELECTION | WB_IGNORETAB); - pMEdit->Show(); - aOldSel=pMEdit->GetSelection(); - Resize(); - WinBits nWinStyle=GetStyle() | WB_DIALOGCONTROL; - SetStyle(nWinStyle); - - // #105582# the HelpId from the resource must be set for the MultiLineEdit, - // not for the control that contains it. - pMEdit->SetHelpId( GetHelpId() ); - SetHelpId( "" ); -} - -VCL_BUILDER_FACTORY_ARGS(EditBox, WB_BORDER) - -EditBox::~EditBox() -{ - disposeOnce(); -} - -void EditBox::dispose() -{ - pMEdit->Disable(); - pMEdit.disposeAndClear(); - Control::dispose(); -} - -// When the size is changed, MultiLineEdit must be adapted.. -void EditBox::Resize() -{ - Size aSize=GetOutputSizePixel(); - if(pMEdit!=nullptr) pMEdit->SetOutputSizePixel(aSize); -} - -// When the Control is activated, the Selection is repealed -// and the Cursor set at the end. -void EditBox::GetFocus() -{ - if(pMEdit!=nullptr) - { - pMEdit->GrabFocus(); - } -} - -// When an event is being triggered, this routine is called first and -// a PostUserEvent is sent. -bool EditBox::PreNotify( NotifyEvent& rNEvt ) -{ - bool bResult = true; - - if(pMEdit==nullptr) return bResult; - - MouseNotifyEvent nSwitch=rNEvt.GetType(); - if(nSwitch==MouseNotifyEvent::KEYINPUT)// || nSwitch==MouseNotifyEvent::KEYUP) - { - const vcl::KeyCode& aKeyCode=rNEvt.GetKeyEvent()->GetKeyCode(); - sal_uInt16 nKey=aKeyCode.GetCode(); - if( (nKey==KEY_RETURN && !aKeyCode.IsShift()) || nKey==KEY_TAB ) - { - bResult = GetParent()->EventNotify(rNEvt); - } - else - { - bResult=Control::PreNotify(rNEvt); - Application::PostUserEvent( LINK( this, EditBox, ChangedHdl ), nullptr, true ); - } - - } - else - { - bResult=Control::PreNotify(rNEvt); - - if(nSwitch==MouseNotifyEvent::MOUSEBUTTONDOWN || nSwitch==MouseNotifyEvent::MOUSEBUTTONUP) - { - Application::PostUserEvent( LINK( this, EditBox, ChangedHdl ), nullptr, true ); - } - } - return bResult; -} - -// When an event was triggered, this routine is called first. -IMPL_LINK_NOARG(EditBox, ChangedHdl, void*, void) -{ - if(pMEdit!=nullptr) - { - Selection aNewSel=pMEdit->GetSelection(); - - if(aNewSel.Min()!=aOldSel.Min() || aNewSel.Max()!=aOldSel.Max()) - { - aSelChangedLink.Call(*this); - aOldSel=aNewSel; - } - } -} - -void EditBox::UpdateOldSel() -{ - // if selection is set for editing a function, store it as aOldSel, - // so SelectionChanged isn't called in the next ChangedHdl call - - if (pMEdit) - aOldSel = pMEdit->GetSelection(); -} - // class RefEdit RefEdit::RefEdit( vcl::Window* _pParent, vcl::Window* pShrinkModeLabel, WinBits nStyle ) diff --git a/formula/source/ui/dlg/parawin.cxx b/formula/source/ui/dlg/parawin.cxx index d901bc1a7cfa..4774b7ba415b 100644 --- a/formula/source/ui/dlg/parawin.cxx +++ b/formula/source/ui/dlg/parawin.cxx @@ -21,6 +21,7 @@ #include <svl/zforlist.hxx> #include <svl/stritem.hxx> #include <vcl/settings.hxx> +#include <vcl/svapp.hxx> #include <sal/log.hxx> #include "parawin.hxx" @@ -34,73 +35,68 @@ namespace formula { - -ParaWin::ParaWin(vcl::Window* pParent,IControlReferenceHandler* _pDlg): - TabPage (pParent, "ParameterPage", "formula/ui/parameter.ui"), - pFuncDesc ( nullptr ), - pMyParent (_pDlg), - m_sOptional ( ForResId( STR_OPTIONAL ) ), - m_sRequired ( ForResId( STR_REQUIRED ) ) +ParaWin::ParaWin(weld::Container* pParent,IControlReferenceHandler* _pDlg) + : pFuncDesc(nullptr) + , pMyParent(_pDlg) + , m_sOptional(ForResId(STR_OPTIONAL)) + , m_sRequired(ForResId(STR_REQUIRED)) + , m_xBuilder(Application::CreateBuilder(pParent, "formula/ui/parameter.ui")) + , m_xContainer(m_xBuilder->weld_container("ParameterPage")) + , m_xSlider(m_xBuilder->weld_scrolled_window("scrollbar")) + , m_xParamGrid(m_xBuilder->weld_widget("paramgrid")) + , m_xGrid(m_xBuilder->weld_widget("grid")) + , m_xFtEditDesc(m_xBuilder->weld_label("editdesc")) + , m_xFtArgName(m_xBuilder->weld_label("parname")) + , m_xFtArgDesc(m_xBuilder->weld_label("pardesc")) + , m_xBtnFx1(m_xBuilder->weld_button("FX1")) + , m_xBtnFx2(m_xBuilder->weld_button("FX2")) + , m_xBtnFx3(m_xBuilder->weld_button("FX3")) + , m_xBtnFx4(m_xBuilder->weld_button("FX4")) + , m_xFtArg1(m_xBuilder->weld_label("FT_ARG1")) + , m_xFtArg2(m_xBuilder->weld_label("FT_ARG2")) + , m_xFtArg3(m_xBuilder->weld_label("FT_ARG3")) + , m_xFtArg4(m_xBuilder->weld_label("FT_ARG4")) + , m_xEdArg1(new ArgEdit(m_xBuilder->weld_entry("ED_ARG1"))) + , m_xEdArg2(new ArgEdit(m_xBuilder->weld_entry("ED_ARG2"))) + , m_xEdArg3(new ArgEdit(m_xBuilder->weld_entry("ED_ARG3"))) + , m_xEdArg4(new ArgEdit(m_xBuilder->weld_entry("ED_ARG4"))) + , m_xRefBtn1(new WeldRefButton(m_xBuilder->weld_button("RB_ARG1"))) + , m_xRefBtn2(new WeldRefButton(m_xBuilder->weld_button("RB_ARG2"))) + , m_xRefBtn3(new WeldRefButton(m_xBuilder->weld_button("RB_ARG3"))) + , m_xRefBtn4(new WeldRefButton(m_xBuilder->weld_button("RB_ARG4"))) { - get(m_pFtEditDesc, "editdesc"); - get(m_pFtArgName, "parname"); - get(m_pFtArgDesc, "pardesc"); - // Space for three lines of text in function description. - m_pFtEditDesc->SetText("X\nX\nX\n"); - long nEditHeight = m_pFtEditDesc->GetOptimalSize().Height(); - m_pFtEditDesc->set_height_request(nEditHeight); - m_pFtEditDesc->SetText(""); + m_xFtEditDesc->set_label("X\nX\nX\n"); + auto nEditHeight = m_xFtEditDesc->get_preferred_size().Height(); + m_xFtEditDesc->set_size_request(-1, nEditHeight); + m_xFtEditDesc->set_label(""); // Space for two lines of text in parameter description. - m_pFtArgDesc->SetText("X\nX\n"); - long nArgHeight = m_pFtArgDesc->GetOptimalSize().Height(); - m_pFtArgDesc->set_height_request(nArgHeight); - m_pFtArgDesc->SetText(""); - - get(m_pBtnFx1, "FX1"); - m_pBtnFx1->SetModeImage(Image(StockImage::Yes, BMP_FX)); - get(m_pBtnFx2, "FX2"); - m_pBtnFx2->SetModeImage(Image(StockImage::Yes, BMP_FX)); - get(m_pBtnFx3, "FX3"); - m_pBtnFx3->SetModeImage(Image(StockImage::Yes, BMP_FX)); - get(m_pBtnFx4, "FX4"); - m_pBtnFx4->SetModeImage(Image(StockImage::Yes, BMP_FX)); - - get(m_pFtArg1, "FT_ARG1"); - get(m_pFtArg2, "FT_ARG2"); - get(m_pFtArg3, "FT_ARG3"); - get(m_pFtArg4, "FT_ARG4"); - - get(m_pEdArg1, "ED_ARG1"); - get(m_pEdArg2, "ED_ARG2"); - get(m_pEdArg3, "ED_ARG3"); - get(m_pEdArg4, "ED_ARG4"); - - get(m_pRefBtn1, "RB_ARG1"); - get(m_pRefBtn2, "RB_ARG2"); - get(m_pRefBtn3, "RB_ARG3"); - get(m_pRefBtn4, "RB_ARG4"); - - get(m_pSlider, "scrollbar"); + m_xFtArgDesc->set_label("X\nX\n"); + auto nArgHeight = m_xFtArgDesc->get_preferred_size().Height(); + m_xFtArgDesc->set_size_request(-1, nArgHeight); + m_xFtArgDesc->set_label(""); + + m_xBtnFx1->set_from_icon_name(BMP_FX); + m_xBtnFx2->set_from_icon_name(BMP_FX); + m_xBtnFx3->set_from_icon_name(BMP_FX); + m_xBtnFx4->set_from_icon_name(BMP_FX); //lock down initial preferences - vcl::Window *pGrid = get<vcl::Window>("paramgrid"); - pGrid->set_height_request(pGrid->get_preferred_size().Height()); - Size aSize(get_preferred_size()); - set_width_request(aSize.Width()); - set_height_request(aSize.Height()); + m_xParamGrid->set_size_request(-1, m_xParamGrid->get_preferred_size().Height()); + Size aSize(m_xContainer->get_preferred_size()); + m_xContainer->set_size_request(aSize.Width(), aSize.Height()); - aDefaultString=m_pFtEditDesc->GetText(); - nEdFocus=NOT_FOUND; - nActiveLine=0; + aDefaultString = m_xFtEditDesc->get_label(); + nEdFocus = NOT_FOUND; + nActiveLine = 0; - m_pSlider->SetEndScrollHdl( LINK( this, ParaWin, ScrollHdl ) ); - m_pSlider->SetScrollHdl( LINK( this, ParaWin, ScrollHdl ) ); + m_xSlider->set_user_managed_scrolling(); + m_xSlider->connect_vadjustment_changed(LINK(this, ParaWin, ScrollHdl)); - InitArgInput( 0, *m_pFtArg1, *m_pBtnFx1, *m_pEdArg1, *m_pRefBtn1); - InitArgInput( 1, *m_pFtArg2, *m_pBtnFx2, *m_pEdArg2, *m_pRefBtn2); - InitArgInput( 2, *m_pFtArg3, *m_pBtnFx3, *m_pEdArg3, *m_pRefBtn3); - InitArgInput( 3, *m_pFtArg4, *m_pBtnFx4, *m_pEdArg4, *m_pRefBtn4); + InitArgInput( 0, *m_xFtArg1, *m_xBtnFx1, *m_xEdArg1, *m_xRefBtn1); + InitArgInput( 1, *m_xFtArg2, *m_xBtnFx2, *m_xEdArg2, *m_xRefBtn2); + InitArgInput( 2, *m_xFtArg3, *m_xBtnFx3, *m_xEdArg3, *m_xRefBtn3); + InitArgInput( 3, *m_xFtArg4, *m_xBtnFx4, *m_xEdArg4, *m_xRefBtn4); ClearAll(); } @@ -228,42 +224,15 @@ void ParaWin::UpdateArgInput( sal_uInt16 nOffset, sal_uInt16 i ) ParaWin::~ParaWin() { - disposeOnce(); -} - -void ParaWin::dispose() -{ // #i66422# if the focus changes during destruction of the controls, // don't call the focus handlers - Link<Control&,void> aEmptyLink; - m_pBtnFx1->SetGetFocusHdl( aEmptyLink ); - m_pBtnFx2->SetGetFocusHdl( aEmptyLink ); - m_pBtnFx3->SetGetFocusHdl( aEmptyLink ); - m_pBtnFx4->SetGetFocusHdl( aEmptyLink ); - m_pFtEditDesc.clear(); - m_pFtArgName.clear(); - m_pFtArgDesc.clear(); - m_pBtnFx1.clear(); - m_pFtArg1.clear(); - m_pEdArg1.clear(); - m_pRefBtn1.clear(); - m_pBtnFx2.clear(); - m_pFtArg2.clear(); - m_pEdArg2.clear(); - m_pRefBtn2.clear(); - m_pBtnFx3.clear(); - m_pFtArg3.clear(); - m_pEdArg3.clear(); - m_pRefBtn3.clear(); - m_pBtnFx4.clear(); - m_pFtArg4.clear(); - m_pEdArg4.clear(); - m_pRefBtn4.clear(); - m_pSlider.clear(); - TabPage::dispose(); + Link<weld::Widget&,void> aEmptyLink; + m_xBtnFx1->connect_focus_in(aEmptyLink); + m_xBtnFx2->connect_focus_in(aEmptyLink); + m_xBtnFx3->connect_focus_in(aEmptyLink); + m_xBtnFx4->connect_focus_in(aEmptyLink); } - void ParaWin::SetActiveLine(sal_uInt16 no) { if(no<nArgs) @@ -282,7 +251,7 @@ void ParaWin::SetActiveLine(sal_uInt16 no) } } -RefEdit* ParaWin::GetActiveEdit() +WeldRefEdit* ParaWin::GetActiveEdit() { if(nArgs>0 && nEdFocus!=NOT_FOUND) { @@ -350,13 +319,14 @@ void ParaWin::SetFunctionDesc(const IFunctionDescription* pFDesc) } nArgs = pFuncDesc->getSuppressedArgumentCount(); pFuncDesc->fillVisibleArgumentMapping(aVisibleArgMapping); - m_pSlider->Hide(); + m_xSlider->set_vpolicy(VclPolicyType::NEVER); + m_xSlider->set_size_request(-1, -1); OString sHelpId = pFuncDesc->getHelpId(); - SetHelpId( sHelpId ); - m_pEdArg1->SetHelpId( sHelpId ); - m_pEdArg2->SetHelpId( sHelpId ); - m_pEdArg3->SetHelpId( sHelpId ); - m_pEdArg4->SetHelpId( sHelpId ); + m_xContainer->set_help_id(sHelpId); + m_xEdArg1->GetWidget()->set_help_id(sHelpId); + m_xEdArg2->GetWidget()->set_help_id(sHelpId); + m_xEdArg3->GetWidget()->set_help_id(sHelpId); + m_xEdArg4->GetWidget()->set_help_id(sHelpId); SetActiveLine(0); } @@ -369,17 +339,17 @@ void ParaWin::SetFunctionDesc(const IFunctionDescription* pFDesc) void ParaWin::SetArgumentText(const OUString& aText) { - m_pFtArgName->SetText(aText); + m_xFtArgName->set_label(aText); } void ParaWin::SetArgumentDesc(const OUString& aText) { - m_pFtArgDesc->SetText(aText); + m_xFtArgDesc->set_label(aText); } void ParaWin::SetEditDesc(const OUString& aText) { - m_pFtEditDesc->SetText(aText); + m_xFtEditDesc->set_label(aText); } void ParaWin::SetArgName(sal_uInt16 no,const OUString& aText) @@ -400,9 +370,8 @@ void ParaWin::SetEdFocus() aArgInput[0].GetArgEdPtr()->GrabFocus(); } - -void ParaWin::InitArgInput( sal_uInt16 nPos, FixedText& rFtArg, PushButton& rBtnFx, - ArgEdit& rEdArg, RefButton& rRefBtn) +void ParaWin::InitArgInput(sal_uInt16 nPos, weld::Label& rFtArg, weld::Button& rBtnFx, + ArgEdit& rEdArg, WeldRefButton& rRefBtn) { rRefBtn.SetReferences(pMyParent, &rEdArg); @@ -428,7 +397,7 @@ void ParaWin::ClearAll() void ParaWin::SetArgumentOffset(sal_uInt16 nOffset) { aParaArray.clear(); - m_pSlider->SetThumbPos(0); + m_xSlider->vadjustment_set_value(0); aParaArray.resize(nArgs); @@ -440,25 +409,24 @@ void ParaWin::SetArgumentOffset(sal_uInt16 nOffset) aArgInput[i].GetArgEdPtr()->Init( (i==0) ? nullptr : aArgInput[i-1].GetArgEdPtr(), (i==3 || i==nArgs-1) ? nullptr : aArgInput[i+1].GetArgEdPtr(), - *m_pSlider, nArgs ); + *m_xSlider, *this, nArgs ); } } + UpdateParas(); + if ( nArgs < 5 ) { - m_pSlider->Hide(); + m_xSlider->set_vpolicy(VclPolicyType::NEVER); + m_xSlider->set_size_request(-1, -1); } else { - m_pSlider->SetPageSize( 4 ); - m_pSlider->SetVisibleSize( 4 ); - m_pSlider->SetLineSize( 1 ); - m_pSlider->SetRange( Range( 0, nArgs ) ); - m_pSlider->SetThumbPos( nOffset ); - m_pSlider->Show(); + m_xSlider->vadjustment_configure(nOffset, 0, nArgs, 1, 4, 4); + m_xSlider->set_vpolicy(VclPolicyType::ALWAYS); + Size aPrefSize(m_xGrid->get_preferred_size()); + m_xSlider->set_size_request(aPrefSize.Width(), aPrefSize.Height()); } - - UpdateParas(); } void ParaWin::UpdateParas() @@ -482,16 +450,16 @@ void ParaWin::UpdateParas() sal_uInt16 ParaWin::GetSliderPos() { - return static_cast<sal_uInt16>(m_pSlider->GetThumbPos()); + return static_cast<sal_uInt16>(m_xSlider->vadjustment_get_value()); } void ParaWin::SetSliderPos(sal_uInt16 nSliderPos) { sal_uInt16 nOffset = GetSliderPos(); - if(m_pSlider->IsVisible() && nOffset!=nSliderPos) + if(m_xSlider->get_visible() && nOffset!=nSliderPos) { - m_pSlider->SetThumbPos(nSliderPos); + m_xSlider->vadjustment_set_value(nSliderPos); for ( sal_uInt16 i=0; i<4; i++ ) { UpdateArgInput( nSliderPos, i ); @@ -510,9 +478,10 @@ void ParaWin::SliderMoved() if(nEdFocus!=NOT_FOUND) { UpdateArgDesc( nEdFocus ); - aArgInput[nEdFocus].SetArgSelection(Selection(0,SELECTION_MAX )); + aArgInput[nEdFocus].SelectAll(); nActiveLine=nEdFocus+nOffset; ArgumentModified(); + aArgInput[nEdFocus].SelectAll(); // ensure all is still selected aArgInput[nEdFocus].UpdateAccessibleNames(); } } @@ -537,7 +506,7 @@ IMPL_LINK( ParaWin, GetFxHdl, ArgInput&, rPtr, void ) if(nEdFocus!=NOT_FOUND) { - aArgInput[nEdFocus].SetArgSelection(Selection(0,SELECTION_MAX )); + aArgInput[nEdFocus].SelectAll(); nActiveLine=nEdFocus+nOffset; aFxLink.Call(*this); } @@ -558,13 +527,12 @@ IMPL_LINK( ParaWin, GetFxFocusHdl, ArgInput&, rPtr, void ) if(nEdFocus!=NOT_FOUND) { - aArgInput[nEdFocus].SetArgSelection(Selection(0,SELECTION_MAX )); + aArgInput[nEdFocus].SelectAll(); UpdateArgDesc( nEdFocus ); nActiveLine=nEdFocus+nOffset; } } - IMPL_LINK( ParaWin, GetEdFocusHdl, ArgInput&, rPtr, void ) { sal_uInt16 nOffset = GetSliderPos(); @@ -580,16 +548,16 @@ IMPL_LINK( ParaWin, GetEdFocusHdl, ArgInput&, rPtr, void ) if(nEdFocus!=NOT_FOUND) { - aArgInput[nEdFocus].SetArgSelection(Selection(0,SELECTION_MAX )); + aArgInput[nEdFocus].SelectAll(); UpdateArgDesc( nEdFocus ); nActiveLine=nEdFocus+nOffset; ArgumentModified(); + aArgInput[nEdFocus].SelectAll(); // ensure all is still selected aArgInput[nEdFocus].UpdateAccessibleNames(); } } - -IMPL_LINK_NOARG(ParaWin, ScrollHdl, ScrollBar*, void) +IMPL_LINK_NOARG(ParaWin, ScrollHdl, weld::ScrolledWindow&, void) { SliderMoved(); } diff --git a/formula/source/ui/dlg/parawin.hxx b/formula/source/ui/dlg/parawin.hxx index 013b9bf1fc0d..8bb6443fed64 100644 --- a/formula/source/ui/dlg/parawin.hxx +++ b/formula/source/ui/dlg/parawin.hxx @@ -25,6 +25,7 @@ #include <vcl/tabpage.hxx> #include <vcl/tabctrl.hxx> #include <vcl/scrbar.hxx> +#include <vcl/weld.hxx> #include <vector> #include <formula/funcutl.hxx> @@ -38,7 +39,7 @@ namespace formula class IFunctionDescription; class IControlReferenceHandler; -class ParaWin final : public TabPage +class ParaWin { private: Link<ParaWin&,void> aFxLink; @@ -51,31 +52,6 @@ private: vcl::Font aFntBold; vcl::Font aFntLight; - VclPtr<FixedText> m_pFtEditDesc; - VclPtr<FixedText> m_pFtArgName; - VclPtr<FixedText> m_pFtArgDesc; - - VclPtr<PushButton> m_pBtnFx1; - VclPtr<FixedText> m_pFtArg1; - VclPtr<ArgEdit> m_pEdArg1; - VclPtr<RefButton> m_pRefBtn1; - - VclPtr<PushButton> m_pBtnFx2; - VclPtr<FixedText> m_pFtArg2; - VclPtr<ArgEdit> m_pEdArg2; - VclPtr<RefButton> m_pRefBtn2; - - VclPtr<PushButton> m_pBtnFx3; - VclPtr<FixedText> m_pFtArg3; - VclPtr<ArgEdit> m_pEdArg3; - VclPtr<RefButton> m_pRefBtn3; - - VclPtr<PushButton> m_pBtnFx4; - VclPtr<FixedText> m_pFtArg4; - VclPtr<ArgEdit> m_pEdArg4; - VclPtr<RefButton> m_pRefBtn4; - - VclPtr<ScrollBar> m_pSlider; OUString m_sOptional; OUString m_sRequired; @@ -84,20 +60,49 @@ private: ArgInput aArgInput[4]; OUString aDefaultString; - ::std::vector<OUString> - aParaArray; + ::std::vector<OUString> aParaArray; + + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Container> m_xContainer; + + std::unique_ptr<weld::ScrolledWindow> m_xSlider; + std::unique_ptr<weld::Widget> m_xParamGrid; + std::unique_ptr<weld::Widget> m_xGrid; + + std::unique_ptr<weld::Label> m_xFtEditDesc; + std::unique_ptr<weld::Label> m_xFtArgName; + std::unique_ptr<weld::Label> m_xFtArgDesc; - DECL_LINK( ScrollHdl, ScrollBar*, void); + std::unique_ptr<weld::Button> m_xBtnFx1; + std::unique_ptr<weld::Button> m_xBtnFx2; + std::unique_ptr<weld::Button> m_xBtnFx3; + std::unique_ptr<weld::Button> m_xBtnFx4; + + std::unique_ptr<weld::Label> m_xFtArg1; + std::unique_ptr<weld::Label> m_xFtArg2; + std::unique_ptr<weld::Label> m_xFtArg3; + std::unique_ptr<weld::Label> m_xFtArg4; + + std::unique_ptr<ArgEdit> m_xEdArg1; + std::unique_ptr<ArgEdit> m_xEdArg2; + std::unique_ptr<ArgEdit> m_xEdArg3; + std::unique_ptr<ArgEdit> m_xEdArg4; + + std::unique_ptr<WeldRefButton> m_xRefBtn1; + std::unique_ptr<WeldRefButton> m_xRefBtn2; + std::unique_ptr<WeldRefButton> m_xRefBtn3; + std::unique_ptr<WeldRefButton> m_xRefBtn4; + + DECL_LINK( ScrollHdl, weld::ScrolledWindow&, void); DECL_LINK( ModifyHdl, ArgInput&, void ); DECL_LINK( GetEdFocusHdl, ArgInput&, void ); DECL_LINK( GetFxFocusHdl, ArgInput&, void ); DECL_LINK( GetFxHdl, ArgInput&, void ); - void SliderMoved(); void ArgumentModified(); - void InitArgInput( sal_uInt16 nPos, FixedText& rFtArg, PushButton& rBtnFx, - ArgEdit& rEdArg, RefButton& rRefBtn); + void InitArgInput(sal_uInt16 nPos, weld::Label& rFtArg, weld::Button& rBtnFx, + ArgEdit& rEdArg, WeldRefButton& rRefBtn); void SetArgumentDesc(const OUString& aText); void SetArgumentText(const OUString& aText); @@ -110,9 +115,8 @@ private: void UpdateArgInput( sal_uInt16 nOffset, sal_uInt16 i ); public: - ParaWin(vcl::Window* pParent,IControlReferenceHandler* _pDlg); - virtual ~ParaWin() override; - virtual void dispose() override; + ParaWin(weld::Container* pParent, IControlReferenceHandler* _pDlg); + ~ParaWin(); void SetFunctionDesc(const IFunctionDescription* pFDesc); void SetArgumentOffset(sal_uInt16 nOffset); @@ -122,7 +126,7 @@ public: sal_uInt16 GetActiveLine() { return nActiveLine;} void SetActiveLine(sal_uInt16 no); - RefEdit* GetActiveEdit(); + WeldRefEdit* GetActiveEdit(); OUString GetActiveArgName(); OUString GetArgument(sal_uInt16 no); @@ -135,6 +139,10 @@ public: void SetArgModifiedHdl( const Link<ParaWin&,void>& rLink ) { aArgModifiedLink = rLink; } void SetFxHdl( const Link<ParaWin&,void>& rLink ) { aFxLink = rLink; } + + void SliderMoved(); + + void Show() { m_xContainer->show(); } }; diff --git a/formula/source/ui/dlg/structpg.cxx b/formula/source/ui/dlg/structpg.cxx index 6f2a51b3228e..365eb20f3362 100644 --- a/formula/source/ui/dlg/structpg.cxx +++ b/formula/source/ui/dlg/structpg.cxx @@ -21,6 +21,7 @@ #include <svl/stritem.hxx> #include <vcl/builderfactory.hxx> #include <vcl/treelistentry.hxx> +#include <vcl/svapp.hxx> #include "structpg.hxx" #include <formula/formdata.hxx> @@ -34,8 +35,6 @@ namespace formula StructListBox::StructListBox(vcl::Window* pParent, WinBits nBits ): SvTreeListBox(pParent, nBits) { - bActiveFlag = false; - vcl::Font aFont( GetFont() ); Size aSize = aFont.GetFontSize(); aSize.AdjustHeight(-2); @@ -53,12 +52,11 @@ SvTreeListEntry* StructListBox::InsertStaticEntry( return pEntry; } -void StructListBox::SetActiveFlag(bool bFlag) +void StructPage::SetActiveFlag(bool bFlag) { bActiveFlag = bFlag; } - void StructListBox::MouseButtonDown( const MouseEvent& rMEvt ) { bActiveFlag = true; @@ -77,89 +75,89 @@ void StructListBox::LoseFocus() SvTreeListBox::LoseFocus(); } -VCL_BUILDER_FACTORY_ARGS(StructListBox, WB_BORDER) - -StructPage::StructPage(vcl::Window* pParent): - TabPage(pParent, "StructPage", "formula/ui/structpage.ui"), - maImgEnd(BitmapEx(BMP_STR_END)), - maImgError(BitmapEx(BMP_STR_ERROR)), - pSelectedToken ( nullptr ) +StructPage::StructPage(weld::Container* pParent) + : m_xBuilder(Application::CreateBuilder(pParent, "formula/ui/structpage.ui")) + , m_xContainer(m_xBuilder->weld_container("StructPage")) + , m_xTlbStruct(m_xBuilder->weld_tree_view("struct")) + , maImgEnd(BMP_STR_END) + , maImgError(BMP_STR_ERROR) + , pSelectedToken(nullptr) + , bActiveFlag(false) { - get(m_pTlbStruct, "struct"); - Size aSize(LogicToPixel(Size(86, 162), MapMode(MapUnit::MapAppFont))); - m_pTlbStruct->set_height_request(aSize.Height()); - m_pTlbStruct->set_width_request(aSize.Width()); - m_pTlbStruct->SetStyle(m_pTlbStruct->GetStyle()|WB_HASLINES|WB_CLIPCHILDREN| - WB_HASBUTTONS|WB_HSCROLL|WB_NOINITIALSELECTION); - - m_pTlbStruct->SetNodeDefaultImages(); - m_pTlbStruct->SetDefaultExpandedEntryBmp(Image(StockImage::Yes, BMP_STR_OPEN)); - m_pTlbStruct->SetDefaultCollapsedEntryBmp(Image(StockImage::Yes, BMP_STR_CLOSE)); - + m_xTlbStruct->set_size_request(m_xTlbStruct->get_approximate_digit_width() * 20, + m_xTlbStruct->get_height_rows(17)); - m_pTlbStruct->SetSelectHdl(LINK( this, StructPage, SelectHdl ) ); + m_xTlbStruct->connect_changed(LINK( this, StructPage, SelectHdl ) ); } StructPage::~StructPage() { - disposeOnce(); -} - -void StructPage::dispose() -{ - m_pTlbStruct.clear(); - TabPage::dispose(); } void StructPage::ClearStruct() { - m_pTlbStruct->SetActiveFlag(false); - m_pTlbStruct->Clear(); + SetActiveFlag(false); + m_xTlbStruct->clear(); } -SvTreeListEntry* StructPage::InsertEntry( const OUString& rText, SvTreeListEntry* pParent, - sal_uInt16 nFlag, sal_uLong nPos, const FormulaToken* pIFormulaToken ) +bool StructPage::InsertEntry(const OUString& rText, weld::TreeIter* pParent, + sal_uInt16 nFlag, int nPos, + const FormulaToken* pIFormulaToken, + weld::TreeIter& rRet) { - m_pTlbStruct->SetActiveFlag( false ); + SetActiveFlag(false); - SvTreeListEntry* pEntry = nullptr; - switch( nFlag ) + OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pIFormulaToken))); + + bool bEntry = false; + switch (nFlag) { case STRUCT_FOLDER: - pEntry = m_pTlbStruct->InsertEntry( rText, pParent, false, nPos, - const_cast<FormulaToken*>(pIFormulaToken)); - break; + m_xTlbStruct->insert(pParent, nPos, &rText, &sId, nullptr, nullptr, + nullptr, false, &rRet); + m_xTlbStruct->set_image(rRet, BMP_STR_OPEN); + bEntry = true; + break; case STRUCT_END: - pEntry = m_pTlbStruct->InsertStaticEntry( rText, maImgEnd, pParent, nPos, pIFormulaToken ); - break; + m_xTlbStruct->insert(pParent, nPos, &rText, &sId, nullptr, nullptr, + nullptr, false, &rRet); + m_xTlbStruct->set_image(rRet, maImgEnd); + bEntry = true; + break; case STRUCT_ERROR: - pEntry = m_pTlbStruct->InsertStaticEntry( rText, maImgError, pParent, nPos, pIFormulaToken ); - break; + m_xTlbStruct->insert(pParent, nPos, &rText, &sId, nullptr, nullptr, + nullptr, false, &rRet); + m_xTlbStruct->set_image(rRet, maImgError); + bEntry = true; + break; } - if ( pEntry && pParent ) - m_pTlbStruct->Expand( pParent ); - return pEntry; + if (bEntry && pParent) + m_xTlbStruct->expand_row(*pParent); + return bEntry; } -OUString StructPage::GetEntryText(SvTreeListEntry* pEntry) const +OUString StructPage::GetEntryText(weld::TreeIter* pEntry) const { OUString aString; - if (pEntry != nullptr) - aString = m_pTlbStruct->GetEntryText(pEntry); - return aString; + if (pEntry) + aString = m_xTlbStruct->get_text(*pEntry); + return aString; } -const FormulaToken* StructPage::GetFunctionEntry(SvTreeListEntry* pEntry) +const FormulaToken* StructPage::GetFunctionEntry(weld::TreeIter* pEntry) { - if (pEntry != nullptr) + if (pEntry) { - const FormulaToken * pToken = static_cast<const FormulaToken *>(pEntry->GetUserData()); - if (pToken != nullptr) + const FormulaToken * pToken = reinterpret_cast<const FormulaToken *>(m_xTlbStruct->get_id(*pEntry).toInt64()); + if (pToken) { if ( !(pToken->IsFunction() || pToken->GetParamCount() > 1 ) ) { - return GetFunctionEntry(m_pTlbStruct->GetParent(pEntry)); + std::unique_ptr<weld::TreeIter> xParent(m_xTlbStruct->make_iterator(pEntry)); + if (!m_xTlbStruct->iter_parent(*xParent)) + return nullptr; + return GetFunctionEntry(xParent.get()); } else { @@ -170,21 +168,21 @@ const FormulaToken* StructPage::GetFunctionEntry(SvTreeListEntry* pEntry) return nullptr; } -IMPL_LINK( StructPage, SelectHdl, SvTreeListBox*, pTlb, void ) +IMPL_LINK(StructPage, SelectHdl, weld::TreeView&, rTlb, void) { - if (m_pTlbStruct->GetActiveFlag()) + if (GetActiveFlag()) { - if (pTlb == m_pTlbStruct) + if (&rTlb == m_xTlbStruct.get()) { - SvTreeListEntry* pCurEntry = m_pTlbStruct->GetCurEntry(); - if (pCurEntry != nullptr) + std::unique_ptr<weld::TreeIter> xCurEntry(m_xTlbStruct->make_iterator()); + if (m_xTlbStruct->get_cursor(xCurEntry.get())) { - pSelectedToken = static_cast<const FormulaToken *>(pCurEntry->GetUserData()); - if (pSelectedToken != nullptr) + pSelectedToken = reinterpret_cast<const FormulaToken *>(m_xTlbStruct->get_id(*xCurEntry).toInt64()); + if (pSelectedToken) { if ( !(pSelectedToken->IsFunction() || pSelectedToken->GetParamCount() > 1) ) { - pSelectedToken = GetFunctionEntry(pCurEntry); + pSelectedToken = GetFunctionEntry(xCurEntry.get()); } } } diff --git a/formula/source/ui/dlg/structpg.hxx b/formula/source/ui/dlg/structpg.hxx index 34c32e0a9cd2..092b29b055ae 100644 --- a/formula/source/ui/dlg/structpg.hxx +++ b/formula/source/ui/dlg/structpg.hxx @@ -51,45 +51,53 @@ public: sal_uLong nPos, const FormulaToken* pToken ); - void SetActiveFlag(bool bFlag); - bool GetActiveFlag() { return bActiveFlag;} void GetFocus() override; void LoseFocus() override; }; -class StructPage final : public TabPage +class StructPage final { private: + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Container> m_xContainer; + std::unique_ptr<weld::TreeView> m_xTlbStruct; + Link<StructPage&,void> aSelLink; - VclPtr<StructListBox> m_pTlbStruct; - Image maImgEnd; - Image maImgError; + OUString maImgEnd; + OUString maImgError; const FormulaToken* pSelectedToken; + bool bActiveFlag; - DECL_LINK( SelectHdl, SvTreeListBox*, void ); + DECL_LINK(SelectHdl, weld::TreeView&, void); - using Window::GetParent; + const FormulaToken* GetFunctionEntry(weld::TreeIter* pEntry); - const FormulaToken* GetFunctionEntry(SvTreeListEntry* pEntry); + void SetActiveFlag(bool bFlag); + bool GetActiveFlag() { return bActiveFlag;} public: - explicit StructPage(vcl::Window* pParent); - virtual ~StructPage() override; - virtual void dispose() override; + explicit StructPage(weld::Container* pParent); + ~StructPage(); void ClearStruct(); - SvTreeListEntry* InsertEntry(const OUString& rText, SvTreeListEntry* pParent, - sal_uInt16 nFlag, sal_uLong nPos, const FormulaToken* pScToken); + bool InsertEntry(const OUString& rText, weld::TreeIter* pParent, + sal_uInt16 nFlag, int nPos, + const FormulaToken* pIFormulaToken, + weld::TreeIter& rRet); - OUString GetEntryText(SvTreeListEntry* pEntry) const; + OUString GetEntryText(weld::TreeIter* pEntry) const; void SetSelectionHdl( const Link<StructPage&,void>& rLink ) { aSelLink = rLink; } - StructListBox* GetTlbStruct() const { return m_pTlbStruct; } + weld::TreeView& GetTlbStruct() const { return *m_xTlbStruct; } + + void Show() { m_xContainer->show(); } + bool IsVisible() { return m_xContainer->get_visible(); } + void Hide() { m_xContainer->hide(); } }; } // formula diff --git a/formula/uiconfig/ui/formuladialog.ui b/formula/uiconfig/ui/formuladialog.ui index 0434fe838d75..504fe8935107 100644 --- a/formula/uiconfig/ui/formuladialog.ui +++ b/formula/uiconfig/ui/formuladialog.ui @@ -1,12 +1,16 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> +<!-- Generated with glade 3.22.1 --> <interface domain="for"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkDialog" id="FormulaDialog"> <property name="can_focus">False</property> <property name="border_width">5</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> @@ -23,9 +27,9 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="use_underline">True</property> <property name="halign">start</property> <property name="hexpand">True</property> + <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> </object> @@ -137,7 +141,6 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="vexpand">True</property> - <property name="scrollable">True</property> <property name="enable_popup">True</property> <child> <object class="GtkGrid"> @@ -146,6 +149,30 @@ <child> <placeholder/> </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> </object> </child> <child type="tab"> @@ -165,6 +192,30 @@ <child> <placeholder/> </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> </object> <packing> <property name="position">1</property> @@ -181,21 +232,6 @@ <property name="tab_fill">False</property> </packing> </child> - <child> - <object class="GtkGrid"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="position">2</property> - </packing> - </child> - <child type="tab"> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> @@ -236,6 +272,7 @@ <property name="can_focus">False</property> <property name="halign">end</property> <property name="editable">False</property> + <property name="activates_default">True</property> </object> <packing> <property name="left_attach">3</property> @@ -392,6 +429,7 @@ <property name="can_focus">False</property> <property name="halign">end</property> <property name="editable">False</property> + <property name="activates_default">True</property> </object> <packing> <property name="left_attach">2</property> @@ -406,13 +444,24 @@ </packing> </child> <child> - <object class="foruilo-EditBox" id="ed_formula"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> - <child internal-child="accessible"> - <object class="AtkObject" id="ed_formula-atkobject"> - <property name="AtkObject::accessible-name" translatable="yes" context="formuladialog|ed_formula-atkobject">Formula</property> + <property name="vscrollbar_policy">always</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTextView" id="ed_formula"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="wrap_mode">word</property> + <property name="accepts_tab">False</property> + <child internal-child="accessible"> + <object class="AtkObject" id="ed_formula-atkobject"> + <property name="AtkObject::accessible-name" translatable="yes" context="formuladialog|ed_formula-atkobject">Formula</property> + </object> + </child> </object> </child> </object> @@ -444,7 +493,7 @@ <property name="row_spacing">6</property> <property name="column_spacing">6</property> <child> - <object class="foruilo-RefEdit" id="ED_REF"> + <object class="GtkEntry" id="ED_REF"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> @@ -456,7 +505,7 @@ </packing> </child> <child> - <object class="foruilo-RefButton" id="RB_REF"> + <object class="GtkButton" id="RB_REF"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> @@ -486,8 +535,8 @@ </child> <action-widgets> <action-widget response="-11">help</action-widget> - <action-widget response="0">back</action-widget> - <action-widget response="0">next</action-widget> + <action-widget response="102">back</action-widget> + <action-widget response="101">next</action-widget> <action-widget response="-5">ok</action-widget> <action-widget response="-6">cancel</action-widget> </action-widgets> diff --git a/formula/uiconfig/ui/functionpage.ui b/formula/uiconfig/ui/functionpage.ui index 28ca825e5072..35500f1d0f38 100644 --- a/formula/uiconfig/ui/functionpage.ui +++ b/formula/uiconfig/ui/functionpage.ui @@ -1,12 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="for"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> + <object class="GtkTreeStore" id="liststore1"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> <object class="GtkBox" id="FunctionPage"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hexpand">True</property> <property name="vexpand">True</property> <property name="border_width">6</property> <property name="orientation">vertical</property> @@ -31,7 +37,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="halign">start</property> - <property name="hexpand">True</property> + <property name="activates_default">True</property> </object> <packing> <property name="expand">False</property> @@ -58,7 +64,6 @@ <object class="GtkComboBoxText" id="category"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hexpand">True</property> <items> <item translatable="yes" context="functionpage|category">Last Used</item> <item translatable="yes" context="functionpage|category">All</item> @@ -86,13 +91,39 @@ </packing> </child> <child> - <object class="foruilo-FormulaListBox" id="function"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="hexpand">True</property> <property name="vexpand">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="Formula ListBox-selection1"/> + <property name="hscrollbar_policy">never</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="function"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="headers_visible">False</property> + <property name="rules_hint">True</property> + <property name="search_column">0</property> + <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn3"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <child> + <object class="GtkCellRendererText" id="cellrenderer3"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> </child> </object> <packing> diff --git a/formula/uiconfig/ui/parameter.ui b/formula/uiconfig/ui/parameter.ui index 9ea3b0aa4d60..78c943d13e17 100644 --- a/formula/uiconfig/ui/parameter.ui +++ b/formula/uiconfig/ui/parameter.ui @@ -1,8 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.16.1 --> +<!-- Generated with glade 3.22.1 --> <interface domain="for"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkBox" id="ParameterPage"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -25,10 +24,10 @@ <property name="can_focus">False</property> <property name="halign">start</property> <property name="hexpand">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> <property name="label" translatable="yes" context="parameter|editdesc">Function not known</property> <property name="wrap">True</property> + <property name="xalign">0</property> + <property name="yalign">0</property> </object> <packing> <property name="expand">False</property> @@ -56,9 +55,9 @@ <property name="halign">start</property> <property name="hexpand">True</property> <property name="vexpand">True</property> + <property name="wrap">True</property> <property name="xalign">0</property> <property name="yalign">0</property> - <property name="wrap">True</property> </object> <packing> <property name="expand">True</property> @@ -80,272 +79,242 @@ <property name="hexpand">True</property> <property name="column_spacing">12</property> <child> - <object class="GtkGrid" id="grid2"> + <object class="GtkScrolledWindow" id="scrollbar"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="halign">end</property> - <property name="valign">start</property> + <property name="can_focus">True</property> <property name="hexpand">True</property> - <property name="vexpand">True</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - <property name="row_homogeneous">True</property> - <child> - <object class="GtkLabel" id="FT_ARG1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">ED_ARG1</property> - <property name="single_line_mode">True</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="FT_ARG2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">ED_ARG2</property> - <property name="single_line_mode">True</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="FT_ARG3"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">ED_ARG3</property> - <property name="single_line_mode">True</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> + <property name="hscrollbar_policy">never</property> + <property name="vscrollbar_policy">never</property> + <property name="shadow_type">in</property> <child> - <object class="GtkLabel" id="FT_ARG4"> + <object class="GtkViewport"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">ED_ARG4</property> - <property name="single_line_mode">True</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="foruilo-ArgEdit" id="ED_ARG1"> - <property name="width_request">150</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="foruilo-ArgEdit" id="ED_ARG2"> - <property name="width_request">150</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="foruilo-ArgEdit" id="ED_ARG3"> - <property name="width_request">150</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="foruilo-ArgEdit" id="ED_ARG4"> - <property name="width_request">150</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkButton" id="FX1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="halign">end</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkButton" id="FX2"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="halign">end</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkButton" id="FX3"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="halign">end</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkButton" id="FX4"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="halign">end</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="foruilo-RefButton" id="RB_ARG1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes" context="parameter|RB_ARG1|tooltip_text">Select</property> - <property name="halign">end</property> - </object> - <packing> - <property name="left_attach">3</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="foruilo-RefButton" id="RB_ARG2"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes" context="parameter|RB_ARG2|tooltip_text">Select</property> - <property name="halign">end</property> - </object> - <packing> - <property name="left_attach">3</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="foruilo-RefButton" id="RB_ARG3"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes" context="parameter|RB_ARG3|tooltip_text">Select</property> - <property name="halign">end</property> - </object> - <packing> - <property name="left_attach">3</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="foruilo-RefButton" id="RB_ARG4"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes" context="parameter|RB_ARG4|tooltip_text">Select</property> - <property name="halign">end</property> + <child> + <object class="GtkGrid" id="grid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkGrid" id="grid2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">6</property> + <property name="margin_right">6</property> + <property name="margin_top">6</property> + <property name="margin_bottom">6</property> + <property name="hexpand">True</property> + <property name="row_spacing">6</property> + <property name="column_spacing">6</property> + <child> + <object class="GtkLabel" id="FT_ARG1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">ED_ARG1</property> + <property name="single_line_mode">True</property> + <property name="xalign">1</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="FT_ARG2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">ED_ARG2</property> + <property name="single_line_mode">True</property> + <property name="xalign">1</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="FT_ARG3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">ED_ARG3</property> + <property name="single_line_mode">True</property> + <property name="xalign">1</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="FT_ARG4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">ED_ARG4</property> + <property name="single_line_mode">True</property> + <property name="xalign">1</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="ED_ARG1"> + <property name="width_request">150</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="ED_ARG2"> + <property name="width_request">150</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="ED_ARG3"> + <property name="width_request">150</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="ED_ARG4"> + <property name="width_request">150</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkButton" id="FX1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="FX2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="FX3"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkButton" id="FX4"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkButton" id="RB_ARG1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes" context="parameter|RB_ARG1|tooltip_text">Select</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="RB_ARG2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes" context="parameter|RB_ARG2|tooltip_text">Select</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="RB_ARG3"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes" context="parameter|RB_ARG3|tooltip_text">Select</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkButton" id="RB_ARG4"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes" context="parameter|RB_ARG4|tooltip_text">Select</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="top_attach">3</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + </object> + </child> </object> - <packing> - <property name="left_attach">3</property> - <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> </child> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkScrollbar" id="scrollbar"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="vexpand">True</property> - <property name="orientation">vertical</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> diff --git a/formula/uiconfig/ui/structpage.ui b/formula/uiconfig/ui/structpage.ui index 3aa18fa7c721..0af026f2b51c 100644 --- a/formula/uiconfig/ui/structpage.ui +++ b/formula/uiconfig/ui/structpage.ui @@ -1,12 +1,20 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.16.1 --> +<!-- Generated with glade 3.22.1 --> <interface domain="for"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> + <object class="GtkTreeStore" id="liststore1"> + <columns> + <!-- column-name image --> + <column type="GdkPixbuf"/> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> <object class="GtkBox" id="StructPage"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hexpand">True</property> <property name="vexpand">True</property> <property name="border_width">6</property> <property name="orientation">vertical</property> @@ -27,13 +35,42 @@ </packing> </child> <child> - <object class="foruilo-StructListBox" id="struct"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="hexpand">True</property> <property name="vexpand">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="Formula ListBox-selection1"/> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="struct"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="headers_visible">False</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <property name="show_expanders">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="treeview-selection1"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn2"> + <property name="spacing">6</property> + <child> + <object class="GtkCellRendererPixbuf" id="cellrenderertext4"/> + <attributes> + <attribute name="pixbuf">0</attribute> + </attributes> + </child> + <child> + <object class="GtkCellRendererText" id="cellrenderertext2"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + </object> </child> </object> <packing> |