[Libreoffice-commits] core.git: sw/source
Caolán McNamara
caolanm at redhat.com
Fri Jan 16 02:01:28 PST 2015
sw/source/core/doc/docdesc.cxx | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
New commits:
commit 82276525ada3112d566d0fbf1859788b7867af0e
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Jan 15 20:50:50 2015 +0000
coverity#1264391 help coverity out wrt Logically dead code
This reverts commit 95f7a01621dd5cd62190c334fcdf02e3941fdcab.
Change-Id: I1712553e592f1313a2591f7dae92453a4a85b7f2
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index 4f3801d..d083b43 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();
+ return 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