[Libreoffice-commits] core.git: 2 commits - formula/source include/formula reportdesign/source sc/source
Eike Rathke
erack at redhat.com
Tue Jul 11 14:45:33 UTC 2017
formula/source/ui/dlg/formula.cxx | 8 ++++----
include/formula/IFunctionDescription.hxx | 9 +++++++++
reportdesign/source/ui/dlg/Formula.cxx | 6 ++++++
reportdesign/source/ui/inc/Formula.hxx | 1 +
sc/source/ui/formdlg/formula.cxx | 10 ++++++++++
sc/source/ui/inc/formula.hxx | 1 +
6 files changed, 31 insertions(+), 4 deletions(-)
New commits:
commit c5cb46b45b69b03e5a6735b9c59bf686069ad401
Author: Eike Rathke <erack at redhat.com>
Date: Tue Jul 11 16:44:40 2017 +0200
Instanciate FormulaCompiler using createCompiler()
So this actually obeys all application specific rules when generating RPN code.
Change-Id: I5e1a89efffe5188d3c4b68176cc410a6cd76483a
diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx
index 9e8e56b4eab1..9e66f7e663fb 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -777,11 +777,11 @@ void FormulaDlg_Impl::UpdateTokenArray( const OUString& rStrExp)
}
} // if ( pTokens && nLen == m_aTokenList.getLength() )
- FormulaCompiler aCompiler(*m_pTokenArray.get());
+ std::unique_ptr<FormulaCompiler> pCompiler( m_pHelper->createCompiler(*m_pTokenArray.get()));
// #i101512# Disable special handling of jump commands.
- aCompiler.EnableJumpCommandReorder(false);
- aCompiler.EnableStopOnError(false);
- aCompiler.CompileTokenArray();
+ pCompiler->EnableJumpCommandReorder(false);
+ pCompiler->EnableStopOnError(false);
+ pCompiler->CompileTokenArray();
}
void FormulaDlg_Impl::FillDialog(bool bFlag)
commit 3087b8f5d500866d17946b9f442af6a74a7f99dd
Author: Eike Rathke <erack at redhat.com>
Date: Tue Jul 11 16:38:38 2017 +0200
Introduce IFormulaEditorHelper::createCompiler()
For application specific derivatives.
Change-Id: I8af95bd120c642e47ec5d0708ed463c98c471567
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;
More information about the Libreoffice-commits
mailing list