diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-01-18 15:07:00 +0100 |
---|---|---|
committer | Petr Mladek <pmladek@suse.cz> | 2013-01-21 18:08:05 +0000 |
commit | d820394160f7448c17934d9d6fabb17263ce2696 (patch) | |
tree | fd0a682f17fced49c1a4b21b44795a966eb36a35 | |
parent | adbe46bcbe03fbb8bad62dbb7969a861201f8d02 (diff) |
prevent to create cond formats with empty range, fdo#58778
Change-Id: I54bac843dc60c419c23c6d3f22c8d2f4b5805327
Reviewed-on: https://gerrit.libreoffice.org/1780
Reviewed-by: Petr Mladek <pmladek@suse.cz>
Tested-by: Petr Mladek <pmladek@suse.cz>
-rw-r--r-- | sc/source/ui/condformat/condformatdlg.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformatmgr.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh1.cxx | 5 |
3 files changed, 19 insertions, 8 deletions
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx index 9a7be0989d77..1af811870589 100644 --- a/sc/source/ui/condformat/condformatdlg.cxx +++ b/sc/source/ui/condformat/condformatdlg.cxx @@ -463,12 +463,20 @@ void ScCondFormatDlg::SetReference(const ScRange& rRef, ScDocument*) ScConditionalFormat* ScCondFormatDlg::GetConditionalFormat() const { rtl::OUString aRangeStr = maEdRange.GetText(); + if(aRangeStr.isEmpty()) + return NULL; + ScRangeList aRange; sal_uInt16 nFlags = aRange.Parse(aRangeStr, mpDoc, SCA_VALID, mpDoc->GetAddressConvention(), maPos.Tab()); ScConditionalFormat* pFormat = maCondFormList.GetConditionalFormat(); if(nFlags & SCA_VALID && !aRange.empty() && pFormat) pFormat->AddRange(aRange); + else + { + delete pFormat; + pFormat = NULL; + } return pFormat; } diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx index 5a5ea1b56dc9..e9278a010b2b 100644 --- a/sc/source/ui/condformat/condformatmgr.cxx +++ b/sc/source/ui/condformat/condformatmgr.cxx @@ -276,14 +276,14 @@ IMPL_LINK_NOARG(ScCondFormatManagerDlg, AddBtnHdl) if(pDlg->Execute() == RET_OK) { ScConditionalFormat* pNewFormat = pDlg->GetConditionalFormat(); - if(!pNewFormat) - return 0; - - mpFormatList->InsertNew(pNewFormat); - pNewFormat->SetKey(FindKey(mpFormatList)); - maCtrlManager.Update(); + if(pNewFormat) + { + mpFormatList->InsertNew(pNewFormat); + pNewFormat->SetKey(FindKey(mpFormatList)); + maCtrlManager.Update(); - mbModified = true; + mbModified = true; + } } Show(true, 0); pScMod->SetRefDialog( nId, false ); diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 2227c199584d..f67717d69954 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -1879,7 +1879,10 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) if( pCondFormatDlg->Execute() == RET_OK ) { ScConditionalFormat* pFormat = pCondFormatDlg->GetConditionalFormat(); - pData->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nKey, pFormat, aPos.Tab(), pFormat->GetRange()); + if(pFormat) + pData->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nKey, pFormat, aPos.Tab(), pFormat->GetRange()); + else + pData->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nKey, NULL, aPos.Tab(), ScRangeList()); } pScMod->SetRefDialog( nId, false ); |