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

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Thu Nov 20 10:21:29 PST 2014


 sw/source/core/layout/flycnt.cxx |   47 +++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 23 deletions(-)

New commits:
commit 36a7bf728d3b68e371b74a15b86ef1ba9cbba83f
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Thu Nov 20 00:25:49 2014 +0100

    refactor into a local function
    
    Change-Id: Id0ba44466216a5fababb7afe891c032aaafe9fee
    Reviewed-on: https://gerrit.libreoffice.org/13000
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
    Tested-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>

diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 425967a..1c2cd21 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -46,6 +46,26 @@
 
 using namespace ::com::sun::star;
 
+namespace
+{
+
+static inline SwTwips lcl_GetTopForObjPos(const SwCntntFrm* pCnt, const bool bVert, const bool bVertL2R)
+{
+    if ( bVert )
+    {
+        SwTwips aResult = pCnt->Frm().Left();
+        if ( bVertL2R )
+            aResult += pCnt->GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid();
+        else
+            aResult += pCnt->Frm().Width() - pCnt->GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid();
+        return aResult;
+    }
+    else
+        return pCnt->Frm().Top() + pCnt->GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid();
+}
+
+}
+
 SwFlyAtCntFrm::SwFlyAtCntFrm( SwFlyFrmFmt *pFmt, SwFrm* pSib, SwFrm *pAnch ) :
     SwFlyFreeFrm( pFmt, pSib, pAnch )
 {
@@ -562,17 +582,7 @@ static const SwFrm * lcl_CalcDownDist( SwDistance &rRet,
         //Follow the text flow.
         // #i70582#
         // --> OD 2009-03-05 - adopted for Support for Classical Mongolian Script
-        SwTwips nTopForObjPos;
-        if ( bVert )
-        {
-            nTopForObjPos = pCnt->Frm().Left();
-            if ( bVertL2R )
-                nTopForObjPos += pCnt->GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid();
-            else
-                nTopForObjPos += pCnt->Frm().Width() - pCnt->GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid();
-        }
-        else
-            nTopForObjPos = pCnt->Frm().Top() + pCnt->GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid();
+        const SwTwips nTopForObjPos = lcl_GetTopForObjPos(pCnt, bVert, bVertL2R);
         if ( pUp->Frm().IsInside( rPt ) )
         {
             // <rPt> point is inside environment of given content frame
@@ -1260,16 +1270,7 @@ void SwFlyAtCntFrm::SetAbsPos( const Point &rNew )
     if ( nY == LONG_MAX )
     {
         // #i70582#
-        const SwTwips nTopForObjPos =
-                bVert
-                ? ( bVertL2R
-                    ? ( pCnt->Frm().Left() +
-                        pCnt->GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid() )
-                    : ( pCnt->Frm().Left() +
-                        pCnt->Frm().Width() -
-                        pCnt->GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid() ) )
-                : ( pCnt->Frm().Top() +
-                    pCnt->GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid() );
+        const SwTwips nTopForObjPos = lcl_GetTopForObjPos(pCnt, bVert, bVertL2R);
         if( bVert )
         {
             if ( bVertL2R )
commit b18adcfd672d9bf7ad412715fbe4c76b998445c2
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Thu Nov 20 00:13:28 2014 +0100

    fix mismerged indent
    
    Change-Id: Ia1f2c822601ac41274b2b3d5a16778c7df472230
    Reviewed-on: https://gerrit.libreoffice.org/12999
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
    Tested-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>

diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 68d3e58..425967a 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -579,7 +579,7 @@ static const SwFrm * lcl_CalcDownDist( SwDistance &rRet,
             // #i70582#
             if( bVert )
             {
-                   if ( bVertL2R )
+                if ( bVertL2R )
                     rRet.nMain =  rPt.X() - nTopForObjPos;
                 else
                     rRet.nMain =  nTopForObjPos - rPt.X();
@@ -608,7 +608,7 @@ static const SwFrm * lcl_CalcDownDist( SwDistance &rRet,
                 // #i70582#
                 if( bVert )
                 {
-                       if ( bVertL2R )
+                    if ( bVertL2R )
                         rRet.nMain = rPt.X() - nTopForObjPos;
                     else
                         rRet.nMain =  nTopForObjPos - rPt.X();


More information about the Libreoffice-commits mailing list