diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-02-11 11:50:38 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-02-11 11:50:38 +0100 |
commit | b871fad7a5b482c6ad1c0054adf0e068701395bd (patch) | |
tree | 17831a3aa66583e27903b3152748f2ceb6bd974c /writerfilter | |
parent | dab503c530c00bf80df590234534082dcaa61043 (diff) |
Guard against createInstance throwing non-Runtime-Exception
...leading to exception specification violations down the road
Change-Id: If017ffd18953d1200fde476ba7e400298dcd5b29
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/SdtHelper.cxx | 20 | ||||
-rw-r--r-- | writerfilter/source/filter/ImportFilter.cxx | 17 |
2 files changed, 32 insertions, 5 deletions
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx b/writerfilter/source/dmapper/SdtHelper.cxx index f5a3bd1ca951..bc91634614f1 100644 --- a/writerfilter/source/dmapper/SdtHelper.cxx +++ b/writerfilter/source/dmapper/SdtHelper.cxx @@ -9,7 +9,9 @@ #include <SdtHelper.hxx> #include <com/sun/star/drawing/XControlShape.hpp> +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <com/sun/star/text/VertOrientation.hpp> +#include <cppuhelper/exc_hlp.hxx> #include <editeng/unoprnms.hxx> #include <vcl/svapp.hxx> #include <unotools/datetime.hxx> @@ -90,8 +92,22 @@ void SdtHelper::createDropDownControl() void SdtHelper::createDateControl(OUString& rContentText, beans::PropertyValue aCharFormat) { - uno::Reference<awt::XControlModel> xControlModel(m_rDM_Impl.GetTextFactory()->createInstance("com.sun.star.form.component.DateField"), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xPropertySet(xControlModel, uno::UNO_QUERY); + uno::Reference<awt::XControlModel> xControlModel; + try { + xControlModel.set( + m_rDM_Impl.GetTextFactory()->createInstance( + "com.sun.star.form.component.DateField"), + uno::UNO_QUERY_THROW); + } catch (css::uno::RuntimeException &) { + throw; + } catch (css::uno::Exception & e) { + css::uno::Any a(cppu::getCaughtException()); + throw css::lang::WrappedTargetRuntimeException( + "wrapped " + a.getValueTypeName() + ": " + e.Message, + css::uno::Reference<css::uno::XInterface>(), a); + } + uno::Reference<beans::XPropertySet> xPropertySet( + xControlModel, uno::UNO_QUERY_THROW); xPropertySet->setPropertyValue("Dropdown", uno::makeAny(sal_True)); diff --git a/writerfilter/source/filter/ImportFilter.cxx b/writerfilter/source/filter/ImportFilter.cxx index 4c4b1af3c756..35f6402f81cc 100644 --- a/writerfilter/source/filter/ImportFilter.cxx +++ b/writerfilter/source/filter/ImportFilter.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/io/WrongFormatException.hpp> #include <com/sun/star/xml/sax/SAXParseException.hpp> #include <unotools/mediadescriptor.hxx> +#include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/supportsservice.hxx> #include <oox/core/filterdetect.hxx> #include <dmapper/DomainMapperFactory.hxx> @@ -89,9 +90,19 @@ sal_Bool WriterFilter::filter( const uno::Sequence< beans::PropertyValue >& aDes if( m_xSrcDoc.is() ) { uno::Reference< lang::XMultiServiceFactory > xMSF(m_xContext->getServiceManager(), uno::UNO_QUERY_THROW); - uno::Reference< uno::XInterface > xIfc( xMSF->createInstance("com.sun.star.comp.Writer.DocxExport"), uno::UNO_QUERY_THROW); - if (!xIfc.is()) - return sal_False; + uno::Reference< uno::XInterface > xIfc; + try { + xIfc.set( + xMSF->createInstance("com.sun.star.comp.Writer.DocxExport"), + uno::UNO_QUERY_THROW); + } catch (css::uno::RuntimeException &) { + throw; + } catch (css::uno::Exception & e) { + css::uno::Any a(cppu::getCaughtException()); + throw css::lang::WrappedTargetRuntimeException( + "wrapped " + a.getValueTypeName() + ": " + e.Message, + css::uno::Reference<css::uno::XInterface>(), a); + } uno::Reference< document::XExporter > xExprtr(xIfc, uno::UNO_QUERY_THROW); uno::Reference< document::XFilter > xFltr(xIfc, uno::UNO_QUERY_THROW); if (!xExprtr.is() || !xFltr.is()) |