extensions/source/abpilot/unodialogabp.hxx | 2 oox/source/export/shapes.cxx | 246 ++++++++++++++------------- sw/source/core/ole/ndole.cxx | 11 - sw/source/filter/ww8/docxattributeoutput.cxx | 11 - 4 files changed, 144 insertions(+), 126 deletions(-)
New commits: commit 680abab7710b7e8e6f2ba9cee37a5ccd224e2993 Author: Caolán McNamara <[email protected]> Date: Sun Jan 10 16:24:27 2016 +0000 crashtesting: don't fail on export of fdo65321-3.ods to xlsx with broken ole object Change-Id: I8dc9e1035893d5cb931d13eafcc3e3ec1c9c00d4 diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 9fcff75..95d1d77 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -1586,14 +1586,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; @@ -1603,154 +1607,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; } commit e634cd9f4f681bcf8401576b5d4ee4ca8fb2eec5 Author: Caolán McNamara <[email protected]> Date: Sun Jan 10 16:14:41 2016 +0000 crashtesting: fix assert on re-export of ooo74510-1.odt to docx Change-Id: Id66ab14772b002b140ba6bbfd098c19aeb1a537f diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx index b9049d7..99b3f77 100644 --- a/sw/source/core/ole/ndole.cxx +++ b/sw/source/core/ole/ndole.cxx @@ -192,7 +192,7 @@ SwEmbedObjectLink::~SwEmbedObjectLink() xObject->changeState( nState ); } } - catch ( uno::Exception& ) + catch (const uno::Exception&) { } } @@ -357,7 +357,7 @@ bool SwOLENode::SavePersistentData() // "unload" object aOLEObj.xOLERef->changeState( embed::EmbedStates::LOADED ); } - catch ( uno::Exception& ) + catch (const uno::Exception&) { } } @@ -549,8 +549,9 @@ bool SwOLENode::UpdateLinkURL_Impl() if ( nCurState != embed::EmbedStates::LOADED ) xObj->changeState( nCurState ); } - catch( uno::Exception& ) - {} + catch (const uno::Exception&) + { + } } if ( !bResult ) @@ -873,7 +874,7 @@ bool SwOLEObj::UnloadObject( uno::Reference< embed::XEmbeddedObject > xObj, cons // setting object to loaded state will remove it from cache xObj->changeState( embed::EmbedStates::LOADED ); } - catch ( uno::Exception& ) + catch (const uno::Exception&) { bRet = false; } diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 7958bf7..e8b5055 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -4522,8 +4522,15 @@ void DocxAttributeOutput::WritePostponedMath(const SwOLENode* pPostponedMath) { uno::Reference < embed::XEmbeddedObject > xObj(const_cast<SwOLENode*>(pPostponedMath)->GetOLEObj().GetOleRef()); if (embed::EmbedStates::LOADED == xObj->getCurrentState()) - { // must be running so there is a Component - xObj->changeState(embed::EmbedStates::RUNNING); + { + // must be running so there is a Component + try + { + xObj->changeState(embed::EmbedStates::RUNNING); + } + catch (const uno::Exception&) + { + } } uno::Reference< uno::XInterface > xInterface( xObj->getComponent(), uno::UNO_QUERY ); if (!xInterface.is()) commit 4e4554f1a674da89f752fe07d557b759b69cf2c9 Author: Caolán McNamara <[email protected]> Date: Sun Jan 10 15:39:46 2016 +0000 cppcheck: noExplicitConstructor Change-Id: I62f1260d75d8a79bd230e2813fc58373aa83b6ab diff --git a/extensions/source/abpilot/unodialogabp.hxx b/extensions/source/abpilot/unodialogabp.hxx index a5145e1..7d5800d 100644 --- a/extensions/source/abpilot/unodialogabp.hxx +++ b/extensions/source/abpilot/unodialogabp.hxx @@ -41,7 +41,7 @@ namespace abp OUString m_sDataSourceName; public: - OABSPilotUno(const css::uno::Reference< css::uno::XComponentContext >& _rxORB); + explicit OABSPilotUno(const css::uno::Reference< css::uno::XComponentContext >& _rxORB); private: // XInterface (disambiguation)
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
