Introduce IFormulaEditorHelper::createCompiler()
For application specific derivatives. Change-Id: I8af95bd120c642e47ec5d0708ed463c98c471567
This commit is contained in:
parent
2f0c10db70
commit
3087b8f5d5
@ -134,8 +134,17 @@ namespace formula
|
|||||||
virtual FormEditData* getFormEditData() const = 0;
|
virtual FormEditData* getFormEditData() const = 0;
|
||||||
virtual bool calculateValue(const OUString& _sExpression, OUString& _rResult, bool bMatrixFormula) = 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;
|
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 switchBack() = 0;
|
||||||
|
|
||||||
virtual void clear() = 0;
|
virtual void clear() = 0;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <formula/formdata.hxx>
|
#include <formula/formdata.hxx>
|
||||||
#include <formula/funcutl.hxx>
|
#include <formula/funcutl.hxx>
|
||||||
#include <formula/tokenarray.hxx>
|
#include <formula/tokenarray.hxx>
|
||||||
|
#include <formula/FormulaCompiler.hxx>
|
||||||
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -118,6 +119,11 @@ std::shared_ptr<formula::FormulaCompiler> FormulaDialog::getCompiler() const
|
|||||||
return nullptr;
|
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)
|
void FormulaDialog::doClose(bool _bOk)
|
||||||
{
|
{
|
||||||
EndDialog(_bOk ? RET_OK : RET_CANCEL);
|
EndDialog(_bOk ? RET_OK : RET_CANCEL);
|
||||||
|
@ -75,6 +75,7 @@ public:
|
|||||||
virtual void fill() override;
|
virtual void fill() override;
|
||||||
virtual bool calculateValue(const OUString& _sExpression, OUString& _rResult, bool bMatrixFormula) override;
|
virtual bool calculateValue(const OUString& _sExpression, OUString& _rResult, bool bMatrixFormula) override;
|
||||||
virtual std::shared_ptr<formula::FormulaCompiler> getCompiler() const 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 doClose(bool _bOk) override;
|
||||||
virtual void insertEntryToLRUList(const formula::IFunctionDescription* pDesc) override;
|
virtual void insertEntryToLRUList(const formula::IFunctionDescription* pDesc) override;
|
||||||
virtual void showReference(const OUString& _sFormula) override;
|
virtual void showReference(const OUString& _sFormula) override;
|
||||||
|
@ -380,6 +380,16 @@ std::shared_ptr<formula::FormulaCompiler> ScFormulaDlg::getCompiler() const
|
|||||||
return m_xCompiler;
|
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:
|
// virtual methods of ScAnyRefDlg:
|
||||||
void ScFormulaDlg::RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton )
|
void ScFormulaDlg::RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton )
|
||||||
{
|
{
|
||||||
|
@ -62,6 +62,7 @@ public:
|
|||||||
virtual void fill() override;
|
virtual void fill() override;
|
||||||
virtual bool calculateValue(const OUString& _sExpression, OUString& _rResult, bool bMatrixFormula) override;
|
virtual bool calculateValue(const OUString& _sExpression, OUString& _rResult, bool bMatrixFormula) override;
|
||||||
virtual std::shared_ptr<formula::FormulaCompiler> getCompiler() const 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 doClose(bool _bOk) override;
|
||||||
virtual void insertEntryToLRUList(const formula::IFunctionDescription* pDesc) override;
|
virtual void insertEntryToLRUList(const formula::IFunctionDescription* pDesc) override;
|
||||||
virtual void showReference(const OUString& _sFormula) override;
|
virtual void showReference(const OUString& _sFormula) override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user