sw/source/uibase/inc/content.hxx | 2 ++ sw/source/uibase/utlui/content.cxx | 29 ++++++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-)
New commits: commit 74bd60c433cdc135d8a465eb5cea8ee6ce84b436 Author: Jim Raykowski <rayk...@gmail.com> AuthorDate: Sat Apr 20 09:14:00 2024 -0800 Commit: Jim Raykowski <rayk...@gmail.com> CommitDate: Wed Apr 24 21:36:57 2024 +0200 Rework SwContentTree context menu item 'Rename' inclusion Change-Id: Ice211a3026d07a21b1b6e47ee1c16086401714d7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166412 Tested-by: Jenkins Reviewed-by: Jim Raykowski <rayk...@gmail.com> diff --git a/sw/source/uibase/inc/content.hxx b/sw/source/uibase/inc/content.hxx index c6698f4b0322..f0aad555619c 100644 --- a/sw/source/uibase/inc/content.hxx +++ b/sw/source/uibase/inc/content.hxx @@ -188,6 +188,7 @@ class SwContentType final : public SwTypeNumber bool m_bDataValid : 1; bool m_bEdit: 1; // can this type be edited? bool m_bDelete: 1; // can this type be deleted? + bool m_bRenamable = false; bool m_bAlphabeticSort = false; @@ -221,6 +222,7 @@ public: bool IsEditable() const {return m_bEdit;} bool IsDeletable() const {return m_bDelete;} + bool IsRenamable() const {return m_bRenamable;} }; #endif diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index eff50a0ea76c..25186110de86 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -379,18 +379,22 @@ SwContentType::SwContentType(SwWrtShell* pShell, ContentTypeId nType, sal_uInt8 case ContentTypeId::TABLE: m_sTypeToken = "table"; m_bEdit = true; + m_bRenamable = true; break; case ContentTypeId::FRAME: m_sTypeToken = "frame"; m_bEdit = true; + m_bRenamable = true; break; case ContentTypeId::GRAPHIC: m_sTypeToken = "graphic"; m_bEdit = true; + m_bRenamable = true; break; case ContentTypeId::OLE: m_sTypeToken = "ole"; m_bEdit = true; + m_bRenamable = true; break; case ContentTypeId::TEXTFIELD: m_bEdit = true; @@ -407,16 +411,19 @@ SwContentType::SwContentType(SwWrtShell* pShell, ContentTypeId nType, sal_uInt8 DocumentSettingId::PROTECT_BOOKMARKS); m_bEdit = true; m_bDelete = !bProtectedBM; + m_bRenamable = !bProtectedBM; } break; case ContentTypeId::REGION: m_sTypeToken = "region"; m_bEdit = true; m_bDelete = true; + m_bRenamable = true; break; case ContentTypeId::INDEX: m_bEdit = true; m_bDelete = true; + m_bRenamable = true; break; case ContentTypeId::REFERENCE: m_bEdit = false; @@ -432,6 +439,7 @@ SwContentType::SwContentType(SwWrtShell* pShell, ContentTypeId nType, sal_uInt8 case ContentTypeId::DRAWOBJECT: m_sTypeToken = "drawingobject"; m_bEdit = true; + m_bRenamable = true; break; default: break; } @@ -1819,15 +1827,11 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) ((bVisible && !bProtected) || ContentTypeId::REGION == nContentType); const bool bDeletable = pType->IsDeletable() && ((bVisible && !bProtected && !bProtectBM) || ContentTypeId::REGION == nContentType); - const bool bRenamable = bEditable && !bReadonly && - (ContentTypeId::TABLE == nContentType || - ContentTypeId::FRAME == nContentType || - ContentTypeId::GRAPHIC == nContentType || - ContentTypeId::OLE == nContentType || - (ContentTypeId::BOOKMARK == nContentType && !bProtectBM) || - ContentTypeId::REGION == nContentType || - ContentTypeId::INDEX == nContentType || - ContentTypeId::DRAWOBJECT == nContentType); + const bool bRenamable + = !bReadonly + && (pType->IsRenamable() + || (ContentTypeId::BOOKMARK == nContentType && !bProtectBM)); + // Choose which Delete entry to show. if (bDeletable) { @@ -1932,12 +1936,11 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) xPop->set_active("protectsection", bProtected); xPop->set_active("hidesection", bHidden); } - else if (bEditable) + else bRemoveEditEntry = false; - //Rename object - if (bRenamable) - bRemoveRenameEntry = false; } + if (bRenamable) + bRemoveRenameEntry = false; } else {