summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-05-08 12:37:39 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-05-08 12:39:01 +0100
commit303f08fe4292341cda40f70da3d0f82d69f697aa (patch)
tree4f2c06eca91dfc7149b8722f810ad16d444bdaca
parent2df138b483f60ffdcd3b62c8c2884d2f5cc076af (diff)
rename these scope lock guards, no logic change
Change-Id: Ib1ec9c07ef38e22d739e80693eeb2d52e8e3b5f7
-rw-r--r--sw/source/core/inc/flowfrm.hxx8
-rw-r--r--sw/source/core/inc/txtfrm.hxx34
-rw-r--r--sw/source/core/layout/flowfrm.cxx2
-rw-r--r--sw/source/core/layout/layact.cxx2
-rw-r--r--sw/source/core/text/frmform.cxx6
-rw-r--r--sw/source/core/text/frmpaint.cxx4
-rw-r--r--sw/source/core/text/txtfrm.cxx4
-rw-r--r--sw/source/core/text/txthyph.cxx2
8 files changed, 41 insertions, 21 deletions
diff --git a/sw/source/core/inc/flowfrm.hxx b/sw/source/core/inc/flowfrm.hxx
index 59bafa4e9054..4d2791095f87 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 7fe60f1be2a6..784db5f8e510 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 f84d7a8311e9..a41bb67ae098 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 88e5fe02f028..732c67a3c855 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 0e2b9e79a4e9..3df734732838 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 cea9731b7d78..9d2c4ad55b24 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 aa5e3c77f429..cc801a926a83 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 059e24edc0a4..9d7344180621 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();