[Libreoffice-commits] core.git: sw/source

Caolán McNamara caolanm at redhat.com
Thu Jan 15 12:34:37 PST 2015


 sw/source/core/doc/docdesc.cxx |   35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)

New commits:
commit 7de5ffbf3de77070a2f71fa3cd0846fc2bef8052
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jan 15 20:33:12 2015 +0000

    coverity#1264391 help coverity out wrt Logically dead code
    
    also
    
    coverity#1264392 Logically dead code
    
    Change-Id: I37c542a6d088a2aca4cf09a341d389efd34f423a

diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index 4f3801d..501d849 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -212,12 +212,29 @@ static void lcl_DescSetAttr( const SwFrmFmt &rSource, SwFrmFmt &rDest,
     rDest.SetPoolHlpFileId( rSource.GetPoolHlpFileId() );
 }
 
+namespace
+{
+    SwFrmFmt& getFrmFmt(SwPageDesc &rDesc, bool bLeft, bool bFirst)
+    {
+        if (bFirst)
+        {
+            if (bLeft)
+                return rDesc.GetFirstLeft();
+            rDesc.GetFirstMaster();
+        }
+        return rDesc.GetLeft();
+    }
+
+    const SwFrmFmt& getConstFrmFmt(const SwPageDesc &rDesc, bool bLeft, bool bFirst)
+    {
+        return getFrmFmt(const_cast<SwPageDesc&>(rDesc), bLeft, bFirst);
+    }
+}
+
 void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead, SwPageDesc &rDesc, bool bLeft, bool bFirst)
 {
     assert(bLeft || bFirst);
-    SwFrmFmt& rDescFrmFmt = (bFirst)
-            ? (bLeft) ? rDesc.GetFirstLeft() : rDesc.GetFirstMaster()
-            : rDesc.GetLeft();
+    SwFrmFmt& rDescFrmFmt = getFrmFmt(rDesc, bLeft, bFirst);
     if (bFirst && bLeft)
     {
         // special case: always shared with something
@@ -252,9 +269,7 @@ void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead,
 
             if (!aCnt.GetCntntIdx())
             {
-                const SwFrmFmt& rChgedFrmFmt = (bFirst)
-                    ? (bLeft) ? rChged.GetFirstLeft() : rChged.GetFirstMaster()
-                    : rChged.GetLeft();
+                const SwFrmFmt& rChgedFrmFmt = getConstFrmFmt(rChged, bLeft, bFirst);
                 rDescFrmFmt.SetFmtAttr( rChgedFrmFmt.GetHeader() );
             }
             else if ((*aRCnt.GetCntntIdx() == *aCnt.GetCntntIdx()) ||
@@ -292,9 +307,7 @@ void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead,
 void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, SwPageDesc &rDesc, bool bLeft, bool bFirst)
 {
     assert(bLeft || bFirst);
-    SwFrmFmt& rDescFrmFmt = (bFirst)
-            ? (bLeft) ? rDesc.GetFirstLeft() : rDesc.GetFirstMaster()
-            : rDesc.GetLeft();
+    SwFrmFmt& rDescFrmFmt = getFrmFmt(rDesc, bLeft, bFirst);
     if (bFirst && bLeft)
     {
         // special case: always shared with something
@@ -328,9 +341,7 @@ void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot,
             const SwFmtCntnt &aLCnt = rFmtFoot.GetFooterFmt()->GetCntnt();
             if( !aLCnt.GetCntntIdx() )
             {
-                const SwFrmFmt& rChgedFrmFmt = (bFirst)
-                    ? (bLeft) ? rChged.GetFirstLeft() : rChged.GetFirstMaster()
-                    : rChged.GetLeft();
+                const SwFrmFmt& rChgedFrmFmt = getConstFrmFmt(rChged, bLeft, bFirst);
                 rDescFrmFmt.SetFmtAttr( rChgedFrmFmt.GetFooter() );
             }
             else if ((*aRCnt.GetCntntIdx() == *aLCnt.GetCntntIdx()) ||


More information about the Libreoffice-commits mailing list