sd/source/core/drawdoc2.cxx |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 68ba889153a63a23c2dd3bf7b9c8d7cd0821dddc
Author:     Mohit Marathe <[email protected]>
AuthorDate: Fri Dec 12 13:19:47 2025 +0530
Commit:     Mohit Marathe <[email protected]>
CommitDate: Tue Dec 16 07:02:13 2025 +0100

    sd: update connectors when a page is inserted or deleted
    
    Signed-off-by: Mohit Marathe <[email protected]>
    Change-Id: Ic70e27ecadfe572f1f1ee267e88594f6dd5580b1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195551
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index 4a4c47c73565..48ae6029bb2d 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -1764,6 +1764,7 @@ void SdDrawDocument::updatePagePreviewsGrid(SdPage* pPage)
 
         mpCanvasPage->CreatePresObj(PresObjKind::PagePreview, true, 
::tools::Rectangle(Point(nX,nY), Size(nPreviewWidth, nPreviewHeight)), 
OUString(), nPageNum);
     }
+    connectPagePreviews();
 }
 
 void SdDrawDocument::connectPagePreviews()
@@ -1776,7 +1777,12 @@ void SdDrawDocument::connectPagePreviews()
     SdrObjListIter aIter(pObjList, SdrIterMode::Flat);
     for (SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next())
     {
-        if (pObj->GetObjIdentifier() == SdrObjKind::Page)
+        //remove the existing connectors
+        if (pObj->GetObjIdentifier() == SdrObjKind::Edge)
+        {
+            pObjList->NbcRemoveObject(pObj->GetOrdNum());
+        }
+        else if (pObj->GetObjIdentifier() == SdrObjKind::Page)
         {
             SdrPageObj* pPageObj = static_cast<SdrPageObj*>(pObj);
             SdPage* pPage = 
static_cast<SdPage*>(pPageObj->GetReferencedPage());
@@ -1790,6 +1796,9 @@ void SdDrawDocument::connectPagePreviews()
         SdrPageObj* pPageObj1 = aPageOrder[i];
         SdrPageObj* pPageObj2 = aPageOrder[i + 1];
 
+        if (!pPageObj1 || !pPageObj2)
+            continue;
+
         ::tools::Rectangle aRect1 = pPageObj1->GetSnapRect();
         ::tools::Rectangle aRect2 = pPageObj2->GetSnapRect();
 

Reply via email to