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

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Mon Dec 12 11:38:18 UTC 2016


 sw/source/core/draw/dcontact.cxx |   65 ++++++++++++++++-----------------------
 1 file changed, 28 insertions(+), 37 deletions(-)

New commits:
commit 880e622d2e324a85a7b2b6ddc60e06cc423195b4
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sun Dec 11 14:30:44 2016 +0100

    refactor out lcl_GetWW8Pos
    
    Change-Id: Ie7127668aceade312c68ed3d7f3398fbaf5e8df7
    Reviewed-on: https://gerrit.libreoffice.org/31864
    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/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index d1c7fc0..e6a448e 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -1366,6 +1366,21 @@ namespace
         }
         return pAnchorFormat;
     }
+    Point lcl_GetWW8Pos(SwAnchoredObject* pAnchoredObj, const sw::WW8AnchorConv eConv, const bool bFollowTextFlow, const bool bHori, bool& bRelToTableCell)
+    {
+        switch(eConv)
+        {
+            case sw::WW8AnchorConv::CONV2PG:
+                return pAnchoredObj->GetRelPosToPageFrame(bFollowTextFlow, bRelToTableCell);
+            case sw::WW8AnchorConv::CONV2COL_OR_PARA:
+                return pAnchoredObj->GetRelPosToAnchorFrame();
+            case sw::WW8AnchorConv::CONV2CHAR_OR_LINE:
+                return bHori ? pAnchoredObj->GetRelPosToChar() : pAnchoredObj->GetRelPosToLine();
+            default: ;
+        }
+        assert(false);
+        return Point();
+    }
 }
 
 void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
@@ -1520,7 +1535,6 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
     }
     else if (auto pWW8AnchorConvHint = dynamic_cast<const sw::WW8AnchorConvHint*>(&rHint))
     {
-        const SwDrawFrameFormat& rFormat = static_cast<const SwDrawFrameFormat&>(rMod);
         // determine anchored object
         SwAnchoredObject* pAnchoredObj(nullptr);
         {
@@ -1539,44 +1553,21 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
         // header/footer of an *unused* page style.
         if(dynamic_cast<SwAnchoredDrawObject*>(pAnchoredObj) && !pAnchoredObj->GetAnchorFrame())
             return;
-        const bool bFollowTextFlow = rFormat.GetFollowTextFlow().GetValue();
-        Point aPos;
-        switch(pWW8AnchorConvHint->m_eHoriConv)
-        {
-            case sw::WW8AnchorConv::CONV2PG:
-                // #i33818#
-                aPos = pAnchoredObj->GetRelPosToPageFrame(bFollowTextFlow, pWW8AnchorConvHint->m_rResult.m_bHoriRelToTableCell);
-                break;
-            case sw::WW8AnchorConv::CONV2COL_OR_PARA:
-                aPos = pAnchoredObj->GetRelPosToAnchorFrame();
-                break;
-            case sw::WW8AnchorConv::CONV2CHAR_OR_LINE:
-                aPos = pAnchoredObj->GetRelPosToChar();
-                break;
-            default:
-                ;
-        }
-        // No distinction between layout directions, because of missing
-        // information about WW8 in vertical layout.
-        pWW8AnchorConvHint->m_rResult.m_aPos.setX(aPos.getX());
-        switch(pWW8AnchorConvHint->m_eVertConv)
-        {
-            case sw::WW8AnchorConv::CONV2PG:
-                // #i33818#
-                aPos = pAnchoredObj->GetRelPosToPageFrame(bFollowTextFlow, pWW8AnchorConvHint->m_rResult.m_bVertRelToTableCell);
-                break;
-            case sw::WW8AnchorConv::CONV2COL_OR_PARA:
-                aPos = pAnchoredObj->GetRelPosToAnchorFrame();
-                break;
-            case sw::WW8AnchorConv::CONV2CHAR_OR_LINE:
-                aPos = pAnchoredObj->GetRelPosToLine();
-                break;
-            default:
-                ;
-        }
+        const bool bFollowTextFlow = static_cast<const SwDrawFrameFormat&>(rMod).GetFollowTextFlow().GetValue();
         // No distinction between layout directions, because of missing
         // information about WW8 in vertical layout.
-        pWW8AnchorConvHint->m_rResult.m_aPos.setY(aPos.getY());
+        pWW8AnchorConvHint->m_rResult.m_aPos.setX(lcl_GetWW8Pos(
+                pAnchoredObj,
+                pWW8AnchorConvHint->m_eHoriConv,
+                bFollowTextFlow,
+                true,
+                pWW8AnchorConvHint->m_rResult.m_bHoriRelToTableCell).getX());
+        pWW8AnchorConvHint->m_rResult.m_aPos.setY(lcl_GetWW8Pos(
+                pAnchoredObj,
+                pWW8AnchorConvHint->m_eHoriConv,
+                bFollowTextFlow,
+                false,
+                pWW8AnchorConvHint->m_rResult.m_bVertRelToTableCell).getY());
         pWW8AnchorConvHint->m_rResult.m_bConverted = true;
     }
 }


More information about the Libreoffice-commits mailing list