summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2023-11-18 18:56:56 -0900
committerJim Raykowski <raykowj@gmail.com>2023-11-29 04:24:57 +0100
commit01a02ee7f1dbe7501a89b41e62599fba6a8b33f3 (patch)
tree35e6feefa9754a85284fafeefe4a6c220c009029 /sw
parent20cbe88ce5610fd8ee302e5780a4c0821ddb3db4 (diff)
tdf#157681 SwNavigator: Add Protect and Hide menu items to Sections
context menu Change-Id: I6a79c06abe2cf4dd44d491046d8ee73d35dfe6ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159718 Tested-by: Jenkins Reviewed-by: Jim Raykowski <raykowj@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/inc/content.hxx2
-rw-r--r--sw/source/uibase/utlui/content.cxx44
-rw-r--r--sw/uiconfig/swriter/ui/navigatorcontextmenu.ui16
3 files changed, 58 insertions, 4 deletions
diff --git a/sw/source/uibase/inc/content.hxx b/sw/source/uibase/inc/content.hxx
index 77cb156b744c..c6698f4b0322 100644
--- a/sw/source/uibase/inc/content.hxx
+++ b/sw/source/uibase/inc/content.hxx
@@ -72,6 +72,8 @@ class SwRegionContent final : public SwContent
m_nRegionLevel(nLevel), m_pSectionFormat(pSectionFormat){}
sal_uInt8 GetRegionLevel() const {return m_nRegionLevel;}
const SwSectionFormat* GetSectionFormat() const {return m_pSectionFormat;}
+
+ bool IsProtect() const override;
};
class SwURLFieldContent final : public SwContent
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index 07fd64dc3bf9..ff354273ff82 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -260,6 +260,11 @@ bool SwURLFieldContent::IsProtect() const
return m_pINetAttr->IsProtect();
}
+bool SwRegionContent::IsProtect() const
+{
+ return m_pSectionFormat->GetSection()->IsProtect();
+}
+
SwGraphicContent::~SwGraphicContent()
{
}
@@ -810,7 +815,7 @@ void SwContentType::FillMemberList(bool* pbContentChanged)
m_bAlphabeticSort ? 0 : getYPos(pNodeIndex->GetNode()),
pFormat));
- if(!pFormat->IsVisible())
+ if (!pFormat->IsVisible() || pSection->IsHidden())
pCnt->SetInvisible();
m_pMember->insert(std::move(pCnt));
}
@@ -1718,6 +1723,9 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool)
bool bRemoveSortEntry = true;
+ bool bRemoveProtectSection = true;
+ bool bRemoveHideSection = true;
+
if (xEntry)
{
const SwContentType* pType;
@@ -1811,7 +1819,8 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool)
&& m_pActiveShell->getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_BOOKMARKS);
const bool bEditable = pType->IsEditable() &&
((bVisible && !bProtected) || ContentTypeId::REGION == nContentType);
- const bool bDeletable = pType->IsDeletable() && bVisible && !bProtected && !bProtectBM;
+ const bool bDeletable = pType->IsDeletable()
+ && ((bVisible && !bProtected && !bProtectBM) || ContentTypeId::REGION == nContentType);
const bool bRenamable = bEditable && !bReadonly &&
(ContentTypeId::TABLE == nContentType ||
ContentTypeId::FRAME == nContentType ||
@@ -1913,8 +1922,17 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool)
}
else if(ContentTypeId::REGION == nContentType)
{
- bRemoveSelectEntry = false;
bRemoveEditEntry = false;
+ bRemoveProtectSection = false;
+ bRemoveHideSection = false;
+ SwContent* pCnt = weld::fromId<SwContent*>(m_xTreeView->get_id(*xEntry));
+ assert(dynamic_cast<SwRegionContent*>(static_cast<SwTypeNumber*>(pCnt)));
+ const SwSectionFormat* pSectionFormat
+ = static_cast<SwRegionContent*>(pCnt)->GetSectionFormat();
+ bool bHidden = pSectionFormat->GetSection()->IsHidden();
+ bRemoveSelectEntry = bHidden || !bVisible;
+ xPop->set_active("protectsection", bProtected);
+ xPop->set_active("hidesection", bHidden);
}
else if (bEditable)
bRemoveEditEntry = false;
@@ -2106,6 +2124,10 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool)
xPop->remove("endnotetracking");
if (bRemoveSortEntry)
xPop->remove("sort");
+ if (bRemoveProtectSection)
+ xPop->remove("protectsection");
+ if (bRemoveHideSection)
+ xPop->remove("hidesection");
bool bSetSensitiveCollapseAllCategories = false;
if (!m_bIsRoot && xEntry)
@@ -4811,7 +4833,21 @@ void SwContentTree::ExecuteContextMenuAction(const OUString& rSelectedPopupEntry
if (!m_xTreeView->get_selected(xFirst.get()))
return; // this shouldn't happen, but better to be safe than ...
- if (rSelectedPopupEntry == "sort")
+ if (rSelectedPopupEntry == "protectsection" || rSelectedPopupEntry == "hidesection")
+ {
+ SwRegionContent* pCnt = weld::fromId<SwRegionContent*>(m_xTreeView->get_id(*xFirst));
+ assert(dynamic_cast<SwRegionContent*>(static_cast<SwTypeNumber*>(pCnt)));
+ const SwSectionFormat* pSectionFormat = pCnt->GetSectionFormat();
+ SwSection* pSection = pSectionFormat->GetSection();
+ SwSectionData aSectionData(*pSection);
+ if (rSelectedPopupEntry == "protectsection")
+ aSectionData.SetProtectFlag(!pSection->IsProtect());
+ else
+ aSectionData.SetHidden(!pSection->IsHidden());
+ m_pActiveShell->UpdateSection(m_pActiveShell->GetSectionFormatPos(*pSectionFormat),
+ aSectionData);
+ }
+ else if (rSelectedPopupEntry == "sort")
{
SwContentType* pCntType;
const OUString& rId(m_xTreeView->get_id(*xFirst));
diff --git a/sw/uiconfig/swriter/ui/navigatorcontextmenu.ui b/sw/uiconfig/swriter/ui/navigatorcontextmenu.ui
index 11400272371c..6ec00b4a20ee 100644
--- a/sw/uiconfig/swriter/ui/navigatorcontextmenu.ui
+++ b/sw/uiconfig/swriter/ui/navigatorcontextmenu.ui
@@ -254,6 +254,22 @@
</object>
</child>
<child>
+ <object class="GtkCheckMenuItem" id="protectsection">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes" context="navigatorcontextmenu|STR_PROTECT_SECTION">Protect Section</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkCheckMenuItem" id="hidesection">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes" context="navigatorcontextmenu|STR_HIDE_SECTION">Hide Section</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ <child>
<object class="GtkMenuItem" id="600">
<property name="visible">True</property>
<property name="can-focus">False</property>