sw/source/core/docnode/ndtbl1.cxx       |    2 +-
 sw/source/core/layout/atrfrm.cxx        |    6 ++----
 sw/source/core/layout/flylay.cxx        |    2 +-
 sw/source/core/layout/paintfrm.cxx      |    6 +++---
 sw/source/core/layout/tabfrm.cxx        |    2 +-
 sw/source/core/layout/wsfrm.cxx         |    6 +++---
 sw/source/filter/html/htmlflywriter.cxx |    5 ++---
 sw/source/filter/html/htmltabw.cxx      |    8 ++++----
 sw/source/filter/ww8/wrtw8esh.cxx       |    6 +-----
 sw/source/ui/dialog/uiregionsw.cxx      |    2 +-
 10 files changed, 19 insertions(+), 26 deletions(-)

New commits:
commit 6585fe3fc154c518d657202295a2c5214de55b56
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Wed Jun 1 20:39:54 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Jun 2 09:45:32 2022 +0200

    elide some unnecessary null checks
    
    getSvxBrushItemFromSourceSet never returns nullptr, and
    therefore neither does SwFormat::makeBackgroundBrushItem
    
    Change-Id: I618e45c5e336f93a7bde3172f4a349b9672d0ff0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135277
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/docnode/ndtbl1.cxx 
b/sw/source/core/docnode/ndtbl1.cxx
index fe3c8f6febe0..35f4b8e7e943 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -529,7 +529,7 @@ bool SwDoc::GetRowBackground( const SwCursor& rCursor, 
std::unique_ptr<SvxBrushI
             {
                 std::unique_ptr<SvxBrushItem> 
aAlternative(aRowArr[i]->GetFrameFormat()->makeBackgroundBrushItem());
 
-                if ( rToFill && aAlternative && *rToFill != *aAlternative )
+                if ( *rToFill != *aAlternative )
                 {
                     bRet = false;
                     break;
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index eaaafde29a26..6b654cc001f1 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3253,8 +3253,7 @@ bool SwFlyFrameFormat::IsBackgroundTransparent() const
     //     and there is no background graphic, it "inherites" the background
     //     from its anchor.
     std::unique_ptr<SvxBrushItem> aBackground(makeBackgroundBrushItem());
-    if ( aBackground &&
-         aBackground->GetColor().IsTransparent() &&
+    if ( aBackground->GetColor().IsTransparent() &&
          aBackground->GetColor() != COL_TRANSPARENT
        )
     {
@@ -3293,8 +3292,7 @@ bool SwFlyFrameFormat::IsBackgroundBrushInherited() const
     else
     {
         std::unique_ptr<SvxBrushItem> aBackground(makeBackgroundBrushItem());
-        if ( aBackground &&
-             (aBackground->GetColor() == COL_TRANSPARENT) &&
+        if ( (aBackground->GetColor() == COL_TRANSPARENT) &&
              !(aBackground->GetGraphicObject()) )
         {
             return true;
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index 38d8f2887c48..48b95e15060e 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -357,7 +357,7 @@ bool SwFlyFreeFrame::supportsAutoContour() const
     {
         const std::unique_ptr<SvxBrushItem> 
aBack(GetFormat()->makeBackgroundBrushItem());
 
-        if(aBack && aBack->isUsed())
+        if(aBack->isUsed())
         {
             return false;
         }
diff --git a/sw/source/core/layout/paintfrm.cxx 
b/sw/source/core/layout/paintfrm.cxx
index 53142f0730c6..560dd0f659bc 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -4123,9 +4123,9 @@ void SwFlyFrame::PaintSwFrame(vcl::RenderContext& 
rRenderContext, SwRect const&
                 //     to determine, if background has to be painted, by 
checking, if
                 //     background color is not COL_TRANSPARENT ("no 
fill"/"auto fill")
                 //     or a background graphic exists.
-                bPaintCompleteBack = aBack &&
-                    ((aBack->GetColor() != COL_TRANSPARENT) ||
-                    aBack->GetGraphicPos() != GPOS_NONE);
+                bPaintCompleteBack =
+                    aBack->GetColor() != COL_TRANSPARENT ||
+                    aBack->GetGraphicPos() != GPOS_NONE;
             }
         }
         // paint of margin needed.
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index e092db0286ef..25213d481fa5 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -3334,7 +3334,7 @@ SwTwips SwTabFrame::GrowFrame( SwTwips nDist, bool bTst, 
bool bInfo )
         SetComplete();
 
         std::unique_ptr<SvxBrushItem> aBack = 
GetFormat()->makeBackgroundBrushItem();
-        const SvxGraphicPosition ePos = aBack ? aBack->GetGraphicPos() : 
GPOS_NONE;
+        const SvxGraphicPosition ePos = aBack->GetGraphicPos();
         if ( GPOS_NONE != ePos && GPOS_TILED != ePos )
             SetCompletePaint();
     }
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index cb50c4613006..e171ab8108be 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -1726,7 +1726,7 @@ SwTwips SwFrame::AdjustNeighbourhood( SwTwips nDiff, bool 
bTst )
 
             //Trigger a repaint if necessary.
             std::unique_ptr<SvxBrushItem> 
aBack(pUp->GetFormat()->makeBackgroundBrushItem());
-            const SvxGraphicPosition ePos = aBack ? aBack->GetGraphicPos() : 
GPOS_NONE;
+            const SvxGraphicPosition ePos = aBack->GetGraphicPos();
             if ( ePos != GPOS_NONE && ePos != GPOS_TILED )
                 pViewShell->InvalidateWindows( pUp->getFrameArea() );
 
@@ -2783,7 +2783,7 @@ SwTwips SwLayoutFrame::GrowFrame( SwTwips nDist, bool 
bTst, bool bInfo )
                 InvaPercentLowers( nReal );
 
             std::unique_ptr<SvxBrushItem> 
aBack(GetFormat()->makeBackgroundBrushItem());
-            const SvxGraphicPosition ePos = aBack ? aBack->GetGraphicPos() : 
GPOS_NONE;
+            const SvxGraphicPosition ePos = aBack->GetGraphicPos();
             if ( GPOS_NONE != ePos && GPOS_TILED != ePos )
                 SetCompletePaint();
         }
@@ -2984,7 +2984,7 @@ SwTwips SwLayoutFrame::ShrinkFrame( SwTwips nDist, bool 
bTst, bool bInfo )
             if (pFormat)
             {
                 std::unique_ptr<SvxBrushItem> 
aBack(pFormat->makeBackgroundBrushItem());
-                const SvxGraphicPosition ePos = aBack ? aBack->GetGraphicPos() 
: GPOS_NONE;
+                const SvxGraphicPosition ePos = aBack->GetGraphicPos();
                 if ( GPOS_NONE == ePos || GPOS_TILED == ePos )
                     bCompletePaint = false;
             }
diff --git a/sw/source/filter/html/htmlflywriter.cxx 
b/sw/source/filter/html/htmlflywriter.cxx
index 940b7c9d9a86..f8ff5c851024 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -260,9 +260,8 @@ sal_uInt16 SwHTMLWriter::GuessFrameType( const 
SwFrameFormat& rFrameFormat,
                     std::unique_ptr<SvxBrushItem> aBrush = 
rFrameFormat.makeBackgroundBrushItem();
                     /// background is not empty, if it has a background graphic
                     /// or its background color is not "no fill"/"auto fill".
-                    if( aBrush &&
-                        (GPOS_NONE != aBrush->GetGraphicPos() ||
-                        aBrush->GetColor() != COL_TRANSPARENT ))
+                    if( GPOS_NONE != aBrush->GetGraphicPos() ||
+                        aBrush->GetColor() != COL_TRANSPARENT )
                     {
                         bEmpty = false;
                     }
diff --git a/sw/source/filter/html/htmltabw.cxx 
b/sw/source/filter/html/htmltabw.cxx
index 46507b6a31b2..b8aac9aed9ba 100644
--- a/sw/source/filter/html/htmltabw.cxx
+++ b/sw/source/filter/html/htmltabw.cxx
@@ -143,8 +143,8 @@ bool SwHTMLWrtTable::HasTabBackground( const SwTableBox& 
rBox,
 
         /// The table box has a background, if its background color is not "no 
fill"/
         /// "auto fill" or it has a background graphic.
-        bRet = aBrushItem && (aBrushItem->GetColor() != COL_TRANSPARENT ||
-               !aBrushItem->GetGraphicLink().isEmpty() || 
aBrushItem->GetGraphic());
+        bRet = aBrushItem->GetColor() != COL_TRANSPARENT ||
+               !aBrushItem->GetGraphicLink().isEmpty() || 
aBrushItem->GetGraphic();
     }
     else
     {
@@ -172,8 +172,8 @@ bool SwHTMLWrtTable::HasTabBackground( const SwTableLine& 
rLine,
     std::unique_ptr<SvxBrushItem> aBrushItem = 
rLine.GetFrameFormat()->makeBackgroundBrushItem();
     /// The table line has a background, if its background color is not "no 
fill"/
     /// "auto fill" or it has a background graphic.
-    bool bRet = aBrushItem && (aBrushItem->GetColor() != COL_TRANSPARENT ||
-           !aBrushItem->GetGraphicLink().isEmpty() || 
aBrushItem->GetGraphic());
+    bool bRet = aBrushItem->GetColor() != COL_TRANSPARENT ||
+           !aBrushItem->GetGraphicLink().isEmpty() || aBrushItem->GetGraphic();
 
     if( !bRet )
     {
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx 
b/sw/source/filter/ww8/wrtw8esh.cxx
index edab0fccf69a..b946c62f75ac 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -2019,11 +2019,7 @@ sal_Int32 SwBasicEscherEx::WriteFlyFrameAttr(const 
SwFrameFormat& rFormat,
     if (bIsInHeader || bIsThrough)
     {
         std::unique_ptr<SvxBrushItem> 
aBrush(rFormat.makeBackgroundBrushItem());
-
-        if(aBrush)
-        {
-            WriteBrushAttr(*aBrush, rPropOpt);
-        }
+        WriteBrushAttr(*aBrush, rPropOpt);
     }
     else
     {
diff --git a/sw/source/ui/dialog/uiregionsw.cxx 
b/sw/source/ui/dialog/uiregionsw.cxx
index ec945dc6f8c3..2391919aa1c4 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -773,7 +773,7 @@ IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl, weld::Button&, void)
                     pSet->Put( pRepr->GetCol() );
 
                 std::unique_ptr<SvxBrushItem> 
aBrush(pFormat->makeBackgroundBrushItem(false));
-                if( aBrush && pRepr->GetBackground() && *aBrush != 
*pRepr->GetBackground() )
+                if( pRepr->GetBackground() && *aBrush != 
*pRepr->GetBackground() )
                     pSet->Put( *pRepr->GetBackground() );
 
                 if( pFormat->GetFootnoteAtTextEnd(false) != 
pRepr->GetFootnoteNtAtEnd() )

Reply via email to