diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-12-14 13:41:57 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-12-15 19:55:55 +0100 |
commit | 4118f8f4c20ae711b95ab3052656bde673aa8852 (patch) | |
tree | 377259e53a41af549dcf059ada20a666eebed247 /comphelper | |
parent | 88cd3f3f33233d93f3f1b13c184282882210c6b6 (diff) |
fix missing BaseURL when loading embedded objects
When the object is edited in the UI, the m_xClient is set to a
SfxInPlaceClient and the DocumentBaseURL is retrieved from it. But if
the object is not edited, it will be loaded during export via the API
and without a m_xClient; in this case the DocumentBaseURL must have been
set previously to be available during import.
There appears to be no way to get the URL of the document via the API
while it is being imported; SfxBaseModel's m_sURL is unfortunately only
initialized from SfxObjectShell::FinishedLoading().
During ODF import, the SvXMLEmbeddedObjectHelper creates the
embedded object, so let's make it pass in the parent's BaseURL.
The "DefaultParentBaseURL" parameter already exists but was unused
previously.
Change-Id: I3d1ed29b3a2c0e77ec606a1d09f7bc07e7860733
(cherry picked from commit b0fc09daf1086423a9bd457d9a2c043e7ff41451)
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/container/embeddedobjectcontainer.cxx | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx index af4bc5ce3b77..21a2f9dd11c1 100644 --- a/comphelper/source/container/embeddedobjectcontainer.cxx +++ b/comphelper/source/container/embeddedobjectcontainer.cxx @@ -280,7 +280,9 @@ OUString EmbeddedObjectContainer::GetEmbeddedObjectName( const css::uno::Referen return OUString(); } -uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::GetEmbeddedObject( const OUString& rName ) +uno::Reference< embed::XEmbeddedObject> +EmbeddedObjectContainer::GetEmbeddedObject( + const OUString& rName, OUString const*const pBaseURL) { SAL_WARN_IF( rName.isEmpty(), "comphelper.container", "Empty object name!"); @@ -303,12 +305,15 @@ uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::GetEmbeddedOb if ( aIt != pImpl->maObjectContainer.end() ) xObj = (*aIt).second; else - xObj = Get_Impl( rName, uno::Reference < embed::XEmbeddedObject >() ); + xObj = Get_Impl(rName, uno::Reference<embed::XEmbeddedObject>(), pBaseURL); return xObj; } -uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::Get_Impl( const OUString& rName, const uno::Reference < embed::XEmbeddedObject >& xCopy ) +uno::Reference<embed::XEmbeddedObject> EmbeddedObjectContainer::Get_Impl( + const OUString& rName, + const uno::Reference<embed::XEmbeddedObject>& xCopy, + rtl::OUString const*const pBaseURL) { uno::Reference < embed::XEmbeddedObject > xObj; try @@ -328,13 +333,20 @@ uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::Get_Impl( con // object was not added until now - should happen only by calling this method from "inside" //TODO/LATER: it would be good to detect an error when an object should be created already, but isn't (not an "inside" call) uno::Reference < embed::XEmbeddedObjectCreator > xFactory = embed::EmbeddedObjectCreator::create( ::comphelper::getProcessComponentContext() ); - uno::Sequence< beans::PropertyValue > aObjDescr( xCopy.is() ? 2 : 1 ); + uno::Sequence< beans::PropertyValue > aObjDescr(1 + (xCopy.is() ? 1 : 0) + (pBaseURL ? 1 : 0)); aObjDescr[0].Name = "Parent"; aObjDescr[0].Value <<= pImpl->m_xModel.get(); + sal_Int32 i = 1; + if (pBaseURL) + { + aObjDescr[i].Name = "DefaultParentBaseURL"; + aObjDescr[i].Value <<= *pBaseURL; + ++i; + } if ( xCopy.is() ) { - aObjDescr[1].Name = "CloneFrom"; - aObjDescr[1].Value <<= xCopy; + aObjDescr[i].Name = "CloneFrom"; + aObjDescr[i].Value <<= xCopy; } uno::Sequence< beans::PropertyValue > aMediaDescr( 1 ); |