diff options
-rw-r--r-- | include/svl/itempool.hxx | 8 | ||||
-rw-r--r-- | sc/source/core/data/attarray.cxx | 27 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/patattr.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/excel/xistyle.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/oox/stylesbuffer.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk3.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/undo/undocell.cxx | 6 | ||||
-rw-r--r-- | svl/source/items/poolcach.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/undo/rolbck.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/writer/writer.cxx | 4 |
11 files changed, 31 insertions, 35 deletions
diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx index 391e1b942544..7f74cb85c11d 100644 --- a/include/svl/itempool.hxx +++ b/include/svl/itempool.hxx @@ -146,10 +146,10 @@ public: virtual SfxItemPool* Clone() const; const OUString& GetName() const; - const SfxPoolItem& Put( std::unique_ptr<SfxPoolItem> xItem, sal_uInt16 nWhich = 0 ) - { return PutImpl( *xItem.release(), nWhich, /*bPassingOwnership*/true); } - const SfxPoolItem& Put( const SfxPoolItem& rItem, sal_uInt16 nWhich = 0 ) - { return PutImpl( rItem, nWhich, /*bPassingOwnership*/false); } + template<class T> const T& Put( std::unique_ptr<T> xItem, sal_uInt16 nWhich = 0 ) + { return static_cast<const T&>(PutImpl( *xItem.release(), nWhich, /*bPassingOwnership*/true)); } + template<class T> const T& Put( const T& rItem, sal_uInt16 nWhich = 0 ) + { return static_cast<const T&>(PutImpl( rItem, nWhich, /*bPassingOwnership*/false)); } void Remove( const SfxPoolItem& ); const SfxPoolItem& GetDefaultItem( sal_uInt16 nWhich ) const; diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index 3c91d5b9dc03..3805ad4fa662 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -60,7 +60,7 @@ ScAttrArray::ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc, ScAttr { mvData[nIdx].nEndRow = pDefaultColAttrArray->mvData[nIdx].nEndRow; ScPatternAttr aNewPattern( *(pDefaultColAttrArray->mvData[nIdx].pPattern) ); - mvData[nIdx].pPattern = static_cast<const ScPatternAttr*>( &pDocument->GetPool()->Put( aNewPattern ) ); + mvData[nIdx].pPattern = &pDocument->GetPool()->Put( aNewPattern ); bool bNumFormatChanged = false; if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged, mvData[nIdx].pPattern->GetItemSet(), pDocument->GetDefPattern()->GetItemSet() ) ) @@ -145,7 +145,7 @@ void ScAttrArray::Reset( const ScPatternAttr* pPattern ) pDocument->SetStreamValid(nTab, false); mvData.resize(1); - const ScPatternAttr* pNewPattern = static_cast<const ScPatternAttr*>( &pDocPool->Put(*pPattern) ); + const ScPatternAttr* pNewPattern = &pDocPool->Put(*pPattern); mvData[0].nEndRow = MAXROW; mvData[0].pPattern = pNewPattern; } @@ -455,9 +455,9 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd if (bPutToPool) { if (bPassingOwnership) - pPattern = static_cast<const ScPatternAttr*>(&pDocument->GetPool()->Put(std::unique_ptr<ScPatternAttr>(const_cast<ScPatternAttr*>(pPattern)))); + pPattern = &pDocument->GetPool()->Put(std::unique_ptr<ScPatternAttr>(const_cast<ScPatternAttr*>(pPattern))); else - pPattern = static_cast<const ScPatternAttr*>(&pDocument->GetPool()->Put(*pPattern)); + pPattern = &pDocument->GetPool()->Put(*pPattern); } if ((nStartRow == 0) && (nEndRow == MAXROW)) Reset(pPattern); @@ -684,8 +684,7 @@ void ScAttrArray::ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleS } pDocument->GetPool()->Remove(*mvData[nPos].pPattern); - mvData[nPos].pPattern = static_cast<const ScPatternAttr*>( - &pDocument->GetPool()->Put(*pNewPattern)); + mvData[nPos].pPattern = &pDocument->GetPool()->Put(*pNewPattern); if (Concat(nPos)) Search(nStart, nPos); else @@ -825,8 +824,8 @@ void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow, { // remove from pool ? pDocument->GetPool()->Remove(*mvData[nPos].pPattern); - mvData[nPos].pPattern = static_cast<const ScPatternAttr*>( - &pDocument->GetPool()->Put(std::move(pNewPattern)) ); + mvData[nPos].pPattern = + &pDocument->GetPool()->Put(std::move(pNewPattern)); if (Concat(nPos)) Search(nStart, nPos); @@ -1830,8 +1829,7 @@ void ScAttrArray::FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBo Find( ScResId(STR_STYLENAME_STANDARD), SfxStyleFamily::Para, SfxStyleSearchBits::Auto | SfxStyleSearchBits::ScStandard ) ) ); - mvData[nPos].pPattern = static_cast<const ScPatternAttr*>( - &pDocument->GetPool()->Put(*pNewPattern)); + mvData[nPos].pPattern = &pDocument->GetPool()->Put(*pNewPattern); pNewPattern.reset(); if (Concat(nPos)) @@ -2439,14 +2437,14 @@ void ScAttrArray::CopyArea( pTmpPattern->GetItemSet().ClearItem( ATTR_MERGE_FLAG ); if (bSamePool) - pNewPattern = static_cast<const ScPatternAttr*>( &pDestDocPool->Put(*pTmpPattern) ); + pNewPattern = &pDestDocPool->Put(*pTmpPattern); else pNewPattern = pTmpPattern->PutInPool( rAttrArray.pDocument, pDocument ); } else { if (bSamePool) - pNewPattern = static_cast<const ScPatternAttr*>( &pDestDocPool->Put(*pOldPattern) ); + pNewPattern = &pDestDocPool->Put(*pOldPattern); else pNewPattern = pOldPattern->PutInPool( rAttrArray.pDocument, pDocument ); } @@ -2487,8 +2485,7 @@ void ScAttrArray::CopyAreaSafe( SCROW nStartRow, SCROW nEndRow, long nDy, ScAttr { const ScPatternAttr* pNewPattern; if (bSamePool) - pNewPattern = static_cast<const ScPatternAttr*>( - &pDestDocPool->Put(*pDocument->GetDefPattern())); + pNewPattern = &pDestDocPool->Put(*pDocument->GetDefPattern()); else pNewPattern = pDocument->GetDefPattern()->PutInPool( rAttrArray.pDocument, pDocument ); @@ -2505,7 +2502,7 @@ void ScAttrArray::CopyAreaSafe( SCROW nStartRow, SCROW nEndRow, long nDy, ScAttr const ScPatternAttr* pNewPattern; if (bSamePool) - pNewPattern = static_cast<const ScPatternAttr*>( &pDestDocPool->Put(*pOldPattern) ); + pNewPattern = &pDestDocPool->Put(*pOldPattern); else pNewPattern = pOldPattern->PutInPool( rAttrArray.pDocument, pDocument ); diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index b5e3577c35a4..312f59682ee9 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -715,7 +715,7 @@ void ScColumn::ApplyAttr( SCROW nRow, const SfxPoolItem& rAttr ) const ScPatternAttr* pOldPattern = pAttrArray->GetPattern( nRow ); std::unique_ptr<ScPatternAttr> pTemp(new ScPatternAttr(*pOldPattern)); pTemp->GetItemSet().Put(rAttr); - const ScPatternAttr* pNewPattern = static_cast<const ScPatternAttr*>( &pDocPool->Put( *pTemp ) ); + const ScPatternAttr* pNewPattern = &pDocPool->Put( *pTemp ); if ( pNewPattern != pOldPattern ) pAttrArray->SetPattern( nRow, pNewPattern ); diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index 13639a9977e3..efaebde867b5 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -1106,8 +1106,7 @@ ScPatternAttr* ScPatternAttr::PutInPool( ScDocument* pDestDoc, ScDocument* pSrcD } } - ScPatternAttr* pPatternAttr = - const_cast<ScPatternAttr*>( static_cast<const ScPatternAttr*>( &pDestDoc->GetPool()->Put(*pDestPattern) ) ); + ScPatternAttr* pPatternAttr = const_cast<ScPatternAttr*>( &pDestDoc->GetPool()->Put(*pDestPattern) ); return pPatternAttr; } diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx index 4460f140e74d..0a833ee34807 100644 --- a/sc/source/filter/excel/xistyle.cxx +++ b/sc/source/filter/excel/xistyle.cxx @@ -1394,7 +1394,7 @@ void XclImpXF::ApplyPatternToAttrVector( ScAttrEntry aEntry; aEntry.nEndRow = nRow2; - aEntry.pPattern = static_cast<const ScPatternAttr*>(&rDoc.GetPool()->Put(rPat)); + aEntry.pPattern = &rDoc.GetPool()->Put(rPat); rAttrs.push_back(aEntry); } } diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx index be046906a033..bb5e6f934f19 100644 --- a/sc/source/filter/oox/stylesbuffer.cxx +++ b/sc/source/filter/oox/stylesbuffer.cxx @@ -2079,7 +2079,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 = static_cast<const ScPatternAttr*>(&rDoc.GetPool()->Put(*rAttrs.mpDefPattern)); + aEntry.pPattern = &rDoc.GetPool()->Put(*rAttrs.mpDefPattern); rAttrs.maAttrs.push_back(aEntry); // Check if the default pattern is 'General'. @@ -2089,7 +2089,7 @@ void Xf::applyPatternToAttrList( AttrList& rAttrs, SCROW nRow1, SCROW nRow2, sal ScAttrEntry aEntry; aEntry.nEndRow = nRow2; - aEntry.pPattern = static_cast<const ScPatternAttr*>(&rDoc.GetPool()->Put(rPat)); + aEntry.pPattern = &rDoc.GetPool()->Put(rPat); rAttrs.maAttrs.push_back(aEntry); if (!sc::NumFmtUtil::isLatinScript(*aEntry.pPattern, rDoc)) diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx index 3c1a95e8ed5d..5a7b79852980 100644 --- a/sc/source/ui/undo/undoblk3.cxx +++ b/sc/source/ui/undo/undoblk3.cxx @@ -351,9 +351,9 @@ ScUndoSelectionAttr::ScUndoSelectionAttr( ScDocShell* pNewDocShell, bMulti ( bNewMulti ) { ScDocumentPool* pPool = pDocShell->GetDocument().GetPool(); - pApplyPattern = const_cast<ScPatternAttr*>(static_cast<const ScPatternAttr*>( &pPool->Put( *pNewApply ) )); - pLineOuter = pNewOuter ? const_cast<SvxBoxItem*>(static_cast<const SvxBoxItem*>( &pPool->Put( *pNewOuter ) )) : nullptr; - pLineInner = pNewInner ? const_cast<SvxBoxInfoItem*>(static_cast<const SvxBoxInfoItem*>( &pPool->Put( *pNewInner ) )) : nullptr; + 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; aRangeCover = pRangeCover ? *pRangeCover : aRange; } diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index debc9465a8d9..f56ef4a2051f 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -75,9 +75,9 @@ ScUndoCursorAttr::ScUndoCursorAttr( ScDocShell* pNewDocShell, pNewEditData( static_cast<EditTextObject*>(nullptr) ) { ScDocumentPool* pPool = pDocShell->GetDocument().GetPool(); - pNewPattern = const_cast<ScPatternAttr*>(static_cast<const ScPatternAttr*>( &pPool->Put( *pNewPat ) )); - pOldPattern = const_cast<ScPatternAttr*>(static_cast<const ScPatternAttr*>( &pPool->Put( *pOldPat ) )); - pApplyPattern = const_cast<ScPatternAttr*>(static_cast<const ScPatternAttr*>( &pPool->Put( *pApplyPat ) )); + pNewPattern = const_cast<ScPatternAttr*>( &pPool->Put( *pNewPat ) ); + pOldPattern = const_cast<ScPatternAttr*>( &pPool->Put( *pOldPat ) ); + pApplyPattern = const_cast<ScPatternAttr*>( &pPool->Put( *pApplyPat ) ); } ScUndoCursorAttr::~ScUndoCursorAttr() diff --git a/svl/source/items/poolcach.cxx b/svl/source/items/poolcach.cxx index 2cc33549659b..01f238caa3fb 100644 --- a/svl/source/items/poolcach.cxx +++ b/svl/source/items/poolcach.cxx @@ -88,7 +88,7 @@ const SfxSetItem& SfxItemPoolCache::ApplyTo( const SfxSetItem &rOrigItem ) } else pNewItem->GetItemSet().Put( *pSetToPut ); - const SfxSetItem* pNewPoolItem = static_cast<const SfxSetItem*>(&pPool->Put( *pNewItem )); + const SfxSetItem* pNewPoolItem = &pPool->Put( *pNewItem ); DBG_ASSERT( pNewPoolItem != pNewItem.get(), "Pool: same in and out?" ); pNewItem.reset(); diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index b2782a55532f..1c5e6098f0d2 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -467,7 +467,7 @@ void SwHistorySetFootnote::SetInDoc( SwDoc* pDoc, bool ) // set the footnote in the TextNode SwFormatFootnote aTemp( m_bEndNote ); SwFormatFootnote& rNew = const_cast<SwFormatFootnote&>( - static_cast<const SwFormatFootnote&>(pDoc->GetAttrPool().Put(aTemp)) ); + pDoc->GetAttrPool().Put(aTemp) ); if ( !m_FootnoteNumber.isEmpty() ) { rNew.SetNumStr( m_FootnoteNumber ); diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx index 8b5c2406b181..c374d261ce65 100644 --- a/sw/source/filter/writer/writer.cxx +++ b/sw/source/filter/writer/writer.cxx @@ -420,10 +420,10 @@ void Writer::AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont ) { SvxFontItem aFont( rFont ); aFont.SetWhich( RES_CHRATR_FONT ); - pItem = static_cast<const SvxFontItem*>(&rPool.Put( aFont )); + pItem = &rPool.Put( aFont ); } else - pItem = static_cast<const SvxFontItem*>(&rPool.Put( rFont )); + pItem = &rPool.Put( rFont ); if( 1 < pItem->GetRefCount() ) rPool.Remove( *pItem ); |