diff options
-rw-r--r-- | comphelper/source/container/embeddedobjectcontainer.cxx | 24 | ||||
-rw-r--r-- | include/comphelper/embeddedobjectcontainer.hxx | 6 | ||||
-rw-r--r-- | include/sfx2/objsh.hxx | 2 | ||||
-rw-r--r-- | reportdesign/inc/ReportDefinition.hxx | 1 | ||||
-rw-r--r-- | reportdesign/source/core/api/ReportDefinition.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 6 | ||||
-rw-r--r-- | svx/source/xml/xmleohlp.cxx | 3 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport2.cxx | 30 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 4 |
9 files changed, 66 insertions, 15 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 ); diff --git a/include/comphelper/embeddedobjectcontainer.hxx b/include/comphelper/embeddedobjectcontainer.hxx index f2b108d88631..24153c2b2fd3 100644 --- a/include/comphelper/embeddedobjectcontainer.hxx +++ b/include/comphelper/embeddedobjectcontainer.hxx @@ -43,6 +43,7 @@ namespace comphelper virtual css::uno::Reference < css::embed::XStorage > getStorage() const = 0; virtual css::uno::Reference< css::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; css::uno::Reference < css::embed::XEmbeddedObject > Get_Impl( const OUString&, - const css::uno::Reference < css::embed::XEmbeddedObject >& xCopy); + const css::uno::Reference < css::embed::XEmbeddedObject >& xCopy, + OUString const* pBaseURL = nullptr); public: // add an embedded object to the container storage @@ -92,7 +94,7 @@ public: OUString GetEmbeddedObjectName( const css::uno::Reference < css::embed::XEmbeddedObject >& ); // retrieve an embedded object by name that either has been added already or is available in the container storage - css::uno::Reference < css::embed::XEmbeddedObject > GetEmbeddedObject( const OUString& ); + css::uno::Reference<css::embed::XEmbeddedObject> GetEmbeddedObject(const OUString&, OUString const* pBaseURL = nullptr); // create an object from a ClassId css::uno::Reference < css::embed::XEmbeddedObject > diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index 5b32ae833c22..90e2f577458e 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -583,6 +583,8 @@ public: { return IsEnableSetModified(); } + virtual OUString getDocumentBaseURL() const override; + comphelper::EmbeddedObjectContainer& GetEmbeddedObjectContainer() const; void ClearEmbeddedObjects(); diff --git a/reportdesign/inc/ReportDefinition.hxx b/reportdesign/inc/ReportDefinition.hxx index 36d325f2e339..9e582ea235c8 100644 --- a/reportdesign/inc/ReportDefinition.hxx +++ b/reportdesign/inc/ReportDefinition.hxx @@ -392,6 +392,7 @@ namespace reportdesign virtual ::comphelper::EmbeddedObjectContainer& getEmbeddedObjectContainer() const override; virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const override; virtual bool isEnableSetModified() const override; + virtual OUString getDocumentBaseURL() const override; css::uno::Reference< css::ui::XUIConfigurationManager2 > getUIConfigurationManager2( ) throw (css::uno::RuntimeException); }; diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index 3355055e776c..c5d3f9cea857 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -2512,6 +2512,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 ea768f7ca3c9..722630f6db57 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -3618,6 +3618,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; @@ -3626,4 +3627,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 ec40121adcaf..f75376abac07 100644 --- a/svx/source/xml/xmleohlp.cxx +++ b/svx/source/xml/xmleohlp.cxx @@ -445,7 +445,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/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx index f4fad502544f..a850c811fb21 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"); } /* diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 041e54b3e85a..a4503a3ecf9d 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -828,13 +828,13 @@ DECLARE_OOXMLEXPORT_TEST(testContentTypeXLSM, "fdo76098.docx") assertXPath(pXmlDoc, "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/Microsoft_Excel_Macro-Enabled_Worksheet1.xlsm']", "ContentType", "application/vnd.ms-excel.sheet.macroEnabled.12"); // check the rels too - xmlDocPtr pXmlDocRels = parseExport("word/charts/_rels/chart1.xml.rels"); + xmlDocPtr pXmlDocRels = parseExport("word/charts/_rels/chart2.xml.rels"); assertXPath(pXmlDocRels, "/rels:Relationships/rels:Relationship[@Target='../embeddings/Microsoft_Excel_Macro-Enabled_Worksheet1.xlsm']", "Type", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); // check the content too - xmlDocPtr pXmlDocChart1 = parseExport("word/charts/chart1.xml"); + xmlDocPtr pXmlDocChart1 = parseExport("word/charts/chart2.xml"); assertXPath(pXmlDocChart1, "/c:chartSpace/c:externalData", "id", |