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

Caolán McNamara caolanm at redhat.com
Fri May 8 04:39:37 PDT 2015


 sw/source/core/inc/flowfrm.hxx    |    8 ++++----
 sw/source/core/inc/txtfrm.hxx     |   34 +++++++++++++++++++++++++++-------
 sw/source/core/layout/flowfrm.cxx |    2 +-
 sw/source/core/layout/layact.cxx  |    2 +-
 sw/source/core/text/frmform.cxx   |    6 +++---
 sw/source/core/text/frmpaint.cxx  |    4 ++--
 sw/source/core/text/txtfrm.cxx    |    4 ++--
 sw/source/core/text/txthyph.cxx   |    2 +-
 8 files changed, 41 insertions(+), 21 deletions(-)

New commits:
commit 303f08fe4292341cda40f70da3d0f82d69f697aa
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 8 12:37:39 2015 +0100

    rename these scope lock guards, no logic change
    
    Change-Id: Ib1ec9c07ef38e22d739e80693eeb2d52e8e3b5f7

diff --git a/sw/source/core/inc/flowfrm.hxx b/sw/source/core/inc/flowfrm.hxx
index 59bafa4..4d27910 100644
--- a/sw/source/core/inc/flowfrm.hxx
+++ b/sw/source/core/inc/flowfrm.hxx
@@ -62,7 +62,7 @@ class SwFlowFrm
     friend inline void TableSplitRecalcUnlock( SwFlowFrm * );
     // #i44049#
     friend class SwObjectFormatterTxtFrm;
-    friend class JoinLockGuard;
+    friend class FlowFrmJoinLockGuard;
 
     // TblSel is allowed to reset the follow-bit
     friend inline void UnsetFollow( SwFlowFrm *pFlow );
@@ -238,7 +238,7 @@ inline bool SwFlowFrm::IsFwdMoveAllowed()
 
 //use this to protect a SwLayoutFrm for a given scope from getting merged with
 //its neighbour and thus deleted
-class JoinLockGuard
+class FlowFrmJoinLockGuard
 {
 private:
     SwFlowFrm *m_pFlow;
@@ -247,7 +247,7 @@ public:
     //JoinLock pParent for the lifetime of the Cut/Paste call, etc. to avoid
     //SwSectionFrm::MergeNext removing the pParent we're trying to reparent
     //into
-    JoinLockGuard(SwLayoutFrm* pFrm)
+    FlowFrmJoinLockGuard(SwLayoutFrm* pFrm)
     {
         m_pFlow = SwFlowFrm::CastFlowFrm(pFrm);
         if (m_pFlow)
@@ -261,7 +261,7 @@ public:
         }
     }
 
-    ~JoinLockGuard()
+    ~FlowFrmJoinLockGuard()
     {
         if (m_pFlow && !m_bOldJoinLocked)
             m_pFlow->UnlockJoin();
diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index 7fe60f1..784db5f 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -53,7 +53,7 @@ class SwTxtFrm: public SwCntntFrm
     friend class SwTxtIter;
     friend class SwTestFormat;
     friend class WidowsAndOrphans;
-    friend class SwTxtFrmLocker; // May Lock()/Unlock()
+    friend class TxtFrmLockGuard; // May Lock()/Unlock()
     friend bool sw_ChangeOffset( SwTxtFrm* pFrm, sal_Int32 nNew );
 
     static SwCache *pTxtCache;  // Pointer to the Line Cache
@@ -649,15 +649,35 @@ public:
     virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const SAL_OVERRIDE;
 };
 
-class SwTxtFrmLocker
+//use this to protect a SwTxtFrm for a given scope from getting merged with
+//its neighbour and thus deleted
+class TxtFrmLockGuard
 {
 private:
-    SwTxtFrm * const pFrm;
+    SwTxtFrm *m_pTxtFrm;
+    bool m_bOldLocked;
 public:
-    inline SwTxtFrmLocker( SwTxtFrm *pTxtFrm )
-        : pFrm( pTxtFrm->IsLocked() ? 0 : pTxtFrm )
-    { if( pFrm ) pFrm->Lock(); }
-    inline ~SwTxtFrmLocker() { if( pFrm ) pFrm->Unlock(); }
+    //Lock pFrm for the lifetime of the Cut/Paste call, etc. to avoid
+    //SwTxtFrm::_AdjustFollow removing the pFrm we're trying to Make
+    TxtFrmLockGuard(SwFrm* pFrm)
+    {
+        m_pTxtFrm = pFrm->IsTxtFrm() ? static_cast<SwTxtFrm*>(pFrm) : 0;
+        if (m_pTxtFrm)
+        {
+            m_bOldLocked = m_pTxtFrm->IsLocked();
+            m_pTxtFrm->Lock();
+        }
+        else
+        {
+            m_bOldLocked = false;
+        }
+    }
+
+    ~TxtFrmLockGuard()
+    {
+        if (m_pTxtFrm && !m_bOldLocked)
+            m_pTxtFrm->Unlock();
+    }
 };
 
 inline const SwParaPortion *SwTxtFrm::GetPara() const
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index f84d7a8..a41bb67 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -581,7 +581,7 @@ void SwFlowFrm::MoveSubTree( SwLayoutFrm* pParent, SwFrm* pSibling )
         //JoinLock pParent for the lifetime of the Cut/Paste call to avoid
         //SwSectionFrm::MergeNext removing the pParent we're trying to reparent
         //into
