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 1e2c32fd54a56d026ab37db405f1c7f75bfa0bb0 Author: Mohit Marathe <[email protected]> AuthorDate: Thu Nov 20 16:48:45 2025 +0530 Commit: Michael Stahl <[email protected]> CommitDate: Mon Jan 12 19:38:23 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/+/196705 diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index 7917d988cd20..6fddea9c5fb3 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -740,6 +740,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; @@ -891,6 +893,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 e163bc2cf525..e1ceca8573fd 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 3fa54ec4622b..9b27feffcd83 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -353,6 +353,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; @@ -388,6 +389,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; @@ -2754,6 +2756,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 31769f19ce1b..7f4c0674d351 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.");
