User: kz Date: 2008-06-25 12:33:58+0000 Modified: dba/dbaccess/source/filter/xml/dbloader2.cxx
Log: INTEGRATION: CWS dba30d (1.35.2); FILE MERGED 2008/06/11 20:27:50 fs 1.35.2.1: #i80943#: use a NamedDatabaseObject for selecting the Tables container #i90586# don't attachResource for a newly created document 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.35&r2=1.36 Delta lines: +25 -27 --------------------- --- dbloader2.cxx 2008-06-06 14:06:16+0000 1.35 +++ dbloader2.cxx 2008-06-25 12:33:55+0000 1.36 @@ -60,6 +60,8 @@ #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp> +#include <com/sun/star/sdb/application/NamedDatabaseObject.hpp> /** === end UNO includes === **/ #include <comphelper/componentcontext.hxx> @@ -101,6 +103,7 @@ namespace css = ::com::sun::star; using namespace ::com::sun::star::ui::dialogs; using ::com::sun::star::awt::XWindow; +using ::com::sun::star::sdb::application::NamedDatabaseObject; // ------------------------------------------------------------------------- namespace dbaxml @@ -408,7 +411,6 @@ ::rtl::OUString sSalvagedURL = aMediaDesc.getOrDefault( "SalvagedFile", _rURL ); sal_Bool bCreateNew = sal_False; // does the URL denote the private:factory URL? - sal_Bool bDidLoadExisting = sal_False; // when it does, did we (the wizard) load an existing document instead sal_Bool bStartTableWizard = sal_False; // start the table wizard after everything was loaded successfully? sal_Bool bSuccess = sal_True; @@ -435,7 +437,7 @@ ::rtl::OUString sViewName = aMediaDesc.getOrDefault( "ViewName", ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Default" ) ) ); aMediaDesc.remove( "ViewName" ); - sal_Bool bInteractive = sal_False; + sal_Int32 nInitialSelection = -1; if ( !xModel.is() ) { Reference< XSingleServiceFactory > xDatabaseContext; @@ -444,32 +446,29 @@ ::rtl::OUString sFactoryName = SvtModuleOptions().GetFactoryEmptyDocumentURL(SvtModuleOptions::E_DATABASE); bCreateNew = sFactoryName.match(_rURL); - Sequence<Any> aCreationArgs; - if ( !bCreateNew ) - { - aCreationArgs.realloc(1); - aCreationArgs[0] <<= NamedValue( INFO_POOLURL, makeAny( sSalvagedURL ) ); - } - else - bInteractive = lcl_urlAllowsInteraction( m_aContext, _rURL ); Reference< XDocumentDataSource > xDocumentDataSource; - xDocumentDataSource.set(xDatabaseContext->createInstanceWithArguments(aCreationArgs),UNO_QUERY_THROW); - xModel.set(xDocumentDataSource->getDatabaseDocument(),UNO_QUERY); - if ( xModel.is() ) - { - const ::rtl::OUString sURL = xModel->getURL(); + bool bNewAndInteractive = false; if ( bCreateNew ) { - xModel->attachResource( sURL, aMediaDesc.getPropertyValues() ); + bNewAndInteractive = lcl_urlAllowsInteraction( m_aContext, _rURL ); + xDocumentDataSource.set( xDatabaseContext->createInstance(), UNO_QUERY_THROW ); + } + else + { + Sequence< Any > aCreationArgs( 1 ); + aCreationArgs[0] <<= NamedValue( INFO_POOLURL, makeAny( sSalvagedURL ) ); + xDocumentDataSource.set( xDatabaseContext->createInstanceWithArguments( aCreationArgs ), UNO_QUERY_THROW ); } - if ( bInteractive ) + xModel.set( xDocumentDataSource->getDatabaseDocument(), UNO_QUERY ); + if ( xModel.is() && bNewAndInteractive ) { + const ::rtl::OUString sURL = xModel->getURL(); bSuccess = impl_executeNewDatabaseWizard( xModel, bStartTableWizard ); - if ( sURL != xModel->getURL() ) - bDidLoadExisting = sal_True; - } + + // initially select the "Tables" category (will be done below) + nInitialSelection = ::com::sun::star::sdb::application::DatabaseObjectContainer::TABLES; } } @@ -560,15 +559,14 @@ if ( rListener.is() ) rListener->loadFinished(this); - if ( bCreateNew && bInteractive ) + if ( nInitialSelection != -1 ) { Reference< css::view::XSelectionSupplier > xDocView( xModel->getCurrentController(), UNO_QUERY ); if ( xDocView.is() ) { - Sequence< NamedValue > aSelection(1); - aSelection[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Type")); - aSelection[0].Value <<= sal_Int32(0); - xDocView->select(makeAny(aSelection)); + NamedDatabaseObject aSelection; + aSelection.Type = nInitialSelection; + xDocView->select( makeAny( aSelection ) ); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
