summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorTünde Tóth <toth.tunde@nisz.hu>2023-01-24 15:02:09 +0100
committerLászló Németh <nemeth@numbertext.org>2023-01-30 11:25:32 +0000
commitf589d7e769bee4b82826a944fed3cf2382d84fb2 (patch)
tree6ca4ac02b86fa43e7f258158082ba0f03d5b306c /oox
parent9c9a711ac5d8f32ac318d0e4ecab7b3a26bc2150 (diff)
tdf#153185 PPTX: fix export of linked OLE objects
Linked OLE objects were not exported. Change-Id: If6e8c6e0d0c9917e8ec476ad14dcaa1602c74b29 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146073 Tested-by: Jenkins Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/shapes.cxx64
1 files changed, 39 insertions, 25 deletions
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index d6b3a9e9ef99..1c828d438653 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -2602,49 +2602,60 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const Reference< XShape >& xShape )
OUString sRelationType;
OUString sSuffix;
const char * pProgID(nullptr);
+ OString anotherProgID;
uno::Reference<io::XInputStream> const xInStream =
oox::GetOLEObjectStream(
mpFB->getComponentContext(), xObj, progID,
sMediaType, sRelationType, sSuffix, pProgID);
+ OUString sURL;
+ OUString sRelId;
if (!xInStream.is())
{
- return *this;
- }
+ xPropSet->getPropertyValue("LinkURL") >>= sURL;
+ if (sURL.isEmpty())
+ return *this;
- OString anotherProgID;
- if (!pProgID && !progID.isEmpty())
- {
- anotherProgID = OUStringToOString(progID, RTL_TEXTENCODING_UTF8);
- pProgID = anotherProgID.getStr();
+ sRelId = mpFB->addRelation(mpFS->getOutputStream(),
+ oox::getRelationship(Relationship::OLEOBJECT), sURL, true);
}
+ else
+ {
+ if (!pProgID && !progID.isEmpty())
+ {
+ anotherProgID = OUStringToOString(progID, RTL_TEXTENCODING_UTF8);
+ pProgID = anotherProgID.getStr();
+ }
+
+ assert(!sMediaType.isEmpty());
+ assert(!sRelationType.isEmpty());
+ assert(!sSuffix.isEmpty());
- assert(!sMediaType.isEmpty());
- assert(!sRelationType.isEmpty());
- assert(!sSuffix.isEmpty());
+ OUString sFileName
+ = "embeddings/oleObject" + OUString::number(++m_nEmbeddedObjects) + "." + sSuffix;
+ uno::Reference<io::XOutputStream> const xOutStream(mpFB->openFragmentStream(
+ OUString::createFromAscii(GetComponentDir()) + "/" + sFileName, sMediaType));
+ assert(xOutStream.is()); // no reason why that could fail
- OUString sFileName = "embeddings/oleObject" + OUString::number(++m_nEmbeddedObjects) + "." + sSuffix;
- uno::Reference<io::XOutputStream> const xOutStream(
- mpFB->openFragmentStream(
- OUString::createFromAscii(GetComponentDir()) + "/" + sFileName,
- sMediaType));
- assert(xOutStream.is()); // no reason why that could fail
+ try
+ {
+ ::comphelper::OStorageHelper::CopyInputToOutput(xInStream, xOutStream);
+ }
+ catch (uno::Exception const&)
+ {
+ TOOLS_WARN_EXCEPTION("oox.shape", "ShapeExport::WriteOLEObject");
+ }
- try {
- ::comphelper::OStorageHelper::CopyInputToOutput(xInStream, xOutStream);
- } catch (uno::Exception const&) {
- TOOLS_WARN_EXCEPTION("oox.shape", "ShapeExport::WriteOLEObject");
+ sRelId = mpFB->addRelation(
+ mpFS->getOutputStream(), sRelationType,
+ Concat2View(OUString::createFromAscii(GetRelationCompPrefix()) + sFileName));
}
sal_Int64 nAspect;
bool bShowAsIcon = (xPropSet->getPropertyValue("Aspect") >>= nAspect)
&& nAspect == embed::Aspects::MSOLE_ICON;
- OUString const sRelId = mpFB->addRelation(
- mpFS->getOutputStream(), sRelationType,
- Concat2View(OUString::createFromAscii(GetRelationCompPrefix()) + sFileName));
-
mpFS->startElementNS(mnXmlNamespace, XML_graphicFrame);
mpFS->startElementNS(mnXmlNamespace, XML_nvGraphicFramePr);
@@ -2682,7 +2693,10 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const Reference< XShape >& xShape )
XML_spid, "" );
}
- mpFS->singleElementNS( mnXmlNamespace, XML_embed );
+ if (sURL.isEmpty())
+ mpFS->singleElementNS(mnXmlNamespace, XML_embed);
+ else
+ mpFS->singleElementNS(mnXmlNamespace, XML_link, XML_updateAutomatic, "1");
// pic element
SdrObject* pSdrOLE2(SdrObject::getSdrObjectFromXShape(xShape));