diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-02-10 16:05:58 +0000 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-02-11 16:00:49 +0000 |
commit | 64fe9d34c6bae221309a037fc1ca399076a53de9 (patch) | |
tree | e7696f8b69269578597507fd74f86875c8e8c5b4 | |
parent | dd53735c5fe98fa4f8da4bf214a04b7883bf73c8 (diff) |
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 61a5abd5fab308c9e6580e752fa846f5bf0d7e51
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
(cherry picked from commit 233da237ad4b593c945903c3b32185a540025516)
Reviewed-on: https://gerrit.libreoffice.org/14403
Tested-by: Michael Stahl <mstahl@redhat.com>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r-- | sw/source/core/docnode/swbaslnk.cxx | 46 | ||||
-rw-r--r-- | sw/source/filter/html/htmlgrin.cxx | 11 |
2 files changed, 41 insertions, 16 deletions
diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx index f52e2854d77c..85ec6f84f0da 100644 --- a/sw/source/core/docnode/swbaslnk.cxx +++ b/sw/source/core/docnode/swbaslnk.cxx @@ -53,7 +53,7 @@ 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 ); @@ -103,6 +103,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) { // Only a status change - serve Events? OUString sState; + if( rValue.hasValue() && ( rValue >>= sState )) { sal_uInt16 nEvent = 0; @@ -128,12 +129,15 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) bool bGraphicArrived = false; bool bGraphicPieceArrived = false; bool bDontNotify = false; - Size aGrfSz, aFrmFmtSz; + Size aGrfSz, aOldSz, aFrmFmtSz; + + SwGrfNode* pSwGrfNode = NULL; - if( pCntntNode->IsGrfNode() ) + if (pCntntNode->IsGrfNode()) { - SwGrfNode* pSwGrfNode = pCntntNode->GetGrfNode(); - OSL_ENSURE(pSwGrfNode, "Error, pSwGrfNode expected when node answers IsGrfNode() with true (!)"); + pSwGrfNode = pCntntNode->GetGrfNode(); + assert(pSwGrfNode && "Error, pSwGrfNode expected when node answers IsGrfNode() with true (!)"); + aOldSz = pSwGrfNode->GetTwipSize(); const GraphicObject& rGrfObj = pSwGrfNode->GetGrfObj(); bDontNotify = pSwGrfNode->IsFrameInPaint(); @@ -143,6 +147,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) pSwGrfNode->SetGraphicArrived( bGraphicArrived ); Graphic aGrf; + if( sfx2::LinkManager::GetGraphicFromAny( rMimeType, rValue, aGrf ) && ( GRAPHIC_DEFAULT != aGrf.GetType() || GRAPHIC_DEFAULT != rGrfObj.GetType() ) ) @@ -159,10 +164,9 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) { aFrmFmtSz = aGrfSz; } - Size aSz( pSwGrfNode->GetTwipSize() ); 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 // we need to go through bGraphicArrived down there. @@ -181,9 +185,12 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) { // Always use the correct graphic size if( aGrfSz.Height() && aGrfSz.Width() && - aSz.Height() && aSz.Width() && - aGrfSz != aSz ) + aOldSz.Height() && aOldSz.Width() && + aGrfSz != aOldSz ) + { pSwGrfNode->SetTwipSize( aGrfSz ); + aOldSz = aGrfSz; + } } } if ( bUpdate && !bGraphicArrived && !bGraphicPieceArrived ) @@ -244,6 +251,8 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) ( !bSwapIn || GRAPHIC_DEFAULT == pGrfNd->GetGrfObj().GetType())) { + Size aPreArriveSize(pGrfNd->GetTwipSize()); + pBLink->bIgnoreDataChanged = false; pBLink->DataChanged( rMimeType, rValue ); pBLink->bIgnoreDataChanged = true; @@ -252,13 +261,18 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) IsGraphicArrived() ); // Adjust the Fly's graphic - if( !::SetGrfFlySize( aGrfSz, aFrmFmtSz, pGrfNd ) ) + if (!::SetGrfFlySize(aGrfSz, aFrmFmtSz, pGrfNd, aPreArriveSize)) ::lcl_CallModify( *pGrfNd, aMsgHint ); } - else if( pBLink == this && - !::SetGrfFlySize( aGrfSz, aFrmFmtSz, pGrfNd ) ) - // Adjust the Fly's graphic - ::lcl_CallModify( *pGrfNd, aMsgHint ); + else if (pBLink == this) + { + assert(pGrfNd == pSwGrfNode && "fdo#87083 needs a different fix"); + 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 ) 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; SwViewShell *pSh = pGrfNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); @@ -294,7 +308,7 @@ static bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pG if ( pGrfNd->GetDoc()->GetEditShell() ) pCurr = new CurrShell( pSh ); - Size aSz = pGrfNd->GetTwipSize(); + Size aSz = rOrigGrfSize; if ( !(aSz.Width() && aSz.Height()) && rGrfSz.Width() && rGrfSz.Height() ) { diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index 6d5281ec945a..bf2e17a5d797 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -598,6 +598,7 @@ IMAGE_SETEVENT: Size aGrfSz( 0, 0 ); bool bSetTwipSize = true; // Twip-Size am Node setzen? bool bChangeFrmSize = false; // Frame-Format nachtraeglich anpassen? + bool bRequestGrfNow = false; bool bSetScaleImageMap = false; sal_uInt8 nPrcWidth = 0, nPrcHeight = 0; @@ -609,6 +610,7 @@ IMAGE_SETEVENT: // Tabelle layoutet wird. if( pTable!=0 && !nWidth ) { + bRequestGrfNow = true; IncGrfsThatResizeTable(); } @@ -810,6 +812,15 @@ IMAGE_SETEVENT: if( !aMacroItem.GetMacroTable().empty() ) 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 RegisterFlyFrm( pFlyFmt ); |