diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-10-04 17:31:47 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-10-04 20:42:50 +0200 |
commit | ffbc494b2a139eabf062432f5b4fed3a4ce46382 (patch) | |
tree | c34bfd695c3e66dbef6156ad1068949b1562b9cd /sw/source | |
parent | 6539ff3f4123a961a949c8d6a5fae8880c3d7081 (diff) |
SwXAutoStylesEnumerator always dereferences its SwDoc* arg
ditto:
SwNumFormat::UpdateNumNodes
SwEditShell::CopySelToDoc
Change-Id: I5f18b04e420facb703fcace20c645281d409cea6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103923
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/doc/number.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/edit/edglss.cxx | 24 | ||||
-rw-r--r-- | sw/source/core/frmedt/fecopy.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/sw3io/swacorr.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 24 |
5 files changed, 31 insertions, 33 deletions
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx index 4de390353fdf..5430df621177 100644 --- a/sw/source/core/doc/number.cxx +++ b/sw/source/core/doc/number.cxx @@ -293,7 +293,7 @@ void SwNumFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) } if( pFormat && !pFormat->GetDoc()->IsInDtor() ) - UpdateNumNodes( const_cast<SwDoc*>(pFormat->GetDoc()) ); + UpdateNumNodes( *const_cast<SwDoc*>(pFormat->GetDoc()) ); else CheckRegistration( pOld ); } @@ -314,13 +314,13 @@ void SwNumFormat::SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size SvxNumberFormat::SetGraphicBrush( pBrushItem, pSize, pOrient); } -void SwNumFormat::UpdateNumNodes( SwDoc* pDoc ) +void SwNumFormat::UpdateNumNodes( SwDoc& rDoc ) { - bool bDocIsModified = pDoc->getIDocumentState().IsModified(); + bool bDocIsModified = rDoc.getIDocumentState().IsModified(); bool bFnd = false; - for( SwNumRuleTable::size_type n = pDoc->GetNumRuleTable().size(); !bFnd && n; ) + for( SwNumRuleTable::size_type n = rDoc.GetNumRuleTable().size(); !bFnd && n; ) { - const SwNumRule* pRule = pDoc->GetNumRuleTable()[ --n ]; + const SwNumRule* pRule = rDoc.GetNumRuleTable()[ --n ]; for( sal_uInt8 i = 0; i < MAXLEVEL; ++i ) if( pRule->GetNumFormat( i ) == this ) { @@ -336,7 +336,7 @@ void SwNumFormat::UpdateNumNodes( SwDoc* pDoc ) } if( bFnd && !bDocIsModified ) - pDoc->getIDocumentState().ResetModified(); + rDoc.getIDocumentState().ResetModified(); } const SwFormatVertOrient* SwNumFormat::GetGraphicOrientation() const diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index 9ae88459452e..ce1aaecad7a4 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -64,7 +64,7 @@ sal_uInt16 SwEditShell::MakeGlossary( SwTextBlocks& rBlks, const OUString& rName if( rBlks.BeginPutDoc( rShortName, rName ) ) { rBlks.GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::DeleteRedlines ); - CopySelToDoc( pGDoc ); + CopySelToDoc(*pGDoc); rBlks.GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::NONE ); return rBlks.PutDoc(); } @@ -151,11 +151,9 @@ sal_uInt16 SwEditShell::SaveGlossaryDoc( SwTextBlocks& rBlock, } /// copy all selections to the doc -bool SwEditShell::CopySelToDoc( SwDoc* pInsDoc ) +bool SwEditShell::CopySelToDoc( SwDoc& rInsDoc ) { - OSL_ENSURE( pInsDoc, "no Ins.Document" ); - - SwNodes& rNds = pInsDoc->GetNodes(); + SwNodes& rNds = rInsDoc.GetNodes(); SwNodeIndex aIdx( rNds.GetEndOfContent(), -1 ); SwContentNode *const pContentNode = aIdx.GetNode().GetContentNode(); @@ -165,7 +163,7 @@ bool SwEditShell::CopySelToDoc( SwDoc* pInsDoc ) bool bRet = false; CurrShell aCurr( this ); - pInsDoc->getIDocumentFieldsAccess().LockExpFields(); + rInsDoc.getIDocumentFieldsAccess().LockExpFields(); if( IsTableMode() ) { @@ -184,7 +182,7 @@ bool SwEditShell::CopySelToDoc( SwDoc* pInsDoc ) if( bCpyTableNm ) { const OUString rTableName = pTableNd->GetTable().GetFrameFormat()->GetName(); - const SwFrameFormats& rTableFormats = *pInsDoc->GetTableFrameFormats(); + const SwFrameFormats& rTableFormats = *rInsDoc.GetTableFrameFormats(); for( auto n = rTableFormats.size(); n; ) if( rTableFormats[ --n ]->GetName() == rTableName ) { @@ -192,7 +190,7 @@ bool SwEditShell::CopySelToDoc( SwDoc* pInsDoc ) break; } } - bRet = pInsDoc->InsCopyOfTable( aPos, aBoxes, nullptr, bCpyTableNm ); + bRet = rInsDoc.InsCopyOfTable( aPos, aBoxes, nullptr, bCpyTableNm ); } else bRet = false; @@ -200,8 +198,8 @@ bool SwEditShell::CopySelToDoc( SwDoc* pInsDoc ) else { bool bColSel = GetCursor_()->IsColumnSelection(); - if( bColSel && pInsDoc->IsClipBoard() ) - pInsDoc->SetColumnSelection( true ); + if( bColSel && rInsDoc.IsClipBoard() ) + rInsDoc.SetColumnSelection( true ); bool bSelectAll = StartsWithTable() && ExtendedSelectedAll(); { for(SwPaM& rPaM : GetCursor()->GetRingContainer()) @@ -251,9 +249,9 @@ bool SwEditShell::CopySelToDoc( SwDoc* pInsDoc ) } } - pInsDoc->getIDocumentFieldsAccess().UnlockExpFields(); - if( !pInsDoc->getIDocumentFieldsAccess().IsExpFieldsLocked() ) - pInsDoc->getIDocumentFieldsAccess().UpdateExpFields(nullptr, true); + rInsDoc.getIDocumentFieldsAccess().UnlockExpFields(); + if( !rInsDoc.getIDocumentFieldsAccess().IsExpFieldsLocked() ) + rInsDoc.getIDocumentFieldsAccess().UpdateExpFields(nullptr, true); return bRet; } diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index 0716d652fa05..2ee2dc9092b3 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -214,7 +214,7 @@ void SwFEShell::Copy( SwDoc* pClpDoc, const OUString* pNewClpText ) } } else - CopySelToDoc( pClpDoc ); // copy the selections + CopySelToDoc(*pClpDoc); // copy the selections pClpDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::NONE ); pClpDoc->getIDocumentFieldsAccess().UnlockExpFields(); diff --git a/sw/source/core/sw3io/swacorr.cxx b/sw/source/core/sw3io/swacorr.cxx index 748f764a3b71..19c0b236fa05 100644 --- a/sw/source/core/sw3io/swacorr.cxx +++ b/sw/source/core/sw3io/swacorr.cxx @@ -77,7 +77,7 @@ bool SwAutoCorrect::PutText( const uno::Reference < embed::XStorage >& rStg, nRet = aBlk.BeginPutDoc( rShort, rShort ); if( ! nRet.IsError() ) { - rDShell.GetEditShell()->CopySelToDoc( pDoc ); + rDShell.GetEditShell()->CopySelToDoc( *pDoc ); nRet = aBlk.PutDoc(); aBlk.AddName ( rShort, rShort ); if( ! nRet.IsError() ) diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 2f07bd534f66..e0562aec456d 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -3373,14 +3373,14 @@ class SwAutoStylesEnumImpl { std::vector<std::shared_ptr<SfxItemSet>> mAutoStyles; std::vector<std::shared_ptr<SfxItemSet>>::iterator aIter; - SwDoc* pDoc; + SwDoc& rDoc; IStyleAccess::SwAutoStyleFamily eFamily; public: - SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam ); + SwAutoStylesEnumImpl( SwDoc& rInitDoc, IStyleAccess::SwAutoStyleFamily eFam ); bool hasMoreElements() { return aIter != mAutoStyles.end(); } std::shared_ptr<SfxItemSet> const & nextElement() { return *(aIter++); } IStyleAccess::SwAutoStyleFamily getFamily() const { return eFamily; } - SwDoc* getDoc() const { return pDoc; } + SwDoc& getDoc() const { return rDoc; } }; SwXAutoStyles::SwXAutoStyles(SwDocShell& rDocShell) : @@ -3732,7 +3732,7 @@ uno::Reference< container::XEnumeration > SwXAutoStyleFamily::createEnumeration( if( !m_pDocShell ) throw uno::RuntimeException(); return uno::Reference< container::XEnumeration > - (new SwXAutoStylesEnumerator( m_pDocShell->GetDoc(), m_eFamily )); + (new SwXAutoStylesEnumerator( *m_pDocShell->GetDoc(), m_eFamily )); } uno::Type SwXAutoStyleFamily::getElementType( ) @@ -3745,14 +3745,14 @@ sal_Bool SwXAutoStyleFamily::hasElements( ) return false; } -SwAutoStylesEnumImpl::SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam ) -: pDoc( pInitDoc ), eFamily( eFam ) +SwAutoStylesEnumImpl::SwAutoStylesEnumImpl( SwDoc& rInitDoc, IStyleAccess::SwAutoStyleFamily eFam ) +: rDoc( rInitDoc ), eFamily( eFam ) { // special case for ruby auto styles: if ( IStyleAccess::AUTO_STYLE_RUBY == eFam ) { std::set< std::pair< sal_uInt16, text::RubyAdjust > > aRubyMap; - SwAttrPool& rAttrPool = pDoc->GetAttrPool(); + SwAttrPool& rAttrPool = rDoc.GetAttrPool(); // do this in two phases otherwise we invalidate the iterators when we insert into the pool std::vector<const SwFormatRuby*> vRubyItems; @@ -3775,17 +3775,17 @@ SwAutoStylesEnumImpl::SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAut } else { - pDoc->GetIStyleAccess().getAllStyles( mAutoStyles, eFamily ); + rDoc.GetIStyleAccess().getAllStyles( mAutoStyles, eFamily ); } aIter = mAutoStyles.begin(); } -SwXAutoStylesEnumerator::SwXAutoStylesEnumerator( SwDoc* pDoc, IStyleAccess::SwAutoStyleFamily eFam ) -: m_pImpl( new SwAutoStylesEnumImpl( pDoc, eFam ) ) +SwXAutoStylesEnumerator::SwXAutoStylesEnumerator( SwDoc& rDoc, IStyleAccess::SwAutoStyleFamily eFam ) +: m_pImpl( new SwAutoStylesEnumImpl( rDoc, eFam ) ) { // Register ourselves as a listener to the document (via the page descriptor) - StartListening(pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier()); + StartListening(rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier()); } SwXAutoStylesEnumerator::~SwXAutoStylesEnumerator() @@ -3813,7 +3813,7 @@ uno::Any SwXAutoStylesEnumerator::nextElement( ) if( m_pImpl->hasMoreElements() ) { std::shared_ptr<SfxItemSet> pNextSet = m_pImpl->nextElement(); - uno::Reference< style::XAutoStyle > xAutoStyle = new SwXAutoStyle(m_pImpl->getDoc(), + uno::Reference< style::XAutoStyle > xAutoStyle = new SwXAutoStyle(&m_pImpl->getDoc(), pNextSet, m_pImpl->getFamily()); aRet <<= xAutoStyle; } |