-        JoinLockGuard aJoinGuard(pParent);
+        FlowFrmJoinLockGuard aJoinGuard(pParent);
         pOldParent = CutTree( &m_rThis );
         bInvaLay = PasteTree( &m_rThis, pParent, pSibling, pOldParent );
     }
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 88e5fe0..732c67a 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -1242,7 +1242,7 @@ bool SwLayAction::FormatLayout( SwLayoutFrm *pLay, bool bAddRect )
         {
             //JoinLock pParent for the lifetime of the Calc call to avoid
             //SwSectionFrm::MergeNext removing the pLay we're trying to Format
-            JoinLockGuard aJoinGuard(pLay);
+            FlowFrmJoinLockGuard aJoinGuard(pLay);
             pLay->Calc();
         }
 
diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index 0e2b9e7..3df7347 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -676,7 +676,7 @@ SwCntntFrm *SwTxtFrm::SplitFrm( const sal_Int32 nTxtPos )
 
     // The Paste sends a Modify() to me
     // I lock myself, so that my data does not disappear
-    SwTxtFrmLocker aLock( this );
+    TxtFrmLockGuard aLock( this );
     SwTxtFrm *pNew = static_cast<SwTxtFrm *>(GetTxtNode()->MakeFrm( this ));
 
     pNew->SetFollow( GetFollow() );
@@ -1767,7 +1767,7 @@ void SwTxtFrm::Format( const SwBorderAttrs * )
         }
 
         // We do not want to be interrupted during formatting
-        SwTxtFrmLocker aLock(this);
+        TxtFrmLockGuard aLock(this);
         SwTxtLineAccess aAccess( this );
         const bool bNew = !aAccess.SwTxtLineAccess::IsAvailable();
         const bool bSetOfst =
@@ -1889,7 +1889,7 @@ bool SwTxtFrm::FormatQuick( bool bForceQuickFormat )
 
     SwFrmSwapper aSwapper( this, true );
 
-    SwTxtFrmLocker aLock(this);
+    TxtFrmLockGuard aLock(this);
     SwTxtFormatInfo aInf( this, false, true );
     if( 0 != aInf.MaxHyph() )   // Respect MaxHyphen!
         return false;
diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx
index cea9731..9d2c4ad 100644
--- a/sw/source/core/text/frmpaint.cxx
+++ b/sw/source/core/text/frmpaint.cxx
@@ -316,7 +316,7 @@ void SwTxtFrm::PaintExtraData( const SwRect &rRect ) const
 
         if( HasPara() )
         {
-            SwTxtFrmLocker aLock(const_cast<SwTxtFrm*>(this));
+            TxtFrmLockGuard aLock(const_cast<SwTxtFrm*>(this));
 
             SwTxtLineAccess aAccess( this );
             aAccess.GetPara();
@@ -620,7 +620,7 @@ void SwTxtFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
 
         // We don't want to be interrupted while painting.
         // Do that after thr Format()!
-        SwTxtFrmLocker aLock(const_cast<SwTxtFrm*>(this));
+        TxtFrmLockGuard aLock(const_cast<SwTxtFrm*>(this));
 
         // We only paint the part of the TxtFrm which changed, is within the
         // range and was requested to paint.
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index aa5e3c7..cc801a9 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -2104,7 +2104,7 @@ SwTwips SwTxtFrm::CalcFitToContent()
         Frm().Pos().X() += nOldFrmWidth - nPageWidth;
 
     // #i31490#
-    SwTxtFrmLocker aLock( this );
+    TxtFrmLockGuard aLock( this );
 
     SwTxtFormatInfo aInf( this, false, true, true );
     aInf.SetIgnoreFly( true );
@@ -2163,7 +2163,7 @@ void SwTxtFrm::CalcAdditionalFirstLineOffset()
             SetPara( pDummy, false );
 
             // lock paragraph
-            SwTxtFrmLocker aLock( this );
+            TxtFrmLockGuard aLock( this );
 
             // simulate text formatting
             SwTxtFormatInfo aInf( this, false, true, true );
diff --git a/sw/source/core/text/txthyph.cxx b/sw/source/core/text/txthyph.cxx
index 059e24e..9d73441 100644
--- a/sw/source/core/text/txthyph.cxx
+++ b/sw/source/core/text/txthyph.cxx
@@ -73,7 +73,7 @@ bool SwTxtFrm::Hyphenate( SwInterHyphInfo &rHyphInf )
     {
         // We always need to enable hyphenation
         // Don't be afraid: the SwTxtIter saves the old row in the hyphenate
-        SwTxtFrmLocker aLock( this );
+        TxtFrmLockGuard aLock( this );
 
         if ( IsVertical() )
             SwapWidthAndHeight();


More information about the Libreoffice-commits mailing list