openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1408375 - /incubator/ooo/branches/alg/aw080/main/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
Date Mon, 12 Nov 2012 17:51:35 GMT
Author: alg
Date: Mon Nov 12 17:51:34 2012
New Revision: 1408375

URL: http://svn.apache.org/viewvc?rev=1408375&view=rev
Log:
Secured SlideSorterModel::DeleteSlide for negative page indices

Modified:
    incubator/ooo/branches/alg/aw080/main/sd/source/ui/slidesorter/model/SlideSorterModel.cxx

Modified: incubator/ooo/branches/alg/aw080/main/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/aw080/main/sd/source/ui/slidesorter/model/SlideSorterModel.cxx?rev=1408375&r1=1408374&r2=1408375&view=diff
==============================================================================
--- incubator/ooo/branches/alg/aw080/main/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
(original)
+++ incubator/ooo/branches/alg/aw080/main/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
Mon Nov 12 17:51:34 2012
@@ -675,13 +675,36 @@ void SlideSorterModel::InsertSlide (SdPa
 
 void SlideSorterModel::DeleteSlide (const SdPage* pPage)
 {
-    const sal_Int32 nIndex (GetIndex(pPage));
-    if (maPageDescriptors[nIndex])
-        if (maPageDescriptors[nIndex]->GetPage() != pPage)
-            return;
+    sal_Int32 nIndex(0);
 
-    maPageDescriptors.erase(maPageDescriptors.begin()+nIndex);
-    UpdateIndices(nIndex);
+    // Caution, GetIndex() may be negative since it uses GetPageNumber()-1
+    // for calculation, so do this only when page is inserted, else the
+    // GetPageNumber() will be zero and thus GetIndex() == -1
+    if(pPage->IsInserted())
+    {
+        nIndex = GetIndex(pPage);
+    }
+    else
+    {
+        // if not inserted, search for page
+        for(; nIndex < maPageDescriptors.size(); nIndex++)
+        {
+            if(maPageDescriptors[nIndex]->GetPage() == pPage)
+            {
+                break;
+            }
+        }
+    }
+
+    if(nIndex >= 0 && nIndex < maPageDescriptors.size())
+    {
+        if (maPageDescriptors[nIndex])
+            if (maPageDescriptors[nIndex]->GetPage() != pPage)
+                return;
+
+        maPageDescriptors.erase(maPageDescriptors.begin()+nIndex);
+        UpdateIndices(nIndex);
+    }
     OSL_TRACE("page removed");
 }
 



Mime
View raw message