formula/source/ui/dlg/formula.cxx | 17 ++++++++++------- include/formula/FormulaCompiler.hxx | 10 +++++----- include/formula/IFunctionDescription.hxx | 3 +++ reportdesign/source/ui/dlg/Formula.cxx | 6 ++++++ reportdesign/source/ui/inc/Formula.hxx | 1 + sc/source/ui/formdlg/formula.cxx | 7 +++++++ sc/source/ui/inc/formula.hxx | 6 ++++-- 7 files changed, 36 insertions(+), 14 deletions(-)
New commits: commit e8fcb1fbd365b7c6104c7941abee07a612ba7813 Author: Eike Rathke <[email protected]> Date: Mon Jul 10 20:04:08 2017 +0200 Make GetForceArrayParameter() public Change-Id: I3a82c43e80fffb4bf37bb2f7a3f5b3b26f1baf98 diff --git a/include/formula/FormulaCompiler.hxx b/include/formula/FormulaCompiler.hxx index 31a3cf5e5ee4..45166193487c 100644 --- a/include/formula/FormulaCompiler.hxx +++ b/include/formula/FormulaCompiler.hxx @@ -259,6 +259,11 @@ public: */ bool NeedsTableRefTransformation() const; + /** If a parameter nParam (0-based) is to be forced to array for OpCode + eOp, i.e. classified as ParamClass::ForceArray or + ParamClass::ReferenceOrForceArray type. */ + virtual formula::ParamClass GetForceArrayParameter( const FormulaToken* pToken, sal_uInt16 nParam ) const; + static void UpdateSeparatorsNative( const OUString& rSep, const OUString& rArrayColSep, const OUString& rArrayRowSep ); static void ResetNativeSymbols(); static void SetNativeSymbols( const OpCodeMapPtr& xMap ); @@ -295,11 +300,6 @@ protected: virtual void CreateStringFromIndex( OUStringBuffer& rBuffer, const FormulaToken* pToken ) const; virtual void LocalizeString( OUString& rName ) const; // modify rName - input: exact name - /** If a parameter nParam (0-based) is to be forced to array for OpCode - eOp, i.e. classified as ParamClass::ForceArray or - ParamClass::ReferenceOrForceArray type. */ - virtual formula::ParamClass GetForceArrayParameter( const FormulaToken* pToken, sal_uInt16 nParam ) const; - void AppendErrorConstant( OUStringBuffer& rBuffer, FormulaError nError ) const; bool GetToken(); commit 741f61d0ca70069e875f6f57bf08d9aa282c0676 Author: Eike Rathke <[email protected]> Date: Mon Jul 10 18:33:22 2017 +0200 Introduce IFormulaEditorHelper::getCompiler() Implemented at rptui::FormulaDialog as nullptr and at ScFormulaDlg as ScCompiler* Change-Id: I0edaca56f5d9e3505ed766d43bc9ee4af80f03ff diff --git a/include/formula/IFunctionDescription.hxx b/include/formula/IFunctionDescription.hxx index 40820ebbe040..3a310d704563 100644 --- a/include/formula/IFunctionDescription.hxx +++ b/include/formula/IFunctionDescription.hxx @@ -42,6 +42,7 @@ namespace formula class IFunctionDescription; class FormEditData; class FormulaTokenArray; + class FormulaCompiler; class SAL_NO_VTABLE IFunctionManager { @@ -133,6 +134,8 @@ namespace formula virtual FormEditData* getFormEditData() const = 0; virtual bool calculateValue(const OUString& _sExpression, OUString& _rResult, bool bMatrixFormula) = 0; + virtual std::shared_ptr<FormulaCompiler> getCompiler() const = 0; + virtual void switchBack() = 0; virtual void clear() = 0; diff --git a/reportdesign/source/ui/dlg/Formula.cxx b/reportdesign/source/ui/dlg/Formula.cxx index 480f017e7ac1..826ad3253ca6 100644 --- a/reportdesign/source/ui/dlg/Formula.cxx +++ b/reportdesign/source/ui/dlg/Formula.cxx @@ -112,6 +112,12 @@ bool FormulaDialog::calculateValue( const OUString& rStrExp, OUString& rStrResul rStrResult = rStrExp; return false; } + +std::shared_ptr<formula::FormulaCompiler> FormulaDialog::getCompiler() const +{ + return nullptr; +} + void FormulaDialog::doClose(bool _bOk) { EndDialog(_bOk ? RET_OK : RET_CANCEL); diff --git a/reportdesign/source/ui/inc/Formula.hxx b/reportdesign/source/ui/inc/Formula.hxx index 77153a0db40d..ceba75141964 100644 --- a/reportdesign/source/ui/inc/Formula.hxx +++ b/reportdesign/source/ui/inc/Formula.hxx @@ -74,6 +74,7 @@ public: virtual void notifyChange() override; virtual void fill() override; virtual bool calculateValue(const OUString& _sExpression, OUString& _rResult, bool bMatrixFormula) override; + virtual std::shared_ptr<formula::FormulaCompiler> getCompiler() const; virtual void doClose(bool _bOk) override; virtual void insertEntryToLRUList(const formula::IFunctionDescription* pDesc) override; virtual void showReference(const OUString& _sFormula) override; diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx index ac8b3369fe4a..547ee391919c 100644 --- a/sc/source/ui/formdlg/formula.cxx +++ b/sc/source/ui/formdlg/formula.cxx @@ -373,6 +373,13 @@ bool ScFormulaDlg::calculateValue( const OUString& rStrExp, OUString& rStrResult return true; } +std::shared_ptr<formula::FormulaCompiler> ScFormulaDlg::getCompiler() const +{ + if (!m_xCompiler) + m_xCompiler.reset( new ScCompiler( m_pDoc, m_CursorPos, m_pDoc->GetGrammar())); + return m_xCompiler; +} + // virtual methods of ScAnyRefDlg: void ScFormulaDlg::RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton ) { diff --git a/sc/source/ui/inc/formula.hxx b/sc/source/ui/inc/formula.hxx index 05a0bf99c422..71cdd4246c19 100644 --- a/sc/source/ui/inc/formula.hxx +++ b/sc/source/ui/inc/formula.hxx @@ -47,8 +47,9 @@ class ScFormulaDlg : public formula::FormulaDlg, css::uno::Reference< css::sheet::XFormulaParser> m_xParser; css::uno::Reference< css::sheet::XFormulaOpCodeMapper> m_xOpCodeMapper; - ScDocument* m_pDoc; - ScAddress m_CursorPos; + ScDocument* m_pDoc; + ScAddress m_CursorPos; + mutable std::shared_ptr<ScCompiler> m_xCompiler; public: ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW, @@ -60,6 +61,7 @@ public: virtual void notifyChange() override; virtual void fill() override; virtual bool calculateValue(const OUString& _sExpression, OUString& _rResult, bool bMatrixFormula) override; + virtual std::shared_ptr<formula::FormulaCompiler> getCompiler() const; virtual void doClose(bool _bOk) override; virtual void insertEntryToLRUList(const formula::IFunctionDescription* pDesc) override; virtual void showReference(const OUString& _sFormula) override; commit f6574be0e375e215e6f21830b9e09d77d01b5097 Author: Eike Rathke <[email protected]> Date: Mon Jul 10 17:05:58 2017 +0200 FormulaDlg_Impl::MakeTree: pass down current function/operator token In preparation of better argument evaluation. Change-Id: I364fe03c58a975ae95f070112e11a9eec9505f3d diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx index 890125065c71..8a188ceefc0e 100644 --- a/formula/source/ui/dlg/formula.cxx +++ b/formula/source/ui/dlg/formula.cxx @@ -86,7 +86,8 @@ public: sal_Int32 GetFunctionPos(sal_Int32 nPos); void ClearAllParas(); - void MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, const FormulaToken* _pToken, long Count ); + void MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, const FormulaToken* pFuncToken, + const FormulaToken* _pToken, long Count ); void fillTree(StructPage* _pTree); void UpdateTokenArray( const OUString& rStrExp); OUString RepairFormula(const OUString& aFormula); @@ -621,7 +622,8 @@ bool FormulaDlg_Impl::CalcStruct( const OUString& rStrExp, bool bForceRecalcStru } -void FormulaDlg_Impl::MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, const FormulaToken* _pToken, long Count ) +void FormulaDlg_Impl::MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, const FormulaToken* pFuncToken, + const FormulaToken* _pToken, long Count ) { if ( _pToken != nullptr && Count > 0 ) { @@ -672,7 +674,7 @@ void FormulaDlg_Impl::MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, co } } - MakeTree( _pTree, pEntry, m_pTokenArrayIterator->PrevRPN(), nParas); + MakeTree( _pTree, pEntry, _pToken, m_pTokenArrayIterator->PrevRPN(), nParas); if (bCalcSubformula) { @@ -698,8 +700,8 @@ void FormulaDlg_Impl::MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, co } --Count; - m_pTokenArrayIterator->NextRPN(); - MakeTree( _pTree, pParent, m_pTokenArrayIterator->PrevRPN(), Count); + m_pTokenArrayIterator->NextRPN(); /* TODO: what's this to be? ThisRPN()? */ + MakeTree( _pTree, pParent, _pToken, m_pTokenArrayIterator->PrevRPN(), Count); } else { @@ -714,6 +716,7 @@ void FormulaDlg_Impl::MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, co /* TODO: this should depend on parameter classification, if * a scalar value is expected matrix should not be forced. * */ + (void)pFuncToken; bool bForceMatrix = (!m_pBtnMatrix->IsChecked() && (_pToken->GetType() == svDoubleRef || _pToken->GetType() == svExternalDoubleRef)); OUString aCellResult; @@ -728,7 +731,7 @@ void FormulaDlg_Impl::MakeTree( StructPage* _pTree, SvTreeListEntry* pParent, co _pTree->InsertEntry( aResult, pParent, STRUCT_END, 0, _pToken); } --Count; - MakeTree( _pTree, pParent, m_pTokenArrayIterator->PrevRPN(), Count); + MakeTree( _pTree, pParent, _pToken, m_pTokenArrayIterator->PrevRPN(), Count); } } catch (const uno::Exception&) @@ -745,7 +748,7 @@ void FormulaDlg_Impl::fillTree(StructPage* _pTree) if ( pToken != nullptr) { - MakeTree( _pTree, nullptr, pToken, 1); + MakeTree( _pTree, nullptr, nullptr, pToken, 1); bMakingTree = false; } } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
