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