diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-05-15 18:28:31 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-05-15 17:30:59 +0200 |
commit | 3c6b0eb0f16e4cb6d427a160e8ff766209c49f99 (patch) | |
tree | edf08a80de041a12dda5c2128dd375dc5869aa6a | |
parent | 92ca8dfeb3a05178ea0698fbb519e79af2ad2408 (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | sw/source/core/graphic/ndgrf.cxx | 45 |
1 files changed, 27 insertions, 18 deletions
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 ) { |