summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-01-10 16:24:27 +0000
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-01-12 09:00:51 +0000
commit6a1f52054fefdcf5905a5ba3616b20fee7e5e26f (patch)
treecdb9a8a2eaf63affaab8fa6466a13046b8ea9bd6 /oox
parentddf27300ca209c74896994ef31fe7a1efcdad4fa (diff)
crashtesting: don't fail on export of fdo65321-3.ods to xlsx
with broken ole object Change-Id: I8dc9e1035893d5cb931d13eafcc3e3ec1c9c00d4 (cherry picked from commit 680abab7710b7e8e6f2ba9cee37a5ccd224e2993) Reviewed-on: https://gerrit.libreoffice.org/21354 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/shapes.cxx246
1 files changed, 128 insertions, 118 deletions
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index e6025334cbe6..9f028e6e48ca 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1587,14 +1587,18 @@ ShapeExport& ShapeExport::WriteOLE2Shape( Reference< XShape > xShape )
if (!xPropSet.is())
return *this;
+ bool bIsChart(false);
OUString clsid;
xPropSet->getPropertyValue("CLSID") >>= clsid;
- assert(!clsid.isEmpty());
- SvGlobalName aClassID;
- bool const isValid(aClassID.MakeId(clsid));
- assert(isValid); (void)isValid;
+ if (!clsid.isEmpty())
+ {
+ SvGlobalName aClassID;
+ bool const isValid = aClassID.MakeId(clsid);
+ assert(isValid); (void)isValid;
+ bIsChart = SotExchange::IsChart(aClassID);
+ }
- if (SotExchange::IsChart(aClassID))
+ if (bIsChart)
{
Reference< XChartDocument > xChartDoc;
xPropSet->getPropertyValue("Model") >>= xChartDoc;
@@ -1604,154 +1608,160 @@ ShapeExport& ShapeExport::WriteOLE2Shape( Reference< XShape > xShape )
ChartExport aChartExport( mnXmlNamespace, GetFS(), xModel, GetFB(), GetDocumentType() );
static sal_Int32 nChartCount = 0;
aChartExport.WriteChartObj( xShape, ++nChartCount );
+ return *this;
}
- else
+
+ uno::Reference<embed::XEmbeddedObject> const xObj(
+ xPropSet->getPropertyValue("EmbeddedObject"), uno::UNO_QUERY);
+
+ if (!xObj.is())
{
- uno::Reference<embed::XEmbeddedObject> const xObj(
- xPropSet->getPropertyValue("EmbeddedObject"), uno::UNO_QUERY);
+ SAL_WARN("oox", "ShapeExport::WriteOLE2Shape: no object");
+ return *this;
+ }
- uno::Reference<beans::XPropertySet> const xParent(
- uno::Reference<container::XChild>(xObj, uno::UNO_QUERY)->getParent(),
- uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> const xParent(
+ uno::Reference<container::XChild>(xObj, uno::UNO_QUERY)->getParent(),
+ uno::UNO_QUERY);
- uno::Sequence<beans::PropertyValue> grabBag;
- xParent->getPropertyValue("InteropGrabBag") >>= grabBag;
+ uno::Sequence<beans::PropertyValue> grabBag;
+ xParent->getPropertyValue("InteropGrabBag") >>= grabBag;
- OUString const entryName(
- uno::Reference<embed::XEmbedPersist>(xObj, uno::UNO_QUERY)->getEntryName());
- OUString progID;
+ OUString const entryName(
+ uno::Reference<embed::XEmbedPersist>(xObj, uno::UNO_QUERY)->getEntryName());
+ OUString progID;
- for (auto const& it : grabBag)
+ for (auto const& it : grabBag)
+ {
+ if (it.Name == "EmbeddedObjects")
{
- if (it.Name == "EmbeddedObjects")
+ uno::Sequence<beans::PropertyValue> objects;
+ it.Value >>= objects;
+ for (auto const& object : objects)
{
- uno::Sequence<beans::PropertyValue> objects;
- it.Value >>= objects;
- for (auto const& object : objects)
+ if (object.Name == entryName)
{
- if (object.Name == entryName)
+ uno::Sequence<beans::PropertyValue> props;
+ object.Value >>= props;
+ for (auto const& prop : props)
{
- uno::Sequence<beans::PropertyValue> props;
- object.Value >>= props;
- for (auto const& prop : props)
+ if (prop.Name == "ProgID")
{
- if (prop.Name == "ProgID")
- {
- prop.Value >>= progID;
- break;
- }
+ prop.Value >>= progID;
+ break;
}
- break;
}
+ break;
}
- break;
}
+ break;
}
+ }
- OUString sMediaType;
- OUString sRelationType;
- OUString sSuffix;
- const char * pProgID(nullptr);
+ OUString sMediaType;
+ OUString sRelationType;
+ OUString sSuffix;
+ const char * pProgID(nullptr);
- uno::Reference<io::XInputStream> const xInStream =
- oox::GetOLEObjectStream(
- mpFB->getComponentContext(), xObj, progID,
- sMediaType, sRelationType, sSuffix, pProgID);
+ uno::Reference<io::XInputStream> const xInStream =
+ oox::GetOLEObjectStream(
+ mpFB->getComponentContext(), xObj, progID,
+ sMediaType, sRelationType, sSuffix, pProgID);
- if (!xInStream.is())
- {
- return *this;
- }
+ if (!xInStream.is())
+ {
+ return *this;
+ }
- OString anotherProgID;
- if (!pProgID && !progID.isEmpty())
- {
- anotherProgID = OUStringToOString(progID, RTL_TEXTENCODING_UTF8);
- pProgID = anotherProgID.getStr();
- }
+ OString anotherProgID;
+ if (!pProgID && !progID.isEmpty())
+ {
+ anotherProgID = OUStringToOString(progID, RTL_TEXTENCODING_UTF8);
+ pProgID = anotherProgID.getStr();
+ }
- assert(!sMediaType.isEmpty());
- assert(!sRelationType.isEmpty());
- assert(!sSuffix.isEmpty());
-
- OUString sFileName = "embeddings/oleObject" + OUString::number(mnEmbeddeDocumentCounter++) + "." + 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& e) {
- SAL_WARN("oox", "ShapeExport::WriteOLEObject: exception: " << e.Message);
- }
+ assert(!sMediaType.isEmpty());
+ assert(!sRelationType.isEmpty());
+ assert(!sSuffix.isEmpty());
+
+ OUString sFileName = "embeddings/oleObject" + OUString::number(mnEmbeddeDocumentCounter++) + "." + 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& e) {
+ SAL_WARN("oox", "ShapeExport::WriteOLEObject: exception: " << e.Message);
+ }
- OUString const sRelId = mpFB->addRelation(
- mpFS->getOutputStream(), sRelationType,
- OUString::createFromAscii(GetRelationCompPrefix()) + sFileName);
+ OUString const sRelId = mpFB->addRelation(
+ mpFS->getOutputStream(), sRelationType,
+ OUString::createFromAscii(GetRelationCompPrefix()) + sFileName);
- mpFS->startElementNS( mnXmlNamespace, XML_graphicFrame, FSEND );
+ mpFS->startElementNS( mnXmlNamespace, XML_graphicFrame, FSEND );
- mpFS->startElementNS( mnXmlNamespace, XML_nvGraphicFramePr, FSEND );
+ mpFS->startElementNS( mnXmlNamespace, XML_nvGraphicFramePr, FSEND );
- mpFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
- XML_id, I32S( GetNewShapeID( xShape ) ),
- XML_name, IDS(Object),
- FSEND );
+ mpFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
+ XML_id, I32S( GetNewShapeID( xShape ) ),
+ XML_name, IDS(Object),
+ FSEND );
- mpFS->singleElementNS( mnXmlNamespace, XML_cNvGraphicFramePr,
- FSEND );
+ mpFS->singleElementNS( mnXmlNamespace, XML_cNvGraphicFramePr,
+ FSEND );
- if (GetDocumentType() == DOCUMENT_PPTX)
- mpFS->singleElementNS( mnXmlNamespace, XML_nvPr,
- FSEND );
- mpFS->endElementNS( mnXmlNamespace, XML_nvGraphicFramePr );
+ if (GetDocumentType() == DOCUMENT_PPTX)
+ mpFS->singleElementNS( mnXmlNamespace, XML_nvPr,
+ FSEND );
+ mpFS->endElementNS( mnXmlNamespace, XML_nvGraphicFramePr );
- WriteShapeTransformation( xShape, mnXmlNamespace );
+ WriteShapeTransformation( xShape, mnXmlNamespace );
- mpFS->startElementNS( XML_a, XML_graphic, FSEND );
- mpFS->startElementNS( XML_a, XML_graphicData,
- XML_uri, "http://schemas.openxmlformats.org/presentationml/2006/ole",
- FSEND );
- if (pProgID)
- {
- mpFS->startElementNS( mnXmlNamespace, XML_oleObj,
- XML_progId, pProgID,
- FSNS(XML_r, XML_id), USS( sRelId ),
- XML_spid, "",
- FSEND );
- }
- else
- {
- mpFS->startElementNS( mnXmlNamespace, XML_oleObj,
+ mpFS->startElementNS( XML_a, XML_graphic, FSEND );
+ mpFS->startElementNS( XML_a, XML_graphicData,
+ XML_uri, "http://schemas.openxmlformats.org/presentationml/2006/ole",
+ FSEND );
+ if (pProgID)
+ {
+ mpFS->startElementNS( mnXmlNamespace, XML_oleObj,
+ XML_progId, pProgID,
+ FSNS(XML_r, XML_id), USS( sRelId ),
+ XML_spid, "",
+ FSEND );
+ }
+ else
+ {
+ mpFS->startElementNS( mnXmlNamespace, XML_oleObj,
//? XML_name, "Document",
- FSNS(XML_r, XML_id), USS( sRelId ),
- // The spec says that this is a required attribute, but PowerPoint can only handle an empty value.
- XML_spid, "",
- FSEND );
- }
+ FSNS(XML_r, XML_id), USS( sRelId ),
+ // The spec says that this is a required attribute, but PowerPoint can only handle an empty value.
+ XML_spid, "",
+ FSEND );
+ }
- mpFS->singleElementNS( mnXmlNamespace, XML_embed, FSEND );
+ mpFS->singleElementNS( mnXmlNamespace, XML_embed, FSEND );
- // pic element
- SdrObject* pSdrOLE2( GetSdrObjectFromXShape( xShape ) );
- // The spec doesn't allow <p:pic> here, but PowerPoint requires it.
- bool bEcma = mpFB->getVersion() == oox::core::ECMA_DIALECT;
- if (pSdrOLE2 && dynamic_cast<const SdrOle2Obj*>( pSdrOLE2) != nullptr && bEcma)
- {
- const Graphic* pGraphic = static_cast<SdrOle2Obj*>(pSdrOLE2)->GetGraphic();
- if (pGraphic)
- WriteGraphicObjectShapePart( xShape, pGraphic );
- }
+ // pic element
+ SdrObject* pSdrOLE2( GetSdrObjectFromXShape( xShape ) );
+ // The spec doesn't allow <p:pic> here, but PowerPoint requires it.
+ bool bEcma = mpFB->getVersion() == oox::core::ECMA_DIALECT;
+ if (pSdrOLE2 && dynamic_cast<const SdrOle2Obj*>( pSdrOLE2) != nullptr && bEcma)
+ {
+ const Graphic* pGraphic = static_cast<SdrOle2Obj*>(pSdrOLE2)->GetGraphic();
+ if (pGraphic)
+ WriteGraphicObjectShapePart( xShape, pGraphic );
+ }
- mpFS->endElementNS( mnXmlNamespace, XML_oleObj );
+ mpFS->endElementNS( mnXmlNamespace, XML_oleObj );
- mpFS->endElementNS( XML_a, XML_graphicData );
- mpFS->endElementNS( XML_a, XML_graphic );
+ mpFS->endElementNS( XML_a, XML_graphicData );
+ mpFS->endElementNS( XML_a, XML_graphic );
+
+ mpFS->endElementNS( mnXmlNamespace, XML_graphicFrame );
- mpFS->endElementNS( mnXmlNamespace, XML_graphicFrame );
- }
return *this;
}