diff options
author | Eike Rathke <erack@redhat.com> | 2017-07-11 16:38:38 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-07-11 16:42:23 +0200 |
commit | 3087b8f5d500866d17946b9f442af6a74a7f99dd (patch) | |
tree | 4148231daddcedc6f6c0cbbfeded24490e11dc88 | |
parent | 2f0c10db707bbd11d8ca456bcf3d2559a1ce15dd (diff) |
Introduce IFormulaEditorHelper::createCompiler()
For application specific derivatives.
Change-Id: I8af95bd120c642e47ec5d0708ed463c98c471567
-rw-r--r-- | include/formula/IFunctionDescription.hxx | 9 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/Formula.cxx | 6 | ||||
-rw-r--r-- | reportdesign/source/ui/inc/Formula.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/formdlg/formula.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/inc/formula.hxx | 1 |
5 files changed, 27 insertions, 0 deletions
diff --git a/include/formula/IFunctionDescription.hxx b/include/formula/IFunctionDescription.hxx index 3a310d704563..b0211aa2cd88 100644 --- a/include/formula/IFunctionDescription.hxx +++ b/include/formula/IFunctionDescription.hxx @@ -134,8 +134,17 @@ namespace formula virtual FormEditData* getFormEditData() const = 0; virtual bool calculateValue(const OUString& _sExpression, OUString& _rResult, bool bMatrixFormula) = 0; + /** Obtain a resident FormulaCompiler instance, created without + FormulaTokenArray and reused but being application specific derived. + */ virtual std::shared_ptr<FormulaCompiler> getCompiler() const = 0; + /** Create an application specific FormulaCompiler instance with + FormulaTokenArray. The FormulaTokenArray had to be created using + convertToTokenArray(). + */ + virtual std::unique_ptr<FormulaCompiler> createCompiler( FormulaTokenArray& rArray ) 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 826ad3253ca6..738d63f84b00 100644 --- a/reportdesign/source/ui/dlg/Formula.cxx +++ b/reportdesign/source/ui/dlg/Formula.cxx @@ -25,6 +25,7 @@ #include <formula/formdata.hxx> #include <formula/funcutl.hxx> #include <formula/tokenarray.hxx> +#include <formula/FormulaCompiler.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <memory> @@ -118,6 +119,11 @@ std::shared_ptr<formula::FormulaCompiler> FormulaDialog::getCompiler() const return nullptr; } +std::unique_ptr<formula::FormulaCompiler> FormulaDialog::createCompiler( formula::FormulaTokenArray& rArray ) const +{ + return std::unique_ptr<formula::FormulaCompiler>(new FormulaCompiler(rArray)); +} + 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 39cd6e92d246..a2f4aa707692 100644 --- a/reportdesign/source/ui/inc/Formula.hxx +++ b/reportdesign/source/ui/inc/Formula.hxx @@ -75,6 +75,7 @@ public: virtual void fill() override; virtual bool calculateValue(const OUString& _sExpression, OUString& _rResult, bool bMatrixFormula) override; virtual std::shared_ptr<formula::FormulaCompiler> getCompiler() const override; + virtual std::unique_ptr<formula::FormulaCompiler> createCompiler( formula::FormulaTokenArray& rArray ) const override; 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 547ee391919c..675b6eac9680 100644 --- a/sc/source/ui/formdlg/formula.cxx +++ b/sc/source/ui/formdlg/formula.cxx @@ -380,6 +380,16 @@ std::shared_ptr<formula::FormulaCompiler> ScFormulaDlg::getCompiler() const return m_xCompiler; } +std::unique_ptr<formula::FormulaCompiler> ScFormulaDlg::createCompiler( formula::FormulaTokenArray& rArray ) const +{ + ScCompiler* pCompiler = nullptr; + ScTokenArray* pArr = dynamic_cast<ScTokenArray*>(&rArray); + assert(pArr); // violation of contract and not created using convertToTokenArray()? + if (pArr) + pCompiler = new ScCompiler( m_pDoc, m_CursorPos, *pArr, m_pDoc->GetGrammar()); + return std::unique_ptr<formula::FormulaCompiler>(pCompiler); +} + // 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 85c646e41409..0c07a769a862 100644 --- a/sc/source/ui/inc/formula.hxx +++ b/sc/source/ui/inc/formula.hxx @@ -62,6 +62,7 @@ public: virtual void fill() override; virtual bool calculateValue(const OUString& _sExpression, OUString& _rResult, bool bMatrixFormula) override; virtual std::shared_ptr<formula::FormulaCompiler> getCompiler() const override; + virtual std::unique_ptr<formula::FormulaCompiler> createCompiler( formula::FormulaTokenArray& rArray ) const override; virtual void doClose(bool _bOk) override; virtual void insertEntryToLRUList(const formula::IFunctionDescription* pDesc) override; virtual void showReference(const OUString& _sFormula) override; |