summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-02-10 16:05:58 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-02-10 16:27:45 +0000
commit233da237ad4b593c945903c3b32185a540025516 (patch)
tree9ddcd46dcec1254a20e8d9987cae407f547efccd
parent8c8e536c2c36cdf31494e7b9b9c0871169ed043c (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
-rw-r--r--sw/source/core/docnode/swbaslnk.cxx46
-rw-r--r--sw/source/filter/html/htmlgrin.cxx11
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 0ca33732d700..cb4db4c34edf 100644
--- a/sw/source/filter/html/htmlgrin.cxx
+++ b/sw/source/filter/html/htmlgrin.cxx
@@ -597,6 +597,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;
@@ -608,6 +609,7 @@ IMAGE_SETEVENT:
// Tabelle layoutet wird.
if( pTable!=0 && !nWidth )
{
+ bRequestGrfNow = true;
IncGrfsThatResizeTable();
}
@@ -811,6 +813,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 );