diff options
Diffstat (limited to 'sc')
38 files changed, 301 insertions, 326 deletions
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx index 521f3b7bb1d6..0d2457c0db25 100644 --- a/sc/inc/attarray.hxx +++ b/sc/inc/attarray.hxx @@ -84,7 +84,7 @@ struct ScAttrEntry const ScPatternAttr* pPattern; bool operator==( const ScAttrEntry& other ) const { - return nEndRow == other.nEndRow && pPattern == other.pPattern; + return nEndRow == other.nEndRow && SfxPoolItem::areSame(pPattern, other.pPattern); } }; diff --git a/sc/inc/attrib.hxx b/sc/inc/attrib.hxx index dc394dfb1c08..ec004f37d8b6 100644 --- a/sc/inc/attrib.hxx +++ b/sc/inc/attrib.hxx @@ -280,8 +280,6 @@ public: virtual ~ScCondFormatItem() override; virtual bool operator==(const SfxPoolItem& rCmp ) const override; - virtual bool operator<(const SfxPoolItem& rCmp) const override; - virtual bool IsSortable() const override { return true; } virtual ScCondFormatItem* Clone( SfxItemPool* = nullptr ) const override; const ScCondFormatIndexes& GetCondFormatData() const { return maIndex;} diff --git a/sc/inc/docpool.hxx b/sc/inc/docpool.hxx index 9280fb3602b0..c73d034f2fb2 100644 --- a/sc/inc/docpool.hxx +++ b/sc/inc/docpool.hxx @@ -47,7 +47,8 @@ public: OUString& rText, const IntlWrapper& rIntl ) const override; private: - virtual const SfxPoolItem& PutImpl( const SfxPoolItem&, sal_uInt16 nWhich = 0, bool bPassingOwnership = false ) override; + virtual void newItem_Callback(const SfxPoolItem& rItem) const override; + virtual bool newItem_UseDirect(const SfxPoolItem& rItem) const override; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx index eacb69fd640b..b5deb19826d9 100644 --- a/sc/inc/patattr.hxx +++ b/sc/inc/patattr.hxx @@ -56,7 +56,7 @@ class SC_DLLPUBLIC ScPatternAttr final : public SfxSetItem mutable std::optional<sal_uInt32> mxHashCode; mutable std::optional<bool> mxVisible; ScStyleSheet* pStyle; - sal_uInt64 mnKey; + sal_uInt64 mnPAKey; public: ScPatternAttr(SfxItemSet&& pItemSet, const OUString& rStyleName); ScPatternAttr(SfxItemSet&& pItemSet); @@ -66,9 +66,6 @@ public: virtual ScPatternAttr* Clone( SfxItemPool *pPool = nullptr ) const override; virtual bool operator==(const SfxPoolItem& rCmp) const override; - // Class cannot be IsSortable() because it's mutable, implement at least Lookup(). - virtual bool HasLookup() const override { return true; } - virtual lookup_iterator Lookup(lookup_iterator begin, lookup_iterator end ) const override; const SfxPoolItem& GetItem( sal_uInt16 nWhichP ) const { return GetItemSet().Get(nWhichP); } @@ -181,8 +178,8 @@ public: Degree100 GetRotateVal( const SfxItemSet* pCondSet ) const; ScRotateDir GetRotateDir( const SfxItemSet* pCondSet ) const; - void SetKey(sal_uInt64 nKey); - sal_uInt64 GetKey() const; + void SetPAKey(sal_uInt64 nKey); + sal_uInt64 GetPAKey() const; static std::optional<bool> FastEqualPatternSets( const SfxItemSet& rSet1, const SfxItemSet& rSet2 ); diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index c7bfc3eb8198..a3e2d2ddd567 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -1211,7 +1211,7 @@ CPPUNIT_TEST_FIXTURE(Test, testHorizontalAttrIterator) size_t nCheckPos = 0; for (const ScPatternAttr* pAttr = aIter.GetNext(nCol1, nCol2, nRow); pAttr; pAttr = aIter.GetNext(nCol1, nCol2, nRow)) { - if( pAttr == m_pDoc->GetDefPattern()) + if (SfxPoolItem::areSame( pAttr, m_pDoc->GetDefPattern())) continue; CPPUNIT_ASSERT_MESSAGE("Iteration longer than expected.", nCheckPos < nCheckLen); CPPUNIT_ASSERT_EQUAL(aChecks[nCheckPos][0], static_cast<int>(nCol1)); @@ -1302,7 +1302,7 @@ CPPUNIT_TEST_FIXTURE(Test, testIteratorsDefPattern) CPPUNIT_ASSERT_EQUAL(SCCOL(102 + 1), m_pDoc->GetAllocatedColumnsCount(0)); const ScPatternAttr* pattern = m_pDoc->GetPattern(100, 0, 0); const ScPatternAttr* defPattern = m_pDoc->GetDefPattern(); - CPPUNIT_ASSERT(pattern != defPattern); + CPPUNIT_ASSERT(!SfxPoolItem::areSame(pattern, defPattern)); CPPUNIT_ASSERT_EQUAL(pattern, m_pDoc->GetPattern(102, 0, 0)); CPPUNIT_ASSERT_EQUAL(defPattern, m_pDoc->GetPattern(101, 0, 0)); CPPUNIT_ASSERT_EQUAL(defPattern, m_pDoc->GetPattern(103, 0, 0)); diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index b6d062b93d66..3e56226f3704 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -63,7 +63,7 @@ ScAttrArray::ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument& rDoc, ScAttr { mvData[nIdx].nEndRow = pDefaultColAttrArray->mvData[nIdx].nEndRow; ScPatternAttr aNewPattern( *(pDefaultColAttrArray->mvData[nIdx].pPattern) ); - mvData[nIdx].pPattern = &rDocument.GetPool()->Put( aNewPattern ); + mvData[nIdx].pPattern = &rDocument.GetPool()->DirectPutItemInPool( aNewPattern ); bool bNumFormatChanged = false; if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged, mvData[nIdx].pPattern->GetItemSet(), rDocument.GetDefPattern()->GetItemSet() ) ) @@ -83,7 +83,7 @@ ScAttrArray::~ScAttrArray() ScDocumentPool* pDocPool = rDocument.GetPool(); for (auto const & rEntry : mvData) - pDocPool->Remove(*rEntry.pPattern); + pDocPool->DirectRemoveItemFromPool(*rEntry.pPattern); } #if DEBUG_SC_TESTATTRARRAY @@ -140,14 +140,14 @@ void ScAttrArray::Reset( const ScPatternAttr* pPattern ) rDocument.InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged ); } } - pDocPool->Remove(*pOldPattern); + pDocPool->DirectRemoveItemFromPool(*pOldPattern); } mvData.resize(0); rDocument.SetStreamValid(nTab, false); mvData.resize(1); - const ScPatternAttr* pNewPattern = &pDocPool->Put(*pPattern); + const ScPatternAttr* pNewPattern = &pDocPool->DirectPutItemInPool(*pPattern); mvData[0].nEndRow = rDocument.MaxRow(); mvData[0].pPattern = pNewPattern; } @@ -159,10 +159,10 @@ bool ScAttrArray::Concat(SCSIZE nPos) { if (nPos > 0) { - if (mvData[nPos - 1].pPattern == mvData[nPos].pPattern) + if (SfxPoolItem::areSame(mvData[nPos - 1].pPattern, mvData[nPos].pPattern)) { mvData[nPos - 1].nEndRow = mvData[nPos].nEndRow; - rDocument.GetPool()->Remove(*mvData[nPos].pPattern); + rDocument.GetPool()->DirectRemoveItemFromPool(*mvData[nPos].pPattern); mvData.erase(mvData.begin() + nPos); nPos--; bRet = true; @@ -170,10 +170,10 @@ bool ScAttrArray::Concat(SCSIZE nPos) } if (nPos + 1 < mvData.size()) { - if (mvData[nPos + 1].pPattern == mvData[nPos].pPattern) + if (SfxPoolItem::areSame(mvData[nPos + 1].pPattern, mvData[nPos].pPattern)) { mvData[nPos].nEndRow = mvData[nPos + 1].nEndRow; - rDocument.GetPool()->Remove(*mvData[nPos].pPattern); + rDocument.GetPool()->DirectRemoveItemFromPool(*mvData[nPos].pPattern); mvData.erase(mvData.begin() + nPos + 1); bRet = true; } @@ -459,9 +459,9 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd if (bPutToPool) { if (bPassingOwnership) - pPattern = &rDocument.GetPool()->Put(std::unique_ptr<ScPatternAttr>(const_cast<ScPatternAttr*>(pPattern))); + pPattern = &rDocument.GetPool()->DirectPutItemInPool(std::unique_ptr<ScPatternAttr>(const_cast<ScPatternAttr*>(pPattern))); else - pPattern = &rDocument.GetPool()->Put(*pPattern); + pPattern = &rDocument.GetPool()->DirectPutItemInPool(*pPattern); } if ((nStartRow == 0) && (nEndRow == rDocument.MaxRow())) Reset(pPattern); @@ -520,7 +520,7 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd if ( nStartRow > 0 ) { nInsert = rDocument.MaxRow() + 1; - if ( mvData[ni].pPattern != pPattern ) + if ( !SfxPoolItem::areSame(mvData[ni].pPattern, pPattern ) ) { if ( ni == 0 || (mvData[ni-1].nEndRow < nStartRow - 1) ) { // may be a split or a simple insert or just a shrink, @@ -533,7 +533,7 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd else if (mvData[ni - 1].nEndRow == nStartRow - 1) nInsert = ni; } - if ( ni > 0 && mvData[ni-1].pPattern == pPattern ) + if ( ni > 0 && SfxPoolItem::areSame(mvData[ni-1].pPattern, pPattern) ) { // combine mvData[ni-1].nEndRow = nEndRow; nInsert = rDocument.MaxRow() + 1; @@ -548,11 +548,11 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd nj++; if ( !bSplit ) { - if ( nj < mvData.size() && mvData[nj].pPattern == pPattern ) + if ( nj < mvData.size() && SfxPoolItem::areSame(mvData[nj].pPattern, pPattern ) ) { // combine if ( ni > 0 ) { - if ( mvData[ni-1].pPattern == pPattern ) + if ( SfxPoolItem::areSame(mvData[ni-1].pPattern, pPattern ) ) { // adjacent entries mvData[ni-1].nEndRow = mvData[nj].nEndRow; nj++; @@ -569,13 +569,13 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd ScDocumentPool* pDocPool = rDocument.GetPool(); if ( bSplit ) { // duplicate split entry in pool - pDocPool->Put( *mvData[ni-1].pPattern ); + pDocPool->DirectPutItemInPool( *mvData[ni-1].pPattern ); } if ( ni < nj ) { // remove middle entries for ( SCSIZE nk=ni; nk<nj; nk++) { // remove entries from pool - pDocPool->Remove( *mvData[nk].pPattern ); + pDocPool->DirectRemoveItemFromPool( *mvData[nk].pPattern ); } if ( !bCombined ) { // replace one entry @@ -681,8 +681,8 @@ void ScAttrArray::ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleS } } - rDocument.GetPool()->Remove(*mvData[nPos].pPattern); - mvData[nPos].pPattern = &rDocument.GetPool()->Put(*pNewPattern); + rDocument.GetPool()->DirectRemoveItemFromPool(*mvData[nPos].pPattern); + mvData[nPos].pPattern = &rDocument.GetPool()->DirectPutItemInPool(*pNewPattern); if (Concat(nPos)) Search(nStart, nPos); else @@ -818,9 +818,9 @@ void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow, else { // remove from pool ? - rDocument.GetPool()->Remove(*mvData[nPos].pPattern); + rDocument.GetPool()->DirectRemoveItemFromPool(*mvData[nPos].pPattern); mvData[nPos].pPattern = - &rDocument.GetPool()->Put(std::move(pNewPattern)); + &rDocument.GetPool()->DirectPutItemInPool(std::move(pNewPattern)); if (Concat(nPos)) Search(nStart, nPos); @@ -862,7 +862,7 @@ void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCac { const ScPatternAttr* pOldPattern = mvData[nPos].pPattern; const ScPatternAttr* pNewPattern = static_cast<const ScPatternAttr*>( &pCache->ApplyTo( *pOldPattern ) ); - if (pNewPattern != pOldPattern) + if (!SfxPoolItem::areSame(pNewPattern, pOldPattern)) { SCROW nY1 = nStart; SCROW nY2 = mvData[nPos].nEndRow; @@ -897,7 +897,7 @@ void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCac } } - rDocument.GetPool()->Remove(*mvData[nPos].pPattern); + rDocument.GetPool()->DirectRemoveItemFromPool(*mvData[nPos].pPattern); mvData[nPos].pPattern = pNewPattern; if (Concat(nPos)) Search(nStart, nPos); @@ -924,7 +924,7 @@ void ScAttrArray::SetAttrEntries(std::vector<ScAttrEntry> && vNewData) { ScDocumentPool* pDocPool = rDocument.GetPool(); for (auto const & rEntry : mvData) - pDocPool->Remove(*rEntry.pPattern); + pDocPool->DirectRemoveItemFromPool(*rEntry.pPattern); mvData = std::move(vNewData); @@ -961,7 +961,7 @@ static void lcl_MergeDeep( SfxItemSet& rMergeSet, const SfxItemSet& rSource ) SfxItemState eNewState = rSource.GetItemState( nId, true, &pNewItem ); if ( eNewState == SfxItemState::SET ) { - if ( pNewItem != pOldItem ) // Both pulled + if ( !SfxPoolItem::areSame(pNewItem, pOldItem) ) // Both pulled rMergeSet.InvalidateItem( nId ); } else // Default @@ -996,7 +996,7 @@ void ScAttrArray::MergePatternArea( SCROW nStartRow, SCROW nEndRow, pPattern = mvData[nPos].pPattern; else pPattern = rDocument.GetDefPattern(); - if ( pPattern != rState.pOld1 && pPattern != rState.pOld2 ) + if ( !SfxPoolItem::areSame(pPattern, rState.pOld1) && !SfxPoolItem::areSame(pPattern, rState.pOld2) ) { const SfxItemSet& rThisSet = pPattern->GetItemSet(); if (rState.pItemSet) @@ -1012,7 +1012,7 @@ void ScAttrArray::MergePatternArea( SCROW nStartRow, SCROW nEndRow, // first pattern - copied from parent rState.pItemSet.emplace( *rThisSet.GetPool(), rThisSet.GetRanges() ); rState.pItemSet->Set( rThisSet, bDeep ); - rState.mnPatternId = pPattern->GetKey(); + rState.mnPatternId = pPattern->GetPAKey(); } rState.pOld2 = rState.pOld1; @@ -1585,7 +1585,7 @@ void ScAttrArray::SetPatternAreaSafe( SCROW nStartRow, SCROW nEndRow, while ( nThisRow <= nEndRow ) { pOldPattern = mvData[nIndex].pPattern; - if (pOldPattern != pWantedPattern) // FIXME: else-branch? + if (!SfxPoolItem::areSame(pOldPattern, pWantedPattern)) // FIXME: else-branch? { if (nThisRow < nStartRow) nThisRow = nStartRow; nRow = mvData[nIndex].nEndRow; @@ -1610,7 +1610,7 @@ void ScAttrArray::SetPatternAreaSafe( SCROW nStartRow, SCROW nEndRow, bFirstUse = false; else // it's in the pool - rDocument.GetPool()->Put( *pWantedPattern ); + rDocument.GetPool()->DirectPutItemInPool( *pWantedPattern ); } SetPatternArea( nThisRow, nAttrRow, pWantedPattern ); } @@ -1843,13 +1843,13 @@ void ScAttrArray::FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBo if (bReset) { ScPatternAttr aNewPattern(*mvData[nPos].pPattern); - rDocument.GetPool()->Remove(*mvData[nPos].pPattern); + rDocument.GetPool()->DirectRemoveItemFromPool(*mvData[nPos].pPattern); aNewPattern.SetStyleSheet( static_cast<ScStyleSheet*>( rDocument.GetStyleSheetPool()-> Find( ScResId(STR_STYLENAME_STANDARD), SfxStyleFamily::Para, SfxStyleSearchBits::Auto | SfxStyleSearchBits::ScStandard ) ) ); - mvData[nPos].pPattern = &rDocument.GetPool()->Put(aNewPattern); + mvData[nPos].pPattern = &rDocument.GetPool()->DirectPutItemInPool(aNewPattern); if (Concat(nPos)) { @@ -1904,7 +1904,7 @@ bool ScAttrArray::IsEmpty() const if (mvData.size() == 1) { - return mvData[0].pPattern == rDocument.GetDefPattern(); + return SfxPoolItem::areSame(mvData[0].pPattern, rDocument.GetDefPattern()); } else return false; @@ -2043,7 +2043,7 @@ bool ScAttrArray::IsVisibleEqual( const ScAttrArray& rOther, { const ScPatternAttr* pDefPattern1 = rDocument.GetDefPattern(); const ScPatternAttr* pDefPattern2 = rOther.rDocument.GetDefPattern(); - return ( pDefPattern1 == pDefPattern2 || pDefPattern1->IsVisibleEqual( *pDefPattern2 ) ); + return ( SfxPoolItem::areSame(pDefPattern1, pDefPattern2) || pDefPattern1->IsVisibleEqual( *pDefPattern2 ) ); } { @@ -2073,7 +2073,7 @@ bool ScAttrArray::IsVisibleEqual( const ScAttrArray& rOther, while ( nPos < pNonDefault->Count() && bEqual ) { const ScPatternAttr* pNonDefPattern = pNonDefault->mvData[nPos].pPattern; - bEqual = ( pNonDefPattern == pDefPattern || + bEqual = ( SfxPoolItem::areSame(pNonDefPattern, pDefPattern) || pNonDefPattern->IsVisibleEqual( *pDefPattern ) ); if ( pNonDefault->mvData[nPos].nEndRow >= nEndRow ) break; @@ -2098,7 +2098,7 @@ bool ScAttrArray::IsVisibleEqual( const ScAttrArray& rOther, SCROW nOtherRow = rOther.mvData[nOtherPos].nEndRow; const ScPatternAttr* pThisPattern = mvData[nThisPos].pPattern; const ScPatternAttr* pOtherPattern = rOther.mvData[nOtherPos].pPattern; - bEqual = ( pThisPattern == pOtherPattern || + bEqual = ( SfxPoolItem::areSame(pThisPattern, pOtherPattern) || pThisPattern->IsVisibleEqual(*pOtherPattern) ); if ( nThisRow >= nOtherRow ) @@ -2123,7 +2123,7 @@ bool ScAttrArray::IsAllEqual( const ScAttrArray& rOther, SCROW nStartRow, SCROW { const ScPatternAttr* pDefPattern1 = rDocument.GetDefPattern(); const ScPatternAttr* pDefPattern2 = rOther.rDocument.GetDefPattern(); - return ( pDefPattern1 == pDefPattern2 ); + return SfxPoolItem::areSame(pDefPattern1, pDefPattern2); } { @@ -2153,7 +2153,7 @@ bool ScAttrArray::IsAllEqual( const ScAttrArray& rOther, SCROW nStartRow, SCROW while ( nPos < pNonDefault->Count() && bEqual ) { const ScPatternAttr* pNonDefPattern = pNonDefault->mvData[nPos].pPattern; - bEqual = ( pNonDefPattern == pDefPattern ); + bEqual = SfxPoolItem::areSame( pNonDefPattern, pDefPattern ); if ( pNonDefault->mvData[nPos].nEndRow >= nEndRow ) break; ++nPos; @@ -2177,7 +2177,7 @@ bool ScAttrArray::IsAllEqual( const ScAttrArray& rOther, SCROW nStartRow, SCROW SCROW nOtherRow = rOther.mvData[nOtherPos].nEndRow; const ScPatternAttr* pThisPattern = mvData[nThisPos].pPattern; const ScPatternAttr* pOtherPattern = rOther.mvData[nOtherPos].pPattern; - bEqual = ( pThisPattern == pOtherPattern ); + bEqual = SfxPoolItem::areSame( pThisPattern, pOtherPattern ); if ( nThisRow >= nOtherRow ) { @@ -2323,7 +2323,7 @@ void ScAttrArray::DeleteRow( SCROW nStartRow, SCSIZE nSize ) { DeleteRange( nStartIndex, nEndIndex ); if (nStartIndex > 0) - if ( mvData[nStartIndex-1].pPattern == mvData[nStartIndex].pPattern ) + if ( SfxPoolItem::areSame( mvData[nStartIndex-1].pPattern, mvData[nStartIndex].pPattern ) ) DeleteRange( nStartIndex-1, nStartIndex-1 ); } } @@ -2341,7 +2341,7 @@ void ScAttrArray::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex ) SetDefaultIfNotInit(); ScDocumentPool* pDocPool = rDocument.GetPool(); for (SCSIZE i = nStartIndex; i <= nEndIndex; i++) - pDocPool->Remove(*mvData[i].pPattern); + pDocPool->DirectRemoveItemFromPool(*mvData[i].pPattern); mvData.erase(mvData.begin() + nStartIndex, mvData.begin() + nEndIndex + 1); } @@ -2468,14 +2468,14 @@ void ScAttrArray::CopyArea( aTmpPattern.GetItemSet().ClearItem( ATTR_MERGE_FLAG ); if (bSamePool) - pNewPattern = &pDestDocPool->Put(aTmpPattern); + pNewPattern = &pDestDocPool->DirectPutItemInPool(aTmpPattern); else pNewPattern = aTmpPattern.PutInPool( &rAttrArray.rDocument, &rDocument ); } else { if (bSamePool) - pNewPattern = &pDestDocPool->Put(*pOldPattern); + pNewPattern = &pDestDocPool->DirectPutItemInPool(*pOldPattern); else pNewPattern = pOldPattern->PutInPool( &rAttrArray.rDocument, &rDocument ); } @@ -2516,7 +2516,7 @@ void ScAttrArray::CopyAreaSafe( SCROW nStartRow, SCROW nEndRow, tools::Long nDy, { const ScPatternAttr* pNewPattern; if (bSamePool) - pNewPattern = &pDestDocPool->Put(*rDocument.GetDefPattern()); + pNewPattern = &pDestDocPool->DirectPutItemInPool(*rDocument.GetDefPattern()); else pNewPattern = rDocument.GetDefPattern()->PutInPool( &rAttrArray.rDocument, &rDocument ); @@ -2533,7 +2533,7 @@ void ScAttrArray::CopyAreaSafe( SCROW nStartRow, SCROW nEndRow, tools::Long nDy, const ScPatternAttr* pNewPattern; if (bSamePool) - pNewPattern = &pDestDocPool->Put(*pOldPattern); + pNewPattern = &pDestDocPool->DirectPutItemInPool(*pOldPattern); else pNewPattern = pOldPattern->PutInPool( &rAttrArray.rDocument, &rDocument ); diff --git a/sc/source/core/data/attrib.cxx b/sc/source/core/data/attrib.cxx index efe494c316a5..1a587d2b6572 100644 --- a/sc/source/core/data/attrib.cxx +++ b/sc/source/core/data/attrib.cxx @@ -733,21 +733,6 @@ bool ScCondFormatItem::operator==( const SfxPoolItem& rCmp ) const && memcmp(&maIndex.front(), &other.maIndex.front(), maIndex.size() * sizeof(sal_uInt32)) == 0; } -bool ScCondFormatItem::operator<( const SfxPoolItem& rCmp ) const -{ - auto const & other = static_cast<const ScCondFormatItem&>(rCmp); - if ( maIndex.size() < other.maIndex.size() ) - return true; - if ( maIndex.size() > other.maIndex.size() ) - return false; - if (maIndex.empty() && other.maIndex.empty()) - return false; - // memcmp is faster than operator< on std::vector - // Note that on little-endian this results in a confusing ordering (256 < 1), - // which technically doesn't matter as the ordering may be arbitrary. - return memcmp(&maIndex.front(), &other.maIndex.front(), maIndex.size() * sizeof(sal_uInt32)) < 0; -} - ScCondFormatItem* ScCondFormatItem::Clone(SfxItemPool*) const { return new ScCondFormatItem(maIndex); diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 7ffd5ae9c735..c448f79ae996 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -476,7 +476,7 @@ void ScColumn::ApplyPattern( SCROW nRow, const ScPatternAttr& rPatAttr ) const ScPatternAttr* pNewPattern = static_cast<const ScPatternAttr*>( &aCache.ApplyTo( *pPattern ) ); - if (pNewPattern != pPattern) + if (!SfxPoolItem::areSame(pNewPattern, pPattern)) pAttrArray->SetPattern( nRow, pNewPattern ); } @@ -628,12 +628,12 @@ void ScColumn::ApplyAttr( SCROW nRow, const SfxPoolItem& rAttr ) const ScPatternAttr* pOldPattern = pAttrArray->GetPattern( nRow ); ScPatternAttr aTemp(*pOldPattern); aTemp.GetItemSet().Put(rAttr); - const ScPatternAttr* pNewPattern = &pDocPool->Put( aTemp ); + const ScPatternAttr* pNewPattern = &pDocPool->DirectPutItemInPool( aTemp ); - if ( pNewPattern != pOldPattern ) + if (!SfxPoolItem::areSame( pNewPattern, pOldPattern )) pAttrArray->SetPattern( nRow, pNewPattern ); else - pDocPool->Remove( *pNewPattern ); // free up resources + pDocPool->DirectRemoveItemFromPool( *pNewPattern ); // free up resources } ScRefCellValue ScColumn::GetCellValue( SCROW nRow ) const diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index e7ca588a0b34..28d928cacea1 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -203,7 +203,7 @@ tools::Long ScColumn::GetNeededSize( } if (bNumeric) { - if (!bMayInvalidatePattern || pPattern == pOldPattern) + if (!bMayInvalidatePattern || SfxPoolItem::areSame(pPattern, pOldPattern)) bBreak = false; else { @@ -772,7 +772,7 @@ sal_uInt16 ScColumn::GetOptimalColWidth( // Or again in case there was a leading sep=";" row or two header // rows.. const ScPatternAttr* pNextPattern = GetPattern( ++nRow ); - if (pNextPattern != pPattern) + if (!SfxPoolItem::areSame(pNextPattern, pPattern)) nFormat = pNextPattern->GetNumberFormat( pFormatter ); } OUString aLongStr; @@ -830,7 +830,7 @@ sal_uInt16 ScColumn::GetOptimalColWidth( const ScPatternAttr* pPattern = GetPattern(nRow); aOptions.pPattern = pPattern; - aOptions.bGetFont = (pPattern != pOldPattern || nScript != SvtScriptType::NONE); + aOptions.bGetFont = (!SfxPoolItem::areSame(pPattern, pOldPattern) || nScript != SvtScriptType::NONE); pOldPattern = pPattern; sal_uInt16 nThis = static_cast<sal_uInt16>(GetNeededSize( nRow, pDev, nPPTX, nPPTY, rZoomX, rZoomY, true, aOptions, &pOldPattern)); @@ -1079,7 +1079,7 @@ void ScColumn::GetOptimalHeight( if (nHeight > rHeights.GetValue(nRow)) rHeights.SetValue(nRow, nRow, nHeight); // Pattern changed due to calculation? => sync. - if (pPattern != pOldPattern) + if (!SfxPoolItem::areSame(pPattern, pOldPattern)) { pPattern = aIter.Resync( nRow, nStart, nEnd); nNextEnd = 0; diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index 8e22b13a8e1e..324e54be2a92 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -1248,10 +1248,10 @@ void ScColumn::Swap( ScColumn& rOther, SCROW nRow1, SCROW nRow2, bool bPattern ) { const ScPatternAttr* pPat1 = GetPattern(nRow); const ScPatternAttr* pPat2 = rOther.GetPattern(nRow); - if (pPat1 != pPat2) + if (!SfxPoolItem::areSame(pPat1, pPat2)) { if (pPat1->GetRefCount() == 1) - pPat1 = &rOther.GetDoc().GetPool()->Put(*pPat1); + pPat1 = &rOther.GetDoc().GetPool()->DirectPutItemInPool(*pPat1); SetPattern(nRow, *pPat2); rOther.SetPattern(nRow, *pPat1); } diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index 5c0f0984b308..35c0d2caa8fd 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -1424,7 +1424,7 @@ void ScHorizontalAttrIterator::InitForNextRow(bool bInitialization) nMinNextEnd = pNextEnd[nPos]; // store positions of ScHorizontalAttrIterator elements (minimizing expensive ScPatternAttr comparisons) - if (i > nStartCol && ppPatterns[nThisHead] != ppPatterns[nPos]) + if (i > nStartCol && !SfxPoolItem::areSame(ppPatterns[nThisHead], ppPatterns[nPos])) { pHorizEnd[nThisHead] = i - 1; nThisHead = nPos; // start position of the next horizontal group diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx index 47c485e4f139..05dd88958288 100644 --- a/sc/source/core/data/docpool.cxx +++ b/sc/source/core/data/docpool.cxx @@ -88,96 +88,97 @@ SvxFontItem* getDefaultFontItem(LanguageType eLang, DefaultFontType nFontType, s SfxItemInfo const aItemInfos[] = { - { SID_ATTR_CHAR_FONT, true }, // ATTR_FONT - { SID_ATTR_CHAR_FONTHEIGHT, true }, // ATTR_FONT_HEIGHT - { SID_ATTR_CHAR_WEIGHT, true }, // ATTR_FONT_WEIGHT - { SID_ATTR_CHAR_POSTURE, true }, // ATTR_FONT_POSTURE - { SID_ATTR_CHAR_UNDERLINE, true }, // ATTR_FONT_UNDERLINE - { SID_ATTR_CHAR_OVERLINE, true }, // ATTR_FONT_OVERLINE - { SID_ATTR_CHAR_STRIKEOUT, true }, // ATTR_FONT_CROSSEDOUT - { SID_ATTR_CHAR_CONTOUR, true }, // ATTR_FONT_CONTOUR - { SID_ATTR_CHAR_SHADOWED, true }, // ATTR_FONT_SHADOWED - { SID_ATTR_CHAR_COLOR, true }, // ATTR_FONT_COLOR - { SID_ATTR_CHAR_LANGUAGE, true }, // ATTR_FONT_LANGUAGE - { SID_ATTR_CHAR_CJK_FONT, true }, // ATTR_CJK_FONT from 614 - { SID_ATTR_CHAR_CJK_FONTHEIGHT, true }, // ATTR_CJK_FONT_HEIGHT from 614 - { SID_ATTR_CHAR_CJK_WEIGHT, true }, // ATTR_CJK_FONT_WEIGHT from 614 - { SID_ATTR_CHAR_CJK_POSTURE, true }, // ATTR_CJK_FONT_POSTURE from 614 - { SID_ATTR_CHAR_CJK_LANGUAGE, true }, // ATTR_CJK_FONT_LANGUAGE from 614 - { SID_ATTR_CHAR_CTL_FONT, true }, // ATTR_CTL_FONT from 614 - { SID_ATTR_CHAR_CTL_FONTHEIGHT, true }, // ATTR_CTL_FONT_HEIGHT from 614 - { SID_ATTR_CHAR_CTL_WEIGHT, true }, // ATTR_CTL_FONT_WEIGHT from 614 - { SID_ATTR_CHAR_CTL_POSTURE, true }, // ATTR_CTL_FONT_POSTURE from 614 - { SID_ATTR_CHAR_CTL_LANGUAGE, true }, // ATTR_CTL_FONT_LANGUAGE from 614 - { SID_ATTR_CHAR_EMPHASISMARK, true }, // ATTR_FONT_EMPHASISMARK from 614 - { 0, true }, // ATTR_USERDEF from 614 / 641c - { SID_ATTR_CHAR_WORDLINEMODE, true }, // ATTR_FONT_WORDLINE from 632b - { SID_ATTR_CHAR_RELIEF, true }, // ATTR_FONT_RELIEF from 632b - { SID_ATTR_ALIGN_HYPHENATION, true }, // ATTR_HYPHENATE from 632b - { 0, true }, // ATTR_SCRIPTSPACE from 614d - { 0, true }, // ATTR_HANGPUNCTUATION from 614d - { SID_ATTR_PARA_FORBIDDEN_RULES,true }, // ATTR_FORBIDDEN_RULES from 614d - { SID_ATTR_ALIGN_HOR_JUSTIFY, true }, // ATTR_HOR_JUSTIFY - { SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD, true }, // ATTR_HOR_JUSTIFY_METHOD - { SID_ATTR_ALIGN_INDENT, true }, // ATTR_INDENT from 350 - { SID_ATTR_ALIGN_VER_JUSTIFY, true }, // ATTR_VER_JUSTIFY - { SID_ATTR_ALIGN_VER_JUSTIFY_METHOD, true }, // ATTR_VER_JUSTIFY_METHOD - { SID_ATTR_ALIGN_STACKED, true }, // ATTR_STACKED from 680/dr14 (replaces ATTR_ORIENTATION) - { SID_ATTR_ALIGN_DEGREES, true }, // ATTR_ROTATE_VALUE from 367 - { SID_ATTR_ALIGN_LOCKPOS, true }, // ATTR_ROTATE_MODE from 367 - { SID_ATTR_ALIGN_ASIANVERTICAL, true }, // ATTR_VERTICAL_ASIAN from 642 - { SID_ATTR_FRAMEDIRECTION, true }, // ATTR_WRITINGDIR from 643 - { SID_ATTR_ALIGN_LINEBREAK, true }, // ATTR_LINEBREAK - { SID_ATTR_ALIGN_SHRINKTOFIT, true }, // ATTR_SHRINKTOFIT from 680/dr14 - { SID_ATTR_BORDER_DIAG_TLBR, true }, // ATTR_BORDER_TLBR from 680/dr14 - { SID_ATTR_BORDER_DIAG_BLTR, true }, // ATTR_BORDER_BLTR from 680/dr14 - { SID_ATTR_ALIGN_MARGIN, true }, // ATTR_MARGIN - { 0, true }, // ATTR_MERGE - { 0, true }, // ATTR_MERGE_FLAG - { SID_ATTR_NUMBERFORMAT_VALUE, true }, // ATTR_VALUE_FORMAT - { 0, true }, // ATTR_LANGUAGE_FORMAT from 329, is combined with SID_ATTR_NUMBERFORMAT_VALUE in the dialog - { SID_ATTR_BRUSH, true }, // ATTR_BACKGROUND - { SID_SCATTR_PROTECTION, true }, // ATTR_PROTECTION - { SID_ATTR_BORDER_OUTER, true }, // ATTR_BORDER - { SID_ATTR_BORDER_INNER, true }, // ATTR_BORDER_INNER - { SID_ATTR_BORDER_SHADOW, true }, // ATTR_SHADOW - { 0, true }, // ATTR_VALIDDATA - { 0, true }, // ATTR_CONDITIONAL - { 0, true }, // ATTR_HYPERLINK - { 0, true }, // ATTR_PATTERN - { SID_ATTR_LRSPACE, true }, // ATTR_LRSPACE - { SID_ATTR_ULSPACE, true }, // ATTR_ULSPACE - { SID_ATTR_PAGE, true }, // ATTR_PAGE - { SID_ATTR_PAGE_PAPERBIN, true }, // ATTR_PAGE_PAPERBIN - { SID_ATTR_PAGE_SIZE, true }, // ATTR_PAGE_SIZE - { SID_ATTR_PAGE_EXT1, true }, // ATTR_PAGE_HORCENTER - { SID_ATTR_PAGE_EXT2, true }, // ATTR_PAGE_VERCENTER - { SID_ATTR_PAGE_ON, true }, // ATTR_PAGE_ON - { SID_ATTR_PAGE_DYNAMIC, true }, // ATTR_PAGE_DYNAMIC - { SID_ATTR_PAGE_SHARED, true }, // ATTR_PAGE_SHARED - { SID_ATTR_PAGE_SHARED_FIRST, true }, // ATTR_PAGE_SHARED_FIRST - { 0, true }, // ATTR_PAGE_NOTES aka. SID_SCATTR_PAGE_NOTES - { 0, true }, // ATTR_PAGE_GRID aka. SID_SCATTR_PAGE_GRID - { 0, true }, // ATTR_PAGE_HEADERS aka. SID_SCATTR_PAGE_HEADERS - { 0, true }, // ATTR_PAGE_CHARTS aka. SID_SCATTR_PAGE_CHARTS - { 0, true }, // ATTR_PAGE_OBJECTS aka. SID_SCATTR_PAGE_OBJECTS - { 0, true }, // ATTR_PAGE_DRAWINGS aka. SID_SCATTR_PAGE_DRAWINGS - { 0, true }, // ATTR_PAGE_TOPDOWN aka. SID_SCATTR_PAGE_TOPDOWN - { 0, true }, // ATTR_PAGE_SCALE aka SID_SCATTR_PAGE_SCALE - { 0, true }, // ATTR_PAGE_SCALETOPAGES aka SID_SCATTR_PAGE_SCALETOPAGES - { 0, true }, // ATTR_PAGE_FIRSTPAGENO aka SID_SCATTR_PAGE_FIRSTPAGENO - { 0, true }, // ATTR_PAGE_HEADERLEFT aka SID_SCATTR_PAGE_HEADERLEFT - { 0, true }, // ATTR_PAGE_FOOTERLEFT aka SID_SCATTR_PAGE_FOOTERLEFT - { 0, true }, // ATTR_PAGE_HEADERRIGHT aka SID_SCATTR_PAGE_HEADERRIGHT - { 0, true }, // ATTR_PAGE_FOOTERRIGHT aka. SID_SCATTR_PAGE_FOOTERRIGHT - { 0, true }, // ATTR_PAGE_HEADERFIRST aka. SID_SCATTR_PAGE_HEADERFIRST - { 0, true }, // ATTR_PAGE_FOOTERFIRST aka. SID_SCATTR_PAGE_FOOTERFIRST` - { SID_ATTR_PAGE_HEADERSET, true }, // ATTR_PAGE_HEADERSET - { SID_ATTR_PAGE_FOOTERSET, true }, // ATTR_PAGE_FOOTERSET - { 0, true }, // ATTR_PAGE_FORMULAS aka. SID_SCATTR_PAGE_FORMULAS - { 0, true }, // ATTR_PAGE_NULLVALS aka. SID_SCATTR_PAGE_NULLVALS - { 0, true }, // ATTR_PAGE_SCALETO aka. SID_SCATTR_PAGE_SCALETO - { 0, true } // ATTR_HIDDEN + // _nSID, _bNeedsPoolRegistration, _bShareable + { SID_ATTR_CHAR_FONT, true, true }, // ATTR_FONT + { SID_ATTR_CHAR_FONTHEIGHT, false, true }, // ATTR_FONT_HEIGHT + { SID_ATTR_CHAR_WEIGHT, false, true }, // ATTR_FONT_WEIGHT + { SID_ATTR_CHAR_POSTURE, false, true }, // ATTR_FONT_POSTURE + { SID_ATTR_CHAR_UNDERLINE, false, true }, // ATTR_FONT_UNDERLINE + { SID_ATTR_CHAR_OVERLINE, false, true }, // ATTR_FONT_OVERLINE + { SID_ATTR_CHAR_STRIKEOUT, false, true }, // ATTR_FONT_CROSSEDOUT + { SID_ATTR_CHAR_CONTOUR, false, true }, // ATTR_FONT_CONTOUR + { SID_ATTR_CHAR_SHADOWED, false, true }, // ATTR_FONT_SHADOWED + { SID_ATTR_CHAR_COLOR, true, true }, // ATTR_FONT_COLOR + { SID_ATTR_CHAR_LANGUAGE, false, true }, // ATTR_FONT_LANGUAGE + { SID_ATTR_CHAR_CJK_FONT, true, true }, // ATTR_CJK_FONT from 614 + { SID_ATTR_CHAR_CJK_FONTHEIGHT, false, true }, // ATTR_CJK_FONT_HEIGHT from 614 + { SID_ATTR_CHAR_CJK_WEIGHT, false, true }, // ATTR_CJK_FONT_WEIGHT from 614 + { SID_ATTR_CHAR_CJK_POSTURE, false, true }, // ATTR_CJK_FONT_POSTURE from 614 + { SID_ATTR_CHAR_CJK_LANGUAGE, false, true }, // ATTR_CJK_FONT_LANGUAGE from 614 + { SID_ATTR_CHAR_CTL_FONT, true, true }, // ATTR_CTL_FONT from 614 + { SID_ATTR_CHAR_CTL_FONTHEIGHT, false, true }, // ATTR_CTL_FONT_HEIGHT from 614 + { SID_ATTR_CHAR_CTL_WEIGHT, false, true }, // ATTR_CTL_FONT_WEIGHT from 614 + { SID_ATTR_CHAR_CTL_POSTURE, false, true }, // ATTR_CTL_FONT_POSTURE from 614 + { SID_ATTR_CHAR_CTL_LANGUAGE, false, true }, // ATTR_CTL_FONT_LANGUAGE from 614 + { SID_ATTR_CHAR_EMPHASISMARK, false, true }, // ATTR_FONT_EMPHASISMARK from 614 + { 0, true, true }, // ATTR_USERDEF from 614 / 641c + { SID_ATTR_CHAR_WORDLINEMODE, false, true }, // ATTR_FONT_WORDLINE from 632b + { SID_ATTR_CHAR_RELIEF, false, true }, // ATTR_FONT_RELIEF from 632b + { SID_ATTR_ALIGN_HYPHENATION, false, true }, // ATTR_HYPHENATE from 632b + { 0, false, true }, // ATTR_SCRIPTSPACE from 614d + { 0, false, true }, // ATTR_HANGPUNCTUATION from 614d + { SID_ATTR_PARA_FORBIDDEN_RULES, false, true }, // ATTR_FORBIDDEN_RULES from 614d + { SID_ATTR_ALIGN_HOR_JUSTIFY, false, true }, // ATTR_HOR_JUSTIFY + { SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD, false, true }, // ATTR_HOR_JUSTIFY_METHOD + { SID_ATTR_ALIGN_INDENT, false, true }, // ATTR_INDENT from 350 + { SID_ATTR_ALIGN_VER_JUSTIFY, false, true }, // ATTR_VER_JUSTIFY + { SID_ATTR_ALIGN_VER_JUSTIFY_METHOD, false, true }, // ATTR_VER_JUSTIFY_METHOD + { SID_ATTR_ALIGN_STACKED, false, true }, // ATTR_STACKED from 680/dr14 (replaces ATTR_ORIENTATION) + { SID_ATTR_ALIGN_DEGREES, true, true }, // ATTR_ROTATE_VALUE from 367 + { SID_ATTR_ALIGN_LOCKPOS, false, true }, // ATTR_ROTATE_MODE from 367 + { SID_ATTR_ALIGN_ASIANVERTICAL, false, true }, // ATTR_VERTICAL_ASIAN from 642 + { SID_ATTR_FRAMEDIRECTION, false, true }, // ATTR_WRITINGDIR from 643 + { SID_ATTR_ALIGN_LINEBREAK, false, true }, // ATTR_LINEBREAK + { SID_ATTR_ALIGN_SHRINKTOFIT, false, true }, // ATTR_SHRINKTOFIT from 680/dr14 + { SID_ATTR_BORDER_DIAG_TLBR, false, true }, // ATTR_BORDER_TLBR from 680/dr14 + { SID_ATTR_BORDER_DIAG_BLTR, false, true }, // ATTR_BORDER_BLTR from 680/dr14 + { SID_ATTR_ALIGN_MARGIN, false, true }, // ATTR_MARGIN + { 0, false, true }, // ATTR_MERGE + { 0, false, true }, // ATTR_MERGE_FLAG + { SID_ATTR_NUMBERFORMAT_VALUE, false, true }, // ATTR_VALUE_FORMAT + { 0, false, true }, // ATTR_LANGUAGE_FORMAT from 329, is combined with SID_ATTR_NUMBERFORMAT_VALUE in the dialog + { SID_ATTR_BRUSH, true, true }, // ATTR_BACKGROUND + { SID_SCATTR_PROTECTION, false, true }, // ATTR_PROTECTION + { SID_ATTR_BORDER_OUTER, false, true }, // ATTR_BORDER + { SID_ATTR_BORDER_INNER, false, true }, // ATTR_BORDER_INNER + { SID_ATTR_BORDER_SHADOW, false, true }, // ATTR_SHADOW + { 0, false, true }, // ATTR_VALIDDATA + { 0, false, true }, // ATTR_CONDITIONAL + { 0, false, true }, // ATTR_HYPERLINK + { 0, true, true }, // ATTR_PATTERN + { SID_ATTR_LRSPACE, false, true }, // ATTR_LRSPACE + { SID_ATTR_ULSPACE, false, true }, // ATTR_ULSPACE + { SID_ATTR_PAGE, false, true }, // ATTR_PAGE + { SID_ATTR_PAGE_PAPERBIN, false, true }, // ATTR_PAGE_PAPERBIN + { SID_ATTR_PAGE_SIZE, false, true }, // ATTR_PAGE_SIZE + { SID_ATTR_PAGE_EXT1, false, true }, // ATTR_PAGE_HORCENTER + { SID_ATTR_PAGE_EXT2, false, true }, // ATTR_PAGE_VERCENTER + { SID_ATTR_PAGE_ON, false, true }, // ATTR_PAGE_ON + { SID_ATTR_PAGE_DYNAMIC, false, true }, // ATTR_PAGE_DYNAMIC + { SID_ATTR_PAGE_SHARED, false, true }, // ATTR_PAGE_SHARED + { SID_ATTR_PAGE_SHARED_FIRST, false, true }, // ATTR_PAGE_SHARED_FIRST + { 0, false, true }, // ATTR_PAGE_NOTES aka. SID_SCATTR_PAGE_NOTES + { 0, false, true }, // ATTR_PAGE_GRID aka. SID_SCATTR_PAGE_GRID + { 0, false, true }, // ATTR_PAGE_HEADERS aka. SID_SCATTR_PAGE_HEADERS + { 0, false, true }, // ATTR_PAGE_CHARTS aka. SID_SCATTR_PAGE_CHARTS + { 0, false, true }, // ATTR_PAGE_OBJECTS aka. SID_SCATTR_PAGE_OBJECTS + { 0, false, true }, // ATTR_PAGE_DRAWINGS aka. SID_SCATTR_PAGE_DRAWINGS + { 0, false, true }, // ATTR_PAGE_TOPDOWN aka. SID_SCATTR_PAGE_TOPDOWN + { 0, false, true }, // ATTR_PAGE_SCALE aka SID_SCATTR_PAGE_SCALE + { 0, false, true }, // ATTR_PAGE_SCALETOPAGES aka SID_SCATTR_PAGE_SCALETOPAGES + { 0, false, true }, // ATTR_PAGE_FIRSTPAGENO aka SID_SCATTR_PAGE_FIRSTPAGENO + { 0, true, true }, // ATTR_PAGE_HEADERLEFT aka SID_SCATTR_PAGE_HEADERLEFT + { 0, true, true }, // ATTR_PAGE_FOOTERLEFT aka SID_SCATTR_PAGE_FOOTERLEFT + { 0, true, true }, // ATTR_PAGE_HEADERRIGHT aka SID_SCATTR_PAGE_HEADERRIGHT + { 0, true, true }, // ATTR_PAGE_FOOTERRIGHT aka. SID_SCATTR_PAGE_FOOTERRIGHT + { 0, true, true }, // ATTR_PAGE_HEADERFIRST aka. SID_SCATTR_PAGE_HEADERFIRST + { 0, true, true }, // ATTR_PAGE_FOOTERFIRST aka. SID_SCATTR_PAGE_FOOTERFIRST` + { SID_ATTR_PAGE_HEADERSET, false, true }, // ATTR_PAGE_HEADERSET + { SID_ATTR_PAGE_FOOTERSET, false, true }, // ATTR_PAGE_FOOTERSET + { 0, false, true }, // ATTR_PAGE_FORMULAS aka. SID_SCATTR_PAGE_FORMULAS + { 0, false, true }, // ATTR_PAGE_NULLVALS aka. SID_SCATTR_PAGE_NULLVALS + { 0, false, true }, // ATTR_PAGE_SCALETO aka. SID_SCATTR_PAGE_SCALETO + { 0, false, true } // ATTR_HIDDEN }; static_assert( SAL_N_ELEMENTS(aItemInfos) == ATTR_ENDINDEX - ATTR_STARTINDEX + 1, "these must match"); @@ -336,24 +337,20 @@ ScDocumentPool::~ScDocumentPool() } } -const SfxPoolItem& ScDocumentPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nWhich, bool bPassingOwnership ) +void ScDocumentPool::newItem_Callback(const SfxPoolItem& rItem) const { - if ( rItem.Which() != ATTR_PATTERN ) // Only Pattern is special - return SfxItemPool::PutImpl( rItem, nWhich, bPassingOwnership ); - - // Don't copy the default pattern of this Pool - if (&rItem == mvPoolDefaults[ ATTR_PATTERN - ATTR_STARTINDEX ]) - return rItem; - - // Else Put must always happen, because it could be another Pool - const SfxPoolItem& rNew = SfxItemPool::PutImpl( rItem, nWhich, bPassingOwnership ); - sal_uInt32 nRef = rNew.GetRefCount(); - if (nRef == 1) + if (ATTR_PATTERN == rItem.Which() && 1 == rItem.GetRefCount()) { - ++mnCurrentMaxKey; - const_cast<ScPatternAttr&>(static_cast<const ScPatternAttr&>(rNew)).SetKey(mnCurrentMaxKey); + const_cast<ScDocumentPool*>(this)->mnCurrentMaxKey++; + const_cast<ScPatternAttr&>(static_cast<const ScPatternAttr&>(rItem)).SetPAKey(mnCurrentMaxKey); } - return rNew; +} + +bool ScDocumentPool::newItem_UseDirect(const SfxPoolItem& rItem) const +{ + // I have evaluated that this is currently needed for ATTR_PATTERN/ScPatternAttr to work, + // so this needs to stay at ptr-compare + return (ATTR_PATTERN == rItem.Which() && areSfxPoolItemPtrsEqual(&rItem, mvPoolDefaults[ATTR_PATTERN - ATTR_STARTINDEX])); } void ScDocumentPool::StyleDeleted( const ScStyleSheet* pStyle ) diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 8996577b588e..6225e92781b9 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -5060,7 +5060,7 @@ std::unique_ptr<ScPatternAttr> ScDocument::CreateSelectionPattern( const ScMarkD { std::unique_ptr<ScPatternAttr> pPattern(new ScPatternAttr( std::move(*aState.pItemSet) )); if (aState.mbValidPatternId) - pPattern->SetKey(aState.mnPatternId); + pPattern->SetPAKey(aState.mnPatternId); return pPattern; } diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 9a8675fcd190..4a573e1c21da 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -186,7 +186,7 @@ public: bool isRotateItemUsed(const ScDocumentPool *pPool) { - return pPool->GetItemCount2( ATTR_ROTATE_VALUE ) > 0; + return pPool->GetItemSurrogates(ATTR_ROTATE_VALUE).size() > 0; } void initRowInfo(const ScDocument* pDoc, RowInfo* pRowInfo, const SCSIZE nMaxRow, @@ -488,11 +488,11 @@ void ScDocument::FillInfo( const SvxLineItem* pBLTRLine = &pPattern->GetItem( ATTR_BORDER_BLTR ); const SvxShadowItem* pShadowAttr = &pPattern->GetItem(ATTR_SHADOW); - if (pShadowAttr != pDefShadow) + if (!SfxPoolItem::areSame(pShadowAttr, pDefShadow)) bAnyShadow = true; const ScMergeAttr* pMergeAttr = &pPattern->GetItem(ATTR_MERGE); - bool bMerged = ( pMergeAttr != pDefMerge && *pMergeAttr != *pDefMerge ); + bool bMerged = !SfxPoolItem::areSame( pMergeAttr, pDefMerge ); ScMF nOverlap = pPattern->GetItemSet(). Get(ATTR_MERGE_FLAG).GetValue(); bool bHOverlapped(nOverlap & ScMF::Hor); @@ -530,7 +530,7 @@ void ScDocument::FillInfo( if ( GetPreviewCellStyle( nCol, nCurRow, nTab ) != nullptr ) bAnyPreview = true; RowInfo* pThisRowInfo = &pRowInfo[nArrRow]; - if (pBackground != pDefBackground) // Column background == Default ? + if (!SfxPoolItem::areSame(pBackground, pDefBackground)) // Column background == Default ? pThisRowInfo->bEmptyBack = false; if (bContainsCondFormat) pThisRowInfo->bEmptyBack = false; @@ -687,7 +687,7 @@ void ScDocument::FillInfo( if( bAnyCondition && pInfo->mxColorScale) { pRowInfo[nArrRow].bEmptyBack = false; - pInfo->pBackground = &pPool->Put(SvxBrushItem(*pInfo->mxColorScale, ATTR_BACKGROUND)); + pInfo->pBackground = &pPool->DirectPutItemInPool(SvxBrushItem(*pInfo->mxColorScale, ATTR_BACKGROUND)); } } } @@ -735,7 +735,7 @@ void ScDocument::FillInfo( !(pShadowItem = pStartCond->GetItemIfSet(ATTR_SHADOW)) ) pShadowItem = &pStartPattern->GetItem(ATTR_SHADOW); pInfo->pShadowAttr = pShadowItem; - if (pInfo->pShadowAttr != pDefShadow) + if (!SfxPoolItem::areSame(pInfo->pShadowAttr, pDefShadow)) bAnyShadow = true; const ScCondFormatIndexes& rCondFormatIndex diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 027bc5768a35..57c9759f17a4 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -139,7 +139,7 @@ bool ScGlobal::HasAttrChanged( const SfxItemSet& rNewAttrs, // Both Items set // PoolItems, meaning comparing pointers is valid if ( SfxItemState::SET == eOldState ) - bInvalidate = (pNewItem != pOldItem); + bInvalidate = !SfxPoolItem::areSame(pNewItem, pOldItem); } else { diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index 7638652e6857..d7d460abdbb5 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -72,30 +72,34 @@ ScPatternAttr::ScPatternAttr( SfxItemSet&& pItemSet, const OUString& rStyleName : SfxSetItem ( ATTR_PATTERN, std::move(pItemSet) ), pName ( rStyleName ), pStyle ( nullptr ), - mnKey(0) + mnPAKey(0) { + setNewItemCallback(); } ScPatternAttr::ScPatternAttr( SfxItemSet&& pItemSet ) : SfxSetItem ( ATTR_PATTERN, std::move(pItemSet) ), pStyle ( nullptr ), - mnKey(0) + mnPAKey(0) { + setNewItemCallback(); } ScPatternAttr::ScPatternAttr( SfxItemPool* pItemPool ) : SfxSetItem ( ATTR_PATTERN, SfxItemSetFixed<ATTR_PATTERN_START, ATTR_PATTERN_END>( *pItemPool ) ), pStyle ( nullptr ), - mnKey(0) + mnPAKey(0) { + setNewItemCallback(); } ScPatternAttr::ScPatternAttr( const ScPatternAttr& rPatternAttr ) : SfxSetItem ( rPatternAttr ), pName ( rPatternAttr.pName ), pStyle ( rPatternAttr.pStyle ), - mnKey(rPatternAttr.mnKey) + mnPAKey(rPatternAttr.mnPAKey) { + setNewItemCallback(); } ScPatternAttr* ScPatternAttr::Clone( SfxItemPool *pPool ) const @@ -166,25 +170,6 @@ bool ScPatternAttr::operator==( const SfxPoolItem& rCmp ) const StrCmp( GetStyleName(), rOther.GetStyleName() ); } -SfxPoolItem::lookup_iterator ScPatternAttr::Lookup(lookup_iterator begin, lookup_iterator end ) const -{ - if( !mxHashCode ) - CalcHashCode(); - for( auto it = begin; it != end; ++it) - { - const ScPatternAttr* other = static_cast<const ScPatternAttr*>(*it); - if( !other->mxHashCode ) - other->CalcHashCode(); - if (*mxHashCode == *other->mxHashCode - && EqualPatternSets( GetItemSet(), other->GetItemSet()) - && StrCmp( GetStyleName(), other->GetStyleName())) - { - return it; - } - } - return end; -} - SvxCellOrientation ScPatternAttr::GetCellOrientation( const SfxItemSet& rItemSet, const SfxItemSet* pCondSet ) { SvxCellOrientation eOrient = SvxCellOrientation::Standard; @@ -1027,7 +1012,7 @@ void ScPatternAttr::DeleteUnchanged( const ScPatternAttr* pOldAttrs ) if ( eOldState == SfxItemState::SET ) { // item is set in OldAttrs (or its parent) -> compare pointers - if ( pThisItem == pOldItem ) + if (SfxPoolItem::areSame( pThisItem, pOldItem )) { rThisSet.ClearItem( nSubWhich ); mxHashCode.reset(); @@ -1194,7 +1179,7 @@ ScPatternAttr* ScPatternAttr::PutInPool( ScDocument* pDestDoc, ScDocument* pSrcD } } - ScPatternAttr* pPatternAttr = const_cast<ScPatternAttr*>( &pDestDoc->GetPool()->Put(aDestPattern) ); + ScPatternAttr* pPatternAttr = const_cast<ScPatternAttr*>( &pDestDoc->GetPool()->DirectPutItemInPool(aDestPattern) ); return pPatternAttr; } @@ -1289,7 +1274,7 @@ bool ScPatternAttr::IsVisibleEqual( const ScPatternAttr& rOther ) const if (state1 != state2 && (state1 < SfxItemState::DEFAULT || state2 < SfxItemState::DEFAULT)) return false; - if (pItem1 != pItem2) + if (!SfxPoolItem::areSame(pItem1, pItem2)) return false; } nWhich1 = aIter1.NextWhich(); @@ -1494,14 +1479,14 @@ ScRotateDir ScPatternAttr::GetRotateDir( const SfxItemSet* pCondSet ) const return nRet; } -void ScPatternAttr::SetKey(sal_uInt64 nKey) +void ScPatternAttr::SetPAKey(sal_uInt64 nKey) { - mnKey = nKey; + mnPAKey = nKey; } -sal_uInt64 ScPatternAttr::GetKey() const +sal_uInt64 ScPatternAttr::GetPAKey() const { - return mnKey; + return mnPAKey; } void ScPatternAttr::CalcHashCode() const diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 978bd00ecbac..d6c1eead2c48 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -2905,7 +2905,7 @@ namespace std::vector<ScAttrEntry> aData(rOrigData); for (size_t nIdx = 0; nIdx < aData.size(); ++nIdx) { - aData[nIdx].pPattern = &rDocument.GetPool()->Put(*aData[nIdx].pPattern); + aData[nIdx].pPattern = &rDocument.GetPool()->DirectPutItemInPool(*aData[nIdx].pPattern); } return aData; } diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index f0a55b478c0c..71cf80bcef38 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -1192,13 +1192,13 @@ void ScTable::SortReorderByRow( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol for (const auto& rSpan : aSpans) { assert(rSpan.mpPattern); // should never be NULL. - rDocument.GetPool()->Put(*rSpan.mpPattern); + rDocument.GetPool()->DirectPutItemInPool(*rSpan.mpPattern); } for (const auto& rSpan : aSpans) { aCol[nThisCol].SetPatternArea(rSpan.mnRow1, rSpan.mnRow2, *rSpan.mpPattern); - rDocument.GetPool()->Remove(*rSpan.mpPattern); + rDocument.GetPool()->DirectRemoveItemFromPool(*rSpan.mpPattern); } } @@ -1393,13 +1393,13 @@ void ScTable::SortReorderByRowRefUpdate( for (const auto& rSpan : aSpans) { assert(rSpan.mpPattern); // should never be NULL. - rDocument.GetPool()->Put(*rSpan.mpPattern); + rDocument.GetPool()->DirectPutItemInPool(*rSpan.mpPattern); } for (const auto& rSpan : aSpans) { aCol[nThisCol].SetPatternArea(rSpan.mnRow1, rSpan.mnRow2, *rSpan.mpPattern); - rDocument.GetPool()->Remove(*rSpan.mpPattern); + rDocument.GetPool()->DirectRemoveItemFromPool(*rSpan.mpPattern); } } diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index 9c6852990efe..d8a4cf584132 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -1005,7 +1005,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, if ( bVertical && nISrcStart == nISrcEnd && !bHasFiltered ) { // set all attributes at once (en bloc) - if (pNewPattern || pSrcPattern != rDocument.GetDefPattern()) + if (pNewPattern || !SfxPoolItem::areSame(pSrcPattern, rDocument.GetDefPattern())) { // Default is already present (DeleteArea) SCROW nY1 = static_cast<SCROW>(std::min( nIStart, nIEnd )); @@ -1036,7 +1036,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, DeleteArea(static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), InsertDeleteFlags::AUTOFILL); - if ( pSrcPattern != aCol[nCol].GetPattern( static_cast<SCROW>(nRow) ) ) + if ( !SfxPoolItem::areSame(pSrcPattern, aCol[nCol].GetPattern( static_cast<SCROW>(nRow) ) ) ) { // Transfer template too //TODO: Merge ApplyPattern to AttrArray ?? diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index a68d6408edd9..2230987ce8b0 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -2815,7 +2815,7 @@ sal_uInt32 XclExpXFBuffer::InsertCellXF( const ScPatternAttr* pPattern, sal_Int1 pPattern = pDefPattern; // special handling for default cell formatting - if( (pPattern == pDefPattern) && !bForceLineBreak && + if( SfxPoolItem::areSame(pPattern, pDefPattern) && !bForceLineBreak && (nForceScNumFmt == NUMBERFORMAT_ENTRY_NOT_FOUND) && (nForceXclFont == EXC_FONT_NOTFOUND) ) { diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx index e1dc476e1d9e..21b86a4ed4fa 100644 --- a/sc/source/filter/excel/xistyle.cxx +++ b/sc/source/filter/excel/xistyle.cxx @@ -1405,7 +1405,7 @@ void XclImpXF::ApplyPatternToAttrVector( ScAttrEntry aEntry; aEntry.nEndRow = nRow2; - aEntry.pPattern = &rDoc.GetPool()->Put(rPat); + aEntry.pPattern = &rDoc.GetPool()->DirectPutItemInPool(rPat); rAttrs.push_back(aEntry); } diff --git a/sc/source/filter/lotus/lotattr.cxx b/sc/source/filter/lotus/lotattr.cxx index f87984056fe6..458e3c677b62 100644 --- a/sc/source/filter/lotus/lotattr.cxx +++ b/sc/source/filter/lotus/lotattr.cxx @@ -189,7 +189,7 @@ void LotAttrCol::SetAttr( const ScDocument* pDoc, const SCROW nRow, const ScPatt if(iterLast != aEntries.rend()) { - if( ( (*iterLast)->nLastRow == nRow - 1 ) && ( &rAttr == (*iterLast)->pPattAttr ) ) + if( ( (*iterLast)->nLastRow == nRow - 1 ) && SfxPoolItem::areSame( &rAttr, (*iterLast)->pPattAttr ) ) (*iterLast)->nLastRow = nRow; else { diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx index d1410eb04970..b25dba6eb079 100644 --- a/sc/source/filter/oox/sheetdatabuffer.cxx +++ b/sc/source/filter/oox/sheetdatabuffer.cxx @@ -523,7 +523,7 @@ void SheetDataBuffer::finalizeImport() ScAttrEntry aEntry; aEntry.nEndRow = rDoc.MaxRow(); aEntry.pPattern = pDefPattern; - rDoc.GetPool()->Put(*aEntry.pPattern); + rDoc.GetPool()->DirectPutItemInPool(*aEntry.pPattern); aAttrs.maAttrs.push_back(aEntry); if (!sc::NumFmtUtil::isLatinScript(*aEntry.pPattern, rDoc)) diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx index e38b5cd13002..7481b1dec851 100644 --- a/sc/source/filter/oox/stylesbuffer.cxx +++ b/sc/source/filter/oox/stylesbuffer.cxx @@ -2168,7 +2168,7 @@ void Xf::applyPatternToAttrList( AttrList& rAttrs, SCROW nRow1, SCROW nRow2, sal // Fill this gap with the default pattern. ScAttrEntry aEntry; aEntry.nEndRow = nRow1 - 1; - aEntry.pPattern = &rDoc.GetPool()->Put(*rAttrs.mpDefPattern); + aEntry.pPattern = &rDoc.GetPool()->DirectPutItemInPool(*rAttrs.mpDefPattern); rAttrs.maAttrs.push_back(aEntry); // Check if the default pattern is 'General'. @@ -2178,7 +2178,7 @@ void Xf::applyPatternToAttrList( AttrList& rAttrs, SCROW nRow1, SCROW nRow2, sal ScAttrEntry aEntry; aEntry.nEndRow = nRow2; - aEntry.pPattern = &rDoc.GetPool()->Put(rPat); + aEntry.pPattern = &rDoc.GetPool()->DirectPutItemInPool(rPat); // Put the allocated pattern to cache if (!pCachedPattern) rCache.add(nXfId, nNumFmtId, const_cast<ScPatternAttr*>(aEntry.pPattern)); diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index de2ce3679cca..769f4249a4bf 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -2519,7 +2519,7 @@ bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bIn const ScPatternAttr* pPattern = rDoc.GetPattern( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab() ); - if (pPattern != pLastPattern) + if (!SfxPoolItem::areSame(pPattern, pLastPattern)) { // Percent format? const SfxItemSet& rAttrSet = pPattern->GetItemSet(); diff --git a/sc/source/ui/app/msgpool.cxx b/sc/source/ui/app/msgpool.cxx index 58daba682830..227dbce4560b 100644 --- a/sc/source/ui/app/msgpool.cxx +++ b/sc/source/ui/app/msgpool.cxx @@ -25,16 +25,17 @@ SfxItemInfo const aMsgItemInfos[] = { - { 0, true }, // SCITEM_STRING - { 0, true }, // SCITEM_SEARCHDATA - stop using this! - { SID_SORT, true }, // SCITEM_SORTDATA - { SID_QUERY, true }, // SCITEM_QUERYDATA - { SID_SUBTOTALS, true }, // SCITEM_SUBTDATA - { SID_CONSOLIDATE, true }, // SCITEM_CONSOLIDATEDATA - { SID_PIVOT_TABLE, true }, // SCITEM_PIVOTDATA - { SID_SOLVE, true }, // SCITEM_SOLVEDATA - { SID_SCUSERLISTS, true }, // SCITEM_USERLIST - { 0, false } // SCITEM_CONDFORMATDLGDATA + // _nSID, _bNeedsPoolRegistration, _bShareable + { 0, false, true }, // SCITEM_STRING + { 0, false, true }, // SCITEM_SEARCHDATA - stop using this! + { SID_SORT, false, true }, // SCITEM_SORTDATA + { SID_QUERY, false, true }, // SCITEM_QUERYDATA + { SID_SUBTOTALS, false, true }, // SCITEM_SUBTDATA + { SID_CONSOLIDATE, false, true }, // SCITEM_CONSOLIDATEDATA + { SID_PIVOT_TABLE, false, true }, // SCITEM_PIVOTDATA + { SID_SOLVE, false, true }, // SCITEM_SOLVEDATA + { SID_SCUSERLISTS, false, true }, // SCITEM_USERLIST + { 0, true, false } // SCITEM_CONDFORMATDLGDATA }; ScMessagePool::ScMessagePool() diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx index 6fd71f90f6e9..2a1b72459665 100644 --- a/sc/source/ui/condformat/condformatdlg.cxx +++ b/sc/source/ui/condformat/condformatdlg.cxx @@ -634,7 +634,7 @@ void ScCondFormatDlg::OkPressed() pFormat->SetKey(nKey); pList->InsertNew(std::move(pFormat)); } - mpViewData->GetViewShell()->GetPool().Put(*mpDlgItem); + mpViewData->GetViewShell()->GetPool().DirectPutItemInPool(*mpDlgItem); SetDispatcherLock( false ); // Queue message to open Conditional Format Manager Dialog @@ -650,7 +650,7 @@ void ScCondFormatDlg::CancelPressed() { if ( mpDlgItem->IsManaged() ) { - mpViewData->GetViewShell()->GetPool().Put(*mpDlgItem); + mpViewData->GetViewShell()->GetPool().DirectPutItemInPool(*mpDlgItem); SetDispatcherLock( false ); // Queue message to open Conditional Format Manager Dialog GetBindings().GetDispatcher()->Execute( SID_OPENDLG_CONDFRMT_MANAGER, diff --git a/sc/source/ui/inc/editsh.hxx b/sc/source/ui/inc/editsh.hxx index 01457c3b7f2a..3777d1988887 100644 --- a/sc/source/ui/inc/editsh.hxx +++ b/sc/source/ui/inc/editsh.hxx @@ -29,7 +29,7 @@ class SfxModule; class EditView; class ScViewData; class ScInputHandler; -class SvxURLField; +class SvxFieldData; class TransferableDataHelper; class TransferableClipboardListener; @@ -48,8 +48,14 @@ private: // currently happens to be when the menu was dismissed. std::optional<bool> moAtContextMenu_DisableEditHyperlink; - const SvxURLField* GetURLField(); - const SvxURLField* GetFirstURLFieldFromCell(); + // These methods did return 'const SvxURLField*' before, but + // at least for GetFirstURLFieldFromCell this is not safe: The + // SvxFieldItem accessed there and held in the local temporary + // SfxItemSet may be deleted with it, so return value can be + // corrupted/deleted. To avoid that, return a Clone + std::unique_ptr<const SvxFieldData> GetURLField(); + std::unique_ptr<const SvxFieldData> GetFirstURLFieldFromCell(); + ScInputHandler* GetMyInputHdl(); DECL_LINK( ClipboardChanged, TransferableDataHelper*, void ); diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx index f614e0ff0b4a..b7b615d6608f 100644 --- a/sc/source/ui/undo/undoblk3.cxx +++ b/sc/source/ui/undo/undoblk3.cxx @@ -355,20 +355,20 @@ ScUndoSelectionAttr::ScUndoSelectionAttr( ScDocShell* pNewDocShell, bMulti ( bNewMulti ) { ScDocumentPool* pPool = pDocShell->GetDocument().GetPool(); - pApplyPattern = const_cast<ScPatternAttr*>(&pPool->Put( *pNewApply )); - pLineOuter = pNewOuter ? const_cast<SvxBoxItem*>( &pPool->Put( *pNewOuter ) ) : nullptr; - pLineInner = pNewInner ? const_cast<SvxBoxInfoItem*>( &pPool->Put( *pNewInner ) ) : nullptr; + pApplyPattern = const_cast<ScPatternAttr*>(&pPool->DirectPutItemInPool( *pNewApply )); + pLineOuter = pNewOuter ? const_cast<SvxBoxItem*>( &pPool->DirectPutItemInPool( *pNewOuter ) ) : nullptr; + pLineInner = pNewInner ? const_cast<SvxBoxInfoItem*>( &pPool->DirectPutItemInPool( *pNewInner ) ) : nullptr; aRangeCover = pRangeCover ? *pRangeCover : aRange; } ScUndoSelectionAttr::~ScUndoSelectionAttr() { ScDocumentPool* pPool = pDocShell->GetDocument().GetPool(); - pPool->Remove(*pApplyPattern); + pPool->DirectRemoveItemFromPool(*pApplyPattern); if (pLineOuter) - pPool->Remove(*pLineOuter); + pPool->DirectRemoveItemFromPool(*pLineOuter); if (pLineInner) - pPool->Remove(*pLineInner); + pPool->DirectRemoveItemFromPool(*pLineInner); pUndoDoc.reset(); } diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index 4cb9d03fed6d..84e4a95bcb1e 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -84,17 +84,17 @@ ScUndoCursorAttr::ScUndoCursorAttr( ScDocShell* pNewDocShell, pNewEditData( static_cast<EditTextObject*>(nullptr) ) { ScDocumentPool* pPool = pDocShell->GetDocument().GetPool(); - pNewPattern = const_cast<ScPatternAttr*>( &pPool->Put( *pNewPat ) ); - pOldPattern = const_cast<ScPatternAttr*>( &pPool->Put( *pOldPat ) ); - pApplyPattern = const_cast<ScPatternAttr*>( &pPool->Put( *pApplyPat ) ); + pNewPattern = const_cast<ScPatternAttr*>( &pPool->DirectPutItemInPool( *pNewPat ) ); + pOldPattern = const_cast<ScPatternAttr*>( &pPool->DirectPutItemInPool( *pOldPat ) ); + pApplyPattern = const_cast<ScPatternAttr*>( &pPool->DirectPutItemInPool( *pApplyPat ) ); } ScUndoCursorAttr::~ScUndoCursorAttr() { ScDocumentPool* pPool = pDocShell->GetDocument().GetPool(); - pPool->Remove(*pNewPattern); - pPool->Remove(*pOldPattern); - pPool->Remove(*pApplyPattern); + pPool->DirectRemoveItemFromPool(*pNewPattern); + pPool->DirectRemoveItemFromPool(*pOldPattern); + pPool->DirectRemoveItemFromPool(*pApplyPattern); } OUString ScUndoCursorAttr::GetComment() const diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 59d77e3517fa..3325b0bbcf6c 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -2448,7 +2448,7 @@ void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertyMapEntry* pEntr case SC_WID_UNO_FORMATID: { const ScPatternAttr* pPattern = GetCurrentAttrsFlat(); - rAny <<= pPattern->GetKey(); + rAny <<= pPattern->GetPAKey(); } break; } diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 1b307963dc01..558d5a816615 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -2410,7 +2410,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) // Conditional Format Dialog. ScCondFormatDlgItem aDlgItem(nullptr, nIndex, false); aDlgItem.SetDialogType(eType); - pTabViewShell->GetPool().Put(aDlgItem); + pTabViewShell->GetPool().DirectPutItemInPool(aDlgItem); sal_uInt16 nId = ScCondFormatDlgWrapper::GetChildWindowId(); SfxViewFrame& rViewFrm = pTabViewShell->GetViewFrame(); @@ -2878,7 +2878,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) { // Put the xml string parameter to initialize the // Conditional Format Dialog. ( add new ) - pTabViewShell->GetPool().Put(ScCondFormatDlgItem( + pTabViewShell->GetPool().DirectPutItemInPool(ScCondFormatDlgItem( std::shared_ptr<ScConditionalFormatList>(pCondFormatList.release()), -1, true)); // Queue message to open Conditional Format Dialog GetViewData().GetDispatcher().Execute( SID_OPENDLG_CONDFRMT, SfxCallMode::ASYNCHRON ); @@ -2889,7 +2889,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) sal_Int32 nIndex = pFormat ? pFormat->GetKey() : -1; // Put the xml string parameter to initialize the // Conditional Format Dialog. ( edit selected conditional format ) - pTabViewShell->GetPool().Put(ScCondFormatDlgItem( + pTabViewShell->GetPool().DirectPutItemInPool(ScCondFormatDlgItem( std::shared_ptr<ScConditionalFormatList>(pCondFormatList.release()), nIndex, true)); // Queue message to open Conditional Format Dialog @@ -2899,7 +2899,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) pCondFormatList.reset(); if (pDlgItem) - pTabViewShell->GetPool().Remove(*pDlgItem); + pTabViewShell->GetPool().DirectRemoveItemFromPool(*pDlgItem); pDlg->disposeOnce(); }); diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx index 493ab18f78cc..2c4328d78145 100644 --- a/sc/source/ui/view/editsh.cxx +++ b/sc/source/ui/view/editsh.cxx @@ -577,7 +577,8 @@ void ScEditShell::Execute( SfxRequest& rReq ) bool bDone = false; if ( (eMode == HLINK_DEFAULT || eMode == HLINK_FIELD) && !bCellLinksOnly ) { - const SvxURLField* pURLField = GetURLField(); + std::unique_ptr<const SvxFieldData> aSvxFieldDataPtr(GetURLField()); + const SvxURLField* pURLField(static_cast<const SvxURLField*>(aSvxFieldDataPtr.get())); if ( pURLField ) { // select old field @@ -637,7 +638,8 @@ void ScEditShell::Execute( SfxRequest& rReq ) break; case SID_OPEN_HYPERLINK: { - const SvxURLField* pURLField = GetURLField(); + std::unique_ptr<const SvxFieldData> aSvxFieldDataPtr(GetURLField()); + const SvxURLField* pURLField(static_cast<const SvxURLField*>(aSvxFieldDataPtr.get())); if ( pURLField ) ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame(), true ); return; @@ -792,7 +794,8 @@ void ScEditShell::GetState( SfxItemSet& rSet ) bool bCellLinksOnly = SC_MOD()->GetAppOptions().GetLinksInsertedLikeMSExcel() && rViewData.GetSfxDocShell()->GetMedium()->GetFilter()->IsMSOFormat(); - const SvxURLField* pURLField = GetURLField(); + std::unique_ptr<const SvxFieldData> aSvxFieldDataPtr(GetURLField()); + const SvxURLField* pURLField(static_cast<const SvxURLField*>(aSvxFieldDataPtr.get())); if (!bCellLinksOnly) { if (pURLField) @@ -814,7 +817,8 @@ void ScEditShell::GetState( SfxItemSet& rSet ) { if (!pURLField) { - pURLField = GetFirstURLFieldFromCell(); + aSvxFieldDataPtr = GetFirstURLFieldFromCell(); + pURLField = static_cast<const SvxURLField*>(aSvxFieldDataPtr.get()); } if (pURLField) { @@ -893,21 +897,21 @@ void ScEditShell::GetState( SfxItemSet& rSet ) } } -const SvxURLField* ScEditShell::GetURLField() +std::unique_ptr<const SvxFieldData> ScEditShell::GetURLField() { ScInputHandler* pHdl = GetMyInputHdl(); EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView; if (!pActiveView) - return nullptr; + return std::unique_ptr<const SvxFieldData>(); const SvxFieldData* pField = pActiveView->GetFieldAtCursor(); if (auto pURLField = dynamic_cast<const SvxURLField*>(pField)) - return pURLField; + return pURLField->Clone(); - return nullptr; + return std::unique_ptr<const SvxFieldData>(); } -const SvxURLField* ScEditShell::GetFirstURLFieldFromCell() +std::unique_ptr<const SvxFieldData> ScEditShell::GetFirstURLFieldFromCell() { EditEngine* pEE = GetEditView()->GetEditEngine(); sal_Int32 nParaCount = pEE->GetParagraphCount(); @@ -929,14 +933,15 @@ const SvxURLField* ScEditShell::GetFirstURLFieldFromCell() const SvxFieldData* pField = pItem->GetField(); if (const SvxURLField* pUrlField = dynamic_cast<const SvxURLField*>(pField)) { - return pUrlField; + return pUrlField->Clone(); } } } aSel.nStartPos = aSel.nEndPos; } } - return nullptr; + + return std::unique_ptr<const SvxFieldData>(); } IMPL_LINK( ScEditShell, ClipboardChanged, TransferableDataHelper*, pDataHelper, void ) diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 8461aaaac446..47fdab381c9f 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -766,14 +766,14 @@ static bool lcl_EqualBack( const RowInfo& rFirst, const RowInfo& rOther, const ScPatternAttr* pPat1 = rFirst.cellInfo(nX).pPatternAttr; const ScPatternAttr* pPat2 = rOther.cellInfo(nX).pPatternAttr; if ( !pPat1 || !pPat2 || - &pPat1->GetItem(ATTR_PROTECTION) != &pPat2->GetItem(ATTR_PROTECTION) ) + !SfxPoolItem::areSame(&pPat1->GetItem(ATTR_PROTECTION), &pPat2->GetItem(ATTR_PROTECTION) ) ) return false; } } else { for ( nX=nX1; nX<=nX2; nX++ ) - if ( rFirst.cellInfo(nX).pBackground != rOther.cellInfo(nX).pBackground ) + if ( !SfxPoolItem::areSame(rFirst.cellInfo(nX).pBackground, rOther.cellInfo(nX).pBackground ) ) return false; } @@ -970,7 +970,7 @@ void drawCells(vcl::RenderContext& rRenderContext, std::optional<Color> const & rRect.SetLeft( nPosX - nSignedOneX ); } - if ( pOldBackground && (pColor ||pBackground != pOldBackground || pOldDataBarInfo || pDataBarInfo || pIconSetInfo || pOldIconSetInfo) ) + if ( pOldBackground && (pColor || !SfxPoolItem::areSame(pBackground, pOldBackground) || pOldDataBarInfo || pDataBarInfo || pIconSetInfo || pOldIconSetInfo) ) { rRect.SetRight( nPosX-nSignedOneX ); if (pOldBackground) // ==0 if hidden diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 1b67ab4f4b24..2d6cda3d652a 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -1025,71 +1025,71 @@ static bool StringDiffer( const ScPatternAttr*& rpOldPattern, const ScPatternAtt { OSL_ENSURE( pNewPattern, "pNewPattern" ); - if ( pNewPattern == rpOldPattern ) + if ( SfxPoolItem::areSame( pNewPattern, rpOldPattern ) ) return false; else if ( !rpOldPattern ) return true; - else if ( &pNewPattern->GetItem( ATTR_FONT ) != &rpOldPattern->GetItem( ATTR_FONT ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_FONT ), &rpOldPattern->GetItem( ATTR_FONT ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_CJK_FONT ) != &rpOldPattern->GetItem( ATTR_CJK_FONT ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_CJK_FONT ), &rpOldPattern->GetItem( ATTR_CJK_FONT ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_CTL_FONT ) != &rpOldPattern->GetItem( ATTR_CTL_FONT ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_CTL_FONT ), &rpOldPattern->GetItem( ATTR_CTL_FONT ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_FONT_HEIGHT ) != &rpOldPattern->GetItem( ATTR_FONT_HEIGHT ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_FONT_HEIGHT ), &rpOldPattern->GetItem( ATTR_FONT_HEIGHT ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_CJK_FONT_HEIGHT ) != &rpOldPattern->GetItem( ATTR_CJK_FONT_HEIGHT ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_CJK_FONT_HEIGHT ), &rpOldPattern->GetItem( ATTR_CJK_FONT_HEIGHT ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_CTL_FONT_HEIGHT ) != &rpOldPattern->GetItem( ATTR_CTL_FONT_HEIGHT ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_CTL_FONT_HEIGHT ), &rpOldPattern->GetItem( ATTR_CTL_FONT_HEIGHT ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_FONT_WEIGHT ) != &rpOldPattern->GetItem( ATTR_FONT_WEIGHT ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_FONT_WEIGHT ), &rpOldPattern->GetItem( ATTR_FONT_WEIGHT ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_CJK_FONT_WEIGHT ) != &rpOldPattern->GetItem( ATTR_CJK_FONT_WEIGHT ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_CJK_FONT_WEIGHT ), &rpOldPattern->GetItem( ATTR_CJK_FONT_WEIGHT ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_CTL_FONT_WEIGHT ) != &rpOldPattern->GetItem( ATTR_CTL_FONT_WEIGHT ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_CTL_FONT_WEIGHT ), &rpOldPattern->GetItem( ATTR_CTL_FONT_WEIGHT ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_FONT_POSTURE ) != &rpOldPattern->GetItem( ATTR_FONT_POSTURE ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_FONT_POSTURE ), &rpOldPattern->GetItem( ATTR_FONT_POSTURE ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_CJK_FONT_POSTURE ) != &rpOldPattern->GetItem( ATTR_CJK_FONT_POSTURE ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_CJK_FONT_POSTURE ), &rpOldPattern->GetItem( ATTR_CJK_FONT_POSTURE ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_CTL_FONT_POSTURE ) != &rpOldPattern->GetItem( ATTR_CTL_FONT_POSTURE ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_CTL_FONT_POSTURE ), &rpOldPattern->GetItem( ATTR_CTL_FONT_POSTURE ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_FONT_UNDERLINE ) != &rpOldPattern->GetItem( ATTR_FONT_UNDERLINE ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_FONT_UNDERLINE ), &rpOldPattern->GetItem( ATTR_FONT_UNDERLINE ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_FONT_OVERLINE ) != &rpOldPattern->GetItem( ATTR_FONT_OVERLINE ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_FONT_OVERLINE ), &rpOldPattern->GetItem( ATTR_FONT_OVERLINE ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_FONT_WORDLINE ) != &rpOldPattern->GetItem( ATTR_FONT_WORDLINE ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_FONT_WORDLINE ), &rpOldPattern->GetItem( ATTR_FONT_WORDLINE ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_FONT_CROSSEDOUT ) != &rpOldPattern->GetItem( ATTR_FONT_CROSSEDOUT ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_FONT_CROSSEDOUT ), &rpOldPattern->GetItem( ATTR_FONT_CROSSEDOUT ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_FONT_CONTOUR ) != &rpOldPattern->GetItem( ATTR_FONT_CONTOUR ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_FONT_CONTOUR ), &rpOldPattern->GetItem( ATTR_FONT_CONTOUR ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_FONT_SHADOWED ) != &rpOldPattern->GetItem( ATTR_FONT_SHADOWED ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_FONT_SHADOWED ), &rpOldPattern->GetItem( ATTR_FONT_SHADOWED ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_FONT_COLOR ) != &rpOldPattern->GetItem( ATTR_FONT_COLOR ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_FONT_COLOR ), &rpOldPattern->GetItem( ATTR_FONT_COLOR ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_HOR_JUSTIFY ) != &rpOldPattern->GetItem( ATTR_HOR_JUSTIFY ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_HOR_JUSTIFY ), &rpOldPattern->GetItem( ATTR_HOR_JUSTIFY ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_HOR_JUSTIFY_METHOD ) != &rpOldPattern->GetItem( ATTR_HOR_JUSTIFY_METHOD ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_HOR_JUSTIFY_METHOD ), &rpOldPattern->GetItem( ATTR_HOR_JUSTIFY_METHOD ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_VER_JUSTIFY ) != &rpOldPattern->GetItem( ATTR_VER_JUSTIFY ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_VER_JUSTIFY ), &rpOldPattern->GetItem( ATTR_VER_JUSTIFY ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_VER_JUSTIFY_METHOD ) != &rpOldPattern->GetItem( ATTR_VER_JUSTIFY_METHOD ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_VER_JUSTIFY_METHOD ), &rpOldPattern->GetItem( ATTR_VER_JUSTIFY_METHOD ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_STACKED ) != &rpOldPattern->GetItem( ATTR_STACKED ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_STACKED ), &rpOldPattern->GetItem( ATTR_STACKED ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_LINEBREAK ) != &rpOldPattern->GetItem( ATTR_LINEBREAK ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_LINEBREAK ), &rpOldPattern->GetItem( ATTR_LINEBREAK ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_MARGIN ) != &rpOldPattern->GetItem( ATTR_MARGIN ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_MARGIN ), &rpOldPattern->GetItem( ATTR_MARGIN ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_ROTATE_VALUE ) != &rpOldPattern->GetItem( ATTR_ROTATE_VALUE ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_ROTATE_VALUE ), &rpOldPattern->GetItem( ATTR_ROTATE_VALUE ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_FORBIDDEN_RULES ) != &rpOldPattern->GetItem( ATTR_FORBIDDEN_RULES ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_FORBIDDEN_RULES ), &rpOldPattern->GetItem( ATTR_FORBIDDEN_RULES ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_FONT_EMPHASISMARK ) != &rpOldPattern->GetItem( ATTR_FONT_EMPHASISMARK ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_FONT_EMPHASISMARK ), &rpOldPattern->GetItem( ATTR_FONT_EMPHASISMARK ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_FONT_RELIEF ) != &rpOldPattern->GetItem( ATTR_FONT_RELIEF ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_FONT_RELIEF ), &rpOldPattern->GetItem( ATTR_FONT_RELIEF ) ) ) return true; - else if ( &pNewPattern->GetItem( ATTR_BACKGROUND ) != &rpOldPattern->GetItem( ATTR_BACKGROUND ) ) + else if ( !SfxPoolItem::areSame( &pNewPattern->GetItem( ATTR_BACKGROUND ), &rpOldPattern->GetItem( ATTR_BACKGROUND ) ) ) return true; // needed with automatic text color else { @@ -1714,7 +1714,7 @@ void ScOutputData::LayoutStrings(bool bPixelToLogic) if (nScript == SvtScriptType::NONE) nScript = ScGlobal::GetDefaultScriptType(); - if ( pPattern != pOldPattern || pCondSet != pOldCondSet || + if ( !SfxPoolItem::areSame(pPattern, pOldPattern) || pCondSet != pOldCondSet || nScript != nOldScript || mbSyntaxMode ) { if ( StringDiffer(pOldPattern,pPattern) || @@ -2488,7 +2488,7 @@ void ScOutputData::DrawEditParam::setPatternToEngine(bool bUseStyleColor) // syntax highlighting mode is ignored here // StringDiffer doesn't look at hyphenate, language items - if (mpPattern == mpOldPattern && mpCondSet == mpOldCondSet && mpPreviewFontSet == mpOldPreviewFontSet ) + if (SfxPoolItem::areSame(mpPattern, mpOldPattern) && mpCondSet == mpOldCondSet && mpPreviewFontSet == mpOldPreviewFontSet ) return; Color nConfBackColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor; @@ -4701,7 +4701,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) // syntax mode is ignored here... // StringDiffer doesn't look at hyphenate, language items - if ( pPattern != pOldPattern || pCondSet != pOldCondSet ) + if ( !SfxPoolItem::areSame(pPattern, pOldPattern) || pCondSet != pOldCondSet ) { auto pSet = std::make_unique<SfxItemSet>( mxOutputEditEngine->GetEmptyItemSet() ); pPattern->FillEditItemSet( pSet.get(), pCondSet ); diff --git a/sc/source/ui/view/spelleng.cxx b/sc/source/ui/view/spelleng.cxx index f325d7dd556c..ae50d82930ee 100644 --- a/sc/source/ui/view/spelleng.cxx +++ b/sc/source/ui/view/spelleng.cxx @@ -209,7 +209,7 @@ bool ScConversionEngineBase::FindNextConversionCell() { // GetPattern may implicitly allocates the column if not exists, pPattern = mrDoc.GetPattern( nNewCol, nNewRow, mnStartTab ); - if( pPattern && (pPattern != pLastPattern) ) + if( pPattern && !SfxPoolItem::areSame(pPattern, pLastPattern) ) { pPattern->FillEditItemSet( &aEditDefaults ); SetDefaults( aEditDefaults ); diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index 47a15f64a7c9..d253e8102396 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -440,7 +440,7 @@ std::shared_ptr<SfxModelessDialogController> ScTabViewShell::CreateRefDialogCont xResult = std::make_shared<ScCondFormatDlg>(pB, pCW, pParent, &rViewData, pDlgItem); // Remove the pool item stored by Conditional Format Manager Dialog. - GetPool().Remove(*pDlgItem); + GetPool().DirectRemoveItemFromPool(*pDlgItem); } break; diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index af0dc57357f9..cffb0dcab5c9 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -1050,8 +1050,8 @@ void ScViewFunc::ApplyAttributes( const SfxItemSet* pDialogSet, SfxItemSet& rNewSet = aNewAttrs.GetItemSet(); SfxItemPool* pNewPool = rNewSet.GetPool(); - pNewPool->Put(rNewOuter); // don't delete yet - pNewPool->Put(rNewInner); + pNewPool->DirectPutItemInPool(rNewOuter); // don't delete yet + pNewPool->DirectPutItemInPool(rNewInner); rNewSet.ClearItem( ATTR_BORDER ); rNewSet.ClearItem( ATTR_BORDER_INNER ); @@ -1065,7 +1065,7 @@ void ScViewFunc::ApplyAttributes( const SfxItemSet* pDialogSet, bool bFrame = (pDialogSet->GetItemState( ATTR_BORDER ) != SfxItemState::DEFAULT) || (pDialogSet->GetItemState( ATTR_BORDER_INNER ) != SfxItemState::DEFAULT); - if (&rNewOuter == &rOldOuter && &rNewInner == &rOldInner) + if (SfxPoolItem::areSame(&rNewOuter, &rOldOuter) && SfxPoolItem::areSame(&rNewInner, &rOldInner)) bFrame = false; // this should be intercepted by the pool: ?!??!?? @@ -1095,8 +1095,8 @@ void ScViewFunc::ApplyAttributes( const SfxItemSet* pDialogSet, bDefNewInner ? &rOldInner : &rNewInner ); } - pNewPool->Remove(rNewOuter); // release - pNewPool->Remove(rNewInner); + pNewPool->DirectRemoveItemFromPool(rNewOuter); // release + pNewPool->DirectRemoveItemFromPool(rNewInner); // adjust height only if needed if (bAdjustBlockHeight) |