[PATCH] Change in core[libreoffice-4-0]: prevent to create cond formats with empty range, fdo#58778

Markus Mohrhard (via Code Review) gerrit at gerrit.libreoffice.org
Sun Jan 20 02:26:00 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/1780

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/80/1780/1

prevent to create cond formats with empty range, fdo#58778

Change-Id: I54bac843dc60c419c23c6d3f22c8d2f4b5805327
---
M sc/source/ui/condformat/condformatdlg.cxx
M sc/source/ui/condformat/condformatmgr.cxx
M sc/source/ui/view/cellsh1.cxx
3 files changed, 19 insertions(+), 8 deletions(-)



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 @@
 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 @@
     if(pDlg->Execute() == RET_OK)
     {
         ScConditionalFormat* pNewFormat = pDlg->GetConditionalFormat();
-        if(!pNewFormat)
-            return 0;
+        if(pNewFormat)
+        {
+            mpFormatList->InsertNew(pNewFormat);
+            pNewFormat->SetKey(FindKey(mpFormatList));
+            maCtrlManager.Update();
 
-        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 @@
                 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 );

-- 
To view, visit https://gerrit.libreoffice.org/1780
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I54bac843dc60c419c23c6d3f22c8d2f4b5805327
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Markus Mohrhard <markus.mohrhard at googlemail.com>



More information about the LibreOffice mailing list