[Libreoffice-commits] core.git: sw/inc sw/source
Jan-Marek Glogowski
glogow at fbihome.de
Tue Oct 31 01:42:43 UTC 2017
sw/inc/swbaslnk.hxx | 18 +++++-----
sw/source/core/docnode/swbaslnk.cxx | 60 ++++++++++++++++++------------------
2 files changed, 40 insertions(+), 38 deletions(-)
New commits:
commit 45f76baf6d7f38849e2972b7d0931f4046723f7e
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date: Thu Oct 26 16:22:08 2017 +0200
Refactor SwBaseLink member variables
Change-Id: I5752ff69c4978278d597360a34657e380d71ee4c
Reviewed-on: https://gerrit.libreoffice.org/43907
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
diff --git a/sw/inc/swbaslnk.hxx b/sw/inc/swbaslnk.hxx
index 0ec3d018c970..539f430ddee2 100644
--- a/sw/inc/swbaslnk.hxx
+++ b/sw/inc/swbaslnk.hxx
@@ -26,16 +26,16 @@ class SwContentNode;
class SwBaseLink : public ::sfx2::SvBaseLink
{
- SwContentNode* pContentNode;
- bool bSwapIn : 1;
- bool bNoDataFlag : 1;
- bool bIgnoreDataChanged : 1;
+ SwContentNode* m_pContentNode;
+ bool m_bInSwapIn : 1; ///< Prevent recursion and notifications during SwapIn
+ bool m_bNoDataFlag : 1;
+ bool m_bIgnoreDataChanged : 1;
public:
SwBaseLink( SfxLinkUpdateMode nMode, SotClipboardFormatId nFormat, SwContentNode* pNode = nullptr )
- : ::sfx2::SvBaseLink( nMode, nFormat ), pContentNode( pNode ),
- bSwapIn( false ), bNoDataFlag( false ), bIgnoreDataChanged( false )
+ : ::sfx2::SvBaseLink( nMode, nFormat ), m_pContentNode( pNode ),
+ m_bInSwapIn( false ), m_bNoDataFlag( false ), m_bIgnoreDataChanged( false )
{}
virtual ~SwBaseLink() override;
@@ -58,9 +58,9 @@ public:
virtual bool IsInRange( sal_uLong nSttNd, sal_uLong nEndNd, sal_Int32 nStt = 0,
sal_Int32 nEnd = -1 ) const;
- void SetNoDataFlag() { bNoDataFlag = true; }
- bool ChkNoDataFlag() { const bool bRet = bNoDataFlag; bNoDataFlag = false; return bRet; }
- bool IsNoDataFlag() const { return bNoDataFlag; }
+ void SetNoDataFlag() { m_bNoDataFlag = true; }
+ bool ChkNoDataFlag() { const bool bRet = m_bNoDataFlag; m_bNoDataFlag = false; return bRet; }
+ bool IsNoDataFlag() const { return m_bNoDataFlag; }
};
#endif
diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx
index c6ca7da2b8c2..8320b6306373 100644
--- a/sw/source/core/docnode/swbaslnk.cxx
+++ b/sw/source/core/docnode/swbaslnk.cxx
@@ -82,22 +82,22 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
::sfx2::SvBaseLink::UpdateResult SwBaseLink::DataChanged(
const OUString& rMimeType, const uno::Any & rValue )
{
- if( !pContentNode )
+ if( !m_pContentNode )
{
OSL_ENSURE(false, "DataChanged without ContentNode" );
return ERROR_GENERAL;
}
- SwDoc* pDoc = pContentNode->GetDoc();
- if( pDoc->IsInDtor() || ChkNoDataFlag() || bIgnoreDataChanged )
+ SwDoc* pDoc = m_pContentNode->GetDoc();
+ if( pDoc->IsInDtor() || ChkNoDataFlag() || m_bIgnoreDataChanged )
{
- bIgnoreDataChanged = false;
+ m_bIgnoreDataChanged = false;
return SUCCESS;
}
SotClipboardFormatId nFormat = SotExchange::GetFormatIdFromMimeType( rMimeType );
- if( pContentNode->IsNoTextNode() &&
+ if( m_pContentNode->IsNoTextNode() &&
nFormat == sfx2::LinkManager::RegisterStatusInfoId() )
{
// Only a status change - serve Events?
@@ -114,7 +114,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
}
SwFrameFormat* pFormat;
- if( nEvent != SvMacroItemId::NONE && nullptr != ( pFormat = pContentNode->GetFlyFormat() ))
+ if( nEvent != SvMacroItemId::NONE && nullptr != ( pFormat = m_pContentNode->GetFlyFormat() ))
{
SwCallMouseEvent aCallEvent;
aCallEvent.Set( EVENT_OBJECT_IMAGE, pFormat );
@@ -127,19 +127,19 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
bool bUpdate = false;
bool bGraphicArrived = false;
bool bGraphicPieceArrived = false;
- bool bDontNotify = false;
+ bool bFrameInPaint = false;
Size aGrfSz, aOldSz;
SwGrfNode* pSwGrfNode = nullptr;
- if (pContentNode->IsGrfNode())
+ if (m_pContentNode->IsGrfNode())
{
- pSwGrfNode = pContentNode->GetGrfNode();
+ pSwGrfNode = m_pContentNode->GetGrfNode();
assert(pSwGrfNode && "Error, pSwGrfNode expected when node answers IsGrfNode() with true (!)");
aOldSz = pSwGrfNode->GetTwipSize();
const GraphicObject& rGrfObj = pSwGrfNode->GetGrfObj();
- bDontNotify = pSwGrfNode->IsFrameInPaint();
+ bFrameInPaint = pSwGrfNode->IsFrameInPaint();
bGraphicArrived = GetObj()->IsDataComplete();
bGraphicPieceArrived = GetObj()->IsPending();
@@ -184,26 +184,28 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
if ( bUpdate && !bGraphicArrived && !bGraphicPieceArrived )
pSwGrfNode->SetTwipSize( Size(0,0) );
}
- else if( pContentNode->IsOLENode() )
+ else if( m_pContentNode->IsOLENode() )
bUpdate = true;
+ if ( !bUpdate || bFrameInPaint )
+ return SUCCESS;
+
SwViewShell *pSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
SwEditShell* pESh = pDoc->GetEditShell();
- if ( bUpdate && bGraphicPieceArrived && !(bSwapIn || bDontNotify) )
+ if ( bGraphicPieceArrived && !m_bInSwapIn )
{
// Send hint without Actions; triggers direct paint
if ( (!pSh || !pSh->ActionPend()) && (!pESh || !pESh->ActionPend()) )
{
SwMsgPoolItem aMsgHint( RES_GRAPHIC_PIECE_ARRIVED );
- pContentNode->ModifyNotification( &aMsgHint, &aMsgHint );
+ m_pContentNode->ModifyNotification( &aMsgHint, &aMsgHint );
bUpdate = false;
}
}
static bool bInNotifyLinks = false;
- if( bUpdate && !bDontNotify && (!bSwapIn || bGraphicArrived) &&
- !bInNotifyLinks)
+ if( (!m_bInSwapIn || bGraphicArrived) && !bInNotifyLinks)
{
bool bLockView = false;
if( pSh )
@@ -233,19 +235,19 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
dynamic_cast<const SwBaseLink*>( pLnk) != nullptr && pLnk->GetObj() == GetObj() )
{
SwBaseLink* pBLink = static_cast<SwBaseLink*>(pLnk);
- SwGrfNode* pGrfNd = static_cast<SwGrfNode*>(pBLink->pContentNode);
+ SwGrfNode* pGrfNd = static_cast<SwGrfNode*>(pBLink->m_pContentNode);
if( pBLink != this &&
- ( !bSwapIn ||
+ ( !m_bInSwapIn ||
GraphicType::Default == pGrfNd->GetGrfObj().GetType()))
{
Size aPreArriveSize(pGrfNd->GetTwipSize());
- pBLink->bIgnoreDataChanged = false;
+ pBLink->m_bIgnoreDataChanged = false;
pBLink->DataChanged( rMimeType, rValue );
- pBLink->bIgnoreDataChanged = true;
+ pBLink->m_bIgnoreDataChanged = true;
- pGrfNd->SetGraphicArrived( static_cast<SwGrfNode*>(pContentNode)->
+ pGrfNd->SetGraphicArrived( static_cast<SwGrfNode*>(m_pContentNode)->
IsGraphicArrived() );
// Adjust the Fly's graphic
@@ -268,7 +270,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
}
else
{
- pContentNode->ModifyNotification( &aMsgHint, &aMsgHint );
+ m_pContentNode->ModifyNotification( &aMsgHint, &aMsgHint );
}
if( pESh )
@@ -372,7 +374,7 @@ static bool SetGrfFlySize( const Size& rGrfSz, SwGrfNode* pGrfNd, const Size& rO
bool SwBaseLink::SwapIn( bool bWaitForData, bool bNativFormat )
{
- bSwapIn = true;
+ m_bInSwapIn = true;
if( !GetObj() && ( bNativFormat || ( !IsSynchron() && bWaitForData ) ))
{
@@ -400,7 +402,7 @@ bool SwBaseLink::SwapIn( bool bWaitForData, bool bNativFormat )
{
// The Flag needs to be reset on a SwapIn, because
// we want to reapply the data.
- bIgnoreDataChanged = false;
+ m_bIgnoreDataChanged = false;
DataChanged( aMimeType, aValue );
}
}
@@ -414,26 +416,26 @@ bool SwBaseLink::SwapIn( bool bWaitForData, bool bNativFormat )
else
bRes = Update();
- bSwapIn = false;
+ m_bInSwapIn = false;
return bRes;
}
void SwBaseLink::Closed()
{
- if( pContentNode && !pContentNode->GetDoc()->IsInDtor() )
+ if( m_pContentNode && !m_pContentNode->GetDoc()->IsInDtor() )
{
// Delete the connection
- if( pContentNode->IsGrfNode() )
- static_cast<SwGrfNode*>(pContentNode)->ReleaseLink();
+ if( m_pContentNode->IsGrfNode() )
+ static_cast<SwGrfNode*>(m_pContentNode)->ReleaseLink();
}
SvBaseLink::Closed();
}
const SwNode* SwBaseLink::GetAnchor() const
{
- if (pContentNode)
+ if (m_pContentNode)
{
- SwFrameFormat *const pFormat = pContentNode->GetFlyFormat();
+ SwFrameFormat *const pFormat = m_pContentNode->GetFlyFormat();
if (pFormat)
{
const SwFormatAnchor& rAnchor = pFormat->GetAnchor();
More information about the Libreoffice-commits
mailing list