summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-12-14 13:41:57 +0100
committerAndras Timar <andras.timar@collabora.com>2015-12-21 13:16:17 +0100
commit9cd4cf7258e97f8ca26167bfb9dc175e92dd145d (patch)
treedb1ccc9a6266057d18a838d76e3ff523e534106f /comphelper
parent4d29e69ae1f0c4a35a6785297cdc408762228d92 (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. (cherry picked from commit b0fc09daf1086423a9bd457d9a2c043e7ff41451) (cherry picked from commit 4118f8f4c20ae711b95ab3052656bde673aa8852) sw: loading embedded ODF objects requires unordf component (cherry picked from commit b3b7982f4690f4ac0f0e9680970ba544157c36dc) Change-Id: I3d1ed29b3a2c0e77ec606a1d09f7bc07e7860733 Reviewed-on: https://gerrit.libreoffice.org/20761 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk> (cherry picked from commit fe4c7f20c272cf7a984d0db79199fe74bd31fc86)
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/container/embeddedobjectcontainer.cxx24
1 files changed, 18 insertions, 6 deletions
diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx
index 10a75516e868..34afd6f727d1 100644
--- a/comphelper/source/container/embeddedobjectcontainer.cxx
+++ b/comphelper/source/container/embeddedobjectcontainer.cxx
@@ -296,7 +296,9 @@ OUString EmbeddedObjectContainer::GetEmbeddedObjectName( const ::com::sun::star:
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!");
@@ -319,12 +321,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
@@ -344,13 +349,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 );