sw/inc/editsh.hxx                   |    2 +-
 sw/inc/numrule.hxx                  |    2 +-
 sw/inc/unostyle.hxx                 |    2 +-
 sw/source/core/doc/number.cxx       |   12 ++++++------
 sw/source/core/edit/edglss.cxx      |   24 +++++++++++-------------
 sw/source/core/frmedt/fecopy.cxx    |    2 +-
 sw/source/core/sw3io/swacorr.cxx    |    2 +-
 sw/source/core/unocore/unostyle.cxx |   24 ++++++++++++------------
 8 files changed, 34 insertions(+), 36 deletions(-)

New commits:
commit ffbc494b2a139eabf062432f5b4fed3a4ce46382
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Oct 4 17:31:47 2020 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sun Oct 4 20:42:50 2020 +0200

    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 <caol...@redhat.com>

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 66226bc40d5a..b5d0068bd86a 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -200,7 +200,7 @@ public:
        If table is copied into table, move all cursors away from it.
        Copy and Paste must be in FEShell because of FlyFrames!
        Copy all selections to the document. */
-    bool CopySelToDoc( SwDoc* pInsDoc );
+    bool CopySelToDoc( SwDoc& rInsDoc );
 
     void SplitNode( bool bAutoFormat = false, bool bCheckTableStart = true );
     bool AppendTextNode();
diff --git a/sw/inc/numrule.hxx b/sw/inc/numrule.hxx
index 4da44bbd8ced..84f2bfba5426 100644
--- a/sw/inc/numrule.hxx
+++ b/sw/inc/numrule.hxx
@@ -52,7 +52,7 @@ class SW_DLLPUBLIC SwNumFormat final : public 
SvxNumberFormat, public SwClient
     std::unique_ptr<SwFormatVertOrient> m_pVertOrient;
     //For i120928,record the cp info of graphic within bullet
     sal_Unicode     m_cGrfBulletCP;
-    SAL_DLLPRIVATE void UpdateNumNodes( SwDoc* pDoc );
+    SAL_DLLPRIVATE void UpdateNumNodes(SwDoc& rDoc);
 
     using SvxNumberFormat::operator ==;
     using SvxNumberFormat::operator !=;
diff --git a/sw/inc/unostyle.hxx b/sw/inc/unostyle.hxx
index 2b29d2aa6729..0b40d1e73249 100644
--- a/sw/inc/unostyle.hxx
+++ b/sw/inc/unostyle.hxx
@@ -158,7 +158,7 @@ class SwXAutoStylesEnumerator final : public 
cppu::WeakImplHelper< css::containe
 {
     std::unique_ptr<SwAutoStylesEnumImpl> m_pImpl;
 public:
-    SwXAutoStylesEnumerator( SwDoc* pDoc, IStyleAccess::SwAutoStyleFamily eFam 
);
+    SwXAutoStylesEnumerator( SwDoc& rDoc, IStyleAccess::SwAutoStyleFamily eFam 
);
     virtual ~SwXAutoStylesEnumerator() override;
 
     //XEnumeration
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;
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to