1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "dbwizsetup.hxx" 32*cdf0e10cSrcweir #include "dsmeta.hxx" 33*cdf0e10cSrcweir #include "DBSetupConnectionPages.hxx" 34*cdf0e10cSrcweir #include "dbadminsetup.hrc" 35*cdf0e10cSrcweir #include "dbu_dlg.hrc" 36*cdf0e10cSrcweir #include "dsitems.hxx" 37*cdf0e10cSrcweir #include "dsnItem.hxx" 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX 40*cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 41*cdf0e10cSrcweir #endif 42*cdf0e10cSrcweir #ifndef _SFXSTRITEM_HXX 43*cdf0e10cSrcweir #include <svl/stritem.hxx> 44*cdf0e10cSrcweir #endif 45*cdf0e10cSrcweir #ifndef _SFXENUMITEM_HXX 46*cdf0e10cSrcweir #include <svl/eitem.hxx> 47*cdf0e10cSrcweir #endif 48*cdf0e10cSrcweir #ifndef _SFXINTITEM_HXX 49*cdf0e10cSrcweir #include <svl/intitem.hxx> 50*cdf0e10cSrcweir #endif 51*cdf0e10cSrcweir #ifndef _SV_MSGBOX_HXX 52*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 53*cdf0e10cSrcweir #endif 54*cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC 55*cdf0e10cSrcweir #include "dbustrings.hrc" 56*cdf0e10cSrcweir #endif 57*cdf0e10cSrcweir #ifndef _DBAUI_ADMINPAGES_HXX_ 58*cdf0e10cSrcweir #include "adminpages.hxx" 59*cdf0e10cSrcweir #endif 60*cdf0e10cSrcweir #ifndef _SFX_DOCFILT_HACK_HXX 61*cdf0e10cSrcweir #include <sfx2/docfilt.hxx> 62*cdf0e10cSrcweir #endif 63*cdf0e10cSrcweir #ifndef _UNOTOOLS_UCBHELPER_HXX 64*cdf0e10cSrcweir #include <unotools/ucbhelper.hxx> 65*cdf0e10cSrcweir #endif 66*cdf0e10cSrcweir #ifndef _DBAUI_GENERALPAGE_HXX_ 67*cdf0e10cSrcweir #include "generalpage.hxx" 68*cdf0e10cSrcweir #endif 69*cdf0e10cSrcweir #ifndef _DBAUI_LOCALRESACCESS_HXX_ 70*cdf0e10cSrcweir #include "localresaccess.hxx" 71*cdf0e10cSrcweir #endif 72*cdf0e10cSrcweir #ifndef _DBAUI_STRINGLISTITEM_HXX_ 73*cdf0e10cSrcweir #include "stringlistitem.hxx" 74*cdf0e10cSrcweir #endif 75*cdf0e10cSrcweir #ifndef _DBAUI_PROPERTYSETITEM_HXX_ 76*cdf0e10cSrcweir #include "propertysetitem.hxx" 77*cdf0e10cSrcweir #endif 78*cdf0e10cSrcweir #ifndef _UNOTOOLS_CONFIGNODE_HXX_ 79*cdf0e10cSrcweir #include <unotools/confignode.hxx> 80*cdf0e10cSrcweir #endif 81*cdf0e10cSrcweir #ifndef _DBAUI_DBADMINIMPL_HXX_ 82*cdf0e10cSrcweir #include "DbAdminImpl.hxx" 83*cdf0e10cSrcweir #endif 84*cdf0e10cSrcweir #ifndef _DBA_DBACCESS_HELPID_HRC_ 85*cdf0e10cSrcweir #include "dbaccess_helpid.hrc" 86*cdf0e10cSrcweir #endif 87*cdf0e10cSrcweir #ifndef DBAUI_CONNECTIONPAGESETUP_HXX 88*cdf0e10cSrcweir #include "ConnectionPageSetup.hxx" 89*cdf0e10cSrcweir #endif 90*cdf0e10cSrcweir #ifndef DBAUI_TOOLS_HXX 91*cdf0e10cSrcweir #include "UITools.hxx" 92*cdf0e10cSrcweir #endif 93*cdf0e10cSrcweir #ifndef _DBAUI_DBADMIN_HRC_ 94*cdf0e10cSrcweir #include "dbadmin.hrc" 95*cdf0e10cSrcweir #endif 96*cdf0e10cSrcweir #ifndef DBAUI_ASYNCRONOUSLINK_HXX 97*cdf0e10cSrcweir #include "AsyncronousLink.hxx" 98*cdf0e10cSrcweir #endif 99*cdf0e10cSrcweir #ifndef _FILEDLGHELPER_HXX 100*cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx> 101*cdf0e10cSrcweir #endif 102*cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx> 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir /** === begin UNO includes === **/ 105*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_ 106*cdf0e10cSrcweir #include <com/sun/star/frame/XStorable.hpp> 107*cdf0e10cSrcweir #endif 108*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_ 109*cdf0e10cSrcweir #include <com/sun/star/uno/XNamingService.hpp> 110*cdf0e10cSrcweir #endif 111*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ 112*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp> 113*cdf0e10cSrcweir #endif 114*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_ 115*cdf0e10cSrcweir #include <com/sun/star/sdbc/XDataSource.hpp> 116*cdf0e10cSrcweir #endif 117*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ 118*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 119*cdf0e10cSrcweir #endif 120*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_ 121*cdf0e10cSrcweir #include <com/sun/star/sdb/XDocumentDataSource.hpp> 122*cdf0e10cSrcweir #endif 123*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_ 124*cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp> 125*cdf0e10cSrcweir #endif 126*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_ 127*cdf0e10cSrcweir #include <com/sun/star/frame/XComponentLoader.hpp> 128*cdf0e10cSrcweir #endif 129*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_ 130*cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 131*cdf0e10cSrcweir #endif 132*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UCB_XSIMPLEFILEACCESS_HPP_ 133*cdf0e10cSrcweir #include <com/sun/star/ucb/XSimpleFileAccess.hpp> 134*cdf0e10cSrcweir #endif 135*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_TASK_XJOBEXECUTOR_HPP_ 136*cdf0e10cSrcweir #include <com/sun/star/task/XJobExecutor.hpp> 137*cdf0e10cSrcweir #endif 138*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ 139*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 140*cdf0e10cSrcweir #endif 141*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ 142*cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp> 143*cdf0e10cSrcweir #endif 144*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UCB_INTERACTIVEIOEXCEPTION_HPP_ 145*cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveIOException.hpp> 146*cdf0e10cSrcweir #endif 147*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_IO_IOEXCEPTION_HPP_ 148*cdf0e10cSrcweir #include <com/sun/star/io/IOException.hpp> 149*cdf0e10cSrcweir #endif 150*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FRAME_XTERMINATELISTENER_HPP_ 151*cdf0e10cSrcweir #include <com/sun/star/frame/XTerminateListener.hpp> 152*cdf0e10cSrcweir #endif 153*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_ 154*cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp> 155*cdf0e10cSrcweir #endif 156*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_ 157*cdf0e10cSrcweir #include <com/sun/star/sdbc/XDriverAccess.hpp> 158*cdf0e10cSrcweir #endif 159*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_DOCUMENT_MACROEXECMODE_HPP_ 160*cdf0e10cSrcweir #include <com/sun/star/document/MacroExecMode.hpp> 161*cdf0e10cSrcweir #endif 162*cdf0e10cSrcweir #include <com/sun/star/ucb/IOErrorCode.hpp> 163*cdf0e10cSrcweir #include <com/sun/star/task/XInteractionHandler2.hpp> 164*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir /** === end UNO includes === **/ 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir #include <svl/filenotation.hxx> 170*cdf0e10cSrcweir #include <comphelper/interaction.hxx> 171*cdf0e10cSrcweir #include <comphelper/namedvaluecollection.hxx> 172*cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx> 173*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 174*cdf0e10cSrcweir #include <connectivity/DriversConfig.hxx> 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir #include <memory> 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir //......................................................................... 180*cdf0e10cSrcweir namespace dbaui 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir //......................................................................... 183*cdf0e10cSrcweir using namespace dbtools; 184*cdf0e10cSrcweir using namespace svt; 185*cdf0e10cSrcweir using namespace com::sun::star; 186*cdf0e10cSrcweir using namespace com::sun::star::uno; 187*cdf0e10cSrcweir using namespace com::sun::star::sdbc; 188*cdf0e10cSrcweir using namespace com::sun::star::sdbcx; 189*cdf0e10cSrcweir using namespace com::sun::star::task; 190*cdf0e10cSrcweir using namespace com::sun::star::lang; 191*cdf0e10cSrcweir using namespace com::sun::star::io; 192*cdf0e10cSrcweir using namespace com::sun::star::util; 193*cdf0e10cSrcweir using namespace com::sun::star::beans; 194*cdf0e10cSrcweir using namespace com::sun::star::container; 195*cdf0e10cSrcweir using namespace com::sun::star::frame; 196*cdf0e10cSrcweir using namespace com::sun::star::ucb; 197*cdf0e10cSrcweir using namespace ::com::sun::star::sdb; 198*cdf0e10cSrcweir using namespace ::com::sun::star::document; 199*cdf0e10cSrcweir using namespace ::comphelper; 200*cdf0e10cSrcweir using namespace ::cppu; 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir #define START_PAGE 0 203*cdf0e10cSrcweir #define CONNECTION_PAGE 1 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir //#define DBASE_PATH 1 209*cdf0e10cSrcweir //#define TEXT_PATH 2 210*cdf0e10cSrcweir //#define MSACCESS_PATH 3 211*cdf0e10cSrcweir //#define LDAP_PATH 4 212*cdf0e10cSrcweir //#define ADABAS_PATH 5 213*cdf0e10cSrcweir //#define ADO_PATH 6 214*cdf0e10cSrcweir //#define JDBC_PATH 7 215*cdf0e10cSrcweir //#define ORACLE_PATH 8 216*cdf0e10cSrcweir //#define MYSQL_JDBC_PATH 9 217*cdf0e10cSrcweir //#define MYSQL_ODBC_PATH 10 218*cdf0e10cSrcweir //#define ODBC_PATH 11 219*cdf0e10cSrcweir //#define SPREADSHEET_PATH 12 220*cdf0e10cSrcweir //#define OUTLOOKEXP_PATH 13 221*cdf0e10cSrcweir //#define OUTLOOK_PATH 14 222*cdf0e10cSrcweir //#define MOZILLA_PATH 15 223*cdf0e10cSrcweir //#define EVOLUTION_PATH 16 224*cdf0e10cSrcweir //#define EVOLUTION_PATH_GROUPWISE 17 225*cdf0e10cSrcweir //#define EVOLUTION_PATH_LDAP 18 226*cdf0e10cSrcweir //#define KAB_PATH 19 227*cdf0e10cSrcweir //#define MACAB_PATH 20 228*cdf0e10cSrcweir //#define THUNDERBIRD_PATH 21 229*cdf0e10cSrcweir //#define CREATENEW_PATH 22 230*cdf0e10cSrcweir //#define USERDEFINED_PATH 23 231*cdf0e10cSrcweir //#define OPEN_DOC_PATH 24 232*cdf0e10cSrcweir //#define MSACCESS2007_PATH 25 233*cdf0e10cSrcweir //#define MYSQL_NATIVE_PATH 26 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir OFinalDBPageSetup* pFinalPage; 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir DBG_NAME(ODbTypeWizDialogSetup) 240*cdf0e10cSrcweir //========================================================================= 241*cdf0e10cSrcweir //= ODbTypeWizDialogSetup 242*cdf0e10cSrcweir //========================================================================= 243*cdf0e10cSrcweir //------------------------------------------------------------------------- 244*cdf0e10cSrcweir ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(Window* _pParent 245*cdf0e10cSrcweir ,SfxItemSet* _pItems 246*cdf0e10cSrcweir ,const Reference< XMultiServiceFactory >& _rxORB 247*cdf0e10cSrcweir ,const ::com::sun::star::uno::Any& _aDataSourceName 248*cdf0e10cSrcweir ) 249*cdf0e10cSrcweir :svt::RoadmapWizard( _pParent, ModuleRes(DLG_DATABASE_WIZARD), 250*cdf0e10cSrcweir WZB_NEXT | WZB_PREVIOUS | WZB_FINISH | WZB_CANCEL | WZB_HELP ) 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir , m_pOutSet(NULL) 253*cdf0e10cSrcweir , m_bResetting(sal_False) 254*cdf0e10cSrcweir , m_bApplied(sal_False) 255*cdf0e10cSrcweir , m_bUIEnabled( sal_True ) 256*cdf0e10cSrcweir , m_bIsConnectable( sal_False) 257*cdf0e10cSrcweir , m_sRM_IntroText(ModuleRes(STR_PAGETITLE_INTROPAGE)) 258*cdf0e10cSrcweir , m_sRM_dBaseText(ModuleRes(STR_PAGETITLE_DBASE)) 259*cdf0e10cSrcweir , m_sRM_TextText(ModuleRes(STR_PAGETITLE_TEXT)) 260*cdf0e10cSrcweir , m_sRM_MSAccessText(ModuleRes(STR_PAGETITLE_MSACCESS)) 261*cdf0e10cSrcweir , m_sRM_LDAPText(ModuleRes(STR_PAGETITLE_LDAP)) 262*cdf0e10cSrcweir , m_sRM_ADABASText(ModuleRes(STR_PAGETITLE_ADABAS)) 263*cdf0e10cSrcweir , m_sRM_ADOText(ModuleRes(STR_PAGETITLE_ADO)) 264*cdf0e10cSrcweir , m_sRM_JDBCText(ModuleRes(STR_PAGETITLE_JDBC)) 265*cdf0e10cSrcweir , m_sRM_MySQLNativePageTitle(ModuleRes(STR_PAGETITLE_MYSQL_NATIVE)) 266*cdf0e10cSrcweir , m_pGeneralPage( NULL ) 267*cdf0e10cSrcweir , m_pMySQLIntroPage(NULL) 268*cdf0e10cSrcweir , m_pCollection( NULL ) 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir DBG_CTOR(ODbTypeWizDialogSetup,NULL); 271*cdf0e10cSrcweir // no local resources needed anymore 272*cdf0e10cSrcweir m_sRM_MySQLText = String(ModuleRes(STR_PAGETITLE_MYSQL)); 273*cdf0e10cSrcweir m_sRM_OracleText = String(ModuleRes(STR_PAGETITLE_ORACLE)); 274*cdf0e10cSrcweir m_sRM_ODBCText = String(ModuleRes(STR_PAGETITLE_ODBC)); 275*cdf0e10cSrcweir m_sRM_SpreadSheetText = String(ModuleRes(STR_PAGETITLE_SPREADSHEET)); 276*cdf0e10cSrcweir m_sRM_AuthentificationText = String(ModuleRes(STR_PAGETITLE_AUTHENTIFICATION)); 277*cdf0e10cSrcweir m_sRM_FinalText = String(ModuleRes(STR_PAGETITLE_FINAL)); 278*cdf0e10cSrcweir m_sWorkPath = SvtPathOptions().GetWorkPath(); 279*cdf0e10cSrcweir pFinalPage = NULL; 280*cdf0e10cSrcweir // extract the datasource type collection from the item set 281*cdf0e10cSrcweir DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _pItems->GetItem(DSID_TYPECOLLECTION)); 282*cdf0e10cSrcweir if (pCollectionItem) 283*cdf0e10cSrcweir m_pCollection = pCollectionItem->getCollection(); 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir DBG_ASSERT(m_pCollection, "ODbTypeWizDialogSetup::ODbTypeWizDialogSetup : really need a DSN type collection !"); 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir FreeResource(); 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,this,this)); 290*cdf0e10cSrcweir m_pImpl->setDataSourceOrName(_aDataSourceName); 291*cdf0e10cSrcweir Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); 292*cdf0e10cSrcweir m_pOutSet = new SfxItemSet( *_pItems->GetPool(), _pItems->GetRanges() ); 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir m_pImpl->translateProperties(xDatasource, *m_pOutSet); 295*cdf0e10cSrcweir // eType = m_pImpl->getDatasourceType(*m_pOutSet); 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir SetPageSizePixel(LogicToPixel(::Size(WIZARD_PAGE_X, WIZARD_PAGE_Y), MAP_APPFONT)); 298*cdf0e10cSrcweir ShowButtonFixedLine(sal_True); 299*cdf0e10cSrcweir defaultButton(WZB_NEXT); 300*cdf0e10cSrcweir enableButtons(WZB_FINISH, sal_True); 301*cdf0e10cSrcweir enableAutomaticNextButtonState(); 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir ::dbaccess::ODsnTypeCollection::TypeIterator aIter = m_pCollection->begin(); 304*cdf0e10cSrcweir ::dbaccess::ODsnTypeCollection::TypeIterator aEnd = m_pCollection->end(); 305*cdf0e10cSrcweir for(PathId i = 1;aIter != aEnd;++aIter,++i) 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir const ::rtl::OUString sURLPrefix = aIter.getURLPrefix(); 308*cdf0e10cSrcweir svt::RoadmapWizardTypes::WizardPath aPath; 309*cdf0e10cSrcweir aPath.push_back(PAGE_DBSETUPWIZARD_INTRO); 310*cdf0e10cSrcweir m_pCollection->fillPageIds(sURLPrefix,aPath); 311*cdf0e10cSrcweir aPath.push_back(PAGE_DBSETUPWIZARD_AUTHENTIFICATION); 312*cdf0e10cSrcweir aPath.push_back(PAGE_DBSETUPWIZARD_FINAL); 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir declareAuthDepPath(sURLPrefix,i,aPath); 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir svt::RoadmapWizardTypes::WizardPath aPath; 318*cdf0e10cSrcweir aPath.push_back(PAGE_DBSETUPWIZARD_INTRO); 319*cdf0e10cSrcweir declarePath( static_cast<PathId>(m_pCollection->size()+1), aPath); 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir m_pPrevPage->SetHelpId(HID_DBWIZ_PREVIOUS); 322*cdf0e10cSrcweir m_pNextPage->SetHelpId(HID_DBWIZ_NEXT); 323*cdf0e10cSrcweir m_pCancel->SetHelpId(HID_DBWIZ_CANCEL); 324*cdf0e10cSrcweir m_pFinish->SetHelpId(HID_DBWIZ_FINISH); 325*cdf0e10cSrcweir m_pHelp->SetUniqueId(UID_DBWIZ_HELP); 326*cdf0e10cSrcweir SetRoadmapInteractive( sal_True ); 327*cdf0e10cSrcweir ActivatePage(); 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir void ODbTypeWizDialogSetup::declareAuthDepPath( const ::rtl::OUString& _sURL, PathId _nPathId, const svt::RoadmapWizardTypes::WizardPath& _rPaths) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir bool bHasAuthentication = DataSourceMetaData::getAuthentication( _sURL ) != AuthNone; 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir // collect the elements of the path 335*cdf0e10cSrcweir WizardPath aPath; 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir svt::RoadmapWizardTypes::WizardPath::const_iterator aIter = _rPaths.begin(); 338*cdf0e10cSrcweir svt::RoadmapWizardTypes::WizardPath::const_iterator aEnd = _rPaths.end(); 339*cdf0e10cSrcweir for(;aIter != aEnd;++aIter) 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir if ( bHasAuthentication || ( *aIter != PAGE_DBSETUPWIZARD_AUTHENTIFICATION ) ) 342*cdf0e10cSrcweir aPath.push_back( *aIter ); 343*cdf0e10cSrcweir } // for(;aIter != aEnd;++aIter) 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir // call base method 346*cdf0e10cSrcweir ::svt::RoadmapWizard::declarePath( _nPathId, aPath ); 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir String ODbTypeWizDialogSetup::getStateDisplayName( WizardState _nState ) const 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir String sRoadmapItem; 352*cdf0e10cSrcweir switch( _nState ) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_INTRO: 355*cdf0e10cSrcweir sRoadmapItem = m_sRM_IntroText; 356*cdf0e10cSrcweir break; 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_DBASE: 359*cdf0e10cSrcweir sRoadmapItem = m_sRM_dBaseText; 360*cdf0e10cSrcweir break; 361*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_ADO: 362*cdf0e10cSrcweir sRoadmapItem = m_sRM_ADOText; 363*cdf0e10cSrcweir break; 364*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_TEXT: 365*cdf0e10cSrcweir sRoadmapItem = m_sRM_TextText; 366*cdf0e10cSrcweir break; 367*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_MSACCESS: 368*cdf0e10cSrcweir sRoadmapItem = m_sRM_MSAccessText; 369*cdf0e10cSrcweir break; 370*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_LDAP: 371*cdf0e10cSrcweir sRoadmapItem = m_sRM_LDAPText; 372*cdf0e10cSrcweir break; 373*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_ADABAS: 374*cdf0e10cSrcweir sRoadmapItem = m_sRM_ADABASText; 375*cdf0e10cSrcweir break; 376*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_JDBC: 377*cdf0e10cSrcweir sRoadmapItem = m_sRM_JDBCText; 378*cdf0e10cSrcweir break; 379*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_ORACLE: 380*cdf0e10cSrcweir sRoadmapItem = m_sRM_OracleText; 381*cdf0e10cSrcweir break; 382*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_MYSQL_INTRO: 383*cdf0e10cSrcweir sRoadmapItem = m_sRM_MySQLText; 384*cdf0e10cSrcweir break; 385*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_MYSQL_JDBC: 386*cdf0e10cSrcweir sRoadmapItem = m_sRM_JDBCText; 387*cdf0e10cSrcweir break; 388*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_MYSQL_NATIVE: 389*cdf0e10cSrcweir sRoadmapItem = m_sRM_MySQLNativePageTitle; 390*cdf0e10cSrcweir break; 391*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_MYSQL_ODBC: 392*cdf0e10cSrcweir sRoadmapItem = m_sRM_ODBCText; 393*cdf0e10cSrcweir break; 394*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_ODBC: 395*cdf0e10cSrcweir sRoadmapItem = m_sRM_ODBCText; 396*cdf0e10cSrcweir break; 397*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_SPREADSHEET: 398*cdf0e10cSrcweir sRoadmapItem = m_sRM_SpreadSheetText; 399*cdf0e10cSrcweir break; 400*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_AUTHENTIFICATION: 401*cdf0e10cSrcweir sRoadmapItem = m_sRM_AuthentificationText; 402*cdf0e10cSrcweir break; 403*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_USERDEFINED: 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG); 406*cdf0e10cSrcweir sRoadmapItem = String(ModuleRes(STR_PAGETITLE_CONNECTION)); 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir break; 409*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_FINAL: 410*cdf0e10cSrcweir sRoadmapItem = m_sRM_FinalText; 411*cdf0e10cSrcweir break; 412*cdf0e10cSrcweir default: 413*cdf0e10cSrcweir break; 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir return sRoadmapItem; 416*cdf0e10cSrcweir } 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir //------------------------------------------------------------------------- 419*cdf0e10cSrcweir ODbTypeWizDialogSetup::~ODbTypeWizDialogSetup() 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir delete m_pOutSet; 422*cdf0e10cSrcweir DBG_DTOR(ODbTypeWizDialogSetup,NULL); 423*cdf0e10cSrcweir } 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir //------------------------------------------------------------------------- 426*cdf0e10cSrcweir IMPL_LINK(ODbTypeWizDialogSetup, OnTypeSelected, OGeneralPage*, /*_pTabPage*/) 427*cdf0e10cSrcweir { 428*cdf0e10cSrcweir activateDatabasePath(); 429*cdf0e10cSrcweir return 1L; 430*cdf0e10cSrcweir } 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir void lcl_removeUnused(const ::comphelper::NamedValueCollection& _aOld,const ::comphelper::NamedValueCollection& _aNew,::comphelper::NamedValueCollection& _rDSInfo) 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir _rDSInfo.merge(_aNew,true); 435*cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aOldValues = _aOld.getNamedValues(); 436*cdf0e10cSrcweir const beans::NamedValue* pIter = aOldValues.getConstArray(); 437*cdf0e10cSrcweir const beans::NamedValue* pEnd = pIter + aOldValues.getLength(); 438*cdf0e10cSrcweir for(;pIter != pEnd;++pIter) 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir if ( !_aNew.has(pIter->Name) ) 441*cdf0e10cSrcweir { 442*cdf0e10cSrcweir _rDSInfo.remove(pIter->Name); 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 447*cdf0e10cSrcweir 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) 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir if ( _pCollection->getPrefix(_sOldURLPrefix) == _pCollection->getPrefix(_sNewURLPrefix) ) 450*cdf0e10cSrcweir return ; 451*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue> aInfo; 452*cdf0e10cSrcweir _xDatasource->getPropertyValue(PROPERTY_INFO) >>= aInfo; 453*cdf0e10cSrcweir ::comphelper::NamedValueCollection aDS(aInfo); 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir ::connectivity::DriversConfig aDriverConfig(m_xFactory); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir const ::comphelper::NamedValueCollection& aOldProperties = aDriverConfig.getProperties(_sOldURLPrefix); 458*cdf0e10cSrcweir const ::comphelper::NamedValueCollection& aNewProperties = aDriverConfig.getProperties(_sNewURLPrefix); 459*cdf0e10cSrcweir lcl_removeUnused(aOldProperties,aNewProperties,aDS); 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir aDS >>= aInfo; 462*cdf0e10cSrcweir _xDatasource->setPropertyValue(PROPERTY_INFO,uno::makeAny(aInfo)); 463*cdf0e10cSrcweir } 464*cdf0e10cSrcweir //------------------------------------------------------------------------- 465*cdf0e10cSrcweir void ODbTypeWizDialogSetup::activateDatabasePath() 466*cdf0e10cSrcweir { 467*cdf0e10cSrcweir switch ( m_pGeneralPage->GetDatabaseCreationMode() ) 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir case OGeneralPage::eCreateNew: 470*cdf0e10cSrcweir { 471*cdf0e10cSrcweir sal_Int32 nCreateNewDBIndex = m_pCollection->getIndexOf( m_pCollection->getEmbeddedDatabase() ); 472*cdf0e10cSrcweir if ( nCreateNewDBIndex == -1 ) 473*cdf0e10cSrcweir nCreateNewDBIndex = m_pCollection->getIndexOf( ::rtl::OUString::createFromAscii( "sdbc:dbase:" ) ); 474*cdf0e10cSrcweir OSL_ENSURE( nCreateNewDBIndex != -1, "ODbTypeWizDialogSetup::activateDatabasePath: the GeneralPage should have prevented this!" ); 475*cdf0e10cSrcweir activatePath( static_cast< PathId >( nCreateNewDBIndex + 1 ), sal_True ); 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir enableState(PAGE_DBSETUPWIZARD_FINAL, sal_True ); 478*cdf0e10cSrcweir enableButtons( WZB_FINISH, sal_True); 479*cdf0e10cSrcweir } 480*cdf0e10cSrcweir break; 481*cdf0e10cSrcweir case OGeneralPage::eConnectExternal: 482*cdf0e10cSrcweir { 483*cdf0e10cSrcweir ::rtl::OUString sOld = m_sURL; 484*cdf0e10cSrcweir DataSourceInfoConverter aConverter(getORB()); 485*cdf0e10cSrcweir m_sURL = m_pGeneralPage->GetSelectedType(); 486*cdf0e10cSrcweir aConverter.convert(m_pCollection,sOld,m_sURL,m_pImpl->getCurrentDataSource()); 487*cdf0e10cSrcweir ::dbaccess::DATASOURCE_TYPE eType = VerifyDataSourceType(m_pCollection->determineType(m_sURL)); 488*cdf0e10cSrcweir if (eType == ::dbaccess::DST_UNKNOWN) 489*cdf0e10cSrcweir eType = m_pCollection->determineType(m_sOldURL); 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir activatePath( static_cast<PathId>(m_pCollection->getIndexOf(m_sURL) + 1), sal_True); 492*cdf0e10cSrcweir updateTypeDependentStates(); 493*cdf0e10cSrcweir } 494*cdf0e10cSrcweir break; 495*cdf0e10cSrcweir case OGeneralPage::eOpenExisting: 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir activatePath( static_cast<PathId>(m_pCollection->size() + 1), sal_True ); 498*cdf0e10cSrcweir enableButtons( WZB_FINISH, m_pGeneralPage->GetSelectedDocument().sURL.Len() != 0 ); 499*cdf0e10cSrcweir } 500*cdf0e10cSrcweir break; 501*cdf0e10cSrcweir default: 502*cdf0e10cSrcweir DBG_ERROR( "ODbTypeWizDialogSetup::activateDatabasePath: unknown creation mode!" ); 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir enableButtons( WZB_NEXT, m_pGeneralPage->GetDatabaseCreationMode() != OGeneralPage::eOpenExisting ); 506*cdf0e10cSrcweir // TODO: this should go into the base class. Point is, we activate a path whose *last* 507*cdf0e10cSrcweir // step is also the current one. The base class should automatically disable 508*cdf0e10cSrcweir // the Next button in such a case. However, not for this patch ... 509*cdf0e10cSrcweir } 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir //------------------------------------------------------------------------- 512*cdf0e10cSrcweir void ODbTypeWizDialogSetup::updateTypeDependentStates() 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir sal_Bool bDoEnable = sal_False; 515*cdf0e10cSrcweir sal_Bool bIsConnectionRequired = IsConnectionUrlRequired(); 516*cdf0e10cSrcweir if (!bIsConnectionRequired) 517*cdf0e10cSrcweir { 518*cdf0e10cSrcweir bDoEnable = sal_True; 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir else if ( m_sURL == m_sOldURL ) 521*cdf0e10cSrcweir { 522*cdf0e10cSrcweir bDoEnable = m_bIsConnectable; 523*cdf0e10cSrcweir } 524*cdf0e10cSrcweir enableState(PAGE_DBSETUPWIZARD_AUTHENTIFICATION, bDoEnable); 525*cdf0e10cSrcweir enableState(PAGE_DBSETUPWIZARD_FINAL, bDoEnable ); 526*cdf0e10cSrcweir enableButtons( WZB_FINISH, bDoEnable); 527*cdf0e10cSrcweir } 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir 530*cdf0e10cSrcweir //------------------------------------------------------------------------- 531*cdf0e10cSrcweir sal_Bool ODbTypeWizDialogSetup::IsConnectionUrlRequired() 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir return m_pCollection->isConnectionUrlRequired(m_sURL); 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir //------------------------------------------------------------------------- 537*cdf0e10cSrcweir void ODbTypeWizDialogSetup::resetPages(const Reference< XPropertySet >& _rxDatasource) 538*cdf0e10cSrcweir { 539*cdf0e10cSrcweir // remove all items which relate to indirect properties from the input set 540*cdf0e10cSrcweir // (without this, the following may happen: select an arbitrary data source where some indirect properties 541*cdf0e10cSrcweir // are set. Select another data source of the same type, where the indirect props are not set (yet). Then, 542*cdf0e10cSrcweir // the indirect property values of the first ds are shown in the second ds ...) 543*cdf0e10cSrcweir const ODbDataSourceAdministrationHelper::MapInt2String& rMap = m_pImpl->getIndirectProperties(); 544*cdf0e10cSrcweir for ( ODbDataSourceAdministrationHelper::ConstMapInt2StringIterator aIndirect = rMap.begin(); 545*cdf0e10cSrcweir aIndirect != rMap.end(); 546*cdf0e10cSrcweir ++aIndirect 547*cdf0e10cSrcweir ) 548*cdf0e10cSrcweir getWriteOutputSet()->ClearItem( (sal_uInt16)aIndirect->first ); 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir // extract all relevant data from the property set of the data source 551*cdf0e10cSrcweir m_pImpl->translateProperties(_rxDatasource, *getWriteOutputSet()); 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 554*cdf0e10cSrcweir const SfxItemSet* ODbTypeWizDialogSetup::getOutputSet() const 555*cdf0e10cSrcweir { 556*cdf0e10cSrcweir return m_pOutSet; 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 559*cdf0e10cSrcweir SfxItemSet* ODbTypeWizDialogSetup::getWriteOutputSet() 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir return m_pOutSet; 562*cdf0e10cSrcweir } 563*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 564*cdf0e10cSrcweir ::std::pair< Reference<XConnection>,sal_Bool> ODbTypeWizDialogSetup::createConnection() 565*cdf0e10cSrcweir { 566*cdf0e10cSrcweir return m_pImpl->createConnection(); 567*cdf0e10cSrcweir } 568*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 569*cdf0e10cSrcweir Reference< XMultiServiceFactory > ODbTypeWizDialogSetup::getORB() const 570*cdf0e10cSrcweir { 571*cdf0e10cSrcweir return m_pImpl->getORB(); 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 574*cdf0e10cSrcweir Reference< XDriver > ODbTypeWizDialogSetup::getDriver() 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir return m_pImpl->getDriver(); 577*cdf0e10cSrcweir } 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir ::dbaccess::DATASOURCE_TYPE ODbTypeWizDialogSetup::VerifyDataSourceType(const ::dbaccess::DATASOURCE_TYPE _DatabaseType) const 581*cdf0e10cSrcweir { 582*cdf0e10cSrcweir ::dbaccess::DATASOURCE_TYPE LocDatabaseType = _DatabaseType; 583*cdf0e10cSrcweir if ((LocDatabaseType == ::dbaccess::DST_MYSQL_JDBC) || (LocDatabaseType == ::dbaccess::DST_MYSQL_ODBC) || (LocDatabaseType == ::dbaccess::DST_MYSQL_NATIVE)) 584*cdf0e10cSrcweir { 585*cdf0e10cSrcweir if (m_pMySQLIntroPage != NULL) 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir switch( m_pMySQLIntroPage->getMySQLMode() ) 588*cdf0e10cSrcweir { 589*cdf0e10cSrcweir case OMySQLIntroPageSetup::VIA_JDBC: 590*cdf0e10cSrcweir return ::dbaccess::DST_MYSQL_JDBC; 591*cdf0e10cSrcweir case OMySQLIntroPageSetup::VIA_NATIVE: 592*cdf0e10cSrcweir return ::dbaccess::DST_MYSQL_NATIVE; 593*cdf0e10cSrcweir case OMySQLIntroPageSetup::VIA_ODBC: 594*cdf0e10cSrcweir return ::dbaccess::DST_MYSQL_ODBC; 595*cdf0e10cSrcweir } 596*cdf0e10cSrcweir } 597*cdf0e10cSrcweir } 598*cdf0e10cSrcweir return LocDatabaseType; 599*cdf0e10cSrcweir } 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 604*cdf0e10cSrcweir ::rtl::OUString ODbTypeWizDialogSetup::getDatasourceType(const SfxItemSet& _rSet) const 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir ::rtl::OUString sRet = m_pImpl->getDatasourceType(_rSet); 607*cdf0e10cSrcweir if (m_pMySQLIntroPage != NULL && m_pMySQLIntroPage->IsVisible() ) 608*cdf0e10cSrcweir { 609*cdf0e10cSrcweir switch( m_pMySQLIntroPage->getMySQLMode() ) 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir case OMySQLIntroPageSetup::VIA_JDBC: 612*cdf0e10cSrcweir sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:jdbc:")); 613*cdf0e10cSrcweir break; 614*cdf0e10cSrcweir case OMySQLIntroPageSetup::VIA_NATIVE: 615*cdf0e10cSrcweir sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:")); 616*cdf0e10cSrcweir break; 617*cdf0e10cSrcweir case OMySQLIntroPageSetup::VIA_ODBC: 618*cdf0e10cSrcweir sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:odbc:")); 619*cdf0e10cSrcweir break; 620*cdf0e10cSrcweir } 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir return sRet; 623*cdf0e10cSrcweir } 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 626*cdf0e10cSrcweir void ODbTypeWizDialogSetup::clearPassword() 627*cdf0e10cSrcweir { 628*cdf0e10cSrcweir m_pImpl->clearPassword(); 629*cdf0e10cSrcweir } 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 632*cdf0e10cSrcweir TabPage* ODbTypeWizDialogSetup::createPage(WizardState _nState) 633*cdf0e10cSrcweir { 634*cdf0e10cSrcweir SfxTabPage* pFirstPage; 635*cdf0e10cSrcweir OGenericAdministrationPage* pPage = NULL; 636*cdf0e10cSrcweir switch(_nState) 637*cdf0e10cSrcweir { 638*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_INTRO: 639*cdf0e10cSrcweir pFirstPage = OGeneralPage::Create(this,*m_pOutSet, sal_True); 640*cdf0e10cSrcweir pPage = static_cast<OGenericAdministrationPage*> (pFirstPage); 641*cdf0e10cSrcweir m_pGeneralPage = static_cast<OGeneralPage*>(pFirstPage); 642*cdf0e10cSrcweir m_pGeneralPage->SetTypeSelectHandler(LINK(this, ODbTypeWizDialogSetup, OnTypeSelected)); 643*cdf0e10cSrcweir m_pGeneralPage->SetCreationModeHandler(LINK( this, ODbTypeWizDialogSetup, OnChangeCreationMode ) ); 644*cdf0e10cSrcweir m_pGeneralPage->SetDocumentSelectionHandler(LINK( this, ODbTypeWizDialogSetup, OnRecentDocumentSelected ) ); 645*cdf0e10cSrcweir m_pGeneralPage->SetChooseDocumentHandler(LINK( this, ODbTypeWizDialogSetup, OnSingleDocumentChosen ) ); 646*cdf0e10cSrcweir break; 647*cdf0e10cSrcweir 648*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_DBASE: 649*cdf0e10cSrcweir pPage = OConnectionTabPageSetup::CreateDbaseTabPage(this,*m_pOutSet); 650*cdf0e10cSrcweir break; 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_ADO: 653*cdf0e10cSrcweir pPage = OConnectionTabPageSetup::CreateADOTabPage( this, *m_pOutSet); 654*cdf0e10cSrcweir break; 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_TEXT: 657*cdf0e10cSrcweir pPage = OTextConnectionPageSetup::CreateTextTabPage(this,*m_pOutSet); 658*cdf0e10cSrcweir break; 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_ODBC: 661*cdf0e10cSrcweir pPage = OConnectionTabPageSetup::CreateODBCTabPage( this, *m_pOutSet); 662*cdf0e10cSrcweir break; 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_JDBC: 665*cdf0e10cSrcweir pPage = OJDBCConnectionPageSetup::CreateJDBCTabPage( this, *m_pOutSet); 666*cdf0e10cSrcweir break; 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_MYSQL_ODBC: 669*cdf0e10cSrcweir m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:odbc:"))))); 670*cdf0e10cSrcweir pPage = OConnectionTabPageSetup::CreateODBCTabPage( this, *m_pOutSet); 671*cdf0e10cSrcweir break; 672*cdf0e10cSrcweir 673*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_MYSQL_JDBC: 674*cdf0e10cSrcweir m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:jdbc:"))))); 675*cdf0e10cSrcweir pPage = OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage( this, *m_pOutSet); 676*cdf0e10cSrcweir break; 677*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_MYSQL_NATIVE: 678*cdf0e10cSrcweir m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:"))))); 679*cdf0e10cSrcweir pPage = MySQLNativeSetupPage::Create( this, *m_pOutSet); 680*cdf0e10cSrcweir break; 681*cdf0e10cSrcweir 682*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_ORACLE: 683*cdf0e10cSrcweir pPage = OGeneralSpecialJDBCConnectionPageSetup::CreateOracleJDBCTabPage( this, *m_pOutSet); 684*cdf0e10cSrcweir break; 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_ADABAS: 687*cdf0e10cSrcweir pPage = OConnectionTabPageSetup::CreateAdabasTabPage( this, *m_pOutSet); 688*cdf0e10cSrcweir break; 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_LDAP : 691*cdf0e10cSrcweir pPage = OLDAPConnectionPageSetup::CreateLDAPTabPage(this,*m_pOutSet); 692*cdf0e10cSrcweir break; 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_SPREADSHEET: /// first user defined driver 695*cdf0e10cSrcweir pPage = OSpreadSheetConnectionPageSetup::CreateSpreadSheetTabPage(this,*m_pOutSet); 696*cdf0e10cSrcweir break; 697*cdf0e10cSrcweir 698*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_MSACCESS: 699*cdf0e10cSrcweir pPage = OConnectionTabPageSetup::CreateMSAccessTabPage(this,*m_pOutSet); 700*cdf0e10cSrcweir break; 701*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_MYSQL_INTRO: 702*cdf0e10cSrcweir m_pMySQLIntroPage = OMySQLIntroPageSetup::CreateMySQLIntroTabPage(this,*m_pOutSet); 703*cdf0e10cSrcweir m_pMySQLIntroPage->SetClickHdl(LINK( this, ODbTypeWizDialogSetup, ImplClickHdl ) ); 704*cdf0e10cSrcweir pPage = m_pMySQLIntroPage; 705*cdf0e10cSrcweir break; 706*cdf0e10cSrcweir 707*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_AUTHENTIFICATION: 708*cdf0e10cSrcweir pPage = OAuthentificationPageSetup::CreateAuthentificationTabPage(this,*m_pOutSet); 709*cdf0e10cSrcweir break; 710*cdf0e10cSrcweir 711*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_USERDEFINED: 712*cdf0e10cSrcweir pPage = OConnectionTabPageSetup::CreateUserDefinedTabPage(this,*m_pOutSet); 713*cdf0e10cSrcweir break; 714*cdf0e10cSrcweir 715*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_FINAL: 716*cdf0e10cSrcweir pPage = OFinalDBPageSetup::CreateFinalDBTabPageSetup(this,*m_pOutSet); 717*cdf0e10cSrcweir pFinalPage = static_cast<OFinalDBPageSetup*> (pPage); 718*cdf0e10cSrcweir break; 719*cdf0e10cSrcweir } 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir if ((_nState != PAGE_DBSETUPWIZARD_INTRO) && (_nState != PAGE_DBSETUPWIZARD_AUTHENTIFICATION)) 722*cdf0e10cSrcweir { 723*cdf0e10cSrcweir pPage->SetModifiedHandler(LINK( this, ODbTypeWizDialogSetup, ImplModifiedHdl ) ); 724*cdf0e10cSrcweir } 725*cdf0e10cSrcweir 726*cdf0e10cSrcweir if ( pPage ) 727*cdf0e10cSrcweir { 728*cdf0e10cSrcweir pPage->SetServiceFactory(m_pImpl->getORB()); 729*cdf0e10cSrcweir pPage->SetAdminDialog(this, this); 730*cdf0e10cSrcweir 731*cdf0e10cSrcweir defaultButton( _nState == PAGE_DBSETUPWIZARD_FINAL ? WZB_FINISH : WZB_NEXT ); 732*cdf0e10cSrcweir enableButtons( WZB_FINISH, _nState == PAGE_DBSETUPWIZARD_FINAL ); 733*cdf0e10cSrcweir enableButtons( WZB_NEXT, _nState == PAGE_DBSETUPWIZARD_FINAL ? sal_False : sal_True); 734*cdf0e10cSrcweir pPage->Show(); 735*cdf0e10cSrcweir } 736*cdf0e10cSrcweir return pPage; 737*cdf0e10cSrcweir } 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir 740*cdf0e10cSrcweir IMPL_LINK(ODbTypeWizDialogSetup, ImplModifiedHdl, OGenericAdministrationPage*, _pConnectionPageSetup) 741*cdf0e10cSrcweir { 742*cdf0e10cSrcweir m_bIsConnectable = _pConnectionPageSetup->GetRoadmapStateValue( ); 743*cdf0e10cSrcweir enableState(PAGE_DBSETUPWIZARD_FINAL, m_bIsConnectable); 744*cdf0e10cSrcweir enableState(PAGE_DBSETUPWIZARD_AUTHENTIFICATION, m_bIsConnectable); 745*cdf0e10cSrcweir if (getCurrentState() == PAGE_DBSETUPWIZARD_FINAL) 746*cdf0e10cSrcweir enableButtons( WZB_FINISH, sal_True); 747*cdf0e10cSrcweir else 748*cdf0e10cSrcweir enableButtons( WZB_FINISH, m_bIsConnectable); 749*cdf0e10cSrcweir enableButtons( WZB_NEXT, m_bIsConnectable && (getCurrentState() != PAGE_DBSETUPWIZARD_FINAL)); 750*cdf0e10cSrcweir return sal_True; 751*cdf0e10cSrcweir } 752*cdf0e10cSrcweir 753*cdf0e10cSrcweir 754*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 755*cdf0e10cSrcweir IMPL_LINK(ODbTypeWizDialogSetup, ImplClickHdl, OMySQLIntroPageSetup*, _pMySQLIntroPageSetup) 756*cdf0e10cSrcweir { 757*cdf0e10cSrcweir ::rtl::OUString sURLPrefix; 758*cdf0e10cSrcweir switch( _pMySQLIntroPageSetup->getMySQLMode() ) 759*cdf0e10cSrcweir { 760*cdf0e10cSrcweir case OMySQLIntroPageSetup::VIA_ODBC: 761*cdf0e10cSrcweir sURLPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:odbc:")); 762*cdf0e10cSrcweir break; 763*cdf0e10cSrcweir case OMySQLIntroPageSetup::VIA_JDBC: 764*cdf0e10cSrcweir sURLPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:jdbc:")); 765*cdf0e10cSrcweir break; 766*cdf0e10cSrcweir case OMySQLIntroPageSetup::VIA_NATIVE: 767*cdf0e10cSrcweir sURLPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:")); 768*cdf0e10cSrcweir break; 769*cdf0e10cSrcweir } // switch( _pMySQLIntroPageSetup->getMySQLMode() ) 770*cdf0e10cSrcweir activatePath( static_cast<PathId>(m_pCollection->getIndexOf(sURLPrefix) + 1), sal_True); 771*cdf0e10cSrcweir return sal_True; 772*cdf0e10cSrcweir } 773*cdf0e10cSrcweir 774*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 775*cdf0e10cSrcweir IMPL_LINK(ODbTypeWizDialogSetup, OnChangeCreationMode, OGeneralPage*, /*_pGeneralPage*/) 776*cdf0e10cSrcweir { 777*cdf0e10cSrcweir activateDatabasePath(); 778*cdf0e10cSrcweir return sal_True; 779*cdf0e10cSrcweir } 780*cdf0e10cSrcweir 781*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 782*cdf0e10cSrcweir IMPL_LINK(ODbTypeWizDialogSetup, OnRecentDocumentSelected, OGeneralPage*, /*_pGeneralPage*/) 783*cdf0e10cSrcweir { 784*cdf0e10cSrcweir enableButtons( WZB_FINISH, m_pGeneralPage->GetSelectedDocument().sURL.Len() != 0 ); 785*cdf0e10cSrcweir return 0L; 786*cdf0e10cSrcweir } 787*cdf0e10cSrcweir 788*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 789*cdf0e10cSrcweir IMPL_LINK(ODbTypeWizDialogSetup, OnSingleDocumentChosen, OGeneralPage*, /*_pGeneralPage*/) 790*cdf0e10cSrcweir { 791*cdf0e10cSrcweir if ( prepareLeaveCurrentState( eFinish ) ) 792*cdf0e10cSrcweir onFinish(); 793*cdf0e10cSrcweir return 0L; 794*cdf0e10cSrcweir } 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 797*cdf0e10cSrcweir void ODbTypeWizDialogSetup::enterState(WizardState _nState) 798*cdf0e10cSrcweir { 799*cdf0e10cSrcweir m_sURL = m_pImpl->getDatasourceType(*m_pOutSet); 800*cdf0e10cSrcweir RoadmapWizard::enterState(_nState); 801*cdf0e10cSrcweir switch(_nState) 802*cdf0e10cSrcweir { 803*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_INTRO: 804*cdf0e10cSrcweir m_sOldURL = m_sURL; 805*cdf0e10cSrcweir break; 806*cdf0e10cSrcweir case PAGE_DBSETUPWIZARD_FINAL: 807*cdf0e10cSrcweir enableButtons( WZB_FINISH, sal_True); 808*cdf0e10cSrcweir if ( pFinalPage ) 809*cdf0e10cSrcweir pFinalPage->enableTableWizardCheckBox(m_pCollection->supportsTableCreation(m_sURL)); 810*cdf0e10cSrcweir break; 811*cdf0e10cSrcweir } 812*cdf0e10cSrcweir } 813*cdf0e10cSrcweir 814*cdf0e10cSrcweir //------------------------------------------------------------------------- 815*cdf0e10cSrcweir sal_Bool ODbTypeWizDialogSetup::saveDatasource() 816*cdf0e10cSrcweir { 817*cdf0e10cSrcweir SfxTabPage* pPage = static_cast<SfxTabPage*>(WizardDialog::GetPage(getCurrentState())); 818*cdf0e10cSrcweir if ( pPage ) 819*cdf0e10cSrcweir pPage->FillItemSet(*m_pOutSet); 820*cdf0e10cSrcweir return sal_True; 821*cdf0e10cSrcweir } 822*cdf0e10cSrcweir 823*cdf0e10cSrcweir 824*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 825*cdf0e10cSrcweir sal_Bool ODbTypeWizDialogSetup::leaveState(WizardState _nState) 826*cdf0e10cSrcweir { 827*cdf0e10cSrcweir if (_nState == PAGE_DBSETUPWIZARD_MYSQL_INTRO) 828*cdf0e10cSrcweir return sal_True; 829*cdf0e10cSrcweir if ( _nState == PAGE_DBSETUPWIZARD_INTRO && m_sURL != m_sOldURL ) 830*cdf0e10cSrcweir { 831*cdf0e10cSrcweir resetPages(m_pImpl->getCurrentDataSource()); 832*cdf0e10cSrcweir } 833*cdf0e10cSrcweir SfxTabPage* pPage = static_cast<SfxTabPage*>(WizardDialog::GetPage(_nState)); 834*cdf0e10cSrcweir return pPage && pPage->DeactivatePage(m_pOutSet) != 0; 835*cdf0e10cSrcweir } 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 838*cdf0e10cSrcweir void ODbTypeWizDialogSetup::setTitle(const ::rtl::OUString& /*_sTitle*/) 839*cdf0e10cSrcweir { 840*cdf0e10cSrcweir DBG_ERROR( "ODbTypeWizDialogSetup::setTitle: not implemented!" ); 841*cdf0e10cSrcweir // why? 842*cdf0e10cSrcweir } 843*cdf0e10cSrcweir 844*cdf0e10cSrcweir //------------------------------------------------------------------------- 845*cdf0e10cSrcweir void ODbTypeWizDialogSetup::enableConfirmSettings( bool _bEnable ) 846*cdf0e10cSrcweir { 847*cdf0e10cSrcweir (void)_bEnable; 848*cdf0e10cSrcweir } 849*cdf0e10cSrcweir 850*cdf0e10cSrcweir //------------------------------------------------------------------------- 851*cdf0e10cSrcweir namespace 852*cdf0e10cSrcweir { 853*cdf0e10cSrcweir bool lcl_handle( const Reference< XInteractionHandler2 >& _rxHandler, const Any& _rRequest ) 854*cdf0e10cSrcweir { 855*cdf0e10cSrcweir OInteractionRequest* pRequest = new OInteractionRequest( _rRequest ); 856*cdf0e10cSrcweir Reference < XInteractionRequest > xRequest( pRequest ); 857*cdf0e10cSrcweir OInteractionAbort* pAbort = new OInteractionAbort; 858*cdf0e10cSrcweir pRequest->addContinuation( pAbort ); 859*cdf0e10cSrcweir 860*cdf0e10cSrcweir return _rxHandler->handleInteractionRequest( xRequest ); 861*cdf0e10cSrcweir } 862*cdf0e10cSrcweir } 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir //------------------------------------------------------------------------- 865*cdf0e10cSrcweir sal_Bool ODbTypeWizDialogSetup::SaveDatabaseDocument() 866*cdf0e10cSrcweir { 867*cdf0e10cSrcweir Reference< XInteractionHandler2 > xHandler( getORB()->createInstance( SERVICE_TASK_INTERACTION_HANDLER ), UNO_QUERY ); 868*cdf0e10cSrcweir try 869*cdf0e10cSrcweir { 870*cdf0e10cSrcweir if (callSaveAsDialog() == sal_True) 871*cdf0e10cSrcweir { 872*cdf0e10cSrcweir m_pImpl->saveChanges(*m_pOutSet); 873*cdf0e10cSrcweir Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); 874*cdf0e10cSrcweir Reference< XModel > xModel( getDataSourceOrModel( xDatasource ), UNO_QUERY_THROW ); 875*cdf0e10cSrcweir Reference< XStorable > xStore( xModel, UNO_QUERY_THROW ); 876*cdf0e10cSrcweir 877*cdf0e10cSrcweir if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eCreateNew ) 878*cdf0e10cSrcweir CreateDatabase(); 879*cdf0e10cSrcweir 880*cdf0e10cSrcweir ::comphelper::NamedValueCollection aArgs( xModel->getArgs() ); 881*cdf0e10cSrcweir aArgs.put( "Overwrite", sal_Bool( sal_True ) ); 882*cdf0e10cSrcweir aArgs.put( "InteractionHandler", xHandler ); 883*cdf0e10cSrcweir aArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG ); 884*cdf0e10cSrcweir 885*cdf0e10cSrcweir ::rtl::OUString sPath = m_pImpl->getDocumentUrl( *m_pOutSet ); 886*cdf0e10cSrcweir xStore->storeAsURL( sPath, aArgs.getPropertyValues() ); 887*cdf0e10cSrcweir 888*cdf0e10cSrcweir if ( !pFinalPage || pFinalPage->IsDatabaseDocumentToBeRegistered() ) 889*cdf0e10cSrcweir RegisterDataSourceByLocation( sPath ); 890*cdf0e10cSrcweir 891*cdf0e10cSrcweir return sal_True; 892*cdf0e10cSrcweir } 893*cdf0e10cSrcweir } 894*cdf0e10cSrcweir catch ( const Exception& e ) 895*cdf0e10cSrcweir { 896*cdf0e10cSrcweir Any aError = ::cppu::getCaughtException(); 897*cdf0e10cSrcweir if ( xHandler.is() ) 898*cdf0e10cSrcweir { 899*cdf0e10cSrcweir if ( !lcl_handle( xHandler, aError ) ) 900*cdf0e10cSrcweir { 901*cdf0e10cSrcweir InteractiveIOException aRequest; 902*cdf0e10cSrcweir aRequest.Classification = InteractionClassification_ERROR; 903*cdf0e10cSrcweir if ( aError.isExtractableTo( ::cppu::UnoType< IOException >::get() ) ) 904*cdf0e10cSrcweir // assume savint the document faile 905*cdf0e10cSrcweir aRequest.Code = IOErrorCode_CANT_WRITE; 906*cdf0e10cSrcweir else 907*cdf0e10cSrcweir aRequest.Code = IOErrorCode_GENERAL; 908*cdf0e10cSrcweir aRequest.Message = e.Message; 909*cdf0e10cSrcweir aRequest.Context = e.Context; 910*cdf0e10cSrcweir lcl_handle( xHandler, makeAny( aRequest ) ); 911*cdf0e10cSrcweir } 912*cdf0e10cSrcweir } 913*cdf0e10cSrcweir } 914*cdf0e10cSrcweir return sal_False; 915*cdf0e10cSrcweir } 916*cdf0e10cSrcweir // ------------------------------------------------------------------------ 917*cdf0e10cSrcweir sal_Bool ODbTypeWizDialogSetup::IsDatabaseDocumentToBeOpened() const 918*cdf0e10cSrcweir { 919*cdf0e10cSrcweir if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eOpenExisting ) 920*cdf0e10cSrcweir return sal_True; 921*cdf0e10cSrcweir 922*cdf0e10cSrcweir if ( pFinalPage != NULL ) 923*cdf0e10cSrcweir return pFinalPage->IsDatabaseDocumentToBeOpened(); 924*cdf0e10cSrcweir 925*cdf0e10cSrcweir return sal_True; 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir 928*cdf0e10cSrcweir // ------------------------------------------------------------------------ 929*cdf0e10cSrcweir sal_Bool ODbTypeWizDialogSetup::IsTableWizardToBeStarted() const 930*cdf0e10cSrcweir { 931*cdf0e10cSrcweir if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eOpenExisting ) 932*cdf0e10cSrcweir return sal_False; 933*cdf0e10cSrcweir 934*cdf0e10cSrcweir if ( pFinalPage != NULL ) 935*cdf0e10cSrcweir return pFinalPage->IsTableWizardToBeStarted(); 936*cdf0e10cSrcweir 937*cdf0e10cSrcweir return sal_False; 938*cdf0e10cSrcweir } 939*cdf0e10cSrcweir 940*cdf0e10cSrcweir //------------------------------------------------------------------------- 941*cdf0e10cSrcweir ::rtl::OUString ODbTypeWizDialogSetup::getDefaultDatabaseType() const 942*cdf0e10cSrcweir { 943*cdf0e10cSrcweir ::rtl::OUString sEmbeddedURL = m_pCollection->getEmbeddedDatabase(); 944*cdf0e10cSrcweir ::connectivity::DriversConfig aDriverConfig(getORB()); 945*cdf0e10cSrcweir try 946*cdf0e10cSrcweir { 947*cdf0e10cSrcweir if ( !aDriverConfig.getDriverFactoryName(sEmbeddedURL).getLength() || !m_pImpl->getDriver(sEmbeddedURL).is() ) 948*cdf0e10cSrcweir sEmbeddedURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:")); 949*cdf0e10cSrcweir } 950*cdf0e10cSrcweir catch(const Exception&) 951*cdf0e10cSrcweir { 952*cdf0e10cSrcweir sEmbeddedURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:")); 953*cdf0e10cSrcweir } 954*cdf0e10cSrcweir 955*cdf0e10cSrcweir return sEmbeddedURL; 956*cdf0e10cSrcweir } 957*cdf0e10cSrcweir 958*cdf0e10cSrcweir //------------------------------------------------------------------------- 959*cdf0e10cSrcweir void ODbTypeWizDialogSetup::CreateDatabase() 960*cdf0e10cSrcweir { 961*cdf0e10cSrcweir ::rtl::OUString sUrl; 962*cdf0e10cSrcweir ::rtl::OUString eType = getDefaultDatabaseType(); 963*cdf0e10cSrcweir if ( m_pCollection->isEmbeddedDatabase(eType) ) 964*cdf0e10cSrcweir { 965*cdf0e10cSrcweir sUrl = eType; 966*cdf0e10cSrcweir Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); 967*cdf0e10cSrcweir OSL_ENSURE(xDatasource.is(),"DataSource is null!"); 968*cdf0e10cSrcweir if ( xDatasource.is() ) 969*cdf0e10cSrcweir xDatasource->setPropertyValue( PROPERTY_INFO, makeAny( m_pCollection->getDefaultDBSettings( eType ) ) ); 970*cdf0e10cSrcweir m_pImpl->translateProperties(xDatasource,*m_pOutSet); 971*cdf0e10cSrcweir } 972*cdf0e10cSrcweir else if ( m_pCollection->isFileSystemBased(eType) ) 973*cdf0e10cSrcweir { 974*cdf0e10cSrcweir Reference< XSimpleFileAccess > xSimpleFileAccess(getORB()->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" )), UNO_QUERY); 975*cdf0e10cSrcweir INetURLObject aDBPathURL(m_sWorkPath); 976*cdf0e10cSrcweir aDBPathURL.Append(m_aDocURL.getBase()); 977*cdf0e10cSrcweir createUniqueFolderName(&aDBPathURL); 978*cdf0e10cSrcweir ::rtl::OUString sPrefix = eType; 979*cdf0e10cSrcweir sUrl = aDBPathURL.GetMainURL( INetURLObject::NO_DECODE); 980*cdf0e10cSrcweir xSimpleFileAccess->createFolder(sUrl); 981*cdf0e10cSrcweir //OFileNotation aFileNotation(sUrl); 982*cdf0e10cSrcweir //sUrl = aFileNotation.get(OFileNotation::N_SYSTEM); 983*cdf0e10cSrcweir sUrl = sPrefix.concat(sUrl); 984*cdf0e10cSrcweir } 985*cdf0e10cSrcweir m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, sUrl)); 986*cdf0e10cSrcweir m_pImpl->saveChanges(*m_pOutSet); 987*cdf0e10cSrcweir } 988*cdf0e10cSrcweir 989*cdf0e10cSrcweir //------------------------------------------------------------------------- 990*cdf0e10cSrcweir void ODbTypeWizDialogSetup::RegisterDataSourceByLocation(const ::rtl::OUString& _sPath) 991*cdf0e10cSrcweir { 992*cdf0e10cSrcweir Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); 993*cdf0e10cSrcweir Reference< XNamingService > xDatabaseContext(getORB()->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY); 994*cdf0e10cSrcweir Reference< XNameAccess > xNameAccessDatabaseContext(xDatabaseContext, UNO_QUERY); 995*cdf0e10cSrcweir INetURLObject aURL( _sPath ); 996*cdf0e10cSrcweir ::rtl::OUString sFilename = aURL.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); 997*cdf0e10cSrcweir ::rtl::OUString sDatabaseName = ::dbtools::createUniqueName(xNameAccessDatabaseContext, sFilename,sal_False); 998*cdf0e10cSrcweir xDatabaseContext->registerObject(sDatabaseName, xDatasource); 999*cdf0e10cSrcweir } 1000*cdf0e10cSrcweir 1001*cdf0e10cSrcweir 1002*cdf0e10cSrcweir //------------------------------------------------------------------------- 1003*cdf0e10cSrcweir sal_Bool ODbTypeWizDialogSetup::callSaveAsDialog() 1004*cdf0e10cSrcweir { 1005*cdf0e10cSrcweir sal_Bool bRet = sal_False; 1006*cdf0e10cSrcweir WinBits nBits(WB_STDMODAL|WB_SAVEAS); 1007*cdf0e10cSrcweir ::sfx2::FileDialogHelper aFileDlg( com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION, static_cast<sal_uInt32>(nBits), this); 1008*cdf0e10cSrcweir const SfxFilter* pFilter = getStandardDatabaseFilter(); 1009*cdf0e10cSrcweir if ( pFilter ) 1010*cdf0e10cSrcweir { 1011*cdf0e10cSrcweir INetURLObject aWorkURL( m_sWorkPath ); 1012*cdf0e10cSrcweir aFileDlg.SetDisplayFolder( aWorkURL.GetMainURL( INetURLObject::NO_DECODE )); 1013*cdf0e10cSrcweir 1014*cdf0e10cSrcweir ::rtl::OUString sDefaultName = String( ModuleRes( STR_DATABASEDEFAULTNAME ) ); 1015*cdf0e10cSrcweir ::rtl::OUString sExtension = pFilter->GetDefaultExtension(); 1016*cdf0e10cSrcweir sDefaultName += sExtension.replaceAt( 0, 1, ::rtl::OUString() ); 1017*cdf0e10cSrcweir aWorkURL.Append( sDefaultName ); 1018*cdf0e10cSrcweir sDefaultName = createUniqueFileName( aWorkURL ); 1019*cdf0e10cSrcweir aFileDlg.SetFileName( sDefaultName ); 1020*cdf0e10cSrcweir 1021*cdf0e10cSrcweir aFileDlg.AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension()); 1022*cdf0e10cSrcweir aFileDlg.SetCurrentFilter(pFilter->GetUIName()); 1023*cdf0e10cSrcweir } 1024*cdf0e10cSrcweir if ( aFileDlg.Execute() == ERRCODE_NONE ) 1025*cdf0e10cSrcweir { 1026*cdf0e10cSrcweir m_aDocURL = INetURLObject(aFileDlg.GetPath()); 1027*cdf0e10cSrcweir 1028*cdf0e10cSrcweir if( m_aDocURL.GetProtocol() != INET_PROT_NOT_VALID ) 1029*cdf0e10cSrcweir { 1030*cdf0e10cSrcweir ::rtl::OUString sFileName = m_aDocURL.GetMainURL( INetURLObject::NO_DECODE ); 1031*cdf0e10cSrcweir if ( ::utl::UCBContentHelper::IsDocument(sFileName) ) 1032*cdf0e10cSrcweir ::utl::UCBContentHelper::Kill(sFileName); 1033*cdf0e10cSrcweir m_pOutSet->Put(SfxStringItem(DSID_DOCUMENT_URL, sFileName)); 1034*cdf0e10cSrcweir bRet = sal_True; 1035*cdf0e10cSrcweir } 1036*cdf0e10cSrcweir } 1037*cdf0e10cSrcweir return bRet; 1038*cdf0e10cSrcweir } 1039*cdf0e10cSrcweir 1040*cdf0e10cSrcweir //------------------------------------------------------------------------- 1041*cdf0e10cSrcweir void ODbTypeWizDialogSetup::createUniqueFolderName(INetURLObject* pURL) 1042*cdf0e10cSrcweir { 1043*cdf0e10cSrcweir Reference< XSimpleFileAccess > xSimpleFileAccess(getORB()->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" )), UNO_QUERY); 1044*cdf0e10cSrcweir :: rtl::OUString sLastSegmentName = pURL->getName(); 1045*cdf0e10cSrcweir sal_Bool bFolderExists = sal_True; 1046*cdf0e10cSrcweir sal_Int32 i = 1; 1047*cdf0e10cSrcweir while (bFolderExists == sal_True) 1048*cdf0e10cSrcweir { 1049*cdf0e10cSrcweir bFolderExists = xSimpleFileAccess->isFolder(pURL->GetMainURL( INetURLObject::NO_DECODE )); 1050*cdf0e10cSrcweir if (bFolderExists == sal_True) 1051*cdf0e10cSrcweir { 1052*cdf0e10cSrcweir i++; 1053*cdf0e10cSrcweir pURL->setName(sLastSegmentName.concat(::rtl::OUString::valueOf(i))); 1054*cdf0e10cSrcweir } 1055*cdf0e10cSrcweir } 1056*cdf0e10cSrcweir } 1057*cdf0e10cSrcweir 1058*cdf0e10cSrcweir //------------------------------------------------------------------------- 1059*cdf0e10cSrcweir String ODbTypeWizDialogSetup::createUniqueFileName(const INetURLObject& _rURL) 1060*cdf0e10cSrcweir { 1061*cdf0e10cSrcweir Reference< XSimpleFileAccess > xSimpleFileAccess(getORB()->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" )), UNO_QUERY); 1062*cdf0e10cSrcweir :: rtl::OUString sFilename = _rURL.getName(); 1063*cdf0e10cSrcweir ::rtl::OUString BaseName = _rURL.getBase(); 1064*cdf0e10cSrcweir ::rtl::OUString sExtension = _rURL.getExtension(); 1065*cdf0e10cSrcweir 1066*cdf0e10cSrcweir sal_Bool bElementExists = sal_True; 1067*cdf0e10cSrcweir 1068*cdf0e10cSrcweir INetURLObject aExistenceCheck( _rURL ); 1069*cdf0e10cSrcweir for ( sal_Int32 i = 1; bElementExists; ) 1070*cdf0e10cSrcweir { 1071*cdf0e10cSrcweir bElementExists = xSimpleFileAccess->exists( aExistenceCheck.GetMainURL( INetURLObject::NO_DECODE ) ); 1072*cdf0e10cSrcweir if ( bElementExists ) 1073*cdf0e10cSrcweir { 1074*cdf0e10cSrcweir aExistenceCheck.setBase( BaseName.concat( ::rtl::OUString::valueOf( i ) ) ); 1075*cdf0e10cSrcweir ++i; 1076*cdf0e10cSrcweir } 1077*cdf0e10cSrcweir } 1078*cdf0e10cSrcweir return aExistenceCheck.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); 1079*cdf0e10cSrcweir } 1080*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1081*cdf0e10cSrcweir IWizardPageController* ODbTypeWizDialogSetup::getPageController( TabPage* _pCurrentPage ) const 1082*cdf0e10cSrcweir { 1083*cdf0e10cSrcweir OGenericAdministrationPage* pPage = static_cast<OGenericAdministrationPage*>(_pCurrentPage); 1084*cdf0e10cSrcweir return pPage; 1085*cdf0e10cSrcweir } 1086*cdf0e10cSrcweir 1087*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1088*cdf0e10cSrcweir namespace 1089*cdf0e10cSrcweir { 1090*cdf0e10cSrcweir // ............................................................................. 1091*cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1 < XTerminateListener 1092*cdf0e10cSrcweir > AsyncLoader_Base; 1093*cdf0e10cSrcweir class AsyncLoader : public AsyncLoader_Base 1094*cdf0e10cSrcweir { 1095*cdf0e10cSrcweir private: 1096*cdf0e10cSrcweir Reference< XComponentLoader > m_xFrameLoader; 1097*cdf0e10cSrcweir Reference< XDesktop > m_xDesktop; 1098*cdf0e10cSrcweir Reference< XInteractionHandler > m_xInteractionHandler; 1099*cdf0e10cSrcweir ::rtl::OUString m_sURL; 1100*cdf0e10cSrcweir OAsyncronousLink m_aAsyncCaller; 1101*cdf0e10cSrcweir 1102*cdf0e10cSrcweir public: 1103*cdf0e10cSrcweir AsyncLoader( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rURL ); 1104*cdf0e10cSrcweir 1105*cdf0e10cSrcweir void doLoadAsync(); 1106*cdf0e10cSrcweir 1107*cdf0e10cSrcweir // XTerminateListener 1108*cdf0e10cSrcweir virtual void SAL_CALL queryTermination( const EventObject& Event ) throw (TerminationVetoException, RuntimeException); 1109*cdf0e10cSrcweir virtual void SAL_CALL notifyTermination( const EventObject& Event ) throw (RuntimeException); 1110*cdf0e10cSrcweir // XEventListener 1111*cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 1112*cdf0e10cSrcweir 1113*cdf0e10cSrcweir private: 1114*cdf0e10cSrcweir DECL_LINK( OnOpenDocument, void* ); 1115*cdf0e10cSrcweir }; 1116*cdf0e10cSrcweir 1117*cdf0e10cSrcweir // ............................................................................. 1118*cdf0e10cSrcweir AsyncLoader::AsyncLoader( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rURL ) 1119*cdf0e10cSrcweir :m_sURL( _rURL ) 1120*cdf0e10cSrcweir ,m_aAsyncCaller( LINK( this, AsyncLoader, OnOpenDocument ) ) 1121*cdf0e10cSrcweir { 1122*cdf0e10cSrcweir try 1123*cdf0e10cSrcweir { 1124*cdf0e10cSrcweir m_xDesktop.set( _rxORB->createInstance( SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW ); 1125*cdf0e10cSrcweir m_xFrameLoader.set( m_xDesktop, UNO_QUERY_THROW ); 1126*cdf0e10cSrcweir m_xInteractionHandler.set( 1127*cdf0e10cSrcweir _rxORB->createInstance( 1128*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.InteractionHandler" ) ) 1129*cdf0e10cSrcweir ), 1130*cdf0e10cSrcweir UNO_QUERY_THROW ); 1131*cdf0e10cSrcweir } 1132*cdf0e10cSrcweir catch( const Exception& ) 1133*cdf0e10cSrcweir { 1134*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 1135*cdf0e10cSrcweir } 1136*cdf0e10cSrcweir } 1137*cdf0e10cSrcweir 1138*cdf0e10cSrcweir // ............................................................................. 1139*cdf0e10cSrcweir void AsyncLoader::doLoadAsync() 1140*cdf0e10cSrcweir { 1141*cdf0e10cSrcweir OSL_ENSURE( !m_aAsyncCaller.IsRunning(), "AsyncLoader:doLoadAsync: already running!" ); 1142*cdf0e10cSrcweir 1143*cdf0e10cSrcweir acquire(); 1144*cdf0e10cSrcweir try 1145*cdf0e10cSrcweir { 1146*cdf0e10cSrcweir if ( m_xDesktop.is() ) 1147*cdf0e10cSrcweir m_xDesktop->addTerminateListener( this ); 1148*cdf0e10cSrcweir } 1149*cdf0e10cSrcweir catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } 1150*cdf0e10cSrcweir 1151*cdf0e10cSrcweir m_aAsyncCaller.Call( NULL ); 1152*cdf0e10cSrcweir } 1153*cdf0e10cSrcweir 1154*cdf0e10cSrcweir // ............................................................................. 1155*cdf0e10cSrcweir IMPL_LINK( AsyncLoader, OnOpenDocument, void*, /*_pEmptyArg*/ ) 1156*cdf0e10cSrcweir { 1157*cdf0e10cSrcweir try 1158*cdf0e10cSrcweir { 1159*cdf0e10cSrcweir if ( m_xFrameLoader.is() ) 1160*cdf0e10cSrcweir { 1161*cdf0e10cSrcweir ::comphelper::NamedValueCollection aLoadArgs; 1162*cdf0e10cSrcweir aLoadArgs.put( "InteractionHandler", m_xInteractionHandler ); 1163*cdf0e10cSrcweir aLoadArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG ); 1164*cdf0e10cSrcweir 1165*cdf0e10cSrcweir Sequence< PropertyValue > aLoadArgPV; 1166*cdf0e10cSrcweir aLoadArgs >>= aLoadArgPV; 1167*cdf0e10cSrcweir 1168*cdf0e10cSrcweir m_xFrameLoader->loadComponentFromURL( m_sURL, 1169*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_default" ) ), 1170*cdf0e10cSrcweir FrameSearchFlag::ALL, 1171*cdf0e10cSrcweir aLoadArgPV 1172*cdf0e10cSrcweir ); 1173*cdf0e10cSrcweir } 1174*cdf0e10cSrcweir } 1175*cdf0e10cSrcweir catch( const Exception& ) 1176*cdf0e10cSrcweir { 1177*cdf0e10cSrcweir // do not assert. 1178*cdf0e10cSrcweir // Such an exception happens for instance of the to-be-loaded document does not exist anymore. 1179*cdf0e10cSrcweir } 1180*cdf0e10cSrcweir 1181*cdf0e10cSrcweir try 1182*cdf0e10cSrcweir { 1183*cdf0e10cSrcweir if ( m_xDesktop.is() ) 1184*cdf0e10cSrcweir m_xDesktop->removeTerminateListener( this ); 1185*cdf0e10cSrcweir } 1186*cdf0e10cSrcweir catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } 1187*cdf0e10cSrcweir 1188*cdf0e10cSrcweir release(); 1189*cdf0e10cSrcweir return 0L; 1190*cdf0e10cSrcweir } 1191*cdf0e10cSrcweir 1192*cdf0e10cSrcweir // ............................................................................. 1193*cdf0e10cSrcweir void SAL_CALL AsyncLoader::queryTermination( const EventObject& /*Event*/ ) throw (TerminationVetoException, RuntimeException) 1194*cdf0e10cSrcweir { 1195*cdf0e10cSrcweir throw TerminationVetoException(); 1196*cdf0e10cSrcweir } 1197*cdf0e10cSrcweir 1198*cdf0e10cSrcweir // ............................................................................. 1199*cdf0e10cSrcweir void SAL_CALL AsyncLoader::notifyTermination( const EventObject& /*Event*/ ) throw (RuntimeException) 1200*cdf0e10cSrcweir { 1201*cdf0e10cSrcweir } 1202*cdf0e10cSrcweir // ............................................................................. 1203*cdf0e10cSrcweir void SAL_CALL AsyncLoader::disposing( const EventObject& /*Source*/ ) throw (RuntimeException) 1204*cdf0e10cSrcweir { 1205*cdf0e10cSrcweir } 1206*cdf0e10cSrcweir } 1207*cdf0e10cSrcweir 1208*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1209*cdf0e10cSrcweir sal_Bool ODbTypeWizDialogSetup::onFinish() 1210*cdf0e10cSrcweir { 1211*cdf0e10cSrcweir if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eOpenExisting ) 1212*cdf0e10cSrcweir { 1213*cdf0e10cSrcweir // we're not going to re-use the XModel we have - since the document the user 1214*cdf0e10cSrcweir // wants us to load could be a non-database document. Instead, we asynchronously 1215*cdf0e10cSrcweir // open the selected document. Thus, the wizard's return value is RET_CANCEL, 1216*cdf0e10cSrcweir // which means to not continue loading the database document 1217*cdf0e10cSrcweir if ( !OWizardMachine::Finnish( RET_CANCEL ) ) 1218*cdf0e10cSrcweir return sal_False; 1219*cdf0e10cSrcweir 1220*cdf0e10cSrcweir Reference< XComponentLoader > xFrameLoader; 1221*cdf0e10cSrcweir try 1222*cdf0e10cSrcweir { 1223*cdf0e10cSrcweir AsyncLoader* pAsyncLoader = new AsyncLoader( getORB(), m_pGeneralPage->GetSelectedDocument().sURL ); 1224*cdf0e10cSrcweir ::rtl::Reference< AsyncLoader > xKeepAlive( pAsyncLoader ); 1225*cdf0e10cSrcweir pAsyncLoader->doLoadAsync(); 1226*cdf0e10cSrcweir } 1227*cdf0e10cSrcweir catch( const Exception& ) 1228*cdf0e10cSrcweir { 1229*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 1230*cdf0e10cSrcweir } 1231*cdf0e10cSrcweir 1232*cdf0e10cSrcweir return sal_True; 1233*cdf0e10cSrcweir } 1234*cdf0e10cSrcweir 1235*cdf0e10cSrcweir if (getCurrentState() != PAGE_DBSETUPWIZARD_FINAL) 1236*cdf0e10cSrcweir { 1237*cdf0e10cSrcweir skipUntil(PAGE_DBSETUPWIZARD_FINAL); 1238*cdf0e10cSrcweir } 1239*cdf0e10cSrcweir if (getCurrentState() == PAGE_DBSETUPWIZARD_FINAL) 1240*cdf0e10cSrcweir return SaveDatabaseDocument() ? OWizardMachine::onFinish() : sal_False; 1241*cdf0e10cSrcweir else 1242*cdf0e10cSrcweir { 1243*cdf0e10cSrcweir enableButtons( WZB_FINISH, sal_False ); 1244*cdf0e10cSrcweir return sal_False; 1245*cdf0e10cSrcweir } 1246*cdf0e10cSrcweir } 1247*cdf0e10cSrcweir 1248*cdf0e10cSrcweir //......................................................................... 1249*cdf0e10cSrcweir } // namespace dbaui 1250*cdf0e10cSrcweir //......................................................................... 1251*cdf0e10cSrcweir 1252