summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2024-04-20 09:14:00 -0800
committerJim Raykowski <raykowj@gmail.com>2024-04-24 21:36:57 +0200
commit74bd60c433cdc135d8a465eb5cea8ee6ce84b436 (patch)
tree86d447df8564aad21d7c5cf5c498f7d6803498f3 /sw/source
parentf91e8fe61f15f0365cc65183d3fb3573d5215d3f (diff)
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 <raykowj@gmail.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/uibase/inc/content.hxx2
-rw-r--r--sw/source/uibase/utlui/content.cxx29
2 files changed, 18 insertions, 13 deletions
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
{