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

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Wed Dec 21 19:30:12 UTC 2016


 sw/source/core/text/itrcrsr.cxx  |    8 ++--
 sw/source/core/text/itrform2.cxx |    2 -
 sw/source/core/text/porfly.cxx   |   76 +++++++++++++--------------------------
 sw/source/core/text/porfly.hxx   |   58 ++++++++++++++---------------
 4 files changed, 61 insertions(+), 83 deletions(-)

New commits:
commit 2250d7d4a1643672168387837ba2f9530fdb7dc2
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Dec 19 05:12:39 2016 +0100

    Split out sw::FlyContentPortion
    
    - Also void* as member are really bad, mmkay?
    - also move some OSL_... to SAL_...
    
    Change-Id: Iace3a4331522239eff4a25948a2f0e265e7c016d
    Reviewed-on: https://gerrit.libreoffice.org/32148
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>

diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx
index f025acb..295006e 100644
--- a/sw/source/core/text/itrcrsr.cxx
+++ b/sw/source/core/text/itrcrsr.cxx
@@ -1684,13 +1684,13 @@ sal_Int32 SwTextCursor::GetCursorOfst( SwPosition *pPos, const Point &rPoint,
         }
         else
         {
-            if( bChgNode && pPos && pPor->IsFlyCntPortion()
-                && !static_cast<SwFlyCntPortion*>(pPor)->IsDraw() )
+            sw::FlyContentPortion* pFlyPor(nullptr);
+            if(bChgNode && pPos && (pFlyPor = dynamic_cast<sw::FlyContentPortion*>(pPor)))
             {
                 // JP 24.11.94: if the Position is not in Fly, then
                 //              we many not return with COMPLETE_STRING as value!
                 //              (BugId: 9692 + Change in feshview)
-                SwFlyInContentFrame *pTmp = static_cast<SwFlyCntPortion*>(pPor)->GetFlyFrame();
+                SwFlyInContentFrame *pTmp = pFlyPor->GetFlyFrame();
                 SwFrame* pLower = pTmp->GetLower();
                 bool bChgNodeInner = pLower
                     && (pLower->IsTextFrame() || pLower->IsLayoutFrame());
@@ -1705,7 +1705,7 @@ sal_Int32 SwTextCursor::GetCursorOfst( SwPosition *pPos, const Point &rPoint,
                 if( bChgNodeInner && pTmp->Frame().IsInside( aTmpPoint ) &&
                     !( pTmp->IsProtected() ) )
                 {
-                    static_cast<SwFlyCntPortion*>(pPor)->GetFlyCursorOfst(aTmpPoint, *pPos, pCMS);
+                    pFlyPor->GetFlyCursorOfst(aTmpPoint, *pPos, pCMS);
                     // After a change of the frame, our font must be still
                     // available for/in the OutputDevice.
                     // For comparison: Paint and new SwFlyCntPortion !
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index 1ff4763..667b457 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -2539,7 +2539,7 @@ SwFlyCntPortion *SwTextFormatter::NewFlyCntPortion( SwTextFormatInfo &rInf,
     SwFlyCntPortion* pRet(nullptr);
     if( pFly )
     {
-        pRet = SwFlyCntPortion::Create(*GetInfo().GetTextFrame(), pFly, aTmpBase, nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc, nMode);
+        pRet = sw::FlyContentPortion::Create(*GetInfo().GetTextFrame(), pFly, aTmpBase, nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc, nMode);
         // We need to make sure that our font is set again in the OutputDevice
         // It could be that the FlyInCnt was added anew and GetFlyFrame() would
         // in turn cause, that it'd be created anew again.
diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx
index 298f4ea..57f77c9 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -203,7 +203,7 @@ sal_Int32 SwTextFrame::CalcFlyPos( SwFrameFormat* pSearch )
     return pFound->GetStart();
 }
 
-void SwFlyCntPortion::Paint( const SwTextPaintInfo &rInf ) const
+void sw::FlyContentPortion::Paint(const SwTextPaintInfo& rInf) const
 {
     // Baseline output
     // Re-paint everything at a CompletePaint call
@@ -242,89 +242,67 @@ void SwFlyCntPortion::Paint( const SwTextPaintInfo &rInf ) const
             ((SwTextPaintInfo&)rInf).SetOut( rInf.GetVsh()->GetOut() );
     }
 }
+
 void sw::DrawFlyCntPortion::Paint(const SwTextPaintInfo&) const
 {
-    if(!static_cast<SwDrawContact*>(pContact)->GetAnchorFrame())
+    if(!m_pContact->GetAnchorFrame())
     {
         // No direct positioning of the drawing object is needed
-        SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(pContact);
-        pDrawContact->ConnectToLayout();
+        m_pContact->ConnectToLayout();
     }
 }
 
 /**
  * Use the dimensions of pFly->OutRect()
  */
-SwFlyCntPortion::SwFlyCntPortion(SwFlyInContentFrame* pFly)
-    : pContact(pFly)
-    , bMax(false)
+SwFlyCntPortion::SwFlyCntPortion()
+    : bMax(false)
     , nAlign(0)
 {
-    SAL_WARN_IF(!pFly, "sw.core", "SwFlyCntPortion::SwFlyCntPortion: no SwFlyInContentFrame!");
     nLineLength = 1;
     SetWhichPor(POR_FLYCNT);
 }
 
-sw::DrawFlyCntPortion::DrawFlyCntPortion(SwDrawContact* pDrawContact)
-    : SwFlyCntPortion((SwFlyInContentFrame*) pDrawContact)
+sw::FlyContentPortion::FlyContentPortion(SwFlyInContentFrame* pFly)
+    : m_pFly(pFly)
+{
+    SAL_WARN_IF(!pFly, "sw.core", "SwFlyCntPortion::SwFlyCntPortion: no SwFlyInContentFrame!");
+}
+
+sw::DrawFlyCntPortion::DrawFlyCntPortion(SwDrawContact* pContact)
+    : m_pContact(pContact)
 {
-    SAL_WARN_IF(!pDrawContact, "sw.core",  "SwFlyCntPortion::SwFlyCntPortion: no SwDrawContact!");
-    if(!pDrawContact->GetAnchorFrame())
+    assert(m_pContact);
+    if(!m_pContact->GetAnchorFrame())
     {
         // No direct positioning needed any more
-        pDrawContact->ConnectToLayout();
+        m_pContact->ConnectToLayout();
         // Move object to visible layer
-        pDrawContact->MoveObjToVisibleLayer(pDrawContact->GetMaster());
+        m_pContact->MoveObjToVisibleLayer(m_pContact->GetMaster());
     }
-
 }
 
-SwFlyCntPortion* SwFlyCntPortion::Create(const SwTextFrame& rFrame, SwFlyInContentFrame* pFly, const Point& rBase, long nLnAscent, long nLnDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags)
+sw::FlyContentPortion* sw::FlyContentPortion::Create(const SwTextFrame& rFrame, SwFlyInContentFrame* pFly, const Point& rBase, long nLnAscent, long nLnDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags)
 {
-    auto pNew(new SwFlyCntPortion(pFly));
+    auto pNew(new sw::FlyContentPortion(pFly));
     pNew->SetBase(rFrame, rBase, nLnAscent, nLnDescent, nFlyAsc, nFlyDesc, nFlags | AsCharFlags::UlSpace | AsCharFlags::Init);
     return pNew;
 }
 
-sw::DrawFlyCntPortion* sw::DrawFlyCntPortion::Create(const SwTextFrame& rFrame, SwDrawContact* pDrawContact, const Point& rBase, long nLnAscent, long nLnDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags)
+sw::DrawFlyCntPortion* sw::DrawFlyCntPortion::Create(const SwTextFrame& rFrame, SwDrawContact* pContact, const Point& rBase, long nLnAscent, long nLnDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags)
 {
-    auto pNew(new DrawFlyCntPortion(pDrawContact));
+    auto pNew(new DrawFlyCntPortion(pContact));
     pNew->SetBase(rFrame, rBase, nLnAscent, nLnDescent, nFlyAsc, nFlyDesc, nFlags | AsCharFlags::UlSpace | AsCharFlags::Init);
     return pNew;
 }
 
-SwFlyCntPortion::SwFlyCntPortion( const SwTextFrame& rFrame,
-                                  SwDrawContact *pDrawContact, const Point &rBase,
-                                  long nLnAscent, long nLnDescent,
-                                  long nFlyAsc, long nFlyDesc,
-                                  AsCharFlags nFlags ) :
-    pContact( pDrawContact ),
-    bMax( false ),
-    nAlign( 0 )
-{
-    if( !pDrawContact->GetAnchorFrame() )
-    {
-        // No direct positioning needed any more
-        pDrawContact->ConnectToLayout();
-
-        // Move object to visible layer
-        pDrawContact->MoveObjToVisibleLayer( pDrawContact->GetMaster() );
-    }
-    nLineLength = 1;
-    nFlags |= AsCharFlags::UlSpace | AsCharFlags::Init;
-
-    SetBase( rFrame, rBase, nLnAscent, nLnDescent, nFlyAsc, nFlyDesc, nFlags );
-
-    SetWhichPor( POR_FLYCNT );
-}
-
 SwFlyCntPortion::~SwFlyCntPortion() {};
-
 sw::DrawFlyCntPortion::~DrawFlyCntPortion() {};
+sw::FlyContentPortion::~FlyContentPortion() {};
 
-SdrObject* SwFlyCntPortion::GetSdrObj(const SwTextFrame&)
+SdrObject* sw::FlyContentPortion::GetSdrObj(const SwTextFrame&)
 {
-    return GetFlyFrame()->GetVirtDrawObj();
+    return m_pFly->GetVirtDrawObj();
 }
 
 SdrObject* sw::DrawFlyCntPortion::GetSdrObj(const SwTextFrame& rFrame)
@@ -434,9 +412,9 @@ void SwFlyCntPortion::SetBase( const SwTextFrame& rFrame, const Point &rBase,
     }
 }
 
-void SwFlyCntPortion::GetFlyCursorOfst(Point &rPoint, SwPosition &rPos, SwCursorMoveState* pCMS) const
+void sw::FlyContentPortion::GetFlyCursorOfst(Point& rPoint, SwPosition& rPos, SwCursorMoveState* pCMS) const
 {
-    GetFlyFrame()->GetCursorOfst(&rPos, rPoint, pCMS);
+    m_pFly->GetCursorOfst(&rPos, rPoint, pCMS);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/porfly.hxx b/sw/source/core/text/porfly.hxx
index 28749ea..382d4ea 100644
--- a/sw/source/core/text/porfly.hxx
+++ b/sw/source/core/text/porfly.hxx
@@ -45,54 +45,54 @@ public:
 class SwFlyCntPortion : public SwLinePortion
 {
 protected:
-
-    void *pContact; // bDraw ? DrawContact : FlyInContentFrame
     Point aRef;     // Relatively to this point we calculate the AbsPos
     bool bMax : 1;   // Line adjustment and height == line height
     sal_uInt8 nAlign : 3; // Line adjustment? No, above, middle, bottom
 
-    // Use new datatype for parameter <nFlags>
-    SwFlyCntPortion( const SwTextFrame& rFrame, SwDrawContact *pDrawContact,
-                     const Point &rBase,
-                     long nAscent, long nDescent, long nFlyAsc, long nFlyDesc,
-                     AsCharFlags nFlags );
-    virtual SdrObject* GetSdrObj(const SwTextFrame&);
+    virtual SdrObject* GetSdrObj(const SwTextFrame&) =0;
 
 public:
-    SwFlyCntPortion(SwFlyInContentFrame* pFly);
-    static SwFlyCntPortion* Create(const SwTextFrame& rFrame, SwFlyInContentFrame* pFly, const Point& rBase, long nAscent, long nDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags);
+    SwFlyCntPortion();
     inline const Point& GetRefPoint() const { return aRef; }
-    inline SwFlyInContentFrame *GetFlyFrame() { return static_cast<SwFlyInContentFrame*>(pContact); }
-    inline const SwFlyInContentFrame *GetFlyFrame() const
-        { return static_cast<SwFlyInContentFrame*>(pContact); }
-    inline SwDrawContact *GetDrawContact() { return static_cast<SwDrawContact*>(pContact); }
-    inline const SwDrawContact* GetDrawContact() const
-        { return static_cast<SwDrawContact*>(pContact); }
-    virtual bool IsDraw() const { return false; }
     inline bool IsMax() const { return bMax; }
     inline sal_uInt8 GetAlign() const { return nAlign; }
-    inline void SetAlign( sal_uInt8 nNew ) { nAlign = nNew; }
-    inline void SetMax( bool bNew ) { bMax = bNew; }
-    void SetBase(const SwTextFrame& rFrame, const Point &rBase, long nLnAscent, long nLnDescent, long nFlyAscent, long nFlyDescent, AsCharFlags nFlags);
-    void GetFlyCursorOfst(Point &rPoint, SwPosition& rPos, SwCursorMoveState* pCMS) const;
-    virtual bool Format( SwTextFormatInfo &rInf ) override;
-    virtual void Paint( const SwTextPaintInfo &rInf ) const override;
+    inline void SetAlign(sal_uInt8 nNew) { nAlign = nNew; }
+    inline void SetMax(bool bNew) { bMax = bNew; }
+    void SetBase(const SwTextFrame& rFrame, const Point& rBase, long nLnAscent, long nLnDescent, long nFlyAscent, long nFlyDescent, AsCharFlags nFlags);
+    virtual bool Format(SwTextFormatInfo& rInf) override;
     OUTPUT_OPERATOR_OVERRIDE
-    virtual ~SwFlyCntPortion();
+    virtual bool IsDraw() const =0;
+    virtual ~SwFlyCntPortion() override;
 };
 
 namespace sw
 {
-    class DrawFlyCntPortion : public SwFlyCntPortion
+    class FlyContentPortion final : public SwFlyCntPortion
+    {
+            SwFlyInContentFrame* m_pFly;
+            virtual SdrObject* GetSdrObj(const SwTextFrame&) override;
+        public:
+            FlyContentPortion(SwFlyInContentFrame* pFly);
+            static FlyContentPortion* Create(const SwTextFrame& rFrame, SwFlyInContentFrame* pFly, const Point& rBase, long nAscent, long nDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags);
+            inline SwFlyInContentFrame *GetFlyFrame() { return m_pFly; }
+            inline const SwFlyInContentFrame *GetFlyFrame() const { return m_pFly; }
+            void GetFlyCursorOfst(Point& rPoint, SwPosition& rPos, SwCursorMoveState* pCMS) const;
+            virtual bool IsDraw() const override { return false; }
+            virtual void Paint(const SwTextPaintInfo& rInf) const override;
+            virtual ~FlyContentPortion() override;
+    };
+    class DrawFlyCntPortion final : public SwFlyCntPortion
     {
-        protected:
+            SwDrawContact* m_pContact;
             virtual SdrObject* GetSdrObj(const SwTextFrame&) override;
         public:
             DrawFlyCntPortion(SwDrawContact* pDrawContact);
             static DrawFlyCntPortion* Create(const SwTextFrame& rFrame, SwDrawContact* pDrawContact, const Point& rBase, long nAsc, long nDescent, long nFlyAsc, long nFlyDesc, AsCharFlags nFlags);
-            virtual bool IsDraw() const { return true; }
-            virtual void Paint( const SwTextPaintInfo &rInf ) const override;
-            virtual ~DrawFlyCntPortion();
+            inline SwDrawContact* GetDrawContact() { return m_pContact; }
+            inline const SwDrawContact* GetDrawContact() const { return m_pContact; }
+            virtual bool IsDraw() const override { return true; }
+            virtual void Paint(const SwTextPaintInfo& rInf) const override;
+            virtual ~DrawFlyCntPortion() override;
     };
 }
 


More information about the Libreoffice-commits mailing list