Kaydet (Commit) 233da237 authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: tdf#87083 images in help html stuck at default placeholder size

regression from the SwapIn work.

The graphic size during SetGrfFlySize appears to assume its the pre-swapped in
size, i.e. the old 0 by 0 "size is not set" for an html image used to be the
value used here. So get that value (and update it if necessary) before updating
the image data and pass that to SetGrfFlySize

Without the swap-in in the html filter the data gets swapped in during the
initial draw of the image which is too late to update the image size, so
restore the equivalent of that swap-in via GetTwipSize

commit 61a5abd5
Author: Zolnai Tamás <tamas.zolnai@collabora.com>
Date:   Fri Nov 7 10:43:34 2014 +0100

    Make SwGrfNode swapping methods private

    Change the filter test accordingly.

    Change-Id: Ide3043f2f245c097a7b4c07ba2e0713510296b3e

Change-Id: I0afe244f79d8628236b1e552036587a2b4540a76
üst 8c8e536c
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
using namespace com::sun::star; using namespace com::sun::star;
static bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pGrfNd ); static bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pGrfNd, const Size &rOrigGrfSize );
TYPEINIT1( SwBaseLink, ::sfx2::SvBaseLink ); TYPEINIT1( SwBaseLink, ::sfx2::SvBaseLink );
...@@ -103,6 +103,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) ...@@ -103,6 +103,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
{ {
// Only a status change - serve Events? // Only a status change - serve Events?
OUString sState; OUString sState;
if( rValue.hasValue() && ( rValue >>= sState )) if( rValue.hasValue() && ( rValue >>= sState ))
{ {
sal_uInt16 nEvent = 0; sal_uInt16 nEvent = 0;
...@@ -128,12 +129,15 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) ...@@ -128,12 +129,15 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
bool bGraphicArrived = false; bool bGraphicArrived = false;
bool bGraphicPieceArrived = false; bool bGraphicPieceArrived = false;
bool bDontNotify = false; bool bDontNotify = false;
Size aGrfSz, aFrmFmtSz; Size aGrfSz, aOldSz, aFrmFmtSz;
SwGrfNode* pSwGrfNode = NULL;
if( pCntntNode->IsGrfNode() ) if (pCntntNode->IsGrfNode())
{ {
SwGrfNode* pSwGrfNode = pCntntNode->GetGrfNode(); pSwGrfNode = pCntntNode->GetGrfNode();
OSL_ENSURE(pSwGrfNode, "Error, pSwGrfNode expected when node answers IsGrfNode() with true (!)"); assert(pSwGrfNode && "Error, pSwGrfNode expected when node answers IsGrfNode() with true (!)");
aOldSz = pSwGrfNode->GetTwipSize();
const GraphicObject& rGrfObj = pSwGrfNode->GetGrfObj(); const GraphicObject& rGrfObj = pSwGrfNode->GetGrfObj();
bDontNotify = pSwGrfNode->IsFrameInPaint(); bDontNotify = pSwGrfNode->IsFrameInPaint();
...@@ -143,6 +147,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) ...@@ -143,6 +147,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
pSwGrfNode->SetGraphicArrived( bGraphicArrived ); pSwGrfNode->SetGraphicArrived( bGraphicArrived );
Graphic aGrf; Graphic aGrf;
if( sfx2::LinkManager::GetGraphicFromAny( rMimeType, rValue, aGrf ) && if( sfx2::LinkManager::GetGraphicFromAny( rMimeType, rValue, aGrf ) &&
( GRAPHIC_DEFAULT != aGrf.GetType() || ( GRAPHIC_DEFAULT != aGrf.GetType() ||
GRAPHIC_DEFAULT != rGrfObj.GetType() ) ) GRAPHIC_DEFAULT != rGrfObj.GetType() ) )
...@@ -159,10 +164,9 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) ...@@ -159,10 +164,9 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
{ {
aFrmFmtSz = aGrfSz; aFrmFmtSz = aGrfSz;
} }
Size aSz( pSwGrfNode->GetTwipSize() );
if( bGraphicPieceArrived && GRAPHIC_DEFAULT != aGrf.GetType() && if( bGraphicPieceArrived && GRAPHIC_DEFAULT != aGrf.GetType() &&
( !aSz.Width() || !aSz.Height() ) ) ( !aOldSz.Width() || !aOldSz.Height() ) )
{ {
// If only a part arrives, but the size is not set // If only a part arrives, but the size is not set
// we need to go through bGraphicArrived down there. // we need to go through bGraphicArrived down there.
...@@ -181,9 +185,12 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) ...@@ -181,9 +185,12 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
{ {
// Always use the correct graphic size // Always use the correct graphic size
if( aGrfSz.Height() && aGrfSz.Width() && if( aGrfSz.Height() && aGrfSz.Width() &&
aSz.Height() && aSz.Width() && aOldSz.Height() && aOldSz.Width() &&
aGrfSz != aSz ) aGrfSz != aOldSz )
{
pSwGrfNode->SetTwipSize( aGrfSz ); pSwGrfNode->SetTwipSize( aGrfSz );
aOldSz = aGrfSz;
}
} }
} }
if ( bUpdate && !bGraphicArrived && !bGraphicPieceArrived ) if ( bUpdate && !bGraphicArrived && !bGraphicPieceArrived )
...@@ -244,6 +251,8 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) ...@@ -244,6 +251,8 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
( !bSwapIn || ( !bSwapIn ||
GRAPHIC_DEFAULT == pGrfNd->GetGrfObj().GetType())) GRAPHIC_DEFAULT == pGrfNd->GetGrfObj().GetType()))
{ {
Size aPreArriveSize(pGrfNd->GetTwipSize());
pBLink->bIgnoreDataChanged = false; pBLink->bIgnoreDataChanged = false;
pBLink->DataChanged( rMimeType, rValue ); pBLink->DataChanged( rMimeType, rValue );
pBLink->bIgnoreDataChanged = true; pBLink->bIgnoreDataChanged = true;
...@@ -252,13 +261,18 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) ...@@ -252,13 +261,18 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
IsGraphicArrived() ); IsGraphicArrived() );
// Adjust the Fly's graphic // Adjust the Fly's graphic
if( !::SetGrfFlySize( aGrfSz, aFrmFmtSz, pGrfNd ) ) if (!::SetGrfFlySize(aGrfSz, aFrmFmtSz, pGrfNd, aPreArriveSize))
::lcl_CallModify( *pGrfNd, aMsgHint ); ::lcl_CallModify( *pGrfNd, aMsgHint );
} }
else if( pBLink == this && else if (pBLink == this)
!::SetGrfFlySize( aGrfSz, aFrmFmtSz, pGrfNd ) ) {
// Adjust the Fly's graphic assert(pGrfNd == pSwGrfNode && "fdo#87083 needs a different fix");
::lcl_CallModify( *pGrfNd, aMsgHint ); if (!::SetGrfFlySize(aGrfSz, aFrmFmtSz, pGrfNd, aOldSz))
{
// Adjust the Fly's graphic
::lcl_CallModify( *pGrfNd, aMsgHint );
}
}
} }
} }
...@@ -286,7 +300,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) ...@@ -286,7 +300,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
return SUCCESS; return SUCCESS;
} }
static bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pGrfNd ) static bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pGrfNd, const Size& rOrigGrfSize )
{ {
bool bRet = false; bool bRet = false;
SwViewShell *pSh = pGrfNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); SwViewShell *pSh = pGrfNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell();
...@@ -294,7 +308,7 @@ static bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pG ...@@ -294,7 +308,7 @@ static bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pG
if ( pGrfNd->GetDoc()->GetEditShell() ) if ( pGrfNd->GetDoc()->GetEditShell() )
pCurr = new CurrShell( pSh ); pCurr = new CurrShell( pSh );
Size aSz = pGrfNd->GetTwipSize(); Size aSz = rOrigGrfSize;
if ( !(aSz.Width() && aSz.Height()) && if ( !(aSz.Width() && aSz.Height()) &&
rGrfSz.Width() && rGrfSz.Height() ) rGrfSz.Width() && rGrfSz.Height() )
{ {
......
...@@ -597,6 +597,7 @@ IMAGE_SETEVENT: ...@@ -597,6 +597,7 @@ IMAGE_SETEVENT:
Size aGrfSz( 0, 0 ); Size aGrfSz( 0, 0 );
bool bSetTwipSize = true; // Twip-Size am Node setzen? bool bSetTwipSize = true; // Twip-Size am Node setzen?
bool bChangeFrmSize = false; // Frame-Format nachtraeglich anpassen? bool bChangeFrmSize = false; // Frame-Format nachtraeglich anpassen?
bool bRequestGrfNow = false;
bool bSetScaleImageMap = false; bool bSetScaleImageMap = false;
sal_uInt8 nPrcWidth = 0, nPrcHeight = 0; sal_uInt8 nPrcWidth = 0, nPrcHeight = 0;
...@@ -608,6 +609,7 @@ IMAGE_SETEVENT: ...@@ -608,6 +609,7 @@ IMAGE_SETEVENT:
// Tabelle layoutet wird. // Tabelle layoutet wird.
if( pTable!=0 && !nWidth ) if( pTable!=0 && !nWidth )
{ {
bRequestGrfNow = true;
IncGrfsThatResizeTable(); IncGrfsThatResizeTable();
} }
...@@ -811,6 +813,15 @@ IMAGE_SETEVENT: ...@@ -811,6 +813,15 @@ IMAGE_SETEVENT:
if( !aMacroItem.GetMacroTable().empty() ) if( !aMacroItem.GetMacroTable().empty() )
pFlyFmt->SetFmtAttr( aMacroItem ); pFlyFmt->SetFmtAttr( aMacroItem );
// tdf#87083 If the graphic has not been loaded yet, then load it now.
// Otherwise it may be loaded during the first paint of the object and it
// will be too late to adapt the size of the graphic at that point.
if (bRequestGrfNow && pGrfNd)
{
Size aUpdatedSize = pGrfNd->GetTwipSize(); //trigger a swap-in
SAL_WARN_IF(!aUpdatedSize.Width() || !aUpdatedSize.Width(), "sw.html", "html image with no width or height");
}
// Ggf. Frames anlegen und Auto-gebundenen Rahmen registrieren // Ggf. Frames anlegen und Auto-gebundenen Rahmen registrieren
RegisterFlyFrm( pFlyFmt ); RegisterFlyFrm( pFlyFmt );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment