From d820394160f7448c17934d9d6fabb17263ce2696 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Fri, 18 Jan 2013 15:07:00 +0100 Subject: prevent to create cond formats with empty range, fdo#58778 Change-Id: I54bac843dc60c419c23c6d3f22c8d2f4b5805327 Reviewed-on: https://gerrit.libreoffice.org/1780 Reviewed-by: Petr Mladek Tested-by: Petr Mladek --- sc/source/ui/condformat/condformatdlg.cxx | 8 ++++++++ sc/source/ui/condformat/condformatmgr.cxx | 14 +++++++------- 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 ); -- cgit v1.2.3