Kaydet (Commit) b871fad7 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Guard against createInstance throwing non-Runtime-Exception

...leading to exception specification violations down the road

Change-Id: If017ffd18953d1200fde476ba7e400298dcd5b29
üst dab503c5
......@@ -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));
......
......@@ -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())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment