196de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
396de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
496de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file
596de5490SAndrew Rist * distributed with this work for additional information
696de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file
796de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the
896de5490SAndrew Rist * "License"); you may not use this file except in compliance
996de5490SAndrew Rist * with the License. You may obtain a copy of the License at
1096de5490SAndrew Rist *
1196de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
1296de5490SAndrew Rist *
1396de5490SAndrew Rist * Unless required by applicable law or agreed to in writing,
1496de5490SAndrew Rist * software distributed under the License is distributed on an
1596de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1696de5490SAndrew Rist * KIND, either express or implied. See the License for the
1796de5490SAndrew Rist * specific language governing permissions and limitations
1896de5490SAndrew Rist * under the License.
1996de5490SAndrew Rist *
2096de5490SAndrew Rist *************************************************************/
2196de5490SAndrew Rist
2296de5490SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25*b63233d8Sdamjan #include "precompiled_dbui.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #ifndef DBAUI_DBWIZ_HXX
28cdf0e10cSrcweir #include "dbwiz.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _DBAUI_DBADMIN_HRC_
31cdf0e10cSrcweir #include "dbadmin.hrc"
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _DBU_DLG_HRC_
34cdf0e10cSrcweir #include "dbu_dlg.hrc"
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef _DBAUI_DATASOURCEITEMS_HXX_
37cdf0e10cSrcweir #include "dsitems.hxx"
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #include "dsnItem.hxx"
40cdf0e10cSrcweir #ifndef _SFXSTRITEM_HXX
41cdf0e10cSrcweir #include <svl/stritem.hxx>
42cdf0e10cSrcweir #endif
43cdf0e10cSrcweir #ifndef _SFXENUMITEM_HXX
44cdf0e10cSrcweir #include <svl/eitem.hxx>
45cdf0e10cSrcweir #endif
46cdf0e10cSrcweir #ifndef _SFXINTITEM_HXX
47cdf0e10cSrcweir #include <svl/intitem.hxx>
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir #ifndef _SV_MSGBOX_HXX
50cdf0e10cSrcweir #include <vcl/msgbox.hxx>
51cdf0e10cSrcweir #endif
52cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
53cdf0e10cSrcweir #include "dbustrings.hrc"
54cdf0e10cSrcweir #endif
55cdf0e10cSrcweir #ifndef _DBAUI_ADMINPAGES_HXX_
56cdf0e10cSrcweir #include "adminpages.hxx"
57cdf0e10cSrcweir #endif
58cdf0e10cSrcweir #ifndef _DBAUI_GENERALPAGE_HXX_
59cdf0e10cSrcweir #include "generalpage.hxx"
60cdf0e10cSrcweir #endif
61cdf0e10cSrcweir #ifndef _DBAUI_LOCALRESACCESS_HXX_
62cdf0e10cSrcweir #include "localresaccess.hxx"
63cdf0e10cSrcweir #endif
64cdf0e10cSrcweir #ifndef _DBAUI_STRINGLISTITEM_HXX_
65cdf0e10cSrcweir #include "stringlistitem.hxx"
66cdf0e10cSrcweir #endif
67cdf0e10cSrcweir #ifndef _DBAUI_PROPERTYSETITEM_HXX_
68cdf0e10cSrcweir #include "propertysetitem.hxx"
69cdf0e10cSrcweir #endif
70cdf0e10cSrcweir #ifndef _UNOTOOLS_CONFIGNODE_HXX_
71cdf0e10cSrcweir #include <unotools/confignode.hxx>
72cdf0e10cSrcweir #endif
73cdf0e10cSrcweir #ifndef DBAUI_CONNECTIONPAGE_HXX
74cdf0e10cSrcweir #include "ConnectionPage.hxx"
75cdf0e10cSrcweir #endif
76cdf0e10cSrcweir #ifndef DBAUI_DRIVERSETTINGS_HXX
77cdf0e10cSrcweir #include "DriverSettings.hxx"
78cdf0e10cSrcweir #endif
79cdf0e10cSrcweir #ifndef _DBAUI_DBADMINIMPL_HXX_
80cdf0e10cSrcweir #include "DbAdminImpl.hxx"
81cdf0e10cSrcweir #endif
82cdf0e10cSrcweir #ifndef _DBA_DBACCESS_HELPID_HRC_
83cdf0e10cSrcweir #include "dbaccess_helpid.hrc"
84cdf0e10cSrcweir #endif
85cdf0e10cSrcweir
86cdf0e10cSrcweir //.........................................................................
87cdf0e10cSrcweir namespace dbaui
88cdf0e10cSrcweir {
89cdf0e10cSrcweir //.........................................................................
90cdf0e10cSrcweir using namespace svt;
91cdf0e10cSrcweir using namespace com::sun::star::uno;
92cdf0e10cSrcweir using namespace com::sun::star::sdbc;
93cdf0e10cSrcweir using namespace com::sun::star::lang;
94cdf0e10cSrcweir using namespace com::sun::star::util;
95cdf0e10cSrcweir using namespace com::sun::star::beans;
96cdf0e10cSrcweir using namespace com::sun::star::container;
97cdf0e10cSrcweir
98cdf0e10cSrcweir #define START_PAGE 0
99cdf0e10cSrcweir #define CONNECTION_PAGE 1
100cdf0e10cSrcweir #define ADDITIONAL_PAGE_DBASE 2
101cdf0e10cSrcweir #define ADDITIONAL_PAGE_FLAT 3
102cdf0e10cSrcweir #define ADDITIONAL_PAGE_LDAP 4
103cdf0e10cSrcweir #define ADDITIONAL_PAGE_ADABAS 5
104cdf0e10cSrcweir #define ADDITIONAL_PAGE_MYSQL_JDBC 6
105cdf0e10cSrcweir #define ADDITIONAL_PAGE_MYSQL_ODBC 7
106cdf0e10cSrcweir #define ADDITIONAL_PAGE_ORACLE_JDBC 8
107cdf0e10cSrcweir #define ADDITIONAL_PAGE_ADO 9
108cdf0e10cSrcweir #define ADDITIONAL_PAGE_ODBC 10
109cdf0e10cSrcweir #define ADDITIONAL_USERDEFINED 11
110cdf0e10cSrcweir #define ADDITIONAL_PAGE_MYSQL_NATIVE 12
111cdf0e10cSrcweir
112cdf0e10cSrcweir
DBG_NAME(ODbTypeWizDialog)113cdf0e10cSrcweir DBG_NAME(ODbTypeWizDialog)
114cdf0e10cSrcweir //=========================================================================
115cdf0e10cSrcweir //= ODbTypeWizDialog
116cdf0e10cSrcweir //=========================================================================
117cdf0e10cSrcweir //-------------------------------------------------------------------------
118cdf0e10cSrcweir ODbTypeWizDialog::ODbTypeWizDialog(Window* _pParent
119cdf0e10cSrcweir ,SfxItemSet* _pItems
120cdf0e10cSrcweir ,const Reference< XMultiServiceFactory >& _rxORB
121cdf0e10cSrcweir ,const ::com::sun::star::uno::Any& _aDataSourceName
122cdf0e10cSrcweir )
123cdf0e10cSrcweir :OWizardMachine(_pParent, ModuleRes(DLG_DATABASE_TYPE_CHANGE), WZB_NEXT | WZB_PREVIOUS | WZB_FINISH | WZB_CANCEL | WZB_HELP )
124cdf0e10cSrcweir ,m_pOutSet(NULL)
125cdf0e10cSrcweir ,m_bResetting(sal_False)
126cdf0e10cSrcweir ,m_bApplied(sal_False)
127cdf0e10cSrcweir ,m_bUIEnabled( sal_True )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir DBG_CTOR(ODbTypeWizDialog,NULL);
130cdf0e10cSrcweir m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,this,this));
131cdf0e10cSrcweir m_pImpl->setDataSourceOrName(_aDataSourceName);
132cdf0e10cSrcweir Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
133cdf0e10cSrcweir m_pOutSet = new SfxItemSet( *_pItems->GetPool(), _pItems->GetRanges() );
134cdf0e10cSrcweir
135cdf0e10cSrcweir m_pImpl->translateProperties(xDatasource, *m_pOutSet);
136cdf0e10cSrcweir m_eType = m_pImpl->getDatasourceType(*m_pOutSet);
137cdf0e10cSrcweir
138cdf0e10cSrcweir SetPageSizePixel(LogicToPixel(::Size(PAGE_X, PAGE_Y), MAP_APPFONT));
139cdf0e10cSrcweir ShowButtonFixedLine(sal_True);
140cdf0e10cSrcweir defaultButton(WZB_NEXT);
141cdf0e10cSrcweir enableButtons(WZB_FINISH, sal_False);
142cdf0e10cSrcweir enableAutomaticNextButtonState( true );
143cdf0e10cSrcweir
144cdf0e10cSrcweir m_pPrevPage->SetHelpId(HID_DBWIZ_PREVIOUS);
145cdf0e10cSrcweir m_pNextPage->SetHelpId(HID_DBWIZ_NEXT);
146cdf0e10cSrcweir m_pCancel->SetHelpId(HID_DBWIZ_CANCEL);
147cdf0e10cSrcweir m_pFinish->SetHelpId(HID_DBWIZ_FINISH);
148cdf0e10cSrcweir m_pHelp->SetUniqueId(UID_DBWIZ_HELP);
149cdf0e10cSrcweir // no local resources needed anymore
150cdf0e10cSrcweir
151cdf0e10cSrcweir DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _pItems->GetItem(DSID_TYPECOLLECTION));
152cdf0e10cSrcweir m_pCollection = pCollectionItem->getCollection();
153cdf0e10cSrcweir
154cdf0e10cSrcweir FreeResource();
155cdf0e10cSrcweir ActivatePage();
156cdf0e10cSrcweir }
157cdf0e10cSrcweir
158cdf0e10cSrcweir //-------------------------------------------------------------------------
~ODbTypeWizDialog()159cdf0e10cSrcweir ODbTypeWizDialog::~ODbTypeWizDialog()
160cdf0e10cSrcweir {
161cdf0e10cSrcweir DBG_DTOR(ODbTypeWizDialog,NULL);
162cdf0e10cSrcweir delete m_pOutSet;
163cdf0e10cSrcweir }
164cdf0e10cSrcweir //-------------------------------------------------------------------------
IMPL_LINK(ODbTypeWizDialog,OnTypeSelected,OGeneralPage *,_pTabPage)165cdf0e10cSrcweir IMPL_LINK(ODbTypeWizDialog, OnTypeSelected, OGeneralPage*, _pTabPage)
166cdf0e10cSrcweir {
167cdf0e10cSrcweir m_eType = _pTabPage->GetSelectedType();
168cdf0e10cSrcweir const bool bURLRequired = m_pCollection->isConnectionUrlRequired(m_eType);
169cdf0e10cSrcweir enableButtons(WZB_NEXT,bURLRequired);
170cdf0e10cSrcweir enableButtons(WZB_FINISH,!bURLRequired);
171cdf0e10cSrcweir return 1L;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir //-------------------------------------------------------------------------
determineNextState(WizardState _nCurrentState) const174cdf0e10cSrcweir WizardTypes::WizardState ODbTypeWizDialog::determineNextState( WizardState _nCurrentState ) const
175cdf0e10cSrcweir {
176cdf0e10cSrcweir WizardTypes::WizardState nNextState = WZS_INVALID_STATE;
177cdf0e10cSrcweir switch(_nCurrentState)
178cdf0e10cSrcweir {
179cdf0e10cSrcweir case START_PAGE:
180cdf0e10cSrcweir switch(m_pCollection->determineType(m_eType))
181cdf0e10cSrcweir {
182cdf0e10cSrcweir case ::dbaccess::DST_MOZILLA:
183cdf0e10cSrcweir case ::dbaccess::DST_OUTLOOK:
184cdf0e10cSrcweir case ::dbaccess::DST_OUTLOOKEXP:
185cdf0e10cSrcweir case ::dbaccess::DST_EVOLUTION:
186cdf0e10cSrcweir case ::dbaccess::DST_EVOLUTION_GROUPWISE:
187cdf0e10cSrcweir case ::dbaccess::DST_EVOLUTION_LDAP:
188cdf0e10cSrcweir case ::dbaccess::DST_KAB:
189cdf0e10cSrcweir case ::dbaccess::DST_MACAB:
190cdf0e10cSrcweir nNextState = WZS_INVALID_STATE;
191cdf0e10cSrcweir break;
192cdf0e10cSrcweir case ::dbaccess::DST_MYSQL_NATIVE:
193cdf0e10cSrcweir nNextState = ADDITIONAL_PAGE_MYSQL_NATIVE;
194cdf0e10cSrcweir break;
195cdf0e10cSrcweir default:
196cdf0e10cSrcweir nNextState = CONNECTION_PAGE;
197cdf0e10cSrcweir break;
198cdf0e10cSrcweir }
199cdf0e10cSrcweir break;
200cdf0e10cSrcweir case CONNECTION_PAGE:
201cdf0e10cSrcweir switch(m_pCollection->determineType(m_eType))
202cdf0e10cSrcweir {
203cdf0e10cSrcweir case ::dbaccess::DST_MOZILLA:
204cdf0e10cSrcweir case ::dbaccess::DST_THUNDERBIRD:
205cdf0e10cSrcweir case ::dbaccess::DST_OUTLOOK:
206cdf0e10cSrcweir case ::dbaccess::DST_OUTLOOKEXP:
207cdf0e10cSrcweir case ::dbaccess::DST_EVOLUTION:
208cdf0e10cSrcweir case ::dbaccess::DST_EVOLUTION_GROUPWISE:
209cdf0e10cSrcweir case ::dbaccess::DST_EVOLUTION_LDAP:
210cdf0e10cSrcweir case ::dbaccess::DST_KAB:
211cdf0e10cSrcweir case ::dbaccess::DST_MACAB:
212cdf0e10cSrcweir case ::dbaccess::DST_MSACCESS:
213cdf0e10cSrcweir case ::dbaccess::DST_MSACCESS_2007:
214cdf0e10cSrcweir case ::dbaccess::DST_JDBC:
215cdf0e10cSrcweir case ::dbaccess::DST_CALC:
216cdf0e10cSrcweir nNextState = WZS_INVALID_STATE;
217cdf0e10cSrcweir break;
218cdf0e10cSrcweir case ::dbaccess::DST_DBASE:
219cdf0e10cSrcweir nNextState = ADDITIONAL_PAGE_DBASE;
220cdf0e10cSrcweir break;
221cdf0e10cSrcweir case ::dbaccess::DST_FLAT:
222cdf0e10cSrcweir nNextState = ADDITIONAL_PAGE_FLAT;
223cdf0e10cSrcweir break;
224cdf0e10cSrcweir case ::dbaccess::DST_LDAP:
225cdf0e10cSrcweir nNextState = ADDITIONAL_PAGE_LDAP;
226cdf0e10cSrcweir break;
227cdf0e10cSrcweir case ::dbaccess::DST_ADABAS:
228cdf0e10cSrcweir nNextState = ADDITIONAL_PAGE_ADABAS;
229cdf0e10cSrcweir break;
230cdf0e10cSrcweir case ::dbaccess::DST_MYSQL_JDBC:
231cdf0e10cSrcweir nNextState = ADDITIONAL_PAGE_MYSQL_JDBC;
232cdf0e10cSrcweir break;
233cdf0e10cSrcweir case ::dbaccess::DST_MYSQL_ODBC:
234cdf0e10cSrcweir nNextState = ADDITIONAL_PAGE_MYSQL_ODBC;
235cdf0e10cSrcweir break;
236cdf0e10cSrcweir case ::dbaccess::DST_ORACLE_JDBC:
237cdf0e10cSrcweir nNextState = ADDITIONAL_PAGE_ORACLE_JDBC;
238cdf0e10cSrcweir break;
239cdf0e10cSrcweir case ::dbaccess::DST_ADO:
240cdf0e10cSrcweir nNextState = ADDITIONAL_PAGE_ADO;
241cdf0e10cSrcweir break;
242cdf0e10cSrcweir case ::dbaccess::DST_ODBC:
243cdf0e10cSrcweir nNextState = ADDITIONAL_PAGE_ODBC;
244cdf0e10cSrcweir break;
245cdf0e10cSrcweir default:
246cdf0e10cSrcweir nNextState = WZS_INVALID_STATE;
247cdf0e10cSrcweir break;
248cdf0e10cSrcweir }
249cdf0e10cSrcweir break;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir
252cdf0e10cSrcweir return nNextState;
253cdf0e10cSrcweir }
254cdf0e10cSrcweir
255cdf0e10cSrcweir // -----------------------------------------------------------------------------
getOutputSet() const256cdf0e10cSrcweir const SfxItemSet* ODbTypeWizDialog::getOutputSet() const
257cdf0e10cSrcweir {
258cdf0e10cSrcweir return m_pOutSet;
259cdf0e10cSrcweir }
260cdf0e10cSrcweir // -----------------------------------------------------------------------------
getWriteOutputSet()261cdf0e10cSrcweir SfxItemSet* ODbTypeWizDialog::getWriteOutputSet()
262cdf0e10cSrcweir {
263cdf0e10cSrcweir return m_pOutSet;
264cdf0e10cSrcweir }
265cdf0e10cSrcweir // -----------------------------------------------------------------------------
createConnection()266cdf0e10cSrcweir ::std::pair< Reference<XConnection>,sal_Bool> ODbTypeWizDialog::createConnection()
267cdf0e10cSrcweir {
268cdf0e10cSrcweir return m_pImpl->createConnection();
269cdf0e10cSrcweir }
270cdf0e10cSrcweir // -----------------------------------------------------------------------------
getORB() const271cdf0e10cSrcweir Reference< XMultiServiceFactory > ODbTypeWizDialog::getORB() const
272cdf0e10cSrcweir {
273cdf0e10cSrcweir return m_pImpl->getORB();
274cdf0e10cSrcweir }
275cdf0e10cSrcweir // -----------------------------------------------------------------------------
getDriver()276cdf0e10cSrcweir Reference< XDriver > ODbTypeWizDialog::getDriver()
277cdf0e10cSrcweir {
278cdf0e10cSrcweir return m_pImpl->getDriver();
279cdf0e10cSrcweir }
280cdf0e10cSrcweir // -----------------------------------------------------------------------------
getDatasourceType(const SfxItemSet & _rSet) const281cdf0e10cSrcweir ::rtl::OUString ODbTypeWizDialog::getDatasourceType(const SfxItemSet& _rSet) const
282cdf0e10cSrcweir {
283cdf0e10cSrcweir return m_pImpl->getDatasourceType(_rSet);
284cdf0e10cSrcweir }
285cdf0e10cSrcweir // -----------------------------------------------------------------------------
clearPassword()286cdf0e10cSrcweir void ODbTypeWizDialog::clearPassword()
287cdf0e10cSrcweir {
288cdf0e10cSrcweir m_pImpl->clearPassword();
289cdf0e10cSrcweir }
290cdf0e10cSrcweir
291cdf0e10cSrcweir // -----------------------------------------------------------------------------
createPage(WizardState _nState)292cdf0e10cSrcweir TabPage* ODbTypeWizDialog::createPage(WizardState _nState)
293cdf0e10cSrcweir {
294cdf0e10cSrcweir sal_uInt16 nStringId = STR_PAGETITLE_ADVANCED;
295cdf0e10cSrcweir TabPage* pPage = NULL;
296cdf0e10cSrcweir switch(_nState)
297cdf0e10cSrcweir {
298cdf0e10cSrcweir case START_PAGE: // start state
299cdf0e10cSrcweir {
300cdf0e10cSrcweir pPage = OGeneralPage::Create(this,*m_pOutSet);
301cdf0e10cSrcweir OGeneralPage* pGeneralPage = static_cast< OGeneralPage* >( pPage );
302cdf0e10cSrcweir pGeneralPage->SetTypeSelectHandler( LINK( this, ODbTypeWizDialog, OnTypeSelected));
303cdf0e10cSrcweir // pGeneralPage->SetCreationModeHandler( LINK( this, ODbTypeWizDialog, TODO ) );
304cdf0e10cSrcweir nStringId = STR_PAGETITLE_GENERAL;
305cdf0e10cSrcweir }
306cdf0e10cSrcweir break;
307cdf0e10cSrcweir case CONNECTION_PAGE:
308cdf0e10cSrcweir pPage = OConnectionTabPage::Create(this,*m_pOutSet);
309cdf0e10cSrcweir nStringId = STR_PAGETITLE_CONNECTION;
310cdf0e10cSrcweir break;
311cdf0e10cSrcweir
312cdf0e10cSrcweir case ADDITIONAL_PAGE_DBASE:
313cdf0e10cSrcweir pPage = ODriversSettings::CreateDbase(this,*m_pOutSet);
314cdf0e10cSrcweir break;
315cdf0e10cSrcweir case ADDITIONAL_PAGE_FLAT:
316cdf0e10cSrcweir pPage = ODriversSettings::CreateText(this,*m_pOutSet);
317cdf0e10cSrcweir break;
318cdf0e10cSrcweir case ADDITIONAL_PAGE_LDAP:
319cdf0e10cSrcweir pPage = ODriversSettings::CreateLDAP(this,*m_pOutSet);
320cdf0e10cSrcweir break;
321cdf0e10cSrcweir case ADDITIONAL_PAGE_ADABAS:
322cdf0e10cSrcweir pPage = ODriversSettings::CreateAdabas(this,*m_pOutSet);
323cdf0e10cSrcweir break;
324cdf0e10cSrcweir case ADDITIONAL_PAGE_MYSQL_JDBC:
325cdf0e10cSrcweir pPage = ODriversSettings::CreateMySQLJDBC(this,*m_pOutSet);
326cdf0e10cSrcweir break;
327cdf0e10cSrcweir case ADDITIONAL_PAGE_MYSQL_NATIVE:
328cdf0e10cSrcweir pPage = ODriversSettings::CreateMySQLNATIVE(this,*m_pOutSet);
329cdf0e10cSrcweir break;
330cdf0e10cSrcweir case ADDITIONAL_PAGE_MYSQL_ODBC:
331cdf0e10cSrcweir pPage = ODriversSettings::CreateMySQLODBC(this,*m_pOutSet);
332cdf0e10cSrcweir break;
333cdf0e10cSrcweir case ADDITIONAL_PAGE_ORACLE_JDBC:
334cdf0e10cSrcweir pPage = ODriversSettings::CreateOracleJDBC(this,*m_pOutSet);
335cdf0e10cSrcweir break;
336cdf0e10cSrcweir case ADDITIONAL_PAGE_ADO:
337cdf0e10cSrcweir pPage = ODriversSettings::CreateAdo(this,*m_pOutSet);
338cdf0e10cSrcweir break;
339cdf0e10cSrcweir case ADDITIONAL_PAGE_ODBC:
340cdf0e10cSrcweir pPage = ODriversSettings::CreateODBC(this,*m_pOutSet);
341cdf0e10cSrcweir break;
342cdf0e10cSrcweir case ADDITIONAL_USERDEFINED:
343cdf0e10cSrcweir pPage = ODriversSettings::CreateUser(this,*m_pOutSet);
344cdf0e10cSrcweir break;
345cdf0e10cSrcweir default:
346cdf0e10cSrcweir OSL_ENSURE(0,"Wrong state!");
347cdf0e10cSrcweir break;
348cdf0e10cSrcweir }
349cdf0e10cSrcweir
350cdf0e10cSrcweir // register ourself as modified listener
351cdf0e10cSrcweir if ( pPage )
352cdf0e10cSrcweir {
353cdf0e10cSrcweir static_cast<OGenericAdministrationPage*>(pPage)->SetServiceFactory(m_pImpl->getORB());
354cdf0e10cSrcweir static_cast<OGenericAdministrationPage*>(pPage)->SetAdminDialog(this,this);
355cdf0e10cSrcweir // open our own resource block, as the page titles are strings local to this block
356cdf0e10cSrcweir LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG);
357cdf0e10cSrcweir
358cdf0e10cSrcweir pPage->SetText(String(ModuleRes(nStringId)));
359cdf0e10cSrcweir defaultButton( _nState == START_PAGE ? WZB_NEXT : WZB_FINISH );
360cdf0e10cSrcweir enableButtons( WZB_FINISH, _nState == START_PAGE ? sal_False : sal_True);
361cdf0e10cSrcweir pPage->Show();
362cdf0e10cSrcweir }
363cdf0e10cSrcweir return pPage;
364cdf0e10cSrcweir }
365cdf0e10cSrcweir // -----------------------------------------------------------------------------
leaveState(WizardState _nState)366cdf0e10cSrcweir sal_Bool ODbTypeWizDialog::leaveState(WizardState _nState)
367cdf0e10cSrcweir {
368cdf0e10cSrcweir SfxTabPage* pPage = static_cast<SfxTabPage*>(WizardDialog::GetPage(_nState));
369cdf0e10cSrcweir if ( pPage )
370cdf0e10cSrcweir pPage->FillItemSet(*m_pOutSet);
371cdf0e10cSrcweir return sal_True;
372cdf0e10cSrcweir }
373cdf0e10cSrcweir // -----------------------------------------------------------------------------
setTitle(const::rtl::OUString & _sTitle)374cdf0e10cSrcweir void ODbTypeWizDialog::setTitle(const ::rtl::OUString& _sTitle)
375cdf0e10cSrcweir {
376cdf0e10cSrcweir SetText(_sTitle);
377cdf0e10cSrcweir }
378cdf0e10cSrcweir //-------------------------------------------------------------------------
enableConfirmSettings(bool _bEnable)379cdf0e10cSrcweir void ODbTypeWizDialog::enableConfirmSettings( bool _bEnable )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir enableButtons( WZB_FINISH, _bEnable );
382cdf0e10cSrcweir // TODO:
383cdf0e10cSrcweir // this is hacky. At the moment, this method is used in only one case (#b6532894#).
384cdf0e10cSrcweir // As soon as it is to be used more wide-spread, we should find a proper concept
385cdf0e10cSrcweir // for enabling both the Next and Finish buttons, depending on the current page state.
386cdf0e10cSrcweir // Plus, the concept must also care for the case where those pages are embedded into
387cdf0e10cSrcweir // anormal tab dialog.
388cdf0e10cSrcweir }
389cdf0e10cSrcweir //-------------------------------------------------------------------------
saveDatasource()390cdf0e10cSrcweir sal_Bool ODbTypeWizDialog::saveDatasource()
391cdf0e10cSrcweir {
392cdf0e10cSrcweir SfxTabPage* pPage = static_cast<SfxTabPage*>(WizardDialog::GetPage(getCurrentState()));
393cdf0e10cSrcweir if ( pPage )
394cdf0e10cSrcweir pPage->FillItemSet(*m_pOutSet);
395cdf0e10cSrcweir
396cdf0e10cSrcweir DataSourceInfoConverter aConverter(getORB());
397cdf0e10cSrcweir ::rtl::OUString sOldURL;
398cdf0e10cSrcweir if ( m_pImpl->getCurrentDataSource().is() )
399cdf0e10cSrcweir m_pImpl->getCurrentDataSource()->getPropertyValue(PROPERTY_URL) >>= sOldURL;
400cdf0e10cSrcweir aConverter.convert(m_pCollection,sOldURL,m_eType,m_pImpl->getCurrentDataSource());
401cdf0e10cSrcweir return sal_True;
402cdf0e10cSrcweir }
403cdf0e10cSrcweir // -----------------------------------------------------------------------------
getPageController(TabPage * _pCurrentPage) const404cdf0e10cSrcweir IWizardPageController* ODbTypeWizDialog::getPageController( TabPage* _pCurrentPage ) const
405cdf0e10cSrcweir {
406cdf0e10cSrcweir OGenericAdministrationPage* pPage = static_cast<OGenericAdministrationPage*>(_pCurrentPage);
407cdf0e10cSrcweir return pPage;
408cdf0e10cSrcweir }
409cdf0e10cSrcweir // -----------------------------------------------------------------------------
onFinish()410cdf0e10cSrcweir sal_Bool ODbTypeWizDialog::onFinish()
411cdf0e10cSrcweir {
412cdf0e10cSrcweir saveDatasource();
413cdf0e10cSrcweir return m_pImpl->saveChanges(*m_pOutSet) ? OWizardMachine::onFinish() : sal_False;
414cdf0e10cSrcweir }
415cdf0e10cSrcweir //.........................................................................
416cdf0e10cSrcweir } // namespace dbaui
417cdf0e10cSrcweir //.........................................................................
418