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

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Mon Dec 12 11:36:05 UTC 2016


 sw/inc/frmfmt.hxx                 |   16 ++++
 sw/source/core/draw/dcontact.cxx  |   62 +++++++++++++++
 sw/source/core/layout/atrfrm.cxx  |    1 
 sw/source/filter/ww8/wrtw8esh.cxx |  149 +++++++++++---------------------------
 4 files changed, 124 insertions(+), 104 deletions(-)

New commits:
commit d2be1f90faa64cbbfe789eb62370555eb5400ae3
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sun Dec 11 01:54:46 2016 +0100

    use message passing
    
    Change-Id: I49c448c454f9bb820c3b9afa3825c58cb2dab978
    Reviewed-on: https://gerrit.libreoffice.org/31863
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>

diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index ce28dcd..6cf5619 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -280,6 +280,22 @@ namespace sw
         CONV2COL_OR_PARA,
         CONV2CHAR_OR_LINE
     };
+    struct WW8AnchorConvResult final
+    {
+        bool m_bHoriRelToTableCell;
+        bool m_bVertRelToTableCell;
+        bool m_bConverted;
+        Point m_aPos;
+        WW8AnchorConvResult() : m_bHoriRelToTableCell(false), m_bVertRelToTableCell(false), m_bConverted(false) {};
+    };
+    struct SW_DLLPUBLIC WW8AnchorConvHint final : SfxHint
+    {
+        WW8AnchorConvResult& m_rResult;
+        const WW8AnchorConv m_eHoriConv;
+        const WW8AnchorConv m_eVertConv;
+        WW8AnchorConvHint(WW8AnchorConvResult& rResult, WW8AnchorConv eHoriConv, WW8AnchorConv eVertConv) : m_rResult(rResult), m_eHoriConv(eHoriConv), m_eVertConv(eVertConv) {};
+        virtual ~WW8AnchorConvHint() override;
+    };
 }
 
 class SW_DLLPUBLIC SwDrawFrameFormat: public SwFrameFormat
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 88015f5..d1c7fc0 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -48,6 +48,7 @@
 #include <flyfrm.hxx>
 #include <textboxhelper.hxx>
 #include <frmfmt.hxx>
+#include <fmtfollowtextflow.hxx>
 #include <dflyobj.hxx>
 #include <dcontact.hxx>
 #include <unodraw.hxx>
@@ -1517,6 +1518,67 @@ 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))
+    {
+        const SwDrawFrameFormat& rFormat = static_cast<const SwDrawFrameFormat&>(rMod);
+        // 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 = 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:
+                ;
+        }
+        // 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_bConverted = true;
+    }
 }
 
 // #i26791#
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 7211fc5..9351312 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3332,6 +3332,7 @@ namespace sw
     CheckDrawFrameFormatLayerHint::~CheckDrawFrameFormatLayerHint() {}
     ContactChangedHint::~ContactChangedHint() {}
     DrawFormatLayoutCopyHint::~DrawFormatLayoutCopyHint() {}
+    WW8AnchorConvHint::~WW8AnchorConvHint() {}
 }
 
 SwDrawFrameFormat::~SwDrawFrameFormat()
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 64be787..92e83bc 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -2482,38 +2482,6 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri,
         return false;
     }
 
-    // determine anchored object
-    SwAnchoredObject* pAnchoredObj( nullptr );
-    {
-        const SwContact* pContact = _rFrameFormat.FindContactObj();
-        if ( pContact )
-        {
-            std::list<SwAnchoredObject*> aAnchoredObjs;
-            pContact->GetAnchoredObjs( aAnchoredObjs );
-            if ( !aAnchoredObjs.empty() )
-            {
-                pAnchoredObj = aAnchoredObjs.front();
-            }
-        }
-    }
-    if ( !pAnchoredObj )
-    {
-        // no anchored object found. Thus, the needed layout information can't
-        // be determined. --> no conversion
-        return false;
-    }
-    // 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 false;
-    }
-
-    bool bConverted( false );
-
     // determine value of attribute 'Follow text flow', because positions aligned
     // at page areas have to be converted, if it's set.
     const bool bFollowTextFlow = _rFrameFormat.GetFollowTextFlow().GetValue();
@@ -2536,9 +2504,10 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri,
         }
     }
 
+    sw::WW8AnchorConv eHoriConv(sw::WW8AnchorConv::NO_CONV);
+    sw::WW8AnchorConv eVertConv(sw::WW8AnchorConv::NO_CONV);
     // convert horizontal position, if needed
     {
-        sw::WW8AnchorConv eHoriConv(sw::WW8AnchorConv::NO_CONV);
 
         // determine, if conversion has to be performed due to the position orientation
         bool bConvDueToOrientation( false );
@@ -2602,46 +2571,10 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri,
                     OSL_FAIL( "<WinwordAnchoring::ConvertPosition(..)> - unknown horizontal relation" );
             }
         }
