include/svx/svdobj.hxx | 3 +++ sd/source/core/drawdoc2.cxx | 2 +- sd/source/core/sdpage.cxx | 1 + svx/source/svdraw/svdobj.cxx | 12 ++++++++++++ svx/source/svdraw/svdpage.cxx | 2 ++ 5 files changed, 19 insertions(+), 1 deletion(-)
New commits: commit e26c25b954e733b253d2a0005678f5a26fed8149 Author: Mohit Marathe <[email protected]> AuthorDate: Thu Nov 20 16:48:45 2025 +0530 Commit: Michael Stahl <[email protected]> CommitDate: Mon Jan 12 19:28:32 2026 +0100 sd: make previews in canvas page non-deletable Signed-off-by: Mohit Marathe <[email protected]> Change-Id: Ifb395a99858dcb318dc3851ff118c3edaf447d75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194272 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Stahl <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196806 Tested-by: Jenkins diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index 810670e86c68..1a9a4b37c181 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -743,6 +743,8 @@ public: void SetMoveProtect(bool bProt); bool IsMoveProtect() const { return m_bMovProt;} void SetResizeProtect(bool bProt); + bool IsDeleteProtect() const { return m_bDelProt; } + void SetDeleteProtect(bool bProt); bool IsResizeProtect() const { return m_bSizProt;} virtual void SetPrintable(bool isPrintable); virtual bool IsPrintable() const; @@ -892,6 +894,7 @@ protected: // the following flags will be streamed bool m_bMovProt : 1; // if true, the position is protected bool m_bSizProt : 1; // if true, the size is protected + bool m_bDelProt : 1; // if true, object cannot be deleted // If bEmptyPresObj is true, it is a presentation object that has no content yet. // The flag's default value is false. // The management is done by the application. diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx index 3f719bc4b86c..c15c69f7d31b 100644 --- a/sd/source/core/drawdoc2.cxx +++ b/sd/source/core/drawdoc2.cxx @@ -1715,7 +1715,7 @@ void SdDrawDocument::updatePagePreviewsGrid(SdPage* pPage) } } for (SdrObject* pObject : aToRemove) - pObjList->RemoveObject(pObject->GetOrdNum()); + pObjList->NbcRemoveObject(pObject->GetOrdNum()); // page inserted if (nTotalPreviews < nPageCnt) diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index ecc7e7948139..73482c4d71df 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -443,6 +443,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t pSdrObj->SetMarkProtect(false); pSdrObj->SetResizeProtect(false); pSdrObj->SetMoveProtect(false); + pSdrObj->SetDeleteProtect(true); } break; diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index c6d90fe2b106..8214ce283ae0 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -372,6 +372,7 @@ SdrObject::SdrObject(SdrModel& rSdrModel) m_bSnapRectDirty =true; m_bMovProt =false; m_bSizProt =false; + m_bDelProt =false; m_bNoPrint =false; m_bEmptyPresObj =false; m_bNotVisibleAsMaster=false; @@ -408,6 +409,7 @@ SdrObject::SdrObject(SdrModel& rSdrModel, SdrObject const & rSource) m_bVirtObj =false; m_bSnapRectDirty =true; m_bMovProt =false; + m_bDelProt =false; m_bSizProt =false; m_bNoPrint =false; m_bEmptyPresObj =false; @@ -2730,6 +2732,16 @@ void SdrObject::SetResizeProtect(bool bProt) } } +void SdrObject::SetDeleteProtect(bool bProt) +{ + if (IsDeleteProtect() != bProt) + { + m_bDelProt = bProt; + SetChanged(); + BroadcastObjectChange(); + } +} + bool SdrObject::IsPrintable() const { return !m_bNoPrint; diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index e205b673ae09..1b240af4e5ca 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -408,6 +408,8 @@ rtl::Reference<SdrObject> SdrObjList::RemoveObject(size_t nObjNum) const size_t nCount = GetObjCount(); rtl::Reference<SdrObject> pObj=maList[nObjNum]; + if (pObj->IsDeleteProtect()) + return nullptr; RemoveObjectFromContainer(nObjNum); DBG_ASSERT(pObj!=nullptr,"Object to remove not found.");
