From 251f1b0b38be7d1267339898e44e320f05849e22 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 8 Jan 2013 14:29:06 +0200 Subject: fdo#46808, Adapt embed::*EmbeddedObjectCreator UNO services to new style The services already existed, it just did not have an IDL file. Adapts com.sun.star.embed.OOoEmbeddedObjectFactory com.sun.star.embed.OLEEmbeddedObjectFactory com.sun.star.embed.EmbeddedObjectCreator Change-Id: I8ba01c7fd956a46c87d02dc7d61bdd5fcdf21ab8 --- .../source/core/dataaccess/documentdefinition.cxx | 177 ++++++++++----------- 1 file changed, 86 insertions(+), 91 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx index 0e2b410d0e64..75737630278f 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.cxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx @@ -46,8 +46,9 @@ #include #include #include -#include +#include #include +#include #include #include #include @@ -1215,36 +1216,33 @@ void ODocumentDefinition::onCommandInsert( const ::rtl::OUString& _sURL, const R Reference< XStorage> xStorage = getContainerStorage(); if ( xStorage.is() ) { - Reference< XEmbedObjectCreator> xEmbedFactory( m_aContext.createComponent( "com.sun.star.embed.EmbeddedObjectCreator" ), UNO_QUERY ); - if ( xEmbedFactory.is() ) + Reference< XEmbeddedObjectCreator> xEmbedFactory = EmbeddedObjectCreator::create(m_aContext.getUNOContext()); + Sequence aEmpty,aMediaDesc(1); + aMediaDesc[0].Name = PROPERTY_URL; + aMediaDesc[0].Value <<= _sURL; + m_xEmbeddedObject.set(xEmbedFactory->createInstanceInitFromMediaDescriptor( xStorage + ,m_pImpl->m_aProps.sPersistentName + ,aMediaDesc + ,aEmpty),UNO_QUERY); + + lcl_resetFormsToEmptyDataSource( m_xEmbeddedObject ); + // #i57669# + + Reference xPersist(m_xEmbeddedObject,UNO_QUERY); + if ( xPersist.is() ) { - Sequence aEmpty,aMediaDesc(1); - aMediaDesc[0].Name = PROPERTY_URL; - aMediaDesc[0].Value <<= _sURL; - m_xEmbeddedObject.set(xEmbedFactory->createInstanceInitFromMediaDescriptor( xStorage - ,m_pImpl->m_aProps.sPersistentName - ,aMediaDesc - ,aEmpty),UNO_QUERY); - - lcl_resetFormsToEmptyDataSource( m_xEmbeddedObject ); - // #i57669# - - Reference xPersist(m_xEmbeddedObject,UNO_QUERY); - if ( xPersist.is() ) - { - xPersist->storeOwn(); - } - try - { - Reference< com::sun::star::util::XCloseable> xCloseable(m_xEmbeddedObject,UNO_QUERY); - if ( xCloseable.is() ) - xCloseable->close(sal_True); - } - catch(const Exception&) - { - } - m_xEmbeddedObject = NULL; - } + xPersist->storeOwn(); + } + try + { + Reference< com::sun::star::util::XCloseable> xCloseable(m_xEmbeddedObject,UNO_QUERY); + if ( xCloseable.is() ) + xCloseable->close(sal_True); + } + catch(const Exception&) + { + } + m_xEmbeddedObject = NULL; } } @@ -1617,80 +1615,77 @@ void ODocumentDefinition::loadEmbeddedObject( const Reference< XConnection >& i_ Reference< XStorage> xStorage = getContainerStorage(); if ( xStorage.is() ) { - Reference< XEmbedObjectFactory> xEmbedFactory( m_aContext.createComponent( "com.sun.star.embed.OOoEmbeddedObjectFactory" ), UNO_QUERY ); - if ( xEmbedFactory.is() ) + Reference< XEmbeddedObjectCreator> xEmbedFactory = OOoEmbeddedObjectFactory::create(m_aContext.getUNOContext()); + ::rtl::OUString sDocumentService; + sal_Bool bSetSize = sal_False; + sal_Int32 nEntryConnectionMode = EntryInitModes::DEFAULT_INIT; + Sequence< sal_Int8 > aClassID = _aClassID; + if ( aClassID.getLength() ) { - ::rtl::OUString sDocumentService; - sal_Bool bSetSize = sal_False; - sal_Int32 nEntryConnectionMode = EntryInitModes::DEFAULT_INIT; - Sequence< sal_Int8 > aClassID = _aClassID; - if ( aClassID.getLength() ) - { - nEntryConnectionMode = EntryInitModes::TRUNCATE_INIT; - bSetSize = sal_True; - } - else + nEntryConnectionMode = EntryInitModes::TRUNCATE_INIT; + bSetSize = sal_True; + } + else + { + sDocumentService = GetDocumentServiceFromMediaType( getContentType(), m_aContext, aClassID ); + // check if we are not a form and + // the com.sun.star.report.pentaho.SOReportJobFactory is not present. + if ( !m_bForm && !sDocumentService.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextDocument"))) { - sDocumentService = GetDocumentServiceFromMediaType( getContentType(), m_aContext, aClassID ); - // check if we are not a form and - // the com.sun.star.report.pentaho.SOReportJobFactory is not present. - if ( !m_bForm && !sDocumentService.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextDocument"))) + // we seem to be a "new style" report, check if report extension is present. + Reference< XContentEnumerationAccess > xEnumAccess( m_aContext.getLegacyServiceFactory(), UNO_QUERY ); + const ::rtl::OUString sReportEngineServiceName = ::dbtools::getDefaultReportEngineServiceName(m_aContext.getUNOContext()); + Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(sReportEngineServiceName); + if ( !xEnumDrivers.is() || !xEnumDrivers->hasMoreElements() ) { - // we seem to be a "new style" report, check if report extension is present. - Reference< XContentEnumerationAccess > xEnumAccess( m_aContext.getLegacyServiceFactory(), UNO_QUERY ); - const ::rtl::OUString sReportEngineServiceName = ::dbtools::getDefaultReportEngineServiceName(m_aContext.getUNOContext()); - Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(sReportEngineServiceName); - if ( !xEnumDrivers.is() || !xEnumDrivers->hasMoreElements() ) - { - com::sun::star::io::WrongFormatException aWFE; - aWFE.Message = DBACORE_RESSTRING( RID_STR_MISSING_EXTENSION ); - throw aWFE; - } + com::sun::star::io::WrongFormatException aWFE; + aWFE.Message = DBACORE_RESSTRING( RID_STR_MISSING_EXTENSION ); + throw aWFE; } - if ( !aClassID.getLength() ) + } + if ( !aClassID.getLength() ) + { + if ( m_bForm ) + aClassID = MimeConfigurationHelper::GetSequenceClassID(SO3_SW_CLASSID); + else { - if ( m_bForm ) - aClassID = MimeConfigurationHelper::GetSequenceClassID(SO3_SW_CLASSID); - else - { - aClassID = MimeConfigurationHelper::GetSequenceClassID(SO3_RPT_CLASSID_90); - } + aClassID = MimeConfigurationHelper::GetSequenceClassID(SO3_RPT_CLASSID_90); } } + } - OSL_ENSURE( aClassID.getLength(),"No Class ID" ); + OSL_ENSURE( aClassID.getLength(),"No Class ID" ); - Sequence< PropertyValue > aEmbeddedObjectDescriptor; - Sequence< PropertyValue > aLoadArgs( fillLoadArgs( - i_rConnection, _bSuppressMacros, _bReadOnly, i_rOpenCommandArguments, aEmbeddedObjectDescriptor ) ); + Sequence< PropertyValue > aEmbeddedObjectDescriptor; + Sequence< PropertyValue > aLoadArgs( fillLoadArgs( + i_rConnection, _bSuppressMacros, _bReadOnly, i_rOpenCommandArguments, aEmbeddedObjectDescriptor ) ); - m_xEmbeddedObject.set(xEmbedFactory->createInstanceUserInit(aClassID - ,sDocumentService - ,xStorage - ,m_pImpl->m_aProps.sPersistentName - ,nEntryConnectionMode - ,aLoadArgs - ,aEmbeddedObjectDescriptor - ),UNO_QUERY); - if ( m_xEmbeddedObject.is() ) + m_xEmbeddedObject.set(xEmbedFactory->createInstanceUserInit(aClassID + ,sDocumentService + ,xStorage + ,m_pImpl->m_aProps.sPersistentName + ,nEntryConnectionMode + ,aLoadArgs + ,aEmbeddedObjectDescriptor + ),UNO_QUERY); + if ( m_xEmbeddedObject.is() ) + { + if ( !m_pClientHelper ) { - if ( !m_pClientHelper ) - { - m_pClientHelper = new OEmbeddedClientHelper(this); - m_pClientHelper->acquire(); - } - Reference xClient = m_pClientHelper; - m_xEmbeddedObject->setClientSite(xClient); - m_xEmbeddedObject->changeState(EmbedStates::RUNNING); - if ( bSetSize ) - { - LockModifiable aLockModify( impl_getComponent_throw( false ) ); + m_pClientHelper = new OEmbeddedClientHelper(this); + m_pClientHelper->acquire(); + } + Reference xClient = m_pClientHelper; + m_xEmbeddedObject->setClientSite(xClient); + m_xEmbeddedObject->changeState(EmbedStates::RUNNING); + if ( bSetSize ) + { + LockModifiable aLockModify( impl_getComponent_throw( false ) ); - awt::Size aSize( DEFAULT_WIDTH, DEFAULT_HEIGHT ); - m_xEmbeddedObject->setVisualAreaSize(Aspects::MSOLE_CONTENT,aSize); - } + awt::Size aSize( DEFAULT_WIDTH, DEFAULT_HEIGHT ); + m_xEmbeddedObject->setVisualAreaSize(Aspects::MSOLE_CONTENT,aSize); } - } + } } } else -- cgit