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

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Sun Dec 25 00:09:46 UTC 2016


 sw/source/core/draw/dcontact.cxx |  105 ++++++++++++++++++++-------------------
 1 file changed, 54 insertions(+), 51 deletions(-)

New commits:
commit 85a621be87c88d8c317eb0fa296ae64f2b3253a5
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sat Dec 24 03:56:46 2016 +0100

    move handling of pWW8AnchorConvHint from SwDrawContact to SwContact
    
    ... as the old code did not limit itself to SwDrawContacts either
    
    (possibly fixing regressions from d2be1f90faa64cbbfe789eb62370555eb5400ae3)
    
    Change-Id: Ia821a025979d7eb2b5e244802c708a42ab1256ed
    Reviewed-on: https://gerrit.libreoffice.org/32393
    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 d014583..86bae3e 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -378,7 +378,32 @@ sal_uInt32 SwContact::GetMaxOrdNum() const
     return nMaxOrdNum;
 }
 
-void SwContact::SwClientNotify(const SwModify&, const SfxHint& rHint)
+namespace
+{
+    Point lcl_GetWW8Pos(SwAnchoredObject* pAnchoredObj, const bool bFollowTextFlow, sw::WW8AnchorConv& reConv)
+    {
+        switch(reConv)
+        {
+            case sw::WW8AnchorConv::CONV2PG:
+            {
+                bool bRelToTableCell(false);
+                Point aPos(pAnchoredObj->GetRelPosToPageFrame(bFollowTextFlow, bRelToTableCell));
+                if(bRelToTableCell)
+                    reConv = sw::WW8AnchorConv::RELTOTABLECELL;
+                return aPos;
+            }
+            case sw::WW8AnchorConv::CONV2COL_OR_PARA:
+                return pAnchoredObj->GetRelPosToAnchorFrame();
+            case sw::WW8AnchorConv::CONV2CHAR:
+                return pAnchoredObj->GetRelPosToChar();
+            case sw::WW8AnchorConv::CONV2LINE:
+                return pAnchoredObj->GetRelPosToLine();
+            default: ;
+        }
+        return Point();
+    }
+}
+void SwContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
 {
     // this does not call SwClient::SwClientNotify and thus doesnt handle RES_OBJECTDYING as usual. Is this intentional?
     if (auto pFindSdrObjectHint = dynamic_cast<const sw::FindSdrObjectHint*>(&rHint))
@@ -386,6 +411,34 @@ void SwContact::SwClientNotify(const SwModify&, const SfxHint& rHint)
         if(!*pFindSdrObjectHint->m_ppObject)
             *pFindSdrObjectHint->m_ppObject = GetMaster();
     }
+    else if (auto pWW8AnchorConvHint = dynamic_cast<const sw::WW8AnchorConvHint*>(&rHint))
+    {
+        // determine anchored object
+        SwAnchoredObject* pAnchoredObj(nullptr);
+        {
+            std::list<SwAnchoredObject*> aAnchoredObjs;
+            GetAnchoredObjs(aAnchoredObjs);
+            if(!aAnchoredObjs.empty())
+                pAnchoredObj = aAnchoredObjs.front();
+        }
+        // no anchored object found. Thus, the needed layout information can't
+        // be determined. --> no conversion
+        if(!pAnchoredObj)
+            return;
+        // no conversion for anchored drawing object, which aren't attached to an
+        // anchor frame.
+        // This is the case for drawing objects, which are anchored inside a page
+        // header/footer of an *unused* page style.
+        if(dynamic_cast<SwAnchoredDrawObject*>(pAnchoredObj) && !pAnchoredObj->GetAnchorFrame())
+            return;
+        const bool bFollowTextFlow = static_cast<const SwFrameFormat&>(rMod).GetFollowTextFlow().GetValue();
+        sw::WW8AnchorConvResult& rResult(pWW8AnchorConvHint->m_rResult);
+        // No distinction between layout directions, because of missing
+        // information about WW8 in vertical layout.
+        rResult.m_aPos.setX(lcl_GetWW8Pos(pAnchoredObj, bFollowTextFlow, rResult.m_eHoriConv).getX());
+        rResult.m_aPos.setY(lcl_GetWW8Pos(pAnchoredObj, bFollowTextFlow, rResult.m_eVertConv).getY());
+        rResult.m_bConverted = true;
+    }
 }
 
 
@@ -1363,28 +1416,6 @@ namespace
         }
         return pAnchorFormat;
     }
-    Point lcl_GetWW8Pos(SwAnchoredObject* pAnchoredObj, const bool bFollowTextFlow, sw::WW8AnchorConv& reConv)
-    {
-        switch(reConv)
-        {
-            case sw::WW8AnchorConv::CONV2PG:
-            {
-                bool bRelToTableCell(false);
-                Point aPos(pAnchoredObj->GetRelPosToPageFrame(bFollowTextFlow, bRelToTableCell));
-                if(bRelToTableCell)
-                    reConv = sw::WW8AnchorConv::RELTOTABLECELL;
-                return aPos;
-            }
-            case sw::WW8AnchorConv::CONV2COL_OR_PARA:
-                return pAnchoredObj->GetRelPosToAnchorFrame();
-            case sw::WW8AnchorConv::CONV2CHAR:
-                return pAnchoredObj->GetRelPosToChar();
-            case sw::WW8AnchorConv::CONV2LINE:
-                return pAnchoredObj->GetRelPosToLine();
-            default: ;
-        }
-        return Point();
-    }
 }
 
 void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
@@ -1541,34 +1572,6 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint)
         if(rFormat.IsPosAttrSet())
             pDrawFormatLayoutCopyHint->m_rDestFormat.PosAttrSet();
     }
-    else if (auto pWW8AnchorConvHint = dynamic_cast<const sw::WW8AnchorConvHint*>(&rHint))
-    {
-        // determine anchored object
-        SwAnchoredObject* pAnchoredObj(nullptr);
-        {
-            std::list<SwAnchoredObject*> aAnchoredObjs;
-            GetAnchoredObjs(aAnchoredObjs);
-            if(!aAnchoredObjs.empty())
-                pAnchoredObj = aAnchoredObjs.front();
-        }
-        // no anchored object found. Thus, the needed layout information can't
-        // be determined. --> no conversion
-        if(!pAnchoredObj)
-            return;
-        // no conversion for anchored drawing object, which aren't attached to an
-        // anchor frame.
-        // This is the case for drawing objects, which are anchored inside a page
-        // header/footer of an *unused* page style.
-        if(dynamic_cast<SwAnchoredDrawObject*>(pAnchoredObj) && !pAnchoredObj->GetAnchorFrame())
-            return;
-        const bool bFollowTextFlow = static_cast<const SwDrawFrameFormat&>(rMod).GetFollowTextFlow().GetValue();
-        sw::WW8AnchorConvResult& rResult(pWW8AnchorConvHint->m_rResult);
-        // No distinction between layout directions, because of missing
-        // information about WW8 in vertical layout.
-        rResult.m_aPos.setX(lcl_GetWW8Pos(pAnchoredObj, bFollowTextFlow, rResult.m_eHoriConv).getX());
-        rResult.m_aPos.setY(lcl_GetWW8Pos(pAnchoredObj, bFollowTextFlow, rResult.m_eVertConv).getY());
-        rResult.m_bConverted = true;
-    }
     else if (auto pRestoreFlyAnchorHint = dynamic_cast<const sw::RestoreFlyAnchorHint*>(&rHint))
     {
         SdrObject* pObj = GetMaster();


More information about the Libreoffice-commits mailing list