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>
This commit is contained in:
Tomaž Vajngerl 2018-05-15 18:28:31 +09:00 committed by Tomaž Vajngerl
parent 92ca8dfeb3
commit 3c6b0eb0f1

View File

@ -73,19 +73,11 @@ SwGrfNode::SwGrfNode(
mbLinkedInputStreamReady( false ), mbLinkedInputStreamReady( false ),
mbIsStreamReadOnly( false ) mbIsStreamReadOnly( false )
{ {
OUString sURLLink(pGraphic->getOriginURL());
if (sURLLink.isEmpty() && !rGrfName.isEmpty())
{
sURLLink = rGrfName;
Graphic aGraphic(*pGraphic);
aGraphic.setOriginURL(sURLLink);
}
bInSwapIn = bChgTwipSize = bInSwapIn = bChgTwipSize =
bFrameInPaint = bScaleImageMap = false; bFrameInPaint = bScaleImageMap = false;
bGraphicArrived = true; bGraphicArrived = true;
ReRead(sURLLink, rFltName, pGraphic, false); ReRead(rGrfName, rFltName, pGraphic, false);
} }
SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere, SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere,
@ -155,15 +147,32 @@ bool SwGrfNode::ReRead(
OSL_ENSURE( pGraphic || !rGrfName.isEmpty(), OSL_ENSURE( pGraphic || !rGrfName.isEmpty(),
"GraphicNode without a name, Graphic or GraphicObject" ); "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 // with name
if( refLink.is() ) if( refLink.is() )
{ {
OSL_ENSURE( !bInSwapIn, "ReRead: I am still in SwapIn" ); 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 // Note: If there is DDE in the FltName, than it is a DDE-linked graphic
OUString sCmd( rGrfName ); OUString sCmd( sURLLink );
if( !rFltName.isEmpty() ) if( !rFltName.isEmpty() )
{ {
sal_uInt16 nNewType; sal_uInt16 nNewType;
@ -171,7 +180,7 @@ bool SwGrfNode::ReRead(
nNewType = OBJECT_CLIENT_DDE; nNewType = OBJECT_CLIENT_DDE;
else else
{ {
sfx2::MakeLnkName( sCmd, nullptr, rGrfName, OUString(), &rFltName ); sfx2::MakeLnkName( sCmd, nullptr, sURLLink, OUString(), &rFltName );
nNewType = OBJECT_CLIENT_GRF; nNewType = OBJECT_CLIENT_GRF;
} }
@ -192,7 +201,7 @@ bool SwGrfNode::ReRead(
if( pGraphic ) if( pGraphic )
{ {
maGrfObj.SetGraphic( *pGraphic, rGrfName ); maGrfObj.SetGraphic( *pGraphic, sURLLink );
onGraphicChanged(); onGraphicChanged();
bReadGrf = true; bReadGrf = true;
} }
@ -201,7 +210,7 @@ bool SwGrfNode::ReRead(
// reset data of the old graphic so that the correct placeholder is // reset data of the old graphic so that the correct placeholder is
// shown in case the new link could not be loaded // shown in case the new link could not be loaded
Graphic aGrf; aGrf.SetDefaultType(); Graphic aGrf; aGrf.SetDefaultType();
maGrfObj.SetGraphic( aGrf, rGrfName ); maGrfObj.SetGraphic( aGrf, sURLLink );
if( refLink.is() ) if( refLink.is() )
{ {
@ -220,7 +229,7 @@ bool SwGrfNode::ReRead(
bSetTwipSize = false; bSetTwipSize = false;
} }
} }
else if( pGraphic && rGrfName.isEmpty() ) else if( pGraphic && sURLLink.isEmpty() )
{ {
maGrfObj.SetGraphic( *pGraphic ); maGrfObj.SetGraphic( *pGraphic );
onGraphicChanged(); onGraphicChanged();
@ -232,13 +241,13 @@ bool SwGrfNode::ReRead(
else else
{ {
// create new link for the graphic object // create new link for the graphic object
InsertLink( rGrfName, rFltName ); InsertLink( sURLLink, rFltName );
if( GetNodes().IsDocNodes() ) if( GetNodes().IsDocNodes() )
{ {
if( pGraphic ) if( pGraphic )
{ {
maGrfObj.SetGraphic( *pGraphic, rGrfName ); maGrfObj.SetGraphic( *pGraphic, sURLLink );
onGraphicChanged(); onGraphicChanged();
bReadGrf = true; bReadGrf = true;
// create connection without update, as we have the graphic // create connection without update, as we have the graphic
@ -248,7 +257,7 @@ bool SwGrfNode::ReRead(
{ {
Graphic aGrf; Graphic aGrf;
aGrf.SetDefaultType(); aGrf.SetDefaultType();
maGrfObj.SetGraphic( aGrf, rGrfName ); maGrfObj.SetGraphic( aGrf, sURLLink );
onGraphicChanged(); onGraphicChanged();
if ( bNewGrf ) if ( bNewGrf )
{ {