tdf#117247 just send a GRAPHIC_ARRIVED hint after update

As we always load graphic complete now, we can just hint that it
has arrived. In the future we might properly restore retrieving the
stream of a graphic throught link manager, but not creating the
partial graphic from it - just an async retrieval of the bytes.
The graphic should then always be created completely with the
GraphicFilter.

Change-Id: I8560c9d41a057d228aa558316131ba99d436645b
Reviewed-on: https://gerrit.libreoffice.org/54693
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
Tomaž Vajngerl
2018-05-23 17:36:44 +09:00
committed by Tomaž Vajngerl
parent f8fb04d0af
commit 7581730b27

View File

@@ -126,8 +126,6 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
}
bool bUpdate = false;
bool bGraphicArrived = false;
bool bGraphicPieceArrived = false;
bool bFrameInPaint = false;
Size aGrfSz, aOldSz;
@@ -142,9 +140,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
bFrameInPaint = pSwGrfNode->IsFrameInPaint();
bGraphicArrived = GetObj()->IsDataComplete();
bGraphicPieceArrived = GetObj()->IsPending();
pSwGrfNode->SetGraphicArrived( bGraphicArrived );
pSwGrfNode->SetGraphicArrived(true);
Graphic aGrf;
@@ -154,36 +150,18 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
{
aGrfSz = ::GetGraphicSizeTwip( aGrf, nullptr );
if( bGraphicPieceArrived && GraphicType::Default != aGrf.GetType() &&
( !aOldSz.Width() || !aOldSz.Height() ) )
{
// If only a part arrives, but the size is not set
// we need to go through bGraphicArrived down there.
// Or else the graphic is painted at its definitive size
bGraphicArrived = true;
bGraphicPieceArrived = false;
}
pSwGrfNode->SetGraphic(aGrf, "");
bUpdate = true;
// In order for the Node to have the right transparency status
// without having to access the graphic.
// Or else we cause a SwapIn.
if( bGraphicArrived )
// Always use the correct graphic size
if( aGrfSz.Height() && aGrfSz.Width() &&
aOldSz.Height() && aOldSz.Width() &&
aGrfSz != aOldSz )
{
// Always use the correct graphic size
if( aGrfSz.Height() && aGrfSz.Width() &&
aOldSz.Height() && aOldSz.Width() &&
aGrfSz != aOldSz )
{
pSwGrfNode->SetTwipSize( aGrfSz );
aOldSz = aGrfSz;
}
pSwGrfNode->SetTwipSize(aGrfSz);
aOldSz = aGrfSz;
}
}
if ( bUpdate && !bGraphicArrived && !bGraphicPieceArrived )
pSwGrfNode->SetTwipSize( Size(0,0) );
}
else if( m_pContentNode->IsOLENode() )
bUpdate = true;
@@ -191,103 +169,16 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
if ( !bUpdate || bFrameInPaint )
return SUCCESS;
SwViewShell *pSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
SwEditShell* pESh = pDoc->GetEditShell();
if ( bGraphicPieceArrived && !m_bInSwapIn )
if (bUpdate)
{
// Send hint without Actions; triggers direct paint
if ( (!pSh || !pSh->ActionPend()) && (!pESh || !pESh->ActionPend()) )
if (!SetGrfFlySize(aGrfSz, pSwGrfNode, aOldSz))
{
SwMsgPoolItem aMsgHint( RES_GRAPHIC_PIECE_ARRIVED );
m_pContentNode->ModifyNotification( &aMsgHint, &aMsgHint );
bUpdate = false;
SwMsgPoolItem aMsgHint(RES_GRAPHIC_ARRIVED);
lcl_CallModify(*pSwGrfNode, aMsgHint);
return SUCCESS;
}
}
static bool bInNotifyLinks = false;
if( (!m_bInSwapIn || bGraphicArrived) && !bInNotifyLinks)
{
bool bLockView = false;
if( pSh )
{
bLockView = pSh->IsViewLocked();
pSh->LockView( true );
}
if( pESh )
pESh->StartAllAction();
else if( pSh )
pSh->StartAction();
SwMsgPoolItem aMsgHint(
bGraphicArrived ? sal_uInt16(RES_GRAPHIC_ARRIVED) : sal_uInt16(RES_UPDATE_ATTR) );
if ( bGraphicArrived )
{
// Notify all who are listening at the same link
bInNotifyLinks = true;
const ::sfx2::SvBaseLinks& rLnks = pDoc->getIDocumentLinksAdministration().GetLinkManager().GetLinks();
for( auto n = rLnks.size(); n; )
{
::sfx2::SvBaseLink* pLnk = &(*rLnks[ --n ]);
if( pLnk && OBJECT_CLIENT_GRF == pLnk->GetObjType() &&
dynamic_cast<const SwBaseLink*>( pLnk) != nullptr && pLnk->GetObj() == GetObj() )
{
SwBaseLink* pBLink = static_cast<SwBaseLink*>(pLnk);
SwGrfNode* pGrfNd = static_cast<SwGrfNode*>(pBLink->m_pContentNode);
if( pBLink != this &&
( !m_bInSwapIn ||
GraphicType::Default == pGrfNd->GetGrfObj().GetType()))
{
Size aPreArriveSize(pGrfNd->GetTwipSize());
pBLink->m_bIgnoreDataChanged = false;
pBLink->DataChanged( rMimeType, rValue );
pBLink->m_bIgnoreDataChanged = true;
pGrfNd->SetGraphicArrived( static_cast<SwGrfNode*>(m_pContentNode)->
IsGraphicArrived() );
// Adjust the Fly's graphic
if (!::SetGrfFlySize(aGrfSz, pGrfNd, aPreArriveSize))
::lcl_CallModify( *pGrfNd, aMsgHint );
}
else if (pBLink == this)
{
assert(pGrfNd == pSwGrfNode && "fdo#87083 needs a different fix");
if (!::SetGrfFlySize(aGrfSz, pGrfNd, aOldSz))
{
// Adjust the Fly's graphic
::lcl_CallModify( *pGrfNd, aMsgHint );
}
}
}
}
bInNotifyLinks = false;
}
else
{
m_pContentNode->ModifyNotification( &aMsgHint, &aMsgHint );
}
if( pESh )
{
const bool bEndActionByVirDev = pESh->IsEndActionByVirDev();
pESh->SetEndActionByVirDev( true );
pESh->EndAllAction();
pESh->SetEndActionByVirDev( bEndActionByVirDev );
}
else if( pSh )
pSh->EndAction();
if( pSh && !bLockView )
pSh->LockView( false );
}
return SUCCESS;
}