-        if ( eHoriConv != sw::WW8AnchorConv::NO_CONV )
-        {
-            _iorHoriOri.SetHoriOrient( text::HoriOrientation::NONE );
-            SwTwips nPosX( 0L );
-            {
-                Point aPos;
-                if ( eHoriConv == sw::WW8AnchorConv::CONV2PG )
-                {
-                    _iorHoriOri.SetRelationOrient( text::RelOrientation::PAGE_FRAME );
-                    // #i33818#
-                    bool bRelToTableCell( false );
-                    aPos = pAnchoredObj->GetRelPosToPageFrame( bFollowTextFlow,
-                                                             bRelToTableCell );
-                    if ( bRelToTableCell )
-                    {
-                        _iorHoriOri.SetRelationOrient( text::RelOrientation::PAGE_PRINT_AREA );
-                    }
-                }
-                else if ( eHoriConv == sw::WW8AnchorConv::CONV2COL_OR_PARA )
-                {
-                    _iorHoriOri.SetRelationOrient( text::RelOrientation::FRAME );
-                    aPos = pAnchoredObj->GetRelPosToAnchorFrame();
-                }
-                else if ( eHoriConv == sw::WW8AnchorConv::CONV2CHAR_OR_LINE )
-                {
-                    _iorHoriOri.SetRelationOrient( text::RelOrientation::CHAR );
-                    aPos = pAnchoredObj->GetRelPosToChar();
-                }
-                // No distinction between layout directions, because of missing
-                // information about WW8 in vertical layout.
-                nPosX = aPos.X();
-            }
-            _iorHoriOri.SetPos( nPosX );
-            bConverted = true;
-        }
     }
 
     // convert vertical position, if needed
     {
-        sw::WW8AnchorConv eVertConv(sw::WW8AnchorConv::NO_CONV);
 
         // determine, if conversion has to be performed due to the position orientation
         bool bConvDueToOrientation( false );
@@ -2712,44 +2645,52 @@ bool WinwordAnchoring::ConvertPosition( SwFormatHoriOrient& _iorHoriOri,
             }
         }
 
-        if ( eVertConv != sw::WW8AnchorConv::NO_CONV )
+    }
+    if(eVertConv != sw::WW8AnchorConv::NO_CONV || eHoriConv != sw::WW8AnchorConv::NO_CONV)
+    {
+        sw::WW8AnchorConvResult aResult;
+        _rFrameFormat.CallSwClientNotify(sw::WW8AnchorConvHint(aResult, eHoriConv, eVertConv));
+        if(!aResult.m_bConverted)
+            return false;
+        switch(eHoriConv)
         {
-            _iorVertOri.SetVertOrient( text::VertOrientation::NONE );
-            SwTwips nPosY( 0L );
-            {
-                Point aPos;
-                if ( eVertConv == sw::WW8AnchorConv::CONV2PG )
-                {
-                    _iorVertOri.SetRelationOrient( text::RelOrientation::PAGE_FRAME );
-                    // #i33818#
-                    bool bRelToTableCell( false );
-                    aPos = pAnchoredObj->GetRelPosToPageFrame( bFollowTextFlow,
-                                                             bRelToTableCell );
-                    if ( bRelToTableCell )
-                    {
-                        _iorVertOri.SetRelationOrient( text::RelOrientation::PAGE_PRINT_AREA );
-                    }
-                }
-                else if ( eVertConv == sw::WW8AnchorConv::CONV2COL_OR_PARA )
-                {
-                    _iorVertOri.SetRelationOrient( text::RelOrientation::FRAME );
-                    aPos = pAnchoredObj->GetRelPosToAnchorFrame();
-                }
-                else if ( eVertConv == sw::WW8AnchorConv::CONV2CHAR_OR_LINE )
-                {
-                    _iorVertOri.SetRelationOrient( text::RelOrientation::TEXT_LINE );
-                    aPos = pAnchoredObj->GetRelPosToLine();
-                }
-                // No distinction between layout directions, because of missing
-                // information about WW8 in vertical layout.
-                nPosY = aPos.Y();
-            }
-            _iorVertOri.SetPos( nPosY );
-            bConverted = true;
+            case sw::WW8AnchorConv::CONV2PG:
+                _iorHoriOri.SetRelationOrient(text::RelOrientation::PAGE_FRAME);
+                // #i33818#
+                if(aResult.m_bHoriRelToTableCell)
+                    _iorHoriOri.SetRelationOrient(text::RelOrientation::PAGE_PRINT_AREA);
+                break;
+            case sw::WW8AnchorConv::CONV2COL_OR_PARA:
+                _iorHoriOri.SetRelationOrient(text::RelOrientation::FRAME);
+                break;
+            case sw::WW8AnchorConv::CONV2CHAR_OR_LINE:
+                _iorHoriOri.SetRelationOrient(text::RelOrientation::CHAR);
+                break;
+            default:
+                _iorHoriOri.SetHoriOrient(text::HoriOrientation::NONE);
+        }
+        _iorHoriOri.SetPos(aResult.m_aPos.X());
+        switch(eVertConv)
+        {
+            case sw::WW8AnchorConv::CONV2PG:
+                _iorVertOri.SetRelationOrient(text::RelOrientation::PAGE_FRAME);
+                // #i33818#
+                if(aResult.m_bVertRelToTableCell)
+                    _iorVertOri.SetRelationOrient(text::RelOrientation::PAGE_PRINT_AREA);
+                break;
+            case sw::WW8AnchorConv::CONV2COL_OR_PARA:
+                _iorVertOri.SetRelationOrient(text::RelOrientation::FRAME);
+                break;
+            case sw::WW8AnchorConv::CONV2CHAR_OR_LINE:
+                _iorVertOri.SetRelationOrient(text::RelOrientation::TEXT_LINE);
+                break;
+            default:
+                _iorVertOri.SetVertOrient(text::VertOrientation::NONE);
         }
+        _iorVertOri.SetPos(aResult.m_aPos.Y());
+        return true;
     }
-
-    return bConverted;
+    return false;
 }
 
 void WinwordAnchoring::SetAnchoring(const SwFrameFormat& rFormat)


More information about the Libreoffice-commits mailing list