Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / dbaccess / source / ui / dlg / dbwizsetup.cxx
blobb318d3586e2fc66fe14c0ceed72bf418a0904c80
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "dbwizsetup.hxx"
31 #include "dsmeta.hxx"
32 #include "DBSetupConnectionPages.hxx"
33 #include "dbadminsetup.hrc"
34 #include "dbu_dlg.hrc"
35 #include "dsitems.hxx"
36 #include "dsnItem.hxx"
38 #include <unotools/pathoptions.hxx>
39 #include <svl/stritem.hxx>
40 #include <svl/eitem.hxx>
41 #include <svl/intitem.hxx>
42 #include <vcl/msgbox.hxx>
43 #include "dbustrings.hrc"
44 #include "adminpages.hxx"
45 #include <sfx2/docfilt.hxx>
46 #include <unotools/ucbhelper.hxx>
47 #include "generalpage.hxx"
48 #include "localresaccess.hxx"
49 #include "stringlistitem.hxx"
50 #include "propertysetitem.hxx"
51 #include <unotools/confignode.hxx>
52 #include "DbAdminImpl.hxx"
53 #include "dbaccess_helpid.hrc"
54 #include "ConnectionPageSetup.hxx"
55 #include "UITools.hxx"
56 #include "dbadmin.hrc"
57 #include "AsyncronousLink.hxx"
58 #include <sfx2/filedlghelper.hxx>
59 #include <cppuhelper/exc_hlp.hxx>
61 /** === begin UNO includes === **/
62 #include <com/sun/star/frame/XStorable.hpp>
63 #include <com/sun/star/uno/XNamingService.hpp>
64 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
65 #include <com/sun/star/sdbc/XDataSource.hpp>
66 #include <com/sun/star/container/XNameAccess.hpp>
67 #include <com/sun/star/sdb/XDocumentDataSource.hpp>
68 #include <com/sun/star/frame/FrameSearchFlag.hpp>
69 #include <com/sun/star/frame/XComponentLoader.hpp>
70 #include <com/sun/star/frame/XModel.hpp>
71 #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
72 #include <com/sun/star/task/XJobExecutor.hpp>
73 #include <com/sun/star/lang/XInitialization.hpp>
74 #include <com/sun/star/sdb/CommandType.hpp>
75 #include <com/sun/star/ucb/InteractiveIOException.hpp>
76 #include <com/sun/star/io/IOException.hpp>
77 #include <com/sun/star/frame/XTerminateListener.hpp>
78 #include <com/sun/star/frame/XDesktop.hpp>
79 #include <com/sun/star/sdbc/XDriverAccess.hpp>
80 #include <com/sun/star/document/MacroExecMode.hpp>
81 #include <com/sun/star/ucb/IOErrorCode.hpp>
82 #include <com/sun/star/task/XInteractionHandler2.hpp>
83 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
86 /** === end UNO includes === **/
88 #include <svl/filenotation.hxx>
89 #include <comphelper/interaction.hxx>
90 #include <comphelper/namedvaluecollection.hxx>
91 #include <comphelper/sequenceashashmap.hxx>
92 #include <tools/diagnose_ex.h>
93 #include <osl/diagnose.h>
94 #include <connectivity/DriversConfig.hxx>
96 #include <memory>
99 //.........................................................................
100 namespace dbaui
102 //.........................................................................
103 using namespace dbtools;
104 using namespace svt;
105 using namespace com::sun::star;
106 using namespace com::sun::star::uno;
107 using namespace com::sun::star::sdbc;
108 using namespace com::sun::star::sdbcx;
109 using namespace com::sun::star::task;
110 using namespace com::sun::star::lang;
111 using namespace com::sun::star::io;
112 using namespace com::sun::star::util;
113 using namespace com::sun::star::beans;
114 using namespace com::sun::star::container;
115 using namespace com::sun::star::frame;
116 using namespace com::sun::star::ucb;
117 using namespace ::com::sun::star::sdb;
118 using namespace ::com::sun::star::document;
119 using namespace ::comphelper;
120 using namespace ::cppu;
122 #define START_PAGE 0
123 #define CONNECTION_PAGE 1
125 OFinalDBPageSetup* pFinalPage;
127 DBG_NAME(ODbTypeWizDialogSetup)
128 //=========================================================================
129 //= ODbTypeWizDialogSetup
130 //=========================================================================
131 //-------------------------------------------------------------------------
132 ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(Window* _pParent
133 ,SfxItemSet* _pItems
134 ,const Reference< XMultiServiceFactory >& _rxORB
135 ,const ::com::sun::star::uno::Any& _aDataSourceName
137 :svt::RoadmapWizard( _pParent, ModuleRes(DLG_DATABASE_WIZARD),
138 WZB_NEXT | WZB_PREVIOUS | WZB_FINISH | WZB_CANCEL | WZB_HELP )
140 , m_pOutSet(NULL)
141 , m_bResetting(sal_False)
142 , m_bApplied(sal_False)
143 , m_bUIEnabled( sal_True )
144 , m_bIsConnectable( sal_False)
145 , m_sRM_IntroText(ModuleRes(STR_PAGETITLE_INTROPAGE))
146 , m_sRM_dBaseText(ModuleRes(STR_PAGETITLE_DBASE))
147 , m_sRM_TextText(ModuleRes(STR_PAGETITLE_TEXT))
148 , m_sRM_MSAccessText(ModuleRes(STR_PAGETITLE_MSACCESS))
149 , m_sRM_LDAPText(ModuleRes(STR_PAGETITLE_LDAP))
150 , m_sRM_ADOText(ModuleRes(STR_PAGETITLE_ADO))
151 , m_sRM_JDBCText(ModuleRes(STR_PAGETITLE_JDBC))
152 , m_sRM_MySQLNativePageTitle(ModuleRes(STR_PAGETITLE_MYSQL_NATIVE))
153 , m_pGeneralPage( NULL )
154 , m_pMySQLIntroPage(NULL)
155 , m_pCollection( NULL )
157 DBG_CTOR(ODbTypeWizDialogSetup,NULL);
158 // no local resources needed anymore
159 m_sRM_MySQLText = String(ModuleRes(STR_PAGETITLE_MYSQL));
160 m_sRM_OracleText = String(ModuleRes(STR_PAGETITLE_ORACLE));
161 m_sRM_ODBCText = String(ModuleRes(STR_PAGETITLE_ODBC));
162 m_sRM_SpreadSheetText = String(ModuleRes(STR_PAGETITLE_SPREADSHEET));
163 m_sRM_AuthentificationText = String(ModuleRes(STR_PAGETITLE_AUTHENTIFICATION));
164 m_sRM_FinalText = String(ModuleRes(STR_PAGETITLE_FINAL));
165 m_sWorkPath = SvtPathOptions().GetWorkPath();
166 pFinalPage = NULL;
167 // extract the datasource type collection from the item set
168 DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _pItems->GetItem(DSID_TYPECOLLECTION));
169 if (pCollectionItem)
170 m_pCollection = pCollectionItem->getCollection();
172 OSL_ENSURE(m_pCollection, "ODbTypeWizDialogSetup::ODbTypeWizDialogSetup : really need a DSN type collection !");
174 FreeResource();
176 m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,this,this));
177 m_pImpl->setDataSourceOrName(_aDataSourceName);
178 Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
179 m_pOutSet = new SfxItemSet( *_pItems->GetPool(), _pItems->GetRanges() );
181 m_pImpl->translateProperties(xDatasource, *m_pOutSet);
183 SetPageSizePixel(LogicToPixel(::Size(WIZARD_PAGE_X, WIZARD_PAGE_Y), MAP_APPFONT));
184 ShowButtonFixedLine(sal_True);
185 defaultButton(WZB_NEXT);
186 enableButtons(WZB_FINISH, sal_True);
187 enableAutomaticNextButtonState();
189 ::dbaccess::ODsnTypeCollection::TypeIterator aIter = m_pCollection->begin();
190 ::dbaccess::ODsnTypeCollection::TypeIterator aEnd = m_pCollection->end();
191 for(PathId i = 1;aIter != aEnd;++aIter,++i)
193 const ::rtl::OUString sURLPrefix = aIter.getURLPrefix();
194 svt::RoadmapWizardTypes::WizardPath aPath;
195 aPath.push_back(PAGE_DBSETUPWIZARD_INTRO);
196 m_pCollection->fillPageIds(sURLPrefix,aPath);
197 aPath.push_back(PAGE_DBSETUPWIZARD_AUTHENTIFICATION);
198 aPath.push_back(PAGE_DBSETUPWIZARD_FINAL);
200 declareAuthDepPath(sURLPrefix,i,aPath);
203 svt::RoadmapWizardTypes::WizardPath aPath;
204 aPath.push_back(PAGE_DBSETUPWIZARD_INTRO);
205 declarePath( static_cast<PathId>(m_pCollection->size()+1), aPath);
207 m_pPrevPage->SetHelpId(HID_DBWIZ_PREVIOUS);
208 m_pNextPage->SetHelpId(HID_DBWIZ_NEXT);
209 m_pCancel->SetHelpId(HID_DBWIZ_CANCEL);
210 m_pFinish->SetHelpId(HID_DBWIZ_FINISH);
211 m_pHelp->SetUniqueId(UID_DBWIZ_HELP);
212 SetRoadmapInteractive( sal_True );
213 ActivatePage();
216 void ODbTypeWizDialogSetup::declareAuthDepPath( const ::rtl::OUString& _sURL, PathId _nPathId, const svt::RoadmapWizardTypes::WizardPath& _rPaths)
218 bool bHasAuthentication = DataSourceMetaData::getAuthentication( _sURL ) != AuthNone;
220 // collect the elements of the path
221 WizardPath aPath;
223 svt::RoadmapWizardTypes::WizardPath::const_iterator aIter = _rPaths.begin();
224 svt::RoadmapWizardTypes::WizardPath::const_iterator aEnd = _rPaths.end();
225 for(;aIter != aEnd;++aIter)
227 if ( bHasAuthentication || ( *aIter != PAGE_DBSETUPWIZARD_AUTHENTIFICATION ) )
228 aPath.push_back( *aIter );
231 // call base method
232 ::svt::RoadmapWizard::declarePath( _nPathId, aPath );
235 String ODbTypeWizDialogSetup::getStateDisplayName( WizardState _nState ) const
237 String sRoadmapItem;
238 switch( _nState )
240 case PAGE_DBSETUPWIZARD_INTRO:
241 sRoadmapItem = m_sRM_IntroText;
242 break;
244 case PAGE_DBSETUPWIZARD_DBASE:
245 sRoadmapItem = m_sRM_dBaseText;
246 break;
247 case PAGE_DBSETUPWIZARD_ADO:
248 sRoadmapItem = m_sRM_ADOText;
249 break;
250 case PAGE_DBSETUPWIZARD_TEXT:
251 sRoadmapItem = m_sRM_TextText;
252 break;
253 case PAGE_DBSETUPWIZARD_MSACCESS:
254 sRoadmapItem = m_sRM_MSAccessText;
255 break;
256 case PAGE_DBSETUPWIZARD_LDAP:
257 sRoadmapItem = m_sRM_LDAPText;
258 break;
259 case PAGE_DBSETUPWIZARD_JDBC:
260 sRoadmapItem = m_sRM_JDBCText;
261 break;
262 case PAGE_DBSETUPWIZARD_ORACLE:
263 sRoadmapItem = m_sRM_OracleText;
264 break;
265 case PAGE_DBSETUPWIZARD_MYSQL_INTRO:
266 sRoadmapItem = m_sRM_MySQLText;
267 break;
268 case PAGE_DBSETUPWIZARD_MYSQL_JDBC:
269 sRoadmapItem = m_sRM_JDBCText;
270 break;
271 case PAGE_DBSETUPWIZARD_MYSQL_NATIVE:
272 sRoadmapItem = m_sRM_MySQLNativePageTitle;
273 break;
274 case PAGE_DBSETUPWIZARD_MYSQL_ODBC:
275 sRoadmapItem = m_sRM_ODBCText;
276 break;
277 case PAGE_DBSETUPWIZARD_ODBC:
278 sRoadmapItem = m_sRM_ODBCText;
279 break;
280 case PAGE_DBSETUPWIZARD_SPREADSHEET:
281 sRoadmapItem = m_sRM_SpreadSheetText;
282 break;
283 case PAGE_DBSETUPWIZARD_AUTHENTIFICATION:
284 sRoadmapItem = m_sRM_AuthentificationText;
285 break;
286 case PAGE_DBSETUPWIZARD_USERDEFINED:
288 LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG);
289 sRoadmapItem = String(ModuleRes(STR_PAGETITLE_CONNECTION));
291 break;
292 case PAGE_DBSETUPWIZARD_FINAL:
293 sRoadmapItem = m_sRM_FinalText;
294 break;
295 default:
296 break;
298 return sRoadmapItem;
301 //-------------------------------------------------------------------------
302 ODbTypeWizDialogSetup::~ODbTypeWizDialogSetup()
304 delete m_pOutSet;
305 DBG_DTOR(ODbTypeWizDialogSetup,NULL);
308 //-------------------------------------------------------------------------
309 IMPL_LINK(ODbTypeWizDialogSetup, OnTypeSelected, OGeneralPage*, /*_pTabPage*/)
311 activateDatabasePath();
312 return 1L;
315 void lcl_removeUnused(const ::comphelper::NamedValueCollection& _aOld,const ::comphelper::NamedValueCollection& _aNew,::comphelper::NamedValueCollection& _rDSInfo)
317 _rDSInfo.merge(_aNew,true);
318 uno::Sequence< beans::NamedValue > aOldValues = _aOld.getNamedValues();
319 const beans::NamedValue* pIter = aOldValues.getConstArray();
320 const beans::NamedValue* pEnd = pIter + aOldValues.getLength();
321 for(;pIter != pEnd;++pIter)
323 if ( !_aNew.has(pIter->Name) )
325 _rDSInfo.remove(pIter->Name);
329 // -----------------------------------------------------------------------------
330 void DataSourceInfoConverter::convert(const ::dbaccess::ODsnTypeCollection* _pCollection,const ::rtl::OUString& _sOldURLPrefix,const ::rtl::OUString& _sNewURLPrefix,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDatasource)
332 if ( _pCollection->getPrefix(_sOldURLPrefix) == _pCollection->getPrefix(_sNewURLPrefix) )
333 return ;
334 uno::Sequence< beans::PropertyValue> aInfo;
335 _xDatasource->getPropertyValue(PROPERTY_INFO) >>= aInfo;
336 ::comphelper::NamedValueCollection aDS(aInfo);
338 ::connectivity::DriversConfig aDriverConfig(m_xFactory);
340 const ::comphelper::NamedValueCollection& aOldProperties = aDriverConfig.getProperties(_sOldURLPrefix);
341 const ::comphelper::NamedValueCollection& aNewProperties = aDriverConfig.getProperties(_sNewURLPrefix);
342 lcl_removeUnused(aOldProperties,aNewProperties,aDS);
344 aDS >>= aInfo;
345 _xDatasource->setPropertyValue(PROPERTY_INFO,uno::makeAny(aInfo));
347 //-------------------------------------------------------------------------
348 void ODbTypeWizDialogSetup::activateDatabasePath()
350 switch ( m_pGeneralPage->GetDatabaseCreationMode() )
352 case OGeneralPage::eCreateNew:
354 sal_Int32 nCreateNewDBIndex = m_pCollection->getIndexOf( m_pCollection->getEmbeddedDatabase() );
355 if ( nCreateNewDBIndex == -1 )
356 nCreateNewDBIndex = m_pCollection->getIndexOf( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:")) );
357 OSL_ENSURE( nCreateNewDBIndex != -1, "ODbTypeWizDialogSetup::activateDatabasePath: the GeneralPage should have prevented this!" );
358 activatePath( static_cast< PathId >( nCreateNewDBIndex + 1 ), sal_True );
360 enableState(PAGE_DBSETUPWIZARD_FINAL, sal_True );
361 enableButtons( WZB_FINISH, sal_True);
363 break;
364 case OGeneralPage::eConnectExternal:
366 ::rtl::OUString sOld = m_sURL;
367 DataSourceInfoConverter aConverter(getORB());
368 m_sURL = m_pGeneralPage->GetSelectedType();
369 aConverter.convert(m_pCollection,sOld,m_sURL,m_pImpl->getCurrentDataSource());
370 ::dbaccess::DATASOURCE_TYPE eType = VerifyDataSourceType(m_pCollection->determineType(m_sURL));
371 if (eType == ::dbaccess::DST_UNKNOWN)
372 eType = m_pCollection->determineType(m_sOldURL);
374 activatePath( static_cast<PathId>(m_pCollection->getIndexOf(m_sURL) + 1), sal_True);
375 updateTypeDependentStates();
377 break;
378 case OGeneralPage::eOpenExisting:
380 activatePath( static_cast<PathId>(m_pCollection->size() + 1), sal_True );
381 enableButtons( WZB_FINISH, m_pGeneralPage->GetSelectedDocument().sURL.Len() != 0 );
383 break;
384 default:
385 OSL_FAIL( "ODbTypeWizDialogSetup::activateDatabasePath: unknown creation mode!" );
388 enableButtons( WZB_NEXT, m_pGeneralPage->GetDatabaseCreationMode() != OGeneralPage::eOpenExisting );
389 // TODO: this should go into the base class. Point is, we activate a path whose *last*
390 // step is also the current one. The base class should automatically disable
391 // the Next button in such a case. However, not for this patch ...
394 //-------------------------------------------------------------------------
395 void ODbTypeWizDialogSetup::updateTypeDependentStates()
397 sal_Bool bDoEnable = sal_False;
398 sal_Bool bIsConnectionRequired = IsConnectionUrlRequired();
399 if (!bIsConnectionRequired)
401 bDoEnable = sal_True;
403 else if ( m_sURL == m_sOldURL )
405 bDoEnable = m_bIsConnectable;
407 enableState(PAGE_DBSETUPWIZARD_AUTHENTIFICATION, bDoEnable);
408 enableState(PAGE_DBSETUPWIZARD_FINAL, bDoEnable );
409 enableButtons( WZB_FINISH, bDoEnable);
413 //-------------------------------------------------------------------------
414 sal_Bool ODbTypeWizDialogSetup::IsConnectionUrlRequired()
416 return m_pCollection->isConnectionUrlRequired(m_sURL);
419 //-------------------------------------------------------------------------
420 void ODbTypeWizDialogSetup::resetPages(const Reference< XPropertySet >& _rxDatasource)
422 // remove all items which relate to indirect properties from the input set
423 // (without this, the following may happen: select an arbitrary data source where some indirect properties
424 // are set. Select another data source of the same type, where the indirect props are not set (yet). Then,
425 // the indirect property values of the first ds are shown in the second ds ...)
426 const ODbDataSourceAdministrationHelper::MapInt2String& rMap = m_pImpl->getIndirectProperties();
427 for ( ODbDataSourceAdministrationHelper::ConstMapInt2StringIterator aIndirect = rMap.begin();
428 aIndirect != rMap.end();
429 ++aIndirect
431 getWriteOutputSet()->ClearItem( (sal_uInt16)aIndirect->first );
433 // extract all relevant data from the property set of the data source
434 m_pImpl->translateProperties(_rxDatasource, *getWriteOutputSet());
436 // -----------------------------------------------------------------------------
437 const SfxItemSet* ODbTypeWizDialogSetup::getOutputSet() const
439 return m_pOutSet;
441 // -----------------------------------------------------------------------------
442 SfxItemSet* ODbTypeWizDialogSetup::getWriteOutputSet()
444 return m_pOutSet;
446 // -----------------------------------------------------------------------------
447 ::std::pair< Reference<XConnection>,sal_Bool> ODbTypeWizDialogSetup::createConnection()
449 return m_pImpl->createConnection();
451 // -----------------------------------------------------------------------------
452 Reference< XMultiServiceFactory > ODbTypeWizDialogSetup::getORB() const
454 return m_pImpl->getORB();
456 // -----------------------------------------------------------------------------
457 Reference< XDriver > ODbTypeWizDialogSetup::getDriver()
459 return m_pImpl->getDriver();
463 ::dbaccess::DATASOURCE_TYPE ODbTypeWizDialogSetup::VerifyDataSourceType(const ::dbaccess::DATASOURCE_TYPE _DatabaseType) const
465 ::dbaccess::DATASOURCE_TYPE LocDatabaseType = _DatabaseType;
466 if ((LocDatabaseType == ::dbaccess::DST_MYSQL_JDBC) || (LocDatabaseType == ::dbaccess::DST_MYSQL_ODBC) || (LocDatabaseType == ::dbaccess::DST_MYSQL_NATIVE))
468 if (m_pMySQLIntroPage != NULL)
470 switch( m_pMySQLIntroPage->getMySQLMode() )
472 case OMySQLIntroPageSetup::VIA_JDBC:
473 return ::dbaccess::DST_MYSQL_JDBC;
474 case OMySQLIntroPageSetup::VIA_NATIVE:
475 return ::dbaccess::DST_MYSQL_NATIVE;
476 case OMySQLIntroPageSetup::VIA_ODBC:
477 return ::dbaccess::DST_MYSQL_ODBC;
481 return LocDatabaseType;
486 // -----------------------------------------------------------------------------
487 ::rtl::OUString ODbTypeWizDialogSetup::getDatasourceType(const SfxItemSet& _rSet) const
489 ::rtl::OUString sRet = m_pImpl->getDatasourceType(_rSet);
490 if (m_pMySQLIntroPage != NULL && m_pMySQLIntroPage->IsVisible() )
492 switch( m_pMySQLIntroPage->getMySQLMode() )
494 case OMySQLIntroPageSetup::VIA_JDBC:
495 sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:jdbc:"));
496 break;
497 case OMySQLIntroPageSetup::VIA_NATIVE:
498 sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:"));
499 break;
500 case OMySQLIntroPageSetup::VIA_ODBC:
501 sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:odbc:"));
502 break;
505 return sRet;
508 // -----------------------------------------------------------------------------
509 void ODbTypeWizDialogSetup::clearPassword()
511 m_pImpl->clearPassword();
514 // -----------------------------------------------------------------------------
515 TabPage* ODbTypeWizDialogSetup::createPage(WizardState _nState)
517 SfxTabPage* pFirstPage;
518 OGenericAdministrationPage* pPage = NULL;
519 switch(_nState)
521 case PAGE_DBSETUPWIZARD_INTRO:
522 pFirstPage = OGeneralPage::Create(this,*m_pOutSet, sal_True);
523 pPage = static_cast<OGenericAdministrationPage*> (pFirstPage);
524 m_pGeneralPage = static_cast<OGeneralPage*>(pFirstPage);
525 m_pGeneralPage->SetTypeSelectHandler(LINK(this, ODbTypeWizDialogSetup, OnTypeSelected));
526 m_pGeneralPage->SetCreationModeHandler(LINK( this, ODbTypeWizDialogSetup, OnChangeCreationMode ) );
527 m_pGeneralPage->SetDocumentSelectionHandler(LINK( this, ODbTypeWizDialogSetup, OnRecentDocumentSelected ) );
528 m_pGeneralPage->SetChooseDocumentHandler(LINK( this, ODbTypeWizDialogSetup, OnSingleDocumentChosen ) );
529 break;
531 case PAGE_DBSETUPWIZARD_DBASE:
532 pPage = OConnectionTabPageSetup::CreateDbaseTabPage(this,*m_pOutSet);
533 break;
535 case PAGE_DBSETUPWIZARD_ADO:
536 pPage = OConnectionTabPageSetup::CreateADOTabPage( this, *m_pOutSet);
537 break;
539 case PAGE_DBSETUPWIZARD_TEXT:
540 pPage = OTextConnectionPageSetup::CreateTextTabPage(this,*m_pOutSet);
541 break;
543 case PAGE_DBSETUPWIZARD_ODBC:
544 pPage = OConnectionTabPageSetup::CreateODBCTabPage( this, *m_pOutSet);
545 break;
547 case PAGE_DBSETUPWIZARD_JDBC:
548 pPage = OJDBCConnectionPageSetup::CreateJDBCTabPage( this, *m_pOutSet);
549 break;
551 case PAGE_DBSETUPWIZARD_MYSQL_ODBC:
552 m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:odbc:")))));
553 pPage = OConnectionTabPageSetup::CreateODBCTabPage( this, *m_pOutSet);
554 break;
556 case PAGE_DBSETUPWIZARD_MYSQL_JDBC:
557 m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:jdbc:")))));
558 pPage = OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage( this, *m_pOutSet);
559 break;
560 case PAGE_DBSETUPWIZARD_MYSQL_NATIVE:
561 m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:")))));
562 pPage = MySQLNativeSetupPage::Create( this, *m_pOutSet);
563 break;
565 case PAGE_DBSETUPWIZARD_ORACLE:
566 pPage = OGeneralSpecialJDBCConnectionPageSetup::CreateOracleJDBCTabPage( this, *m_pOutSet);
567 break;
569 case PAGE_DBSETUPWIZARD_LDAP:
570 pPage = OLDAPConnectionPageSetup::CreateLDAPTabPage(this,*m_pOutSet);
571 break;
573 case PAGE_DBSETUPWIZARD_SPREADSHEET: /// first user defined driver
574 pPage = OSpreadSheetConnectionPageSetup::CreateSpreadSheetTabPage(this,*m_pOutSet);
575 break;
577 case PAGE_DBSETUPWIZARD_MSACCESS:
578 pPage = OConnectionTabPageSetup::CreateMSAccessTabPage(this,*m_pOutSet);
579 break;
580 case PAGE_DBSETUPWIZARD_MYSQL_INTRO:
581 m_pMySQLIntroPage = OMySQLIntroPageSetup::CreateMySQLIntroTabPage(this,*m_pOutSet);
582 m_pMySQLIntroPage->SetClickHdl(LINK( this, ODbTypeWizDialogSetup, ImplClickHdl ) );
583 pPage = m_pMySQLIntroPage;
584 break;
586 case PAGE_DBSETUPWIZARD_AUTHENTIFICATION:
587 pPage = OAuthentificationPageSetup::CreateAuthentificationTabPage(this,*m_pOutSet);
588 break;
590 case PAGE_DBSETUPWIZARD_USERDEFINED:
591 pPage = OConnectionTabPageSetup::CreateUserDefinedTabPage(this,*m_pOutSet);
592 break;
594 case PAGE_DBSETUPWIZARD_FINAL:
595 pPage = OFinalDBPageSetup::CreateFinalDBTabPageSetup(this,*m_pOutSet);
596 pFinalPage = static_cast<OFinalDBPageSetup*> (pPage);
597 break;
600 if ((_nState != PAGE_DBSETUPWIZARD_INTRO) && (_nState != PAGE_DBSETUPWIZARD_AUTHENTIFICATION))
602 pPage->SetModifiedHandler(LINK( this, ODbTypeWizDialogSetup, ImplModifiedHdl ) );
605 if ( pPage )
607 pPage->SetServiceFactory(m_pImpl->getORB());
608 pPage->SetAdminDialog(this, this);
610 defaultButton( _nState == PAGE_DBSETUPWIZARD_FINAL ? WZB_FINISH : WZB_NEXT );
611 enableButtons( WZB_FINISH, _nState == PAGE_DBSETUPWIZARD_FINAL );
612 enableButtons( WZB_NEXT, _nState == PAGE_DBSETUPWIZARD_FINAL ? sal_False : sal_True);
613 pPage->Show();
615 return pPage;
619 IMPL_LINK(ODbTypeWizDialogSetup, ImplModifiedHdl, OGenericAdministrationPage*, _pConnectionPageSetup)
621 m_bIsConnectable = _pConnectionPageSetup->GetRoadmapStateValue( );
622 enableState(PAGE_DBSETUPWIZARD_FINAL, m_bIsConnectable);
623 enableState(PAGE_DBSETUPWIZARD_AUTHENTIFICATION, m_bIsConnectable);
624 if (getCurrentState() == PAGE_DBSETUPWIZARD_FINAL)
625 enableButtons( WZB_FINISH, sal_True);
626 else
627 enableButtons( WZB_FINISH, m_bIsConnectable);
628 enableButtons( WZB_NEXT, m_bIsConnectable && (getCurrentState() != PAGE_DBSETUPWIZARD_FINAL));
629 return sal_True;
633 // -----------------------------------------------------------------------------
634 IMPL_LINK(ODbTypeWizDialogSetup, ImplClickHdl, OMySQLIntroPageSetup*, _pMySQLIntroPageSetup)
636 ::rtl::OUString sURLPrefix;
637 switch( _pMySQLIntroPageSetup->getMySQLMode() )
639 case OMySQLIntroPageSetup::VIA_ODBC:
640 sURLPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:odbc:"));
641 break;
642 case OMySQLIntroPageSetup::VIA_JDBC:
643 sURLPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:jdbc:"));
644 break;
645 case OMySQLIntroPageSetup::VIA_NATIVE:
646 sURLPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:"));
647 break;
649 activatePath( static_cast<PathId>(m_pCollection->getIndexOf(sURLPrefix) + 1), sal_True);
650 return sal_True;
653 // -----------------------------------------------------------------------------
654 IMPL_LINK(ODbTypeWizDialogSetup, OnChangeCreationMode, OGeneralPage*, /*_pGeneralPage*/)
656 activateDatabasePath();
657 return sal_True;
660 // -----------------------------------------------------------------------------
661 IMPL_LINK(ODbTypeWizDialogSetup, OnRecentDocumentSelected, OGeneralPage*, /*_pGeneralPage*/)
663 enableButtons( WZB_FINISH, m_pGeneralPage->GetSelectedDocument().sURL.Len() != 0 );
664 return 0L;
667 // -----------------------------------------------------------------------------
668 IMPL_LINK(ODbTypeWizDialogSetup, OnSingleDocumentChosen, OGeneralPage*, /*_pGeneralPage*/)
670 if ( prepareLeaveCurrentState( eFinish ) )
671 onFinish();
672 return 0L;
675 // -----------------------------------------------------------------------------
676 void ODbTypeWizDialogSetup::enterState(WizardState _nState)
678 m_sURL = m_pImpl->getDatasourceType(*m_pOutSet);
679 RoadmapWizard::enterState(_nState);
680 switch(_nState)
682 case PAGE_DBSETUPWIZARD_INTRO:
683 m_sOldURL = m_sURL;
684 break;
685 case PAGE_DBSETUPWIZARD_FINAL:
686 enableButtons( WZB_FINISH, sal_True);
687 if ( pFinalPage )
688 pFinalPage->enableTableWizardCheckBox(m_pCollection->supportsTableCreation(m_sURL));
689 break;
693 //-------------------------------------------------------------------------
694 sal_Bool ODbTypeWizDialogSetup::saveDatasource()
696 SfxTabPage* pPage = static_cast<SfxTabPage*>(WizardDialog::GetPage(getCurrentState()));
697 if ( pPage )
698 pPage->FillItemSet(*m_pOutSet);
699 return sal_True;
703 // -----------------------------------------------------------------------------
704 sal_Bool ODbTypeWizDialogSetup::leaveState(WizardState _nState)
706 if (_nState == PAGE_DBSETUPWIZARD_MYSQL_INTRO)
707 return sal_True;
708 if ( _nState == PAGE_DBSETUPWIZARD_INTRO && m_sURL != m_sOldURL )
710 resetPages(m_pImpl->getCurrentDataSource());
712 SfxTabPage* pPage = static_cast<SfxTabPage*>(WizardDialog::GetPage(_nState));
713 return pPage && pPage->DeactivatePage(m_pOutSet) != 0;
716 // -----------------------------------------------------------------------------
717 void ODbTypeWizDialogSetup::setTitle(const ::rtl::OUString& /*_sTitle*/)
719 OSL_FAIL( "ODbTypeWizDialogSetup::setTitle: not implemented!" );
720 // why?
723 //-------------------------------------------------------------------------
724 void ODbTypeWizDialogSetup::enableConfirmSettings( bool _bEnable )
726 (void)_bEnable;
729 //-------------------------------------------------------------------------
730 namespace
732 bool lcl_handle( const Reference< XInteractionHandler2 >& _rxHandler, const Any& _rRequest )
734 OInteractionRequest* pRequest = new OInteractionRequest( _rRequest );
735 Reference < XInteractionRequest > xRequest( pRequest );
736 OInteractionAbort* pAbort = new OInteractionAbort;
737 pRequest->addContinuation( pAbort );
739 return _rxHandler->handleInteractionRequest( xRequest );
743 //-------------------------------------------------------------------------
744 sal_Bool ODbTypeWizDialogSetup::SaveDatabaseDocument()
746 Reference< XInteractionHandler2 > xHandler( getORB()->createInstance( SERVICE_TASK_INTERACTION_HANDLER ), UNO_QUERY );
749 if (callSaveAsDialog() == sal_True)
751 m_pImpl->saveChanges(*m_pOutSet);
752 Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
753 Reference< XModel > xModel( getDataSourceOrModel( xDatasource ), UNO_QUERY_THROW );
754 Reference< XStorable > xStore( xModel, UNO_QUERY_THROW );
756 if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eCreateNew )
757 CreateDatabase();
759 ::comphelper::NamedValueCollection aArgs( xModel->getArgs() );
760 aArgs.put( "Overwrite", sal_Bool( sal_True ) );
761 aArgs.put( "InteractionHandler", xHandler );
762 aArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG );
764 ::rtl::OUString sPath = m_pImpl->getDocumentUrl( *m_pOutSet );
765 xStore->storeAsURL( sPath, aArgs.getPropertyValues() );
767 if ( !pFinalPage || pFinalPage->IsDatabaseDocumentToBeRegistered() )
768 RegisterDataSourceByLocation( sPath );
770 return sal_True;
773 catch ( const Exception& e )
775 Any aError = ::cppu::getCaughtException();
776 if ( xHandler.is() )
778 if ( !lcl_handle( xHandler, aError ) )
780 InteractiveIOException aRequest;
781 aRequest.Classification = InteractionClassification_ERROR;
782 if ( aError.isExtractableTo( ::cppu::UnoType< IOException >::get() ) )
783 // assume savint the document faile
784 aRequest.Code = IOErrorCode_CANT_WRITE;
785 else
786 aRequest.Code = IOErrorCode_GENERAL;
787 aRequest.Message = e.Message;
788 aRequest.Context = e.Context;
789 lcl_handle( xHandler, makeAny( aRequest ) );
793 return sal_False;
795 // ------------------------------------------------------------------------
796 sal_Bool ODbTypeWizDialogSetup::IsDatabaseDocumentToBeOpened() const
798 if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eOpenExisting )
799 return sal_True;
801 if ( pFinalPage != NULL )
802 return pFinalPage->IsDatabaseDocumentToBeOpened();
804 return sal_True;
807 // ------------------------------------------------------------------------
808 sal_Bool ODbTypeWizDialogSetup::IsTableWizardToBeStarted() const
810 if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eOpenExisting )
811 return sal_False;
813 if ( pFinalPage != NULL )
814 return pFinalPage->IsTableWizardToBeStarted();
816 return sal_False;
819 //-------------------------------------------------------------------------
820 ::rtl::OUString ODbTypeWizDialogSetup::getDefaultDatabaseType() const
822 ::rtl::OUString sEmbeddedURL = m_pCollection->getEmbeddedDatabase();
823 ::connectivity::DriversConfig aDriverConfig(getORB());
826 if ( aDriverConfig.getDriverFactoryName(sEmbeddedURL).isEmpty() || !m_pImpl->getDriver(sEmbeddedURL).is() )
827 sEmbeddedURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:"));
829 catch(const Exception&)
831 sEmbeddedURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:"));
834 return sEmbeddedURL;
837 //-------------------------------------------------------------------------
838 void ODbTypeWizDialogSetup::CreateDatabase()
840 ::rtl::OUString sUrl;
841 ::rtl::OUString eType = getDefaultDatabaseType();
842 if ( m_pCollection->isEmbeddedDatabase(eType) )
844 sUrl = eType;
845 Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
846 OSL_ENSURE(xDatasource.is(),"DataSource is null!");
847 if ( xDatasource.is() )
848 xDatasource->setPropertyValue( PROPERTY_INFO, makeAny( m_pCollection->getDefaultDBSettings( eType ) ) );
849 m_pImpl->translateProperties(xDatasource,*m_pOutSet);
851 else if ( m_pCollection->isFileSystemBased(eType) )
853 Reference< XSimpleFileAccess > xSimpleFileAccess(getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess"))), UNO_QUERY);
854 INetURLObject aDBPathURL(m_sWorkPath);
855 aDBPathURL.Append(m_aDocURL.getBase());
856 createUniqueFolderName(&aDBPathURL);
857 ::rtl::OUString sPrefix = eType;
858 sUrl = aDBPathURL.GetMainURL( INetURLObject::NO_DECODE);
859 xSimpleFileAccess->createFolder(sUrl);
860 sUrl = sPrefix.concat(sUrl);
862 m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, sUrl));
863 m_pImpl->saveChanges(*m_pOutSet);
866 //-------------------------------------------------------------------------
867 void ODbTypeWizDialogSetup::RegisterDataSourceByLocation(const ::rtl::OUString& _sPath)
869 Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
870 Reference< XNamingService > xDatabaseContext(getORB()->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
871 Reference< XNameAccess > xNameAccessDatabaseContext(xDatabaseContext, UNO_QUERY);
872 INetURLObject aURL( _sPath );
873 ::rtl::OUString sFilename = aURL.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
874 ::rtl::OUString sDatabaseName = ::dbtools::createUniqueName(xNameAccessDatabaseContext, sFilename,sal_False);
875 xDatabaseContext->registerObject(sDatabaseName, xDatasource);
879 //-------------------------------------------------------------------------
880 sal_Bool ODbTypeWizDialogSetup::callSaveAsDialog()
882 sal_Bool bRet = sal_False;
883 ::sfx2::FileDialogHelper aFileDlg(
884 ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
885 0, this);
886 const SfxFilter* pFilter = getStandardDatabaseFilter();
887 if ( pFilter )
889 INetURLObject aWorkURL( m_sWorkPath );
890 aFileDlg.SetDisplayFolder( aWorkURL.GetMainURL( INetURLObject::NO_DECODE ));
892 ::rtl::OUString sDefaultName = String( ModuleRes( STR_DATABASEDEFAULTNAME ) );
893 ::rtl::OUString sExtension = pFilter->GetDefaultExtension();
894 sDefaultName += sExtension.replaceAt( 0, 1, ::rtl::OUString() );
895 aWorkURL.Append( sDefaultName );
896 sDefaultName = createUniqueFileName( aWorkURL );
897 aFileDlg.SetFileName( sDefaultName );
899 aFileDlg.AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension());
900 aFileDlg.SetCurrentFilter(pFilter->GetUIName());
902 if ( aFileDlg.Execute() == ERRCODE_NONE )
904 m_aDocURL = INetURLObject(aFileDlg.GetPath());
906 if( m_aDocURL.GetProtocol() != INET_PROT_NOT_VALID )
908 ::rtl::OUString sFileName = m_aDocURL.GetMainURL( INetURLObject::NO_DECODE );
909 if ( ::utl::UCBContentHelper::IsDocument(sFileName) )
910 ::utl::UCBContentHelper::Kill(sFileName);
911 m_pOutSet->Put(SfxStringItem(DSID_DOCUMENT_URL, sFileName));
912 bRet = sal_True;
915 return bRet;
918 //-------------------------------------------------------------------------
919 void ODbTypeWizDialogSetup::createUniqueFolderName(INetURLObject* pURL)
921 Reference< XSimpleFileAccess > xSimpleFileAccess(getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess"))), UNO_QUERY);
922 :: rtl::OUString sLastSegmentName = pURL->getName();
923 sal_Bool bFolderExists = sal_True;
924 sal_Int32 i = 1;
925 while (bFolderExists == sal_True)
927 bFolderExists = xSimpleFileAccess->isFolder(pURL->GetMainURL( INetURLObject::NO_DECODE ));
928 if (bFolderExists == sal_True)
930 i++;
931 pURL->setName(sLastSegmentName.concat(::rtl::OUString::valueOf(i)));
936 //-------------------------------------------------------------------------
937 String ODbTypeWizDialogSetup::createUniqueFileName(const INetURLObject& _rURL)
939 Reference< XSimpleFileAccess > xSimpleFileAccess(getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess"))), UNO_QUERY);
940 :: rtl::OUString sFilename = _rURL.getName();
941 ::rtl::OUString BaseName = _rURL.getBase();
942 ::rtl::OUString sExtension = _rURL.getExtension();
944 sal_Bool bElementExists = sal_True;
946 INetURLObject aExistenceCheck( _rURL );
947 for ( sal_Int32 i = 1; bElementExists; )
949 bElementExists = xSimpleFileAccess->exists( aExistenceCheck.GetMainURL( INetURLObject::NO_DECODE ) );
950 if ( bElementExists )
952 aExistenceCheck.setBase( BaseName.concat( ::rtl::OUString::valueOf( i ) ) );
953 ++i;
956 return aExistenceCheck.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
958 // -----------------------------------------------------------------------------
959 IWizardPageController* ODbTypeWizDialogSetup::getPageController( TabPage* _pCurrentPage ) const
961 OGenericAdministrationPage* pPage = static_cast<OGenericAdministrationPage*>(_pCurrentPage);
962 return pPage;
965 // -----------------------------------------------------------------------------
966 namespace
968 // .............................................................................
969 typedef ::cppu::WeakImplHelper1 < XTerminateListener
970 > AsyncLoader_Base;
971 class AsyncLoader : public AsyncLoader_Base
973 private:
974 Reference< XComponentLoader > m_xFrameLoader;
975 Reference< XDesktop > m_xDesktop;
976 Reference< XInteractionHandler > m_xInteractionHandler;
977 ::rtl::OUString m_sURL;
978 OAsyncronousLink m_aAsyncCaller;
980 public:
981 AsyncLoader( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rURL );
983 void doLoadAsync();
985 // XTerminateListener
986 virtual void SAL_CALL queryTermination( const EventObject& Event ) throw (TerminationVetoException, RuntimeException);
987 virtual void SAL_CALL notifyTermination( const EventObject& Event ) throw (RuntimeException);
988 // XEventListener
989 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
991 private:
992 DECL_LINK( OnOpenDocument, void* );
995 // .............................................................................
996 AsyncLoader::AsyncLoader( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rURL )
997 :m_sURL( _rURL )
998 ,m_aAsyncCaller( LINK( this, AsyncLoader, OnOpenDocument ) )
1002 m_xDesktop.set( _rxORB->createInstance( SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW );
1003 m_xFrameLoader.set( m_xDesktop, UNO_QUERY_THROW );
1004 m_xInteractionHandler.set(
1005 _rxORB->createInstance(
1006 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.InteractionHandler" ) )
1008 UNO_QUERY_THROW );
1010 catch( const Exception& )
1012 DBG_UNHANDLED_EXCEPTION();
1016 // .............................................................................
1017 void AsyncLoader::doLoadAsync()
1019 OSL_ENSURE( !m_aAsyncCaller.IsRunning(), "AsyncLoader:doLoadAsync: already running!" );
1021 acquire();
1024 if ( m_xDesktop.is() )
1025 m_xDesktop->addTerminateListener( this );
1027 catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
1029 m_aAsyncCaller.Call( NULL );
1032 // .............................................................................
1033 IMPL_LINK( AsyncLoader, OnOpenDocument, void*, /*_pEmptyArg*/ )
1037 if ( m_xFrameLoader.is() )
1039 ::comphelper::NamedValueCollection aLoadArgs;
1040 aLoadArgs.put( "InteractionHandler", m_xInteractionHandler );
1041 aLoadArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG );
1043 Sequence< PropertyValue > aLoadArgPV;
1044 aLoadArgs >>= aLoadArgPV;
1046 m_xFrameLoader->loadComponentFromURL( m_sURL,
1047 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_default" ) ),
1048 FrameSearchFlag::ALL,
1049 aLoadArgPV
1053 catch( const Exception& )
1055 // do not assert.
1056 // Such an exception happens for instance of the to-be-loaded document does not exist anymore.
1061 if ( m_xDesktop.is() )
1062 m_xDesktop->removeTerminateListener( this );
1064 catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
1066 release();
1067 return 0L;
1070 // .............................................................................
1071 void SAL_CALL AsyncLoader::queryTermination( const EventObject& /*Event*/ ) throw (TerminationVetoException, RuntimeException)
1073 throw TerminationVetoException();
1076 // .............................................................................
1077 void SAL_CALL AsyncLoader::notifyTermination( const EventObject& /*Event*/ ) throw (RuntimeException)
1080 // .............................................................................
1081 void SAL_CALL AsyncLoader::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
1086 // -----------------------------------------------------------------------------
1087 sal_Bool ODbTypeWizDialogSetup::onFinish()
1089 if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eOpenExisting )
1091 // we're not going to re-use the XModel we have - since the document the user
1092 // wants us to load could be a non-database document. Instead, we asynchronously
1093 // open the selected document. Thus, the wizard's return value is RET_CANCEL,
1094 // which means to not continue loading the database document
1095 if ( !OWizardMachine::Finnish( RET_CANCEL ) )
1096 return sal_False;
1098 Reference< XComponentLoader > xFrameLoader;
1101 AsyncLoader* pAsyncLoader = new AsyncLoader( getORB(), m_pGeneralPage->GetSelectedDocument().sURL );
1102 ::rtl::Reference< AsyncLoader > xKeepAlive( pAsyncLoader );
1103 pAsyncLoader->doLoadAsync();
1105 catch( const Exception& )
1107 DBG_UNHANDLED_EXCEPTION();
1110 return sal_True;
1113 if (getCurrentState() != PAGE_DBSETUPWIZARD_FINAL)
1115 skipUntil(PAGE_DBSETUPWIZARD_FINAL);
1117 if (getCurrentState() == PAGE_DBSETUPWIZARD_FINAL)
1118 return SaveDatabaseDocument() ? OWizardMachine::onFinish() : sal_False;
1119 else
1121 enableButtons( WZB_FINISH, sal_False );
1122 return sal_False;
1126 //.........................................................................
1127 } // namespace dbaui
1128 //.........................................................................
1130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */