diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-04-13 16:58:49 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-04-16 02:52:02 +0200 |
commit | 9fb7aaf570c03c8a26d763f1205fb8c890e8211a (patch) | |
tree | 8f4466b24d9fcae2da5043479a57fabc662a2c43 /svx | |
parent | ba69036c8e889237da4bb312d7c5c94066abbfd3 (diff) |
Make linked graphic register into LinkedManager again
Change-Id: I16b162f86d6221d120f6355f9a52c1abfcd0ac73
Reviewed-on: https://gerrit.libreoffice.org/52911
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdograf.cxx | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 21412a222451..930569cc7832 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -102,6 +102,7 @@ const Graphic ImpLoadLinkedGraphic( const OUString& aFileName, const OUString& a // that it is a SVG graphic, but only because no one yet tried to interpret it. rGF.ImportGraphic( aGraphic, aFileName, *pInStrm, nFilter, nullptr, GraphicFilterImportFlags::NONE, &aFilterData ); } + aGraphic.setOriginURL(aFileName); return aGraphic; } @@ -227,8 +228,7 @@ void SdrGraphicLink::RemoveGraphicUpdater() Graphic aGraphic; if( sfx2::LinkManager::GetGraphicFromAny( rMimeType, rValue, aGraphic )) { - rGrafObj.NbcSetGraphic( aGraphic ); - rGrafObj.ActionChanged(); + rGrafObj.ImpSetLinkedGraphic(aGraphic); } else if( SotExchange::GetFormatIdFromMimeType( rMimeType ) != sfx2::LinkManager::RegisterStatusInfoId() ) { @@ -278,7 +278,6 @@ sdr::contact::ViewContact* SdrGrafObj::CreateObjectSpecificViewContact() return new sdr::contact::ViewContactOfGraphic(*this); } - // check if SVG and if try to get ObjectInfoPrimitive2D and extract info void SdrGrafObj::onGraphicChanged() @@ -426,7 +425,6 @@ const GraphicObject& SdrGrafObj::GetGraphicObject(bool bForceSwapIn) const { if (bForceSwapIn) ForceSwapIn(); - return *mpGraphicObject.get(); } @@ -460,15 +458,29 @@ void SdrGrafObj::NbcSetGraphic(const Graphic& rGraphic) onGraphicChanged(); } -void SdrGrafObj::SetGraphic( const Graphic& rGrf ) +void SdrGrafObj::SetGraphic( const Graphic& rGraphic ) { - NbcSetGraphic(rGrf); + if (!rGraphic.getOriginURL().isEmpty()) + { + ImpDeregisterLink(); + aFileName = rGraphic.getOriginURL(); + aReferer = ""; + aFilterName = ""; + } + NbcSetGraphic(rGraphic); + if (!rGraphic.getOriginURL().isEmpty()) + { + ImpRegisterLink(); + mpGraphicObject->SetUserData(); + } SetChanged(); BroadcastObjectChange(); + ForceSwapIn(); } const Graphic& SdrGrafObj::GetGraphic() const { + ForceSwapIn(); return mpGraphicObject->GetGraphic(); } @@ -597,9 +609,13 @@ Size SdrGrafObj::getOriginalSize() const return aSize; } -// TODO Remove void SdrGrafObj::ForceSwapIn() const { + if (pGraphicLink && (mpGraphicObject->GetType() == GraphicType::NONE || + mpGraphicObject->GetType() == GraphicType::Default) ) + { + pGraphicLink->Update(); + } } void SdrGrafObj::ImpRegisterLink() @@ -630,15 +646,11 @@ void SdrGrafObj::ImpDeregisterLink() } } -void SdrGrafObj::SetGraphicLink(const OUString& rFileName, const OUString& rReferer, const OUString& rFilterName) +void SdrGrafObj::SetGraphicLink(const OUString& rFileName, const OUString& /*rReferer*/, const OUString& /*rFilterName*/) { - ImpDeregisterLink(); - aFileName = rFileName; - aReferer = rReferer; - aFilterName = rFilterName; - ImpRegisterLink(); - mpGraphicObject->SetUserData(); - SetGraphic(vcl::graphic::loadFromURL(aFileName)); + Graphic aGraphic; + aGraphic.setOriginURL(rFileName); + SetGraphic(aGraphic); } void SdrGrafObj::ReleaseGraphicLink() @@ -862,6 +874,7 @@ SdrObject* SdrGrafObj::getFullDragClone() const // temporary interaction object and load graphic if(pRetval && IsLinkedGraphic()) { + pRetval->ForceSwapIn(); pRetval->ReleaseGraphicLink(); } |