diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-07-31 07:41:52 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-07-31 09:54:12 +0200 |
commit | a1be5ede8e7a8042683efa10b823d952e1bd9513 (patch) | |
tree | b909b353af77ec92e5150c88545e5c7c3fb2a26a /sc | |
parent | 07d357756922e35220a924dab82d315fea22cecb (diff) |
reduce number of GetItem calls
if we already call GetItemState, we can use that call to fetch the item
Change-Id: I736dec9bb56ad3bd66bb53e1cef2cf1e3092821d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171269
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/documen4.cxx | 5 | ||||
-rw-r--r-- | sc/source/core/data/table4.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/view/viewdata.cxx | 7 |
4 files changed, 14 insertions, 10 deletions
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index 74a66449ec40..c450e698ecba 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -747,9 +747,10 @@ const SfxPoolItem* ScDocument::GetEffItem( if ( pPattern ) { const SfxItemSet& rSet = pPattern->GetItemSet(); - if ( rSet.GetItemState( ATTR_CONDITIONAL ) == SfxItemState::SET ) + const ScCondFormatItem* pConditionalItem = nullptr; + if ( rSet.GetItemState( ATTR_CONDITIONAL, true, &pConditionalItem ) == SfxItemState::SET ) { - const ScCondFormatIndexes& rIndex = pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData(); + const ScCondFormatIndexes& rIndex = pConditionalItem->GetCondFormatData(); ScConditionalFormatList* pCondFormList = GetCondFormList( nTab ); if (!rIndex.empty() && pCondFormList) { diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index a400762d1ca2..56588d6df5fb 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -279,9 +279,10 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, for (SCSIZE i = 0; i < nCount; ++i) { const ScPatternAttr* pPattern = GetPattern(nColCurr, nRowCurr); + const ScMergeFlagAttr* pMergeFlagItem = nullptr; bool bOverlapped - = pPattern->GetItemSet().GetItemState(ATTR_MERGE_FLAG, false) == SfxItemState::SET - && pPattern->GetItem(ATTR_MERGE_FLAG).IsOverlapped(); + = pPattern->GetItemSet().GetItemState(ATTR_MERGE_FLAG, false, &pMergeFlagItem) == SfxItemState::SET + && pMergeFlagItem->IsOverlapped(); if (bOverlapped) bHasOverlappedCells = true; diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 421733bfecdb..24f9a5270361 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1237,12 +1237,13 @@ OString ScPostIt::NoteRangeToJsonString(const ScDocument& rDoc, const ScAddress& SCROW nY(rPos.Row()); OString aStartCellAddress(OString::number(nX) + " " + OString::number(nY)); const ScPatternAttr* pMarkPattern = rDoc.GetPattern(nX, nY, rPos.Tab()); - if (pMarkPattern && pMarkPattern->GetItemSet().GetItemState(ATTR_MERGE, false) == SfxItemState::SET) + const ScMergeAttr* pMergeItem = nullptr; + if (pMarkPattern && pMarkPattern->GetItemSet().GetItemState(ATTR_MERGE, false, &pMergeItem) == SfxItemState::SET) { - SCCOL nCol = pMarkPattern->GetItem(ATTR_MERGE).GetColMerge(); + SCCOL nCol = pMergeItem->GetColMerge(); if (nCol > 1) nX += nCol - 1; - SCROW nRow = pMarkPattern->GetItem(ATTR_MERGE).GetRowMerge(); + SCROW nRow = pMergeItem->GetRowMerge(); if (nRow > 1) nY += nRow - 1; } diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 40e9ce7a9d5a..102c7ad9adb1 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -1158,10 +1158,11 @@ ScMarkType ScViewData::GetSimpleArea( ScRange & rRange, ScMarkData & rNewMark ) if (eMarkType == SC_MARK_NONE) eMarkType = SC_MARK_SIMPLE; const ScPatternAttr* pMarkPattern = mrDoc.GetPattern(GetCurX(), GetCurY(), GetTabNo()); - if (pMarkPattern && pMarkPattern->GetItemSet().GetItemState(ATTR_MERGE, false) == SfxItemState::SET) + const ScMergeAttr* pMergeItem = nullptr; + if (pMarkPattern && pMarkPattern->GetItemSet().GetItemState(ATTR_MERGE, false, &pMergeItem) == SfxItemState::SET) { - SCROW nRow = pMarkPattern->GetItem(ATTR_MERGE).GetRowMerge(); - SCCOL nCol = pMarkPattern->GetItem(ATTR_MERGE).GetColMerge(); + SCROW nRow = pMergeItem->GetRowMerge(); + SCCOL nCol = pMergeItem->GetColMerge(); if ( nRow < 1 || nCol < 1 ) { // This kind of cells do exist. Not sure if that is intended or a bug. |