merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / filter / xml / dbloader2.cxx
blobecee01aca3377c6d56d747f552df0de4f99bc1c3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dbloader2.cxx,v $
10 * $Revision: 1.32.28.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #include "flt_reghelper.hxx"
35 #include "xmlstrings.hrc"
37 /** === begin UNO includes === **/
38 #include <com/sun/star/beans/NamedValue.hpp>
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 #include <com/sun/star/document/XEventListener.hpp>
41 #include <com/sun/star/document/XExtendedFilterDetection.hpp>
42 #include <com/sun/star/document/XFilter.hpp>
43 #include <com/sun/star/embed/ElementModes.hpp>
44 #include <com/sun/star/embed/XStorage.hpp>
45 #include <com/sun/star/frame/XController.hpp>
46 #include <com/sun/star/frame/XFrame.hpp>
47 #include <com/sun/star/frame/XFrameLoader.hpp>
48 #include <com/sun/star/frame/XFramesSupplier.hpp>
49 #include <com/sun/star/frame/XLoadEventListener.hpp>
50 #include <com/sun/star/frame/XModel2.hpp>
51 #include <com/sun/star/io/XInputStream.hpp>
52 #include <com/sun/star/lang/XInitialization.hpp>
53 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
54 #include <com/sun/star/lang/XServiceInfo.hpp>
55 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
56 #include <com/sun/star/registry/XRegistryKey.hpp>
57 #include <com/sun/star/sdb/XDocumentDataSource.hpp>
58 #include <com/sun/star/task/XJobExecutor.hpp>
59 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
60 #include <com/sun/star/util/XURLTransformer.hpp>
61 #include <com/sun/star/view/XSelectionSupplier.hpp>
62 #include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
63 #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
64 #include <com/sun/star/frame/XLoadable.hpp>
65 /** === end UNO includes === **/
67 #include <comphelper/componentcontext.hxx>
68 #include <comphelper/documentconstants.hxx>
69 #include <comphelper/namedvaluecollection.hxx>
70 #include <comphelper/processfactory.hxx>
71 #include <comphelper/sequenceashashmap.hxx>
72 #include <comphelper/stl_types.hxx>
73 #include <comphelper/storagehelper.hxx>
74 #include <comphelper/types.hxx>
75 #include <cppuhelper/implbase2.hxx>
76 #include <osl/file.hxx>
77 #include <sfx2/docfile.hxx>
78 #include <svtools/moduleoptions.hxx>
79 #include <toolkit/awt/vclxwindow.hxx>
80 #include <toolkit/helper/vclunohelper.hxx>
81 #include <tools/diagnose_ex.h>
82 #include <tools/urlobj.hxx>
83 #include <ucbhelper/commandenvironment.hxx>
84 #include <ucbhelper/content.hxx>
85 #include <ucbhelper/contentbroker.hxx>
86 #include <vcl/msgbox.hxx>
87 #include <vcl/svapp.hxx>
89 using namespace ::ucbhelper;
90 using namespace ::com::sun::star::task;
91 using namespace ::com::sun::star::uno;
92 using namespace ::com::sun::star::ucb;
93 using namespace ::com::sun::star::io;
94 using namespace ::com::sun::star::util;
95 using namespace ::com::sun::star::frame;
96 using namespace ::com::sun::star::beans;
97 using namespace ::com::sun::star::container;
98 using namespace ::com::sun::star::lang;
99 using namespace ::com::sun::star::document;
100 using namespace ::com::sun::star::registry;
101 using namespace ::com::sun::star::sdb;
102 using namespace ::com::sun::star::embed;
103 namespace css = ::com::sun::star;
104 using namespace ::com::sun::star::ui::dialogs;
105 using ::com::sun::star::awt::XWindow;
106 using ::com::sun::star::sdb::application::NamedDatabaseObject;
108 // -------------------------------------------------------------------------
109 namespace dbaxml
112 class DBTypeDetection : public ::cppu::WeakImplHelper2< XExtendedFilterDetection, XServiceInfo>
114 ::comphelper::ComponentContext m_aContext;
116 public:
117 DBTypeDetection(const Reference< XMultiServiceFactory >&);
119 // XServiceInfo
120 ::rtl::OUString SAL_CALL getImplementationName() throw( );
121 sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw( );
122 Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( );
124 // static methods
125 static ::rtl::OUString getImplementationName_Static() throw( )
127 return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbflt.DBTypeDetection");
129 static Sequence< ::rtl::OUString> getSupportedServiceNames_Static(void) throw( );
130 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
131 SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
133 virtual ::rtl::OUString SAL_CALL detect( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Descriptor ) throw (::com::sun::star::uno::RuntimeException);
135 // -------------------------------------------------------------------------
136 DBTypeDetection::DBTypeDetection(const Reference< XMultiServiceFactory >& _rxFactory)
137 :m_aContext( _rxFactory )
140 // -------------------------------------------------------------------------
141 ::rtl::OUString SAL_CALL DBTypeDetection::detect( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Descriptor ) throw (::com::sun::star::uno::RuntimeException)
145 ::comphelper::NamedValueCollection aMedia( Descriptor );
146 sal_Bool bStreamFromDescr = sal_False;
147 ::rtl::OUString sURL = aMedia.getOrDefault( "URL", ::rtl::OUString() );
149 Reference< XInputStream > xInStream( aMedia.getOrDefault( "InputStream", Reference< XInputStream >() ) );
150 Reference< XPropertySet > xStorageProperties;
151 if ( xInStream.is() )
153 bStreamFromDescr = sal_True;
154 xStorageProperties.set( ::comphelper::OStorageHelper::GetStorageFromInputStream(
155 xInStream, m_aContext.getLegacyServiceFactory() ), UNO_QUERY );
157 else
159 ::rtl::OUString sSalvagedURL( aMedia.getOrDefault( "SalvagedFile", ::rtl::OUString() ) );
161 ::rtl::OUString sFileLocation( sSalvagedURL.getLength() ? sSalvagedURL : sURL );
162 if ( sFileLocation.getLength() )
164 xStorageProperties.set( ::comphelper::OStorageHelper::GetStorageFromURL(
165 sFileLocation, ElementModes::READ, m_aContext.getLegacyServiceFactory() ), UNO_QUERY );
169 if ( xStorageProperties.is() )
171 ::rtl::OUString sMediaType;
172 xStorageProperties->getPropertyValue( INFO_MEDIATYPE ) >>= sMediaType;
173 if ( sMediaType.equalsAscii(MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII) || sMediaType.equalsAscii(MIMETYPE_VND_SUN_XML_BASE_ASCII) )
175 if ( bStreamFromDescr && sURL.compareTo( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:stream" ) ), 14 ) != COMPARE_EQUAL )
177 // After fixing of the i88522 issue ( use the new file locking for database files ) the stream from the type detection can be used further
178 // for now the file should be reopened to have read/write access
179 aMedia.remove( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InputStream" ) ) );
180 aMedia.remove( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Stream" ) ) );
181 aMedia >>= Descriptor;
184 ::comphelper::disposeComponent(xStorageProperties);
185 if ( xInStream.is() )
186 xInStream->closeInput();
188 catch( Exception& )
190 DBG_UNHANDLED_EXCEPTION();
194 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StarBase"));
196 ::comphelper::disposeComponent(xStorageProperties);
198 } catch(Exception&){}
199 return ::rtl::OUString();
201 // -------------------------------------------------------------------------
202 Reference< XInterface > SAL_CALL DBTypeDetection::Create( const Reference< XMultiServiceFactory > & rSMgr )
204 return *(new DBTypeDetection(rSMgr));
206 // -------------------------------------------------------------------------
207 // XServiceInfo
208 ::rtl::OUString SAL_CALL DBTypeDetection::getImplementationName() throw( )
210 return getImplementationName_Static();
212 // -------------------------------------------------------------------------
214 // XServiceInfo
215 sal_Bool SAL_CALL DBTypeDetection::supportsService(const ::rtl::OUString& ServiceName) throw( )
217 Sequence< ::rtl::OUString > aSNL = getSupportedServiceNames();
218 const ::rtl::OUString * pBegin = aSNL.getConstArray();
219 const ::rtl::OUString * pEnd = pBegin + aSNL.getLength();
220 for( ; pBegin != pEnd; ++pBegin)
221 if( *pBegin == ServiceName )
222 return sal_True;
223 return sal_False;
225 // -------------------------------------------------------------------------
226 // XServiceInfo
227 Sequence< ::rtl::OUString > SAL_CALL DBTypeDetection::getSupportedServiceNames(void) throw( )
229 return getSupportedServiceNames_Static();
231 // -------------------------------------------------------------------------
232 // ORegistryServiceManager_Static
233 Sequence< ::rtl::OUString > DBTypeDetection::getSupportedServiceNames_Static(void) throw( )
235 Sequence< ::rtl::OUString > aSNS( 1 );
236 aSNS.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.document.ExtendedTypeDetection");
237 return aSNS;
239 // -------------------------------------------------------------------------
240 extern "C" void SAL_CALL createRegistryInfo_DBTypeDetection()
242 static ::dbaxml::OMultiInstanceAutoRegistration< ::dbaxml::DBTypeDetection > aAutoRegistration;
244 // -----------------------------------------------------------------------------
246 class DBContentLoader : public ::cppu::WeakImplHelper2< XFrameLoader, XServiceInfo>
248 private:
249 ::comphelper::ComponentContext m_aContext;
250 Reference< XFrameLoader > m_xMySelf;
251 ::rtl::OUString m_sCurrentURL;
252 ULONG m_nStartWizard;
254 DECL_LINK( OnStartTableWizard, void* );
255 public:
256 DBContentLoader(const Reference< XMultiServiceFactory >&);
257 ~DBContentLoader();
259 // XServiceInfo
260 ::rtl::OUString SAL_CALL getImplementationName() throw( );
261 sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw( );
262 Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( );
264 // static methods
265 static ::rtl::OUString getImplementationName_Static() throw( )
267 return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbflt.DBContentLoader2");
269 static Sequence< ::rtl::OUString> getSupportedServiceNames_Static(void) throw( );
270 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
271 SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
273 // XLoader
274 virtual void SAL_CALL load( const Reference< XFrame > & _rFrame, const ::rtl::OUString& _rURL,
275 const Sequence< PropertyValue >& _rArgs,
276 const Reference< XLoadEventListener > & _rListener) throw(::com::sun::star::uno::RuntimeException);
277 virtual void SAL_CALL cancel(void) throw();
279 private:
280 sal_Bool impl_executeNewDatabaseWizard( Reference< XModel >& _rxModel, sal_Bool& _bShouldStartTableWizard );
282 DBG_NAME(DBContentLoader)
284 DBContentLoader::DBContentLoader(const Reference< XMultiServiceFactory >& _rxFactory)
285 :m_aContext( _rxFactory )
286 ,m_nStartWizard(0)
288 DBG_CTOR(DBContentLoader,NULL);
291 // -------------------------------------------------------------------------
293 DBContentLoader::~DBContentLoader()
296 DBG_DTOR(DBContentLoader,NULL);
298 // -------------------------------------------------------------------------
300 // -------------------------------------------------------------------------
301 Reference< XInterface > SAL_CALL DBContentLoader::Create( const Reference< XMultiServiceFactory > & rSMgr )
303 return *(new DBContentLoader(rSMgr));
305 // -------------------------------------------------------------------------
306 // XServiceInfo
307 ::rtl::OUString SAL_CALL DBContentLoader::getImplementationName() throw( )
309 return getImplementationName_Static();
311 // -------------------------------------------------------------------------
313 // XServiceInfo
314 sal_Bool SAL_CALL DBContentLoader::supportsService(const ::rtl::OUString& ServiceName) throw( )
316 Sequence< ::rtl::OUString > aSNL = getSupportedServiceNames();
317 const ::rtl::OUString * pBegin = aSNL.getConstArray();
318 const ::rtl::OUString * pEnd = pBegin + aSNL.getLength();
319 for( ; pBegin != pEnd; ++pBegin)
320 if( *pBegin == ServiceName )
321 return sal_True;
322 return sal_False;
324 // -------------------------------------------------------------------------
325 // XServiceInfo
326 Sequence< ::rtl::OUString > SAL_CALL DBContentLoader::getSupportedServiceNames(void) throw( )
328 return getSupportedServiceNames_Static();
330 // -------------------------------------------------------------------------
331 // ORegistryServiceManager_Static
332 Sequence< ::rtl::OUString > DBContentLoader::getSupportedServiceNames_Static(void) throw( )
334 Sequence< ::rtl::OUString > aSNS( 1 );
335 aSNS.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.frame.FrameLoader");
336 return aSNS;
339 // -----------------------------------------------------------------------
340 namespace
342 // ...................................................................
343 sal_Bool lcl_urlAllowsInteraction( const ::comphelper::ComponentContext& _rContext, const ::rtl::OUString& _rURL )
345 bool bDoesAllow = sal_False;
348 Reference< XURLTransformer > xTransformer;
349 if ( _rContext.createComponent( "com.sun.star.util.URLTransformer", xTransformer ) )
351 URL aURL;
352 aURL.Complete = _rURL;
353 xTransformer->parseStrict( aURL );
354 bDoesAllow = aURL.Arguments.equalsAscii( "Interactive" );
357 catch( const Exception& )
359 OSL_ENSURE( sal_False, "lcl_urlAllowsInteraction: caught an exception while analyzing the URL!" );
361 return bDoesAllow;
364 // ...................................................................
365 Reference< XWindow > lcl_getTopMostWindow( const ::comphelper::ComponentContext& _rContext )
367 Reference< XWindow > xWindow;
368 // get the top most window
369 Reference < XFramesSupplier > xDesktop;
370 if ( _rContext.createComponent( "com.sun.star.frame.Desktop", xDesktop ) )
372 Reference < XFrame > xActiveFrame = xDesktop->getActiveFrame();
373 if ( xActiveFrame.is() )
375 xWindow = xActiveFrame->getContainerWindow();
376 Reference<XFrame> xFrame = xActiveFrame;
377 while ( xFrame.is() && !xFrame->isTop() )
378 xFrame.set(xFrame->getCreator(),UNO_QUERY);
380 if ( xFrame.is() )
381 xWindow = xFrame->getContainerWindow();
384 return xWindow;
388 // -----------------------------------------------------------------------
389 sal_Bool DBContentLoader::impl_executeNewDatabaseWizard( Reference< XModel >& _rxModel, sal_Bool& _bShouldStartTableWizard )
391 Sequence< Any > aWizardArgs(2);
392 aWizardArgs[0] <<= PropertyValue(
393 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow")),
395 makeAny( lcl_getTopMostWindow( m_aContext ) ),
396 PropertyState_DIRECT_VALUE);
398 aWizardArgs[1] <<= PropertyValue(
399 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InitialSelection")),
401 makeAny( _rxModel ),
402 PropertyState_DIRECT_VALUE);
404 // create the dialog
405 Reference< XExecutableDialog > xAdminDialog;
406 OSL_VERIFY( m_aContext.createComponentWithArguments( "com.sun.star.sdb.DatabaseWizardDialog", aWizardArgs, xAdminDialog ) );
408 // execute it
409 if ( !xAdminDialog.is() || ( RET_OK != xAdminDialog->execute() ) )
410 return sal_False;
412 Reference<XPropertySet> xProp(xAdminDialog,UNO_QUERY);
413 sal_Bool bSuccess = sal_False;
414 xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OpenDatabase"))) >>= bSuccess;
415 xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StartTableWizard"))) >>= _bShouldStartTableWizard;
416 return bSuccess;
419 // -----------------------------------------------------------------------
420 void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const ::rtl::OUString& _rURL,
421 const Sequence< PropertyValue >& rArgs,
422 const Reference< XLoadEventListener > & rListener) throw(::com::sun::star::uno::RuntimeException)
424 // first check if preview is true, if so return with out creating a controller. Preview is not supported
425 ::comphelper::NamedValueCollection aMediaDesc( rArgs );
426 sal_Bool bPreview = aMediaDesc.getOrDefault( "Preview", sal_False );
427 if ( bPreview )
429 if (rListener.is())
430 rListener->loadCancelled(this);
431 return;
434 Reference< XModel > xModel = aMediaDesc.getOrDefault( "Model", Reference< XModel >() );
435 ::rtl::OUString sSalvagedURL = aMediaDesc.getOrDefault( "SalvagedFile", _rURL );
437 sal_Bool bCreateNew = sal_False; // does the URL denote the private:factory URL?
438 sal_Bool bStartTableWizard = sal_False; // start the table wizard after everything was loaded successfully?
440 sal_Bool bSuccess = sal_True;
442 // If there's no interaction handler in the media descriptor, put one.
443 // By definition, loading via loadComponentFromURL (and thus via the content loader here)
444 // is allowed to raise UI. To not burden every place inside the document with creating
445 // a default handler, we simply ensure there is one.
446 // If a handler is present in the media descriptor, even if it is NULL, we will
447 // not touch it.
448 if ( !aMediaDesc.has( "InteractionHandler" ) )
450 Reference< XInteractionHandler > xHandler;
451 if ( m_aContext.createComponent( "com.sun.star.sdb.InteractionHandler", xHandler ) )
452 aMediaDesc.put( "InteractionHandler", xHandler );
455 // it's allowed to pass an existing document
456 Reference< XOfficeDatabaseDocument > xExistentDBDoc;
457 xModel.set( aMediaDesc.getOrDefault( "Model", xExistentDBDoc ), UNO_QUERY );
458 aMediaDesc.remove( "Model" );
460 // also, it's allowed to specify the type of view which should be created
461 ::rtl::OUString sViewName = aMediaDesc.getOrDefault( "ViewName", ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Default" ) ) );
462 aMediaDesc.remove( "ViewName" );
464 sal_Int32 nInitialSelection = -1;
465 if ( !xModel.is() )
467 Reference< XSingleServiceFactory > xDatabaseContext;
468 if ( !m_aContext.createComponent( (::rtl::OUString)SERVICE_SDB_DATABASECONTEXT, xDatabaseContext ) )
469 throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "css.sdb.DatabaseContext not available" ) ), NULL );
471 ::rtl::OUString sFactoryName = SvtModuleOptions().GetFactoryEmptyDocumentURL(SvtModuleOptions::E_DATABASE);
472 bCreateNew = sFactoryName.match(_rURL);
474 Reference< XDocumentDataSource > xDocumentDataSource;
475 bool bNewAndInteractive = false;
476 if ( bCreateNew )
478 bNewAndInteractive = lcl_urlAllowsInteraction( m_aContext, _rURL );
479 xDocumentDataSource.set( xDatabaseContext->createInstance(), UNO_QUERY_THROW );
481 else
483 ::comphelper::NamedValueCollection aCreationArgs;
484 aCreationArgs.put( (::rtl::OUString)INFO_POOLURL, sSalvagedURL );
485 xDocumentDataSource.set( xDatabaseContext->createInstanceWithArguments( aCreationArgs.getWrappedNamedValues() ), UNO_QUERY_THROW );
488 xModel.set( xDocumentDataSource->getDatabaseDocument(), UNO_QUERY );
490 if ( bCreateNew && xModel.is() )
492 if ( bNewAndInteractive )
494 bSuccess = impl_executeNewDatabaseWizard( xModel, bStartTableWizard );
496 else
500 Reference< XLoadable > xLoad( xModel, UNO_QUERY_THROW );
501 xLoad->initNew();
502 bSuccess = true;
504 catch( const Exception& )
506 bSuccess = false;
510 // initially select the "Tables" category (will be done below)
511 nInitialSelection = ::com::sun::star::sdb::application::DatabaseObjectContainer::TABLES;
515 if ( !xModel.is() )
517 if ( rListener.is() )
518 rListener->loadCancelled(this);
519 return;
522 if ( !bCreateNew && !xModel->getURL().getLength() )
526 aMediaDesc.put( "FileName", _rURL );
527 Reference< XLoadable > xLoad( xModel, UNO_QUERY_THROW );
529 Sequence< PropertyValue > aResource( aMediaDesc.getPropertyValues() );
530 xLoad->load( aResource );
531 xModel->attachResource( _rURL, aResource );
533 catch(const Exception&)
535 DBG_UNHANDLED_EXCEPTION();
536 bSuccess = sal_False;
540 Reference< XController2 > xController;
541 if ( bSuccess )
545 Reference< XModel2 > xModel2( xModel, UNO_QUERY_THROW );
546 xController = xModel2->createViewController( sViewName, Sequence< PropertyValue >(), rFrame );
548 bSuccess = xController.is();
549 if ( bSuccess )
551 xController->attachModel( xModel );
552 rFrame->setComponent( xController->getComponentWindow(), xController.get() );
553 xController->attachFrame( rFrame );
554 xModel->setCurrentController( xController.get() );
557 catch( const Exception& )
559 DBG_UNHANDLED_EXCEPTION();
560 bSuccess = sal_False;
564 if (bSuccess)
566 if ( rListener.is() )
567 rListener->loadFinished(this);
569 if ( nInitialSelection != -1 )
571 Reference< css::view::XSelectionSupplier > xDocView( xModel->getCurrentController(), UNO_QUERY );
572 if ( xDocView.is() )
574 NamedDatabaseObject aSelection;
575 aSelection.Type = nInitialSelection;
576 xDocView->select( makeAny( aSelection ) );
580 if ( bStartTableWizard )
582 // reset the data of the previous async drop (if any)
583 if ( m_nStartWizard )
584 Application::RemoveUserEvent(m_nStartWizard);
585 m_sCurrentURL = xModel->getURL();
586 m_xMySelf = this;
587 m_nStartWizard = Application::PostUserEvent(LINK(this, DBContentLoader, OnStartTableWizard));
590 else
592 if ( rListener.is() )
593 rListener->loadCancelled( this );
596 if ( !bSuccess )
597 ::comphelper::disposeComponent(xModel);
600 // -----------------------------------------------------------------------
601 void DBContentLoader::cancel(void) throw()
604 // -----------------------------------------------------------------------------
605 IMPL_LINK( DBContentLoader, OnStartTableWizard, void*, /*NOTINTERESTEDIN*/ )
607 m_nStartWizard = 0;
610 Sequence< Any > aWizArgs(1);
611 PropertyValue aValue;
612 aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DatabaseLocation"));
613 aValue.Value <<= m_sCurrentURL;
614 aWizArgs[0] <<= aValue;
616 ::vos::OGuard aGuard(Application::GetSolarMutex());
617 Reference< XJobExecutor > xTableWizard;
618 if ( m_aContext.createComponentWithArguments( "com.sun.star.wizards.table.CallTableWizard", aWizArgs, xTableWizard ) )
619 xTableWizard->trigger(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("start")));
621 catch(const Exception&)
623 OSL_ENSURE(sal_False, "caught an exception while starting the table wizard!");
625 m_xMySelf = NULL;
626 return 0L;
629 // -------------------------------------------------------------------------
630 extern "C" void SAL_CALL createRegistryInfo_DBContentLoader2()
632 static ::dbaxml::OMultiInstanceAutoRegistration< ::dbaxml::DBContentLoader > aAutoRegistration;
634 // -------------------------------------------------------------------------
635 extern "C" void SAL_CALL writeDBLoaderInfo2(void* pRegistryKey)
637 Reference< XRegistryKey> xKey(reinterpret_cast< XRegistryKey*>(pRegistryKey));
639 // register content loader for dispatch
640 ::rtl::OUString aImpl = ::rtl::OUString::createFromAscii("/");
641 aImpl += ::dbaxml::DBContentLoader::getImplementationName_Static();
643 ::rtl::OUString aImpltwo = aImpl;
644 aImpltwo += ::rtl::OUString::createFromAscii("/UNO/Loader");
645 Reference< XRegistryKey> xNewKey = xKey->createKey( aImpltwo );
646 aImpltwo = aImpl;
647 aImpltwo += ::rtl::OUString::createFromAscii("/Loader");
648 Reference< XRegistryKey > xLoaderKey = xKey->createKey( aImpltwo );
649 xNewKey = xLoaderKey->createKey( ::rtl::OUString::createFromAscii("Pattern") );
650 xNewKey->setAsciiValue( ::rtl::OUString::createFromAscii("private:factory/sdatabase") );
652 // -----------------------------------------------------------------------------