summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2023-12-10 12:48:48 +0000
committerXisco Fauli <xiscofauli@libreoffice.org>2023-12-11 20:40:50 +0100
commitdfb863c70fb0e924fdd053089a40cbcdd3dc5839 (patch)
tree624f67e950dc5964772802ed7eb04c5fd8c3c066 /sw
parent62df2dc0192653d5b62fa8ad84f9f9b53514cf5f (diff)
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.mcnamara@collabora.com> (cherry picked from commit 3f02996475aef76f4e4c7fbe1701534a154d3fe1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160572 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/utlui/content.cxx34
1 files changed, 22 insertions, 12 deletions
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
{