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 "ConnectionPage.hxx" 32*cdf0e10cSrcweir #include "DbAdminImpl.hxx" 33*cdf0e10cSrcweir #include "DriverSettings.hxx" 34*cdf0e10cSrcweir #include "adminpages.hxx" 35*cdf0e10cSrcweir #include "dbadmin.hrc" 36*cdf0e10cSrcweir #include "dbadmin.hxx" 37*cdf0e10cSrcweir #include "dbu_dlg.hrc" 38*cdf0e10cSrcweir #include <svl/stritem.hxx> 39*cdf0e10cSrcweir #include <svl/eitem.hxx> 40*cdf0e10cSrcweir #include <svl/intitem.hxx> 41*cdf0e10cSrcweir #include "dbustrings.hrc" 42*cdf0e10cSrcweir #include "dsitems.hxx" 43*cdf0e10cSrcweir #include "dsnItem.hxx" 44*cdf0e10cSrcweir #include "localresaccess.hxx" 45*cdf0e10cSrcweir #include "optionalboolitem.hxx" 46*cdf0e10cSrcweir #include "propertysetitem.hxx" 47*cdf0e10cSrcweir #include "stringlistitem.hxx" 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir #include <svl/eitem.hxx> 50*cdf0e10cSrcweir #include <svl/intitem.hxx> 51*cdf0e10cSrcweir #include <svl/stritem.hxx> 52*cdf0e10cSrcweir #include <unotools/confignode.hxx> 53*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir //......................................................................... 56*cdf0e10cSrcweir namespace dbaui 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir //......................................................................... 59*cdf0e10cSrcweir using namespace com::sun::star::uno; 60*cdf0e10cSrcweir using namespace com::sun::star::sdbc; 61*cdf0e10cSrcweir using namespace com::sun::star::lang; 62*cdf0e10cSrcweir using namespace com::sun::star::util; 63*cdf0e10cSrcweir using namespace com::sun::star::beans; 64*cdf0e10cSrcweir using namespace com::sun::star::container; 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir //========================================================================= 67*cdf0e10cSrcweir //= ODbAdminDialog 68*cdf0e10cSrcweir //========================================================================= 69*cdf0e10cSrcweir DBG_NAME(ODbAdminDialog) 70*cdf0e10cSrcweir //------------------------------------------------------------------------- 71*cdf0e10cSrcweir ODbAdminDialog::ODbAdminDialog(Window* _pParent 72*cdf0e10cSrcweir , SfxItemSet* _pItems 73*cdf0e10cSrcweir , const Reference< XMultiServiceFactory >& _rxORB 74*cdf0e10cSrcweir ) 75*cdf0e10cSrcweir :SfxTabDialog(_pParent, ModuleRes(DLG_DATABASE_ADMINISTRATION), _pItems) 76*cdf0e10cSrcweir ,m_bApplied(sal_False) 77*cdf0e10cSrcweir ,m_bUIEnabled( sal_True ) 78*cdf0e10cSrcweir ,m_nMainPageID( PAGE_CONNECTION ) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir DBG_CTOR(ODbAdminDialog,NULL); 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,this,this)); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir // add the initial tab page 85*cdf0e10cSrcweir AddTabPage( m_nMainPageID, String( ModuleRes( STR_PAGETITLE_GENERAL ) ), OConnectionTabPage::Create, NULL ); 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir // remove the reset button - it's meaning is much too ambiguous in this dialog 88*cdf0e10cSrcweir RemoveResetButton(); 89*cdf0e10cSrcweir // no local resources needed anymore 90*cdf0e10cSrcweir FreeResource(); 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir //------------------------------------------------------------------------- 94*cdf0e10cSrcweir ODbAdminDialog::~ODbAdminDialog() 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir SetInputSet(NULL); 97*cdf0e10cSrcweir DELETEZ(pExampleSet); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir DBG_DTOR(ODbAdminDialog,NULL); 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir //------------------------------------------------------------------------- 102*cdf0e10cSrcweir short ODbAdminDialog::Ok() 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir SfxTabDialog::Ok(); 105*cdf0e10cSrcweir disabledUI(); 106*cdf0e10cSrcweir return ( AR_LEAVE_MODIFIED == implApplyChanges() ) ? RET_OK : RET_CANCEL; 107*cdf0e10cSrcweir // TODO : AR_ERROR is not handled correctly, we always close the dialog here 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir //------------------------------------------------------------------------- 111*cdf0e10cSrcweir void ODbAdminDialog::PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir // register ourself as modified listener 114*cdf0e10cSrcweir static_cast<OGenericAdministrationPage&>(_rPage).SetServiceFactory(m_pImpl->getORB()); 115*cdf0e10cSrcweir static_cast<OGenericAdministrationPage&>(_rPage).SetAdminDialog(this,this); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir AdjustLayout(); 118*cdf0e10cSrcweir Window *pWin = GetViewWindow(); 119*cdf0e10cSrcweir if(pWin) 120*cdf0e10cSrcweir pWin->Invalidate(); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir SfxTabDialog::PageCreated(_nId, _rPage); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 126*cdf0e10cSrcweir void ODbAdminDialog::addDetailPage(sal_uInt16 _nPageId, sal_uInt16 _nTextId, CreateTabPage _pCreateFunc) 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir // open our own resource block, as the page titles are strings local to this block 129*cdf0e10cSrcweir LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir AddTabPage(_nPageId, String(ModuleRes(_nTextId)), _pCreateFunc, NULL); 132*cdf0e10cSrcweir m_aCurrentDetailPages.push(_nPageId); 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir //------------------------------------------------------------------------- 136*cdf0e10cSrcweir void ODbAdminDialog::impl_selectDataSource(const ::com::sun::star::uno::Any& _aDataSourceName) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir m_pImpl->setDataSourceOrName(_aDataSourceName); 139*cdf0e10cSrcweir Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); 140*cdf0e10cSrcweir impl_resetPages( xDatasource ); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, getOutputSet()->GetItem(DSID_TYPECOLLECTION)); 143*cdf0e10cSrcweir ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection(); 144*cdf0e10cSrcweir ::dbaccess::DATASOURCE_TYPE eType = pCollection->determineType(getDatasourceType(*getOutputSet())); 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir // and insert the new ones 147*cdf0e10cSrcweir switch ( eType ) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir case ::dbaccess::DST_DBASE: 150*cdf0e10cSrcweir addDetailPage(PAGE_DBASE, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateDbase); 151*cdf0e10cSrcweir // bResetPasswordRequired = sal_True; 152*cdf0e10cSrcweir break; 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir case ::dbaccess::DST_ADO: 155*cdf0e10cSrcweir addDetailPage(PAGE_ADO, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateAdo); 156*cdf0e10cSrcweir break; 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir case ::dbaccess::DST_FLAT: 159*cdf0e10cSrcweir addDetailPage(PAGE_TEXT, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateText); 160*cdf0e10cSrcweir // bResetPasswordRequired = sal_True; 161*cdf0e10cSrcweir break; 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir case ::dbaccess::DST_ODBC: 164*cdf0e10cSrcweir addDetailPage(PAGE_ODBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateODBC); 165*cdf0e10cSrcweir break; 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir case ::dbaccess::DST_MYSQL_ODBC: 168*cdf0e10cSrcweir addDetailPage(PAGE_MYSQL_ODBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateMySQLODBC); 169*cdf0e10cSrcweir break; 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir case ::dbaccess::DST_MYSQL_JDBC: 172*cdf0e10cSrcweir addDetailPage(PAGE_MYSQL_JDBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateMySQLJDBC); 173*cdf0e10cSrcweir break; 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir case ::dbaccess::DST_ORACLE_JDBC: 176*cdf0e10cSrcweir addDetailPage(PAGE_ORACLE_JDBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateOracleJDBC); 177*cdf0e10cSrcweir break; 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir case ::dbaccess::DST_ADABAS: 180*cdf0e10cSrcweir // for adabas we have more than one page 181*cdf0e10cSrcweir // CAUTION: the order of inserting pages matters. 182*cdf0e10cSrcweir // the major detail page should be inserted last always (thus, it becomes the first page after 183*cdf0e10cSrcweir // the general page) 184*cdf0e10cSrcweir addDetailPage(PAGE_ADABAS, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateAdabas); 185*cdf0e10cSrcweir break; 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir case ::dbaccess::DST_LDAP: 188*cdf0e10cSrcweir addDetailPage(PAGE_LDAP,STR_PAGETITLE_ADVANCED,ODriversSettings::CreateLDAP); 189*cdf0e10cSrcweir break; 190*cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE1: /// first user defined driver 191*cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE2: 192*cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE3: 193*cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE4: 194*cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE5: 195*cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE6: 196*cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE7: 197*cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE8: 198*cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE9: 199*cdf0e10cSrcweir case ::dbaccess::DST_USERDEFINE10: 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG); 202*cdf0e10cSrcweir String aTitle(ModuleRes(STR_PAGETITLE_ADVANCED)); 203*cdf0e10cSrcweir AddTabPage(PAGE_USERDRIVER, aTitle, ODriversSettings::CreateUser, 0, sal_False, 1); 204*cdf0e10cSrcweir m_aCurrentDetailPages.push(PAGE_USERDRIVER); 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir break; 207*cdf0e10cSrcweir default: 208*cdf0e10cSrcweir break; 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir //------------------------------------------------------------------------- 213*cdf0e10cSrcweir void ODbAdminDialog::impl_resetPages(const Reference< XPropertySet >& _rxDatasource) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir // the selection is valid if and only if we have a datasource now 216*cdf0e10cSrcweir GetInputSetImpl()->Put(SfxBoolItem(DSID_INVALID_SELECTION, !_rxDatasource.is())); 217*cdf0e10cSrcweir // (sal_False tells the tab pages to disable and reset all their controls, which is different 218*cdf0e10cSrcweir // from "just set them to readonly") 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir // reset the pages 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir // prevent flicker 223*cdf0e10cSrcweir SetUpdateMode(sal_False); 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir // remove all items which relate to indirect properties from the input set 226*cdf0e10cSrcweir // (without this, the following may happen: select an arbitrary data source where some indirect properties 227*cdf0e10cSrcweir // are set. Select another data source of the same type, where the indirect props are not set (yet). Then, 228*cdf0e10cSrcweir // the indirect property values of the first ds are shown in the second ds ...) 229*cdf0e10cSrcweir const ODbDataSourceAdministrationHelper::MapInt2String& rMap = m_pImpl->getIndirectProperties(); 230*cdf0e10cSrcweir for ( ODbDataSourceAdministrationHelper::ConstMapInt2StringIterator aIndirect = rMap.begin(); 231*cdf0e10cSrcweir aIndirect != rMap.end(); 232*cdf0e10cSrcweir ++aIndirect 233*cdf0e10cSrcweir ) 234*cdf0e10cSrcweir GetInputSetImpl()->ClearItem( (sal_uInt16)aIndirect->first ); 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir // extract all relevant data from the property set of the data source 237*cdf0e10cSrcweir m_pImpl->translateProperties(_rxDatasource, *GetInputSetImpl()); 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir // propagate this set as our new input set and reset the example set 240*cdf0e10cSrcweir SetInputSet(GetInputSetImpl()); 241*cdf0e10cSrcweir delete pExampleSet; 242*cdf0e10cSrcweir pExampleSet = new SfxItemSet(*GetInputSetImpl()); 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir // special case: MySQL Native does not have the generic PAGE_CONNECTION page 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, getOutputSet()->GetItem(DSID_TYPECOLLECTION)); 247*cdf0e10cSrcweir ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection(); 248*cdf0e10cSrcweir if ( pCollection->determineType(getDatasourceType( *pExampleSet )) == ::dbaccess::DST_MYSQL_NATIVE ) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG); 251*cdf0e10cSrcweir AddTabPage( PAGE_MYSQL_NATIVE, String( ModuleRes( STR_PAGETITLE_CONNECTION ) ), ODriversSettings::CreateMySQLNATIVE, NULL ); 252*cdf0e10cSrcweir RemoveTabPage( PAGE_CONNECTION ); 253*cdf0e10cSrcweir m_nMainPageID = PAGE_MYSQL_NATIVE; 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir ShowPage( m_nMainPageID ); 257*cdf0e10cSrcweir SfxTabPage* pConnectionPage = GetTabPage( m_nMainPageID ); 258*cdf0e10cSrcweir if ( pConnectionPage ) 259*cdf0e10cSrcweir pConnectionPage->Reset(*GetInputSetImpl()); 260*cdf0e10cSrcweir // if this is NULL, the page has not been created yet, which means we're called before the 261*cdf0e10cSrcweir // dialog was displayed (probably from inside the ctor) 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir SetUpdateMode(sal_True); 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 266*cdf0e10cSrcweir void ODbAdminDialog::setTitle(const ::rtl::OUString& _sTitle) 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir SetText(_sTitle); 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir //------------------------------------------------------------------------- 271*cdf0e10cSrcweir void ODbAdminDialog::enableConfirmSettings( bool _bEnable ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir (void)_bEnable; 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir //------------------------------------------------------------------------- 276*cdf0e10cSrcweir sal_Bool ODbAdminDialog::saveDatasource() 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir return PrepareLeaveCurrentPage(); 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir //------------------------------------------------------------------------- 281*cdf0e10cSrcweir ODbAdminDialog::ApplyResult ODbAdminDialog::implApplyChanges() 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir if (!PrepareLeaveCurrentPage()) 284*cdf0e10cSrcweir { // the page did not allow us to leave 285*cdf0e10cSrcweir return AR_KEEP; 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir if ( !m_pImpl->saveChanges(*pExampleSet) ) 289*cdf0e10cSrcweir return AR_KEEP; 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir if ( isUIEnabled() ) 292*cdf0e10cSrcweir ShowPage(GetCurPageId()); 293*cdf0e10cSrcweir // This does the usual ActivatePage, so the pages can save their current status. 294*cdf0e10cSrcweir // This way, next time they're asked what has changed since now and here, they really 295*cdf0e10cSrcweir // can compare with the status they have _now_ (not the one they had before this apply call). 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir m_bApplied = sal_True; 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir return AR_LEAVE_MODIFIED; 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir //------------------------------------------------------------------------- 302*cdf0e10cSrcweir void ODbAdminDialog::selectDataSource(const ::com::sun::star::uno::Any& _aDataSourceName) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir impl_selectDataSource(_aDataSourceName); 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 308*cdf0e10cSrcweir const SfxItemSet* ODbAdminDialog::getOutputSet() const 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir return GetExampleSet(); 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 313*cdf0e10cSrcweir SfxItemSet* ODbAdminDialog::getWriteOutputSet() 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir return pExampleSet; 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 318*cdf0e10cSrcweir ::std::pair< Reference<XConnection>,sal_Bool> ODbAdminDialog::createConnection() 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir return m_pImpl->createConnection(); 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 323*cdf0e10cSrcweir Reference< XMultiServiceFactory > ODbAdminDialog::getORB() const 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir return m_pImpl->getORB(); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 328*cdf0e10cSrcweir Reference< XDriver > ODbAdminDialog::getDriver() 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir return m_pImpl->getDriver(); 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 333*cdf0e10cSrcweir ::rtl::OUString ODbAdminDialog::getDatasourceType(const SfxItemSet& _rSet) const 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir return m_pImpl->getDatasourceType(_rSet); 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 338*cdf0e10cSrcweir void ODbAdminDialog::clearPassword() 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir m_pImpl->clearPassword(); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir //------------------------------------------------------------------------- 343*cdf0e10cSrcweir SfxItemSet* ODbAdminDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults, ::dbaccess::ODsnTypeCollection* _pTypeCollection) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir // just to be sure .... 346*cdf0e10cSrcweir _rpSet = NULL; 347*cdf0e10cSrcweir _rpPool = NULL; 348*cdf0e10cSrcweir _rppDefaults = NULL; 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir const ::rtl::OUString sFilterAll( "%", 1, RTL_TEXTENCODING_ASCII_US ); 351*cdf0e10cSrcweir // create and initialize the defaults 352*cdf0e10cSrcweir _rppDefaults = new SfxPoolItem*[DSID_LAST_ITEM_ID - DSID_FIRST_ITEM_ID + 1]; 353*cdf0e10cSrcweir SfxPoolItem** pCounter = _rppDefaults; // want to modify this without affecting the out param _rppDefaults 354*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_NAME, String()); 355*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_ORIGINALNAME, String()); 356*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_CONNECTURL, String()); 357*cdf0e10cSrcweir *pCounter++ = new OStringListItem(DSID_TABLEFILTER, Sequence< ::rtl::OUString >(&sFilterAll, 1)); 358*cdf0e10cSrcweir *pCounter++ = new DbuTypeCollectionItem(DSID_TYPECOLLECTION, _pTypeCollection); 359*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_INVALID_SELECTION, sal_False); 360*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_READONLY, sal_False); 361*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_USER, String()); 362*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_PASSWORD, String()); 363*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_ADDITIONALOPTIONS, String()); 364*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_CHARSET, String()); 365*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_PASSWORDREQUIRED, sal_False); 366*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_SHOWDELETEDROWS, sal_False); 367*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_ALLOWLONGTABLENAMES, sal_False); 368*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_JDBCDRIVERCLASS, String()); 369*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_FIELDDELIMITER, ','); 370*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_TEXTDELIMITER, '"'); 371*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_DECIMALDELIMITER, '.'); 372*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_THOUSANDSDELIMITER, String()); 373*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_TEXTFILEEXTENSION, String::CreateFromAscii("txt")); 374*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_TEXTFILEHEADER, sal_True); 375*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_PARAMETERNAMESUBST, sal_False); 376*cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_CONN_PORTNUMBER, 8100); 377*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_SUPPRESSVERSIONCL, sal_False); 378*cdf0e10cSrcweir *pCounter++ = new OPropertySetItem(DSID_DATASOURCE_UNO); 379*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_CONN_SHUTSERVICE, sal_False); 380*cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_CONN_DATAINC, 20); 381*cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_CONN_CACHESIZE, 20); 382*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_CONN_CTRLUSER, String()); 383*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_CONN_CTRLPWD, String()); 384*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_USECATALOG, sal_False); 385*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_CONN_HOSTNAME, String()); 386*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_CONN_LDAP_BASEDN, String()); 387*cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_CONN_LDAP_PORTNUMBER, 389); 388*cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_CONN_LDAP_ROWCOUNT, 100); 389*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_SQL92CHECK, sal_False); 390*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_AUTOINCREMENTVALUE, String()); 391*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_AUTORETRIEVEVALUE, String()); 392*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_AUTORETRIEVEENABLED, sal_False); 393*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_APPEND_TABLE_ALIAS, sal_False); 394*cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_MYSQL_PORTNUMBER, 3306); 395*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_IGNOREDRIVER_PRIV, sal_True); 396*cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_BOOLEANCOMPARISON, 0); 397*cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_ORACLE_PORTNUMBER, 1521); 398*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_ENABLEOUTERJOIN, sal_True); 399*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_CATALOG, sal_True); 400*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_SCHEMA, sal_True); 401*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_INDEXAPPENDIX, sal_True); 402*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_CONN_LDAP_USESSL, sal_False); 403*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_DOCUMENT_URL, String()); 404*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_DOSLINEENDS, sal_False); 405*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_DATABASENAME, String()); 406*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_AS_BEFORE_CORRNAME, sal_True); 407*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_CHECK_REQUIRED_FIELDS, sal_True); 408*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_IGNORECURRENCY, sal_False); 409*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_CONN_SOCKET, String()); 410*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem(DSID_ESCAPE_DATETIME, sal_True); 411*cdf0e10cSrcweir *pCounter++ = new SfxStringItem(DSID_NAMED_PIPE, String()); 412*cdf0e10cSrcweir *pCounter++ = new OptionalBoolItem( DSID_PRIMARY_KEY_SUPPORT ); 413*cdf0e10cSrcweir *pCounter++ = new SfxInt32Item(DSID_MAX_ROW_SCAN, 100); 414*cdf0e10cSrcweir *pCounter++ = new SfxBoolItem( DSID_RESPECTRESULTSETTYPE,sal_False ); 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir // create the pool 417*cdf0e10cSrcweir static SfxItemInfo __READONLY_DATA aItemInfos[DSID_LAST_ITEM_ID - DSID_FIRST_ITEM_ID + 1] = 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir {0,0}, 420*cdf0e10cSrcweir {0,0}, 421*cdf0e10cSrcweir {0,0}, 422*cdf0e10cSrcweir {0,0}, 423*cdf0e10cSrcweir {0,0}, 424*cdf0e10cSrcweir {0,0}, 425*cdf0e10cSrcweir {0,0}, 426*cdf0e10cSrcweir {0,0}, 427*cdf0e10cSrcweir {0,0}, 428*cdf0e10cSrcweir {0,0}, 429*cdf0e10cSrcweir {0,0}, 430*cdf0e10cSrcweir {0,0}, 431*cdf0e10cSrcweir {0,0}, 432*cdf0e10cSrcweir {0,0}, 433*cdf0e10cSrcweir {0,0}, 434*cdf0e10cSrcweir {0,0}, 435*cdf0e10cSrcweir {0,0}, 436*cdf0e10cSrcweir {0,0}, 437*cdf0e10cSrcweir {0,0}, 438*cdf0e10cSrcweir {0,0}, 439*cdf0e10cSrcweir {0,0}, 440*cdf0e10cSrcweir {0,0}, 441*cdf0e10cSrcweir {0,0}, 442*cdf0e10cSrcweir {0,0}, 443*cdf0e10cSrcweir {0,0}, 444*cdf0e10cSrcweir {0,0}, 445*cdf0e10cSrcweir {0,0}, 446*cdf0e10cSrcweir {0,0}, 447*cdf0e10cSrcweir {0,0}, 448*cdf0e10cSrcweir {0,0}, 449*cdf0e10cSrcweir {0,0}, 450*cdf0e10cSrcweir {0,0}, 451*cdf0e10cSrcweir {0,0}, 452*cdf0e10cSrcweir {0,0}, 453*cdf0e10cSrcweir {0,0}, 454*cdf0e10cSrcweir {0,0}, 455*cdf0e10cSrcweir {0,0}, 456*cdf0e10cSrcweir {0,0}, 457*cdf0e10cSrcweir {0,0}, 458*cdf0e10cSrcweir {0,0}, 459*cdf0e10cSrcweir {0,0}, 460*cdf0e10cSrcweir {0,0}, 461*cdf0e10cSrcweir {0,0}, 462*cdf0e10cSrcweir {0,0}, 463*cdf0e10cSrcweir {0,0}, 464*cdf0e10cSrcweir {0,0}, 465*cdf0e10cSrcweir {0,0}, 466*cdf0e10cSrcweir {0,0}, 467*cdf0e10cSrcweir {0,0}, 468*cdf0e10cSrcweir {0,0}, 469*cdf0e10cSrcweir {0,0}, 470*cdf0e10cSrcweir {0,0}, 471*cdf0e10cSrcweir {0,0}, 472*cdf0e10cSrcweir {0,0}, 473*cdf0e10cSrcweir {0,0}, 474*cdf0e10cSrcweir {0,0}, 475*cdf0e10cSrcweir {0,0}, 476*cdf0e10cSrcweir {0,0}, 477*cdf0e10cSrcweir {0,0}, 478*cdf0e10cSrcweir {0,0}, 479*cdf0e10cSrcweir {0,0} 480*cdf0e10cSrcweir }; 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir OSL_ENSURE(sizeof(aItemInfos)/sizeof(aItemInfos[0]) == DSID_LAST_ITEM_ID,"Invalid Ids!"); 483*cdf0e10cSrcweir _rpPool = new SfxItemPool(String::CreateFromAscii("DSAItemPool"), DSID_FIRST_ITEM_ID, DSID_LAST_ITEM_ID, 484*cdf0e10cSrcweir aItemInfos, _rppDefaults); 485*cdf0e10cSrcweir _rpPool->FreezeIdRanges(); 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir // and, finally, the set 488*cdf0e10cSrcweir _rpSet = new SfxItemSet(*_rpPool, sal_True); 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir return _rpSet; 491*cdf0e10cSrcweir } 492*cdf0e10cSrcweir //------------------------------------------------------------------------- 493*cdf0e10cSrcweir void ODbAdminDialog::destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults) 494*cdf0e10cSrcweir { 495*cdf0e10cSrcweir // _first_ delete the set (refering the pool) 496*cdf0e10cSrcweir if (_rpSet) 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir delete _rpSet; 499*cdf0e10cSrcweir _rpSet = NULL; 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir // delete the pool 503*cdf0e10cSrcweir if (_rpPool) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir _rpPool->ReleaseDefaults(sal_True); 506*cdf0e10cSrcweir // the "true" means delete the items, too 507*cdf0e10cSrcweir SfxItemPool::Free(_rpPool); 508*cdf0e10cSrcweir _rpPool = NULL; 509*cdf0e10cSrcweir } 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir // reset the defaults ptr 512*cdf0e10cSrcweir _rppDefaults = NULL; 513*cdf0e10cSrcweir // no need to explicitly delete the defaults, this has been done by the ReleaseDefaults 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir //......................................................................... 517*cdf0e10cSrcweir } // namespace dbaui 518*cdf0e10cSrcweir //......................................................................... 519*cdf0e10cSrcweir 520