User: vg Date: 05/03/10 08:39:02 Modified: /dba/dbaccess/source/filter/xml/ dbloader2.cxx
Log: INTEGRATION: CWS dba24 (1.5.18); FILE MERGED 2005/03/09 09:26:58 fs 1.5.18.8: #i10000# don't insert document twice to the GlobalEventBroadcaster 2005/03/08 15:10:23 fs 1.5.18.7: #i10000# 2005/03/08 10:16:15 oj 1.5.18.6: RESYNC: (1.7-1.8); FILE MERGED 2005/03/03 11:30:21 fs 1.5.18.5: #i43975# properly determine the Interactive flag when creating a new database document 2005/02/23 07:41:48 oj 1.5.18.4: #i42461# reinvent the opening of database documents 2005/02/21 13:10:25 oj 1.5.18.3: RESYNC: (1.5-1.7); FILE MERGED 2005/02/18 12:44:39 oj 1.5.18.2: #i42460# changes for the separation of datasource and database document(model) 2005/02/10 11:27:43 oj 1.5.18.1: #i42316# check if model is already set in the mediadescriptor File Changes: Directory: /dba/dbaccess/source/filter/xml/ =========================================== File [changed]: dbloader2.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/filter/xml/dbloader2.cxx?r1=1.8&r2=1.9 Delta lines: +61 -31 --------------------- --- dbloader2.cxx 4 Mar 2005 09:38:43 -0000 1.8 +++ dbloader2.cxx 10 Mar 2005 16:38:59 -0000 1.9 @@ -89,6 +89,9 @@ #ifndef _COM_SUN_STAR_DOCUMENT_XEVENTLISTENER_HPP_ #include <com/sun/star/document/XEventListener.hpp> #endif +#ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_ +#include <com/sun/star/sdb/XDocumentDataSource.hpp> +#endif #ifndef _COM_SUN_STAR_FRAME_XLOADEVENTLISTENER_HPP_ #include <com/sun/star/frame/XLoadEventListener.hpp> #endif @@ -122,6 +125,9 @@ #ifndef _COM_SUN_STAR_DOCUMENT_XFILTER_HPP_ #include <com/sun/star/document/XFilter.hpp> #endif +#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_ +#include <com/sun/star/util/XURLTransformer.hpp> +#endif #ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_ #include <com/sun/star/registry/XRegistryKey.hpp> @@ -183,12 +189,15 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::ucb; using namespace ::com::sun::star::io; +using namespace ::com::sun::star::util; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::document; using namespace ::com::sun::star::registry; +using namespace ::com::sun::star::sdb; +namespace css = ::com::sun::star; using namespace ::com::sun::star::ui::dialogs; namespace css = ::com::sun::star; @@ -377,33 +386,31 @@ { // first check if preview is true, if so return with out creating a controller. Preview is not supported - const PropertyValue* pIter = rArgs.getConstArray(); - const PropertyValue* pEnd = pIter + rArgs.getLength(); - - for ( ; pIter != pEnd; ++pIter ) - { - if ( ( 0 == pIter->Name.compareToAscii( "Preview" ) ) ) - { - sal_Bool bPreview = sal_False; - pIter->Value >>= bPreview; + ::comphelper::SequenceAsHashMap lDescriptor(rArgs); + sal_Bool bPreview = lDescriptor.getUnpackedValueOrDefault(INFO_PREVIEW , sal_False ); if ( bPreview ) { if (rListener.is()) rListener->loadCancelled(this); return; } - } - } + Reference< XModel > xModel = lDescriptor.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Model")), Reference< XModel >()); m_xFrame = rFrame; m_xListener = rListener; m_aURL = rURL; m_aArgs = rArgs; - Reference< XSingleServiceFactory > xDatabaseContext(m_xServiceFactory->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY); - Reference<XComponent> xComponent; sal_Bool bCreateNew = sal_False; sal_Bool bInteractive = sal_False; + Reference<XDocumentDataSource> xDocumentDataSource; + /* special mode: use already loaded model ... + In such case no filter name will be selected and no URL will be given! + Such informations are not neccessary. We have to create a new view only + and call setComponent() at the corresponding frame. */ + if ( !xModel.is() ) + { + Reference< XSingleServiceFactory > xDatabaseContext(m_xServiceFactory->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY); if ( xDatabaseContext.is() ) { bCreateNew = rURL.match(SvtModuleOptions().GetFactoryEmptyDocumentURL(SvtModuleOptions::E_DATABASE)); @@ -414,13 +421,35 @@ aCreationArgs[0] <<= NamedValue(INFO_POOLURL,makeAny(rURL)); } else - bInteractive = rURL.match(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("?Interactive")), SvtModuleOptions().GetFactoryEmptyDocumentURL(SvtModuleOptions::E_DATABASE).getLength() ); - xComponent.set(xDatabaseContext->createInstanceWithArguments(aCreationArgs),UNO_QUERY); + { + try + { + Reference< XURLTransformer > xTransformer( + m_xServiceFactory->createInstance( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ) ) ), + UNO_QUERY + ); + OSL_ENSURE( xTransformer.is(), "DBContentLoader::load: could not create an URLTransformer!" ); + if ( xTransformer.is() ) + { + URL aURL; + aURL.Complete = m_aURL; + xTransformer->parseStrict( aURL ); + bInteractive = aURL.Arguments.equalsAscii( "Interactive" ); + } + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "DBContentLoader::load: caught an exception while analyzing the URL!" ); + } } + xDocumentDataSource.set(xDatabaseContext->createInstanceWithArguments(aCreationArgs),UNO_QUERY_THROW); + xModel.set(xDocumentDataSource->getDatabaseDocument(),UNO_QUERY); + } + } sal_Bool bSuccess = sal_True; - Reference<XModel> xModel(xComponent,UNO_QUERY); if ( !bCreateNew && xModel.is() && !xModel->getURL().getLength() ) { try @@ -524,7 +553,7 @@ } } - if (bSuccess && rListener.is()) + if (bSuccess) { if ( xController.is() && rFrame.is() ) xController->attachFrame(rFrame); @@ -541,6 +570,7 @@ { OSL_ENSURE(0,"Could not add database model to global model collection and broadcast the events OnNew/OnLoad!"); } + if ( rListener.is() ) rListener->loadFinished(this); if ( bStartTableWizard ) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
