summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-12-14 13:41:57 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-12-17 16:24:01 +0000
commitfe4c7f20c272cf7a984d0db79199fe74bd31fc86 (patch)
tree298756014401717a1148306d7715a5772105301b
parentaed57fec1530b4f377f8105b167ab9343c22bc37 (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>
-rw-r--r--comphelper/source/container/embeddedobjectcontainer.cxx24
-rw-r--r--include/comphelper/embeddedobjectcontainer.hxx6
-rw-r--r--include/sfx2/objsh.hxx2
-rw-r--r--reportdesign/inc/ReportDefinition.hxx1
-rw-r--r--reportdesign/source/core/api/ReportDefinition.cxx5
-rw-r--r--sfx2/source/doc/objstor.cxx6
-rw-r--r--svx/source/xml/xmleohlp.cxx3
-rw-r--r--sw/ooxmlexport_setup.mk1
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport2.cxx30
9 files changed, 65 insertions, 13 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 );
diff --git a/include/comphelper/embeddedobjectcontainer.hxx b/include/comphelper/embeddedobjectcontainer.hxx
index 842a3e7f804c..a689ca605818 100644
--- a/include/comphelper/embeddedobjectcontainer.hxx
+++ b/include/comphelper/embeddedobjectcontainer.hxx
@@ -43,6 +43,7 @@ namespace comphelper
virtual com::sun::star::uno::Reference < com::sun::star::embed::XStorage > getStorage() const = 0;
virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > getInteractionHandler() const = 0;
virtual bool isEnableSetModified() const = 0;
+ virtual OUString getDocumentBaseURL() const = 0;
protected:
~IEmbeddedHelper() {}
@@ -54,7 +55,8 @@ class COMPHELPER_DLLPUBLIC EmbeddedObjectContainer
EmbedImpl* pImpl;
::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject > Get_Impl( const OUString&,
- const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >& xCopy);
+ const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >& xCopy,
+ OUString const* pBaseURL = nullptr);
public:
// add an embedded object to the container storage
@@ -92,7 +94,7 @@ public:
OUString GetEmbeddedObjectName( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >& );
// retrieve an embedded object by name that either has been added already or is available in the container storage
- ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject > GetEmbeddedObject( const OUString& );
+ ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject > GetEmbeddedObject( const OUString&, OUString const* pBaseURL = nullptr );
// create an object from a ClassId
::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index ce8ab3018f6f..58e79f0cff25 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -582,6 +582,8 @@ public:
{
return IsEnableSetModified();
}
+ virtual OUString getDocumentBaseURL() const SAL_OVERRIDE;
+
comphelper::EmbeddedObjectContainer& GetEmbeddedObjectContainer() const;
void ClearEmbeddedObjects();
diff --git a/reportdesign/inc/ReportDefinition.hxx b/reportdesign/inc/ReportDefinition.hxx
index 18ac1b88ce6f..cf3da36b63a3 100644
--- a/reportdesign/inc/ReportDefinition.hxx
+++ b/reportdesign/inc/ReportDefinition.hxx
@@ -407,6 +407,7 @@ namespace reportdesign
virtual ::comphelper::EmbeddedObjectContainer& getEmbeddedObjectContainer() const SAL_OVERRIDE;
virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > getInteractionHandler() const SAL_OVERRIDE;
virtual bool isEnableSetModified() const SAL_OVERRIDE;
+ virtual OUString getDocumentBaseURL() const SAL_OVERRIDE;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getContext() const;
diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx
index 42b0baf010a3..a3f46637c0af 100644
--- a/reportdesign/source/core/api/ReportDefinition.cxx
+++ b/reportdesign/source/core/api/ReportDefinition.cxx
@@ -2521,6 +2521,11 @@ bool OReportDefinition::isEnableSetModified() const
return true;
}
+OUString OReportDefinition::getDocumentBaseURL() const
+{
+ return const_cast<OReportDefinition*>(this)->getURL();
+}
+
uno::Reference< frame::XTitle > OReportDefinition::impl_getTitleHelper_throw()
{
SolarMutexGuard aSolarGuard;
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index d431a1e5f400..be8ecd062f66 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -3641,6 +3641,7 @@ bool SfxObjectShell::QuerySaveSizeExceededModules_Impl( const uno::Reference< ta
return true;
}
+// comphelper::IEmbeddedHelper
uno::Reference< task::XInteractionHandler > SfxObjectShell::getInteractionHandler() const
{
uno::Reference< task::XInteractionHandler > xRet;
@@ -3649,4 +3650,9 @@ uno::Reference< task::XInteractionHandler > SfxObjectShell::getInteractionHandle
return xRet;
}
+OUString SfxObjectShell::getDocumentBaseURL() const
+{
+ return GetMedium()->GetBaseURL();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xml/xmleohlp.cxx b/svx/source/xml/xmleohlp.cxx
index 3d699240dc9f..ffdb37d145f1 100644
--- a/svx/source/xml/xmleohlp.cxx
+++ b/svx/source/xml/xmleohlp.cxx
@@ -444,7 +444,8 @@ bool SvXMLEmbeddedObjectHelper::ImplReadObject(
// server that was used to create the object. pClassId could be used to specify the server that should
// be used for the next opening, but this information seems to be out of the file format responsibility
// area.
- rContainer.GetEmbeddedObject( aName );
+ OUString const baseURL(mpDocPersist->getDocumentBaseURL());
+ rContainer.GetEmbeddedObject(aName, &baseURL);
return true;
}
diff --git a/sw/ooxmlexport_setup.mk b/sw/ooxmlexport_setup.mk
index 041ac9eb5910..7b33349598d1 100644
--- a/sw/ooxmlexport_setup.mk
+++ b/sw/ooxmlexport_setup.mk
@@ -66,6 +66,7 @@ define sw_ooxmlexport_components
ucb/source/ucp/file/ucpfile1 \
unotools/util/utl \
unoxml/source/service/unoxml \
+ unoxml/source/rdf/unordf \
uui/util/uui \
writerfilter/util/writerfilter \
xmloff/util/xo
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index 224e546bb803..28506e111360 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -475,10 +475,32 @@ DECLARE_OOXMLEXPORT_TEST(testTableBorders, "table-borders.docx")
DECLARE_OOXMLEXPORT_TEST(testFdo51550, "fdo51550.odt")
{
- // The problem was that we lacked the fallback to export the replacement graphic for OLE objects.
- uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
+ // The problem was that we lacked the fallback to export the replacement
+ // graphic for OLE objects. But we can actually export the OLE itself now,
+ // so check that instead.
+ uno::Reference<text::XTextEmbeddedObjectsSupplier> xTextEmbeddedObjectsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xEmbeddedObjects(xTextEmbeddedObjectsSupplier->getEmbeddedObjects(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xEmbeddedObjects->getCount());
+
+ xmlDocPtr pXmlDocCT = parseExport("[Content_Types].xml");
+
+ if (!pXmlDocCT)
+ return; // initial import
+
+ assertXPath(pXmlDocCT, "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.xlsx']", "ContentType", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+
+ // check the rels too
+ xmlDocPtr pXmlDocRels = parseExport("word/_rels/document.xml.rels");
+ assertXPath(pXmlDocRels,
+ "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.xlsx']",
+ "Type",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
+ // check the content too
+ xmlDocPtr pXmlDocContent = parseExport("word/document.xml");
+ assertXPath(pXmlDocContent,
+ "/w:document/w:body/w:p/w:r/w:object/o:OLEObject",
+ "ProgID",
+ "Excel.Sheet.12");
}
/*