From 3dee30f1c033d3679f7b8dbc7813b7dc03ac8f70 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 2 Oct 2020 20:11:38 +0100 Subject: SwSvxUnoDrawPool ctor never passed a null SwDoc* MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit which is always dereferenced and never changes. so m_pDoc can never be null so delete that redundant condition Change-Id: I4fde5f3f8f0ffcc790d1c8f16a8ab05a842eed06 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103876 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sw/source/uibase/uno/unodefaults.cxx | 25 ++++++++++--------------- sw/source/uibase/uno/unodefaults.hxx | 4 ++-- sw/source/uibase/uno/unotxdoc.cxx | 2 +- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/sw/source/uibase/uno/unodefaults.cxx b/sw/source/uibase/uno/unodefaults.cxx index 6daaeee4edc1..135bf88e80ec 100644 --- a/sw/source/uibase/uno/unodefaults.cxx +++ b/sw/source/uibase/uno/unodefaults.cxx @@ -23,9 +23,9 @@ #include #include -SwSvxUnoDrawPool::SwSvxUnoDrawPool(SwDoc* pDoc) - : SvxUnoDrawPool(pDoc->getIDocumentDrawModelAccess().GetDrawModel(), SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER) - , m_pDoc(pDoc) +SwSvxUnoDrawPool::SwSvxUnoDrawPool(SwDoc& rDoc) + : SvxUnoDrawPool(rDoc.getIDocumentDrawModelAccess().GetDrawModel(), SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER) + , m_rDoc(rDoc) { } @@ -35,18 +35,13 @@ SwSvxUnoDrawPool::~SwSvxUnoDrawPool() throw() SfxItemPool* SwSvxUnoDrawPool::getModelPool( bool /*bReadOnly*/ ) throw() { - if(m_pDoc) - { - - // DVO, OD 01.10.2003 #i18732# - return item pool of writer document; - // it contains draw model item pool as secondary pool. - //SdrModel* pModel = m_pDoc->MakeDrawModel(); - //return &pModel->GetItemPool(); - // #i52858# - method name changed - m_pDoc->getIDocumentDrawModelAccess().GetOrCreateDrawModel(); - return &(m_pDoc->GetAttrPool()); - } - return nullptr; + // DVO, OD 01.10.2003 #i18732# - return item pool of writer document; + // it contains draw model item pool as secondary pool. + //SdrModel* pModel = m_rDoc.MakeDrawModel(); + //return &pModel->GetItemPool(); + // #i52858# - method name changed + m_rDoc.getIDocumentDrawModelAccess().GetOrCreateDrawModel(); + return &(m_rDoc.GetAttrPool()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/uno/unodefaults.hxx b/sw/source/uibase/uno/unodefaults.hxx index 23bd6b543e10..ba218940b6d0 100644 --- a/sw/source/uibase/uno/unodefaults.hxx +++ b/sw/source/uibase/uno/unodefaults.hxx @@ -25,9 +25,9 @@ class SwDoc; class SwSvxUnoDrawPool : public SvxUnoDrawPool { - SwDoc* m_pDoc; + SwDoc& m_rDoc; public: - SwSvxUnoDrawPool(SwDoc* pDoc); + SwSvxUnoDrawPool(SwDoc& rDoc); virtual ~SwSvxUnoDrawPool() throw() override; virtual SfxItemPool* getModelPool( bool bReadOnly ) throw() override; diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 7208fd2d94ca..31f7cf31c68a 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -4356,7 +4356,7 @@ Reference SwXDocumentPropertyHelper::GetDrawTable(SwCreateDrawTable break; case SwCreateDrawTable::Defaults: if(!xDrawDefaults.is()) - xDrawDefaults = static_cast(new SwSvxUnoDrawPool(m_pDoc)); + xDrawDefaults = static_cast(new SwSvxUnoDrawPool(*m_pDoc)); xRet = xDrawDefaults; break; #if OSL_DEBUG_LEVEL > 0 -- cgit