[Libreoffice-commits] .: Branch 'libreoffice-4-0' - sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Jan 21 10:08:24 PST 2013


 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(-)

New commits:
commit d820394160f7448c17934d9d6fabb17263ce2696
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jan 18 15:07:00 2013 +0100

    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 at suse.cz>
    Tested-by: Petr Mladek <pmladek at suse.cz>

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 9a7be09..1af8118 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 5a5ea1b..e9278a0 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 2227c19..f67717d 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 );


More information about the Libreoffice-commits mailing list