summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-11-23 08:05:07 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-11-23 08:05:07 +0100
commitc35bd5f3c42786f0fde4aebebc20422ab85bf099 (patch)
treeff8f7817e1013eca630ca53cfa589d95bdba9c7a /sc
parentab63c12395ed3771b1df6822eaa8572c06db0765 (diff)
ManageNames: handle formula errors in Define Names dialog correctly
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/inc/namedefdlg.hxx1
-rw-r--r--sc/source/ui/namedlg/namedefdlg.cxx25
2 files changed, 26 insertions, 0 deletions
diff --git a/sc/source/ui/inc/namedefdlg.hxx b/sc/source/ui/inc/namedefdlg.hxx
index 35555ceae618..94d9adadf321 100644
--- a/sc/source/ui/inc/namedefdlg.hxx
+++ b/sc/source/ui/inc/namedefdlg.hxx
@@ -83,6 +83,7 @@ private:
void MorePushed();
bool IsNameValid();
+ bool IsFormulaValid();
DECL_LINK( CancelBtnHdl, void * );
DECL_LINK( AddBtnHdl, void* );
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index 508ee7a2d3cd..f7afe22a9d45 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -125,6 +125,24 @@ void ScNameDefDlg::CancelPushed()
Close();
}
+bool ScNameDefDlg::IsFormulaValid()
+{
+ ScCompiler aComp( mpDoc, maCursorPos);
+ aComp.SetGrammar( mpDoc->GetGrammar() );
+ ScTokenArray* pCode = aComp.CompileString(maEdRange.GetText());
+ if (pCode->GetCodeError())
+ {
+ //TODO: info message
+ delete pCode;
+ return false;
+ }
+ else
+ {
+ delete pCode;
+ return true;
+ }
+}
+
bool ScNameDefDlg::IsNameValid()
{
rtl::OUString aScope = maLbScope.GetSelectEntry();
@@ -152,6 +170,13 @@ bool ScNameDefDlg::IsNameValid()
maBtnAdd.Disable();
return false;
}
+
+ if (!IsFormulaValid())
+ {
+ maBtnAdd.Disable();
+ return false;
+ }
+
maFtInfo.SetText(maStrInfoDefault);
maBtnAdd.Enable();
return true;