From 30a6622ca8046691d57eb5c422da7646edcb0cb1 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 20 Apr 2015 09:37:40 +0200 Subject: CID#1295034 uncaught exception Change-Id: I853e520dd60c3e19cbf7a7b620115df50fc25b30 --- starmath/source/unofilter.cxx | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/starmath/source/unofilter.cxx b/starmath/source/unofilter.cxx index 4058609ab2bb..423c46c7ee4f 100644 --- a/starmath/source/unofilter.cxx +++ b/starmath/source/unofilter.cxx @@ -64,34 +64,41 @@ MathTypeFilter::~MathTypeFilter() sal_Bool MathTypeFilter::filter(const uno::Sequence& rDescriptor) throw(uno::RuntimeException, std::exception) { bool bSuccess = false; - utl::MediaDescriptor aMediaDesc(rDescriptor); - aMediaDesc.addInputStream(); - uno::Reference xInputStream; - aMediaDesc[utl::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream; - std::unique_ptr pStream(utl::UcbStreamHelper::CreateStream(xInputStream)); - if (pStream) + try { - if (SotStorage::IsStorageFile(pStream.get())) + utl::MediaDescriptor aMediaDesc(rDescriptor); + aMediaDesc.addInputStream(); + uno::Reference xInputStream; + aMediaDesc[utl::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream; + std::unique_ptr pStream(utl::UcbStreamHelper::CreateStream(xInputStream)); + if (pStream) { - SvStorageRef aStorage(new SotStorage(pStream.get(), false)); - // Is this a MathType Storage? - if (aStorage->IsStream(OUString("Equation Native"))) + if (SotStorage::IsStorageFile(pStream.get())) { - if (SmModel* pModel = dynamic_cast(m_xDstDoc.get())) + SvStorageRef aStorage(new SotStorage(pStream.get(), false)); + // Is this a MathType Storage? + if (aStorage->IsStream(OUString("Equation Native"))) { - SmDocShell* pDocShell = static_cast(pModel->GetObjectShell()); - OUString aText = pDocShell->GetText(); - MathType aEquation(aText); - bSuccess = aEquation.Parse(aStorage) == 1; - if (bSuccess) + if (SmModel* pModel = dynamic_cast(m_xDstDoc.get())) { - pDocShell->SetText(aText); - pDocShell->Parse(); + SmDocShell* pDocShell = static_cast(pModel->GetObjectShell()); + OUString aText = pDocShell->GetText(); + MathType aEquation(aText); + bSuccess = aEquation.Parse(aStorage) == 1; + if (bSuccess) + { + pDocShell->SetText(aText); + pDocShell->Parse(); + } } } } } } + catch (const uno::Exception& rException) + { + SAL_WARN("starmath", "Exception caught: " << rException.Message); + } return bSuccess; } -- cgit