sw/source/uibase/utlui/content.cxx | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)
New commits: commit dfb863c70fb0e924fdd053089a40cbcdd3dc5839 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Sun Dec 10 12:48:48 2023 +0000 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Dec 11 20:40:50 2023 +0100 cid#1558174 Bad bit shift operation and cid#1558175 Bad bit shift operation Change-Id: I44d6f351716cf722abcd19ff866bc247ba9f5cd0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160538 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit 3f02996475aef76f4e4c7fbe1701534a154d3fe1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160572 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index d7e0a61d0b33..8d46ef52303a 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -2428,14 +2428,19 @@ void SwContentTree::Expand(const weld::TreeIter& rParent, { // m_nActiveBlock and m_nHiddenBlock are used to persist the content type expand state for // the all content view mode - const sal_Int32 nOr = 1 << static_cast<int>(eParentContentTypeId); //linear -> Bitposition - if (State::HIDDEN != m_eState) + const int nShift = static_cast<int>(eParentContentTypeId); + SAL_WARN_IF(nShift < 0, "sw.ui", "ContentTypeId::UNKNOWN negative shift"); + if (nShift >= 0) { - m_nActiveBlock |= nOr; - m_pConfig->SetActiveBlock(m_nActiveBlock); + const sal_Int32 nOr = 1 << nShift; //linear -> Bitposition + if (State::HIDDEN != m_eState) + { + m_nActiveBlock |= nOr; + m_pConfig->SetActiveBlock(m_nActiveBlock); + } + else + m_nHiddenBlock |= nOr; } - else - m_nHiddenBlock |= nOr; } if (m_nRootType == ContentTypeId::OUTLINE || (m_nRootType == ContentTypeId::UNKNOWN && @@ -2599,14 +2604,19 @@ IMPL_LINK(SwContentTree, CollapseHdl, const weld::TreeIter&, rParent, bool) } ContentTypeId eContentTypeId = weld::fromId<SwContentType*>(m_xTreeView->get_id(rParent))->GetType(); - const sal_Int32 nAnd = ~(1 << static_cast<int>(eContentTypeId)); - if (State::HIDDEN != m_eState) + const int nShift = static_cast<int>(eContentTypeId); + SAL_WARN_IF(nShift < 0, "sw.ui", "ContentTypeId::UNKNOWN negative shift"); + if (nShift >= 0) { - m_nActiveBlock &= nAnd; - m_pConfig->SetActiveBlock(m_nActiveBlock); + const sal_Int32 nAnd = ~(1 << nShift); + if (State::HIDDEN != m_eState) + { + m_nActiveBlock &= nAnd; + m_pConfig->SetActiveBlock(m_nActiveBlock); + } + else + m_nHiddenBlock &= nAnd; } - else - m_nHiddenBlock &= nAnd; } else // content entry {