diff options
Diffstat (limited to 'embeddedobj/source/general/xcreator.cxx')
-rw-r--r-- | embeddedobj/source/general/xcreator.cxx | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/embeddedobj/source/general/xcreator.cxx b/embeddedobj/source/general/xcreator.cxx index d057aeba4a1a..bceaab63c752 100644 --- a/embeddedobj/source/general/xcreator.cxx +++ b/embeddedobj/source/general/xcreator.cxx @@ -25,6 +25,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/lang/NoSupportException.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <cppuhelper/supportsservice.hxx> @@ -45,6 +46,8 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta const OUString& sEntName, const uno::Sequence< beans::PropertyValue >& lObjArgs ) { + if ( officecfg::Office::Common::Security::Scripting::DisableActiveContent::get() ) + throw lang::NoSupportException("Active OLE content is disabled!"); if ( !xStorage.is() ) throw lang::IllegalArgumentException( "No parent storage is provided!", static_cast< ::cppu::OWeakObject* >(this), @@ -164,7 +167,10 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta aEmbedFactory = m_aConfigHelper.GetFactoryNameByMediaType(MIMETYPE_VND_SUN_XML_BASE_ASCII); } - if ( !aEmbedFactory.isEmpty() ) + if ( !aEmbedFactory.isEmpty() + // when active OLE content is disabled, ignore aEmbedFactory and force + // the embedded object to be an ODummyEmbeddedObject + && !officecfg::Office::Common::Security::Scripting::DisableActiveContent::get() ) { uno::Reference< uno::XInterface > xFact = m_xContext->getServiceManager()->createInstanceWithContext(aEmbedFactory, m_xContext); @@ -188,13 +194,11 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta * Decides if rFilter should be used to load data into a doc model or real OLE embedding should * happen. Empty return value means the later. */ -static OUString HandleFilter(const uno::Reference<uno::XComponentContext>& xComponentContext, - const OUString& rFilter) +static OUString HandleFilter(const OUString& rFilter) { OUString aRet = rFilter; - if (!officecfg::Office::Common::Filter::Microsoft::Import::WinWordToWriter::get( - xComponentContext)) + if (!officecfg::Office::Common::Filter::Microsoft::Import::WinWordToWriter::get()) { if (rFilter == "MS Word 97" || rFilter == "MS Word 2007 XML") { @@ -202,29 +206,28 @@ static OUString HandleFilter(const uno::Reference<uno::XComponentContext>& xComp } } - if (!officecfg::Office::Common::Filter::Microsoft::Import::ExcelToCalc::get(xComponentContext)) + if (!officecfg::Office::Common::Filter::Microsoft::Import::ExcelToCalc::get()) { if (rFilter == "MS Excel 97" || rFilter == "Calc MS Excel 2007 XML") { aRet.clear(); } } - if (!officecfg::Office::Common::Filter::Microsoft::Import::PowerPointToImpress::get( - xComponentContext)) + if (!officecfg::Office::Common::Filter::Microsoft::Import::PowerPointToImpress::get()) { if (rFilter == "MS PowerPoint 97" || rFilter == "Impress MS PowerPoint 2007 XML") { aRet.clear(); } } - if (!officecfg::Office::Common::Filter::Microsoft::Import::VisioToDraw::get(xComponentContext)) + if (!officecfg::Office::Common::Filter::Microsoft::Import::VisioToDraw::get()) { if (rFilter == "Visio Document") { aRet.clear(); } } - if (!officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::get(xComponentContext)) + if (!officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::get()) { if (rFilter == "draw_pdf_import") { @@ -241,6 +244,8 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta const uno::Sequence< beans::PropertyValue >& aMediaDescr, const uno::Sequence< beans::PropertyValue >& lObjArgs ) { + if ( officecfg::Office::Common::Security::Scripting::DisableActiveContent::get() ) + throw lang::NoSupportException("Active OLE content is disabled!"); // TODO: use lObjArgs if ( !xStorage.is() ) @@ -259,7 +264,7 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta // check if there is FilterName OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, false ); - aFilterName = HandleFilter(m_xContext, aFilterName); + aFilterName = HandleFilter(aFilterName); if ( !aFilterName.isEmpty() ) { @@ -302,6 +307,8 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta const uno::Sequence< beans::PropertyValue >& aArgs, const uno::Sequence< beans::PropertyValue >& aObjectArgs ) { + if ( officecfg::Office::Common::Security::Scripting::DisableActiveContent::get() ) + throw lang::NoSupportException("Active OLE content is disabled!"); if ( !xStorage.is() ) throw lang::IllegalArgumentException( "No parent storage is provided!", static_cast< ::cppu::OWeakObject* >(this), @@ -333,13 +340,16 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta const uno::Sequence< beans::PropertyValue >& aMediaDescr, const uno::Sequence< beans::PropertyValue >& lObjArgs ) { + if ( officecfg::Office::Common::Security::Scripting::DisableActiveContent::get() ) + throw lang::NoSupportException("Active OLE content is disabled!"); + uno::Reference< uno::XInterface > xResult; uno::Sequence< beans::PropertyValue > aTempMedDescr( aMediaDescr ); // check if there is URL, URL must exist OUString aURL; - for ( beans::PropertyValue const & prop : std::as_const(aTempMedDescr) ) + for (beans::PropertyValue const& prop : aTempMedDescr) if ( prop.Name == "URL" ) prop.Value >>= aURL; |