sw/source/core/graphic/ndgrf.cxx | 45 +++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 18 deletions(-)
New commits: commit 3c6b0eb0f16e4cb6d427a160e8ff766209c49f99 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> Date: Tue May 15 18:28:31 2018 +0900 tdf#117427 need to check originURL when ReRead is called Previously we checked the originURL of Graphic for SwGrfNode in constructor which then called ReRead. This is OK for linked graphic when they are loaded from the document, but when we change the Graphic through API, only the ReRead method is called. So to get this to work we need to move checking of originURL into the ReRead method. Change-Id: Iaa4a332459baab656740ff209b997c48b7287e16 Reviewed-on: https://gerrit.libreoffice.org/54362 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx index a966a29897bf..5cfd3ce51508 100644 --- a/sw/source/core/graphic/ndgrf.cxx +++ b/sw/source/core/graphic/ndgrf.cxx @@ -73,19 +73,11 @@ SwGrfNode::SwGrfNode( mbLinkedInputStreamReady( false ), mbIsStreamReadOnly( false ) { - OUString sURLLink(pGraphic->getOriginURL()); - if (sURLLink.isEmpty() && !rGrfName.isEmpty()) - { - sURLLink = rGrfName; - Graphic aGraphic(*pGraphic); - aGraphic.setOriginURL(sURLLink); - } - bInSwapIn = bChgTwipSize = bFrameInPaint = bScaleImageMap = false; bGraphicArrived = true; - ReRead(sURLLink, rFltName, pGraphic, false); + ReRead(rGrfName, rFltName, pGraphic, false); } SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere, @@ -155,15 +147,32 @@ bool SwGrfNode::ReRead( OSL_ENSURE( pGraphic || !rGrfName.isEmpty(), "GraphicNode without a name, Graphic or GraphicObject" ); + OUString sURLLink; + if (pGraphic) + { + Graphic aGraphic(*pGraphic); + + sURLLink = aGraphic.getOriginURL(); + if (sURLLink.isEmpty() && !rGrfName.isEmpty()) + { + sURLLink = rGrfName; + aGraphic.setOriginURL(sURLLink); + } + } + else + { + sURLLink = rGrfName; + } + // with name if( refLink.is() ) { OSL_ENSURE( !bInSwapIn, "ReRead: I am still in SwapIn" ); - if( !rGrfName.isEmpty() ) + if( !sURLLink.isEmpty() ) { // Note: If there is DDE in the FltName, than it is a DDE-linked graphic - OUString sCmd( rGrfName ); + OUString sCmd( sURLLink ); if( !rFltName.isEmpty() ) { sal_uInt16 nNewType; @@ -171,7 +180,7 @@ bool SwGrfNode::ReRead( nNewType = OBJECT_CLIENT_DDE; else { - sfx2::MakeLnkName( sCmd, nullptr, rGrfName, OUString(), &rFltName ); + sfx2::MakeLnkName( sCmd, nullptr, sURLLink, OUString(), &rFltName ); nNewType = OBJECT_CLIENT_GRF; } @@ -192,7 +201,7 @@ bool SwGrfNode::ReRead( if( pGraphic ) { - maGrfObj.SetGraphic( *pGraphic, rGrfName ); + maGrfObj.SetGraphic( *pGraphic, sURLLink ); onGraphicChanged(); bReadGrf = true; } @@ -201,7 +210,7 @@ bool SwGrfNode::ReRead( // reset data of the old graphic so that the correct placeholder is // shown in case the new link could not be loaded Graphic aGrf; aGrf.SetDefaultType(); - maGrfObj.SetGraphic( aGrf, rGrfName ); + maGrfObj.SetGraphic( aGrf, sURLLink ); if( refLink.is() ) { @@ -220,7 +229,7 @@ bool SwGrfNode::ReRead( bSetTwipSize = false; } } - else if( pGraphic && rGrfName.isEmpty() ) + else if( pGraphic && sURLLink.isEmpty() ) { maGrfObj.SetGraphic( *pGraphic ); onGraphicChanged(); @@ -232,13 +241,13 @@ bool SwGrfNode::ReRead( else { // create new link for the graphic object - InsertLink( rGrfName, rFltName ); + InsertLink( sURLLink, rFltName ); if( GetNodes().IsDocNodes() ) { if( pGraphic ) { - maGrfObj.SetGraphic( *pGraphic, rGrfName ); + maGrfObj.SetGraphic( *pGraphic, sURLLink ); onGraphicChanged(); bReadGrf = true; // create connection without update, as we have the graphic @@ -248,7 +257,7 @@ bool SwGrfNode::ReRead( { Graphic aGrf; aGrf.SetDefaultType(); - maGrfObj.SetGraphic( aGrf, rGrfName ); + maGrfObj.SetGraphic( aGrf, sURLLink ); onGraphicChanged(); if ( bNewGrf ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits