diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-09-29 20:50:43 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-09-30 09:46:21 +0200 |
commit | 55dfe2c12e450a90cbc05f9ec53f1ed6508d8de9 (patch) | |
tree | 1a312462989f3a521b3471225443ac229db4e7b6 /sw/source/core/unocore | |
parent | ac94aa6f7d2a8e41e7260ba740813cdbbdd6a2ae (diff) |
SwNode::GetDoc can return a reference instead
and remove discovered redundant null checks
Change-Id: I6b8bc9593434f38947e399a48888a8fa0d4f7e77
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103640
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/core/unocore')
-rw-r--r-- | sw/source/core/unocore/unocrsr.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/unocore/unocrsrhelper.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unodraw.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unofield.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/unocore/unoflatpara.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/unocore/unoframe.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj2.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/unocore/unoparagraph.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/unocore/unorefmk.cxx | 14 |
9 files changed, 27 insertions, 27 deletions
diff --git a/sw/source/core/unocore/unocrsr.cxx b/sw/source/core/unocore/unocrsr.cxx index 76bdb939b7a8..115326eabbf7 100644 --- a/sw/source/core/unocore/unocrsr.cxx +++ b/sw/source/core/unocore/unocrsr.cxx @@ -184,8 +184,8 @@ void SwUnoTableCursor::MakeBoxSels() const SwContentNode* pCNd; bool bMakeTableCursors = true; if( GetPoint()->nNode.GetIndex() && GetMark()->nNode.GetIndex() && - nullptr != ( pCNd = GetContentNode() ) && pCNd->getLayoutFrame( pCNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout() ) && - nullptr != ( pCNd = GetContentNode(false) ) && pCNd->getLayoutFrame( pCNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout() ) ) + nullptr != ( pCNd = GetContentNode() ) && pCNd->getLayoutFrame( pCNd->GetDoc().getIDocumentLayoutAccess().GetCurrentLayout() ) && + nullptr != ( pCNd = GetContentNode(false) ) && pCNd->getLayoutFrame( pCNd->GetDoc().getIDocumentLayoutAccess().GetCurrentLayout() ) ) bMakeTableCursors = GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout()->MakeTableCursors( *this ); if ( !bMakeTableCursors ) diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 451c9cce7fa4..6727693d0bcf 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -664,7 +664,7 @@ bool getCursorPropertyValue(const SfxItemPropertySimpleEntry& rEntry { if (pAny) { - uno::Reference<text::XTextContent> xParagraph = SwXParagraph::CreateXParagraph(*pTextNode->GetDoc(), pTextNode); + uno::Reference<text::XTextContent> xParagraph = SwXParagraph::CreateXParagraph(pTextNode->GetDoc(), pTextNode); *pAny <<= xParagraph; } } diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 5a3fdbb38736..5242276dfdd3 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -2048,7 +2048,7 @@ void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange) else if (pPortion) pDoc = pPortion->GetCursor().GetDoc(); else if (pParagraph && pParagraph->GetTextNode()) - pDoc = pParagraph->GetTextNode()->GetDoc(); + pDoc = &pParagraph->GetTextNode()->GetDoc(); } diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 87c8e7b1a876..cd1504545971 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -1290,7 +1290,7 @@ void SwXTextField::TransmuteLeadToInputField(SwSetExpField & rField) assert(tempFormat.Which() == (static_cast<SwSetExpField const*>(tempFormat.GetField())->GetInputFlag() ? RES_TXTATR_INPUTFIELD : RES_TXTATR_FIELD)); SwTextNode & rNode(pOldAttr->GetTextNode()); std::shared_ptr<SwPaM> pPamForTextField; - IDocumentContentOperations & rIDCO(rNode.GetDoc()->getIDocumentContentOperations()); + IDocumentContentOperations & rIDCO(rNode.GetDoc().getIDocumentContentOperations()); SwTextField::GetPamForTextField(*pOldAttr, pPamForTextField); assert(pPamForTextField); sal_Int32 const nStart(pPamForTextField->Start()->nContent.GetIndex()); @@ -1306,7 +1306,7 @@ void SwXTextField::TransmuteLeadToInputField(SwSetExpField & rField) assert(static_cast<SwSetExpField const*>(rNewFormat.GetField())->GetInputFlag() == (dynamic_cast<SwTextInputField const*>(pNewAttr) != nullptr)); if (xField.is()) { - pXField->m_pImpl->SetFormatField(const_cast<SwFormatField*>(&rNewFormat), rNode.GetDoc()); + pXField->m_pImpl->SetFormatField(const_cast<SwFormatField*>(&rNewFormat), &rNode.GetDoc()); const_cast<SwFormatField&>(rNewFormat).SetXTextField(xField); } } diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index ea3ae869c62d..5e405e9ec75c 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -258,11 +258,11 @@ void SAL_CALL SwXFlatParagraph::changeText(::sal_Int32 nPos, ::sal_Int32 nLen, c SwPaM aPaM( *GetTextNode(), nPos, *GetTextNode(), nPos+nLen ); - UnoActionContext aAction( GetTextNode()->GetDoc() ); + UnoActionContext aAction( &GetTextNode()->GetDoc() ); const uno::Reference< text::XTextRange > xRange = SwXTextRange::CreateXTextRange( - *GetTextNode()->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); + GetTextNode()->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); uno::Reference< beans::XPropertySet > xPropSet( xRange, uno::UNO_QUERY ); if ( xPropSet.is() ) { @@ -291,11 +291,11 @@ void SAL_CALL SwXFlatParagraph::changeAttributes(::sal_Int32 nPos, ::sal_Int32 n SwPaM aPaM( *GetTextNode(), nPos, *GetTextNode(), nPos+nLen ); - UnoActionContext aAction( GetTextNode()->GetDoc() ); + UnoActionContext aAction( &GetTextNode()->GetDoc() ); const uno::Reference< text::XTextRange > xRange = SwXTextRange::CreateXTextRange( - *GetTextNode()->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); + GetTextNode()->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); uno::Reference< beans::XPropertySet > xPropSet( xRange, uno::UNO_QUERY ); if ( xPropSet.is() ) { @@ -520,7 +520,7 @@ uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getParaAfter(co return xRet; SwTextNode* pNextTextNode = nullptr; - const SwNodes& rNodes = pCurrentNode->GetDoc()->GetNodes(); + const SwNodes& rNodes = pCurrentNode->GetDoc().GetNodes(); for( sal_uLong nCurrentNode = pCurrentNode->GetIndex() + 1; nCurrentNode < rNodes.Count(); ++nCurrentNode ) { @@ -566,7 +566,7 @@ uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getParaBefore(c return xRet; SwTextNode* pPrevTextNode = nullptr; - const SwNodes& rNodes = pCurrentNode->GetDoc()->GetNodes(); + const SwNodes& rNodes = pCurrentNode->GetDoc().GetNodes(); for( sal_uLong nCurrentNode = pCurrentNode->GetIndex() - 1; nCurrentNode > 0; --nCurrentNode ) { diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 5d7b86fc37e0..5c7bffdc8663 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -3627,7 +3627,7 @@ void SwXOLEListener::modified( const lang::EventObject& /*rEvent*/ ) return; } pNd->SetOLESizeInvalid(true); - pNd->GetDoc()->SetOLEObjModified(); + pNd->GetDoc().SetOLEObjModified(); } void SwXOLEListener::disposing( const lang::EventObject& rEvent ) diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 58cf18b9cea0..b6b96608e6fb 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -144,20 +144,20 @@ void CollectFrameAtNode( const SwNodeIndex& rIdx, // <false>: at-paragraph anchored objects are collected // search all borders, images, and OLEs that are connected to the paragraph - SwDoc* pDoc = rIdx.GetNode().GetDoc(); + SwDoc& rDoc = rIdx.GetNode().GetDoc(); const auto nChkType = bAtCharAnchoredObjs ? RndStdIds::FLY_AT_CHAR : RndStdIds::FLY_AT_PARA; const SwContentFrame* pCFrame; const SwContentNode* pCNd; - if( pDoc->getIDocumentLayoutAccess().GetCurrentViewShell() && + if( rDoc.getIDocumentLayoutAccess().GetCurrentViewShell() && nullptr != (pCNd = rIdx.GetNode().GetContentNode()) && - nullptr != (pCFrame = pCNd->getLayoutFrame( pDoc->getIDocumentLayoutAccess().GetCurrentLayout())) ) + nullptr != (pCFrame = pCNd->getLayoutFrame( rDoc.getIDocumentLayoutAccess().GetCurrentLayout())) ) { lcl_CollectFrameAtNodeWithLayout(pCFrame, rFrames, nChkType); } else { - const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + const SwFrameFormats& rFormats = *rDoc.GetSpzFrameFormats(); const size_t nSize = rFormats.size(); for ( size_t i = 0; i < nSize; i++) { diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index d62ed4ab5710..2cf496283482 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -1186,7 +1186,7 @@ SwXParagraph::getPropertyDefault(const OUString& rPropertyName) if(bBelowFrameAtrEnd || bDrawingLayerRange) { - const SfxPoolItem& rDefItem = rTextNode.GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID); + const SfxPoolItem& rDefItem = rTextNode.GetDoc().GetAttrPool().GetDefaultItem(pEntry->nWID); rDefItem.QueryValue(aRet, pEntry->nMemberId); } @@ -1228,7 +1228,7 @@ void SAL_CALL SwXParagraph::dispose() if (pTextNode) { SwCursor aCursor( SwPosition( *pTextNode ), nullptr ); - pTextNode->GetDoc()->getIDocumentContentOperations().DelFullPara(aCursor); + pTextNode->GetDoc().getIDocumentContentOperations().DelFullPara(aCursor); lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this)); m_pImpl->m_EventListeners.disposeAndClear(ev); } @@ -1408,7 +1408,7 @@ uno::Reference<frame::XModel> SwXParagraph::GetModel() SwTextNode *const pTextNode( m_pImpl->GetTextNode() ); if (pTextNode) { - SwDocShell const*const pShell( pTextNode->GetDoc()->GetDocShell() ); + SwDocShell const*const pShell( pTextNode->GetDoc().GetDocShell() ); return pShell ? pShell->GetModel() : nullptr; } return nullptr; diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 581e8c7656c1..3d6cd98f3551 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -744,13 +744,13 @@ SwXMeta::CreateXMeta(::sw::Meta & rMeta, SAL_WARN_IF(!pTextAttr, "sw.uno", "CreateXMeta: no text attr?"); if (!pTextAttr) { return nullptr; } const SwPosition aPos(*pTextNode, pTextAttr->GetStart()); - xParentText.set( ::sw::CreateParentXText(*pTextNode->GetDoc(), aPos) ); + xParentText.set( ::sw::CreateParentXText(pTextNode->GetDoc(), aPos) ); } if (!xParentText.is()) { return nullptr; } SwXMeta *const pXMeta( (RES_TXTATR_META == rMeta.GetFormatMeta()->Which()) - ? new SwXMeta (pTextNode->GetDoc(), &rMeta, xParentText, + ? new SwXMeta (&pTextNode->GetDoc(), &rMeta, xParentText, std::move(pPortions)) - : new SwXMetaField(pTextNode->GetDoc(), &rMeta, xParentText, + : new SwXMetaField(&pTextNode->GetDoc(), &rMeta, xParentText, std::move(pPortions))); // this is why the constructor is private: need to acquire pXMeta here xMeta.set(pXMeta); @@ -924,8 +924,8 @@ SwXMeta::dispose() { // -1 because of CH_TXTATR SwPaM aPam( *pTextNode, nMetaStart - 1, *pTextNode, nMetaEnd ); - SwDoc * const pDoc( pTextNode->GetDoc() ); - pDoc->getIDocumentContentOperations().DeleteAndJoin( aPam ); + SwDoc& rDoc( pTextNode->GetDoc() ); + rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam ); // removal should call Modify and do the dispose assert(m_pImpl->m_bIsDisposed); @@ -1058,7 +1058,7 @@ SwXMeta::getAnchor() const SwPosition start(*pTextNode, nMetaStart - 1); // -1 due to CH_TXTATR const SwPosition end(*pTextNode, nMetaEnd); - return SwXTextRange::CreateXTextRange(*pTextNode->GetDoc(), start, &end); + return SwXTextRange::CreateXTextRange(pTextNode->GetDoc(), start, &end); } // XTextRange @@ -1237,7 +1237,7 @@ uno::Reference<frame::XModel> SwXMeta::GetModel() SwTextNode const * const pTextNode( pMeta->GetTextNode() ); if (pTextNode) { - SwDocShell const * const pShell(pTextNode->GetDoc()->GetDocShell()); + SwDocShell const * const pShell(pTextNode->GetDoc().GetDocShell()); return pShell ? pShell->GetModel() : nullptr; } } |