update dev300-m58
[ooovba.git] / dbaccess / source / ui / dlg / ConnectionPageSetup.cxx
blobf38e794ed974301482d0e0c3fc0c142da3e1d4d2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ConnectionPageSetup.cxx,v $
10 * $Revision: 1.12.68.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #ifndef DBAUI_CONNECTIONPAGESETUP_HXX
35 #include "ConnectionPageSetup.hxx"
36 #endif
37 #ifndef _DBAUI_AUTOCONTROLS_HRC_
38 #include "AutoControls.hrc"
39 #endif
40 #ifndef _DBAUI_DBADMINSETUP_HRC_
41 #include "dbadminsetup.hrc"
42 #endif
43 #ifndef _DBU_DLG_HRC_
44 #include "dbu_dlg.hrc"
45 #endif
46 #ifndef _SFXITEMSET_HXX
47 #include <svtools/itemset.hxx>
48 #endif
49 #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
50 #include <svtools/pathoptions.hxx>
51 #endif
52 #ifndef _SFXSTRITEM_HXX
53 #include <svtools/stritem.hxx>
54 #endif
55 #ifndef _SFXENUMITEM_HXX
56 #include <svtools/eitem.hxx>
57 #endif
58 #ifndef _SFXINTITEM_HXX
59 #include <svtools/intitem.hxx>
60 #endif
61 #ifndef _DBAUI_DATASOURCEITEMS_HXX_
62 #include "dsitems.hxx"
63 #endif
64 #ifndef _DBA_DBACCESS_HELPID_HRC_
65 #include "dbaccess_helpid.hrc"
66 #endif
67 #ifndef _DBAUI_LOCALRESACCESS_HXX_
68 #include "localresaccess.hxx"
69 #endif
70 #ifndef _OSL_PROCESS_H_
71 #include <osl/process.h>
72 #endif
73 #ifndef _SV_MSGBOX_HXX
74 #include <vcl/msgbox.hxx>
75 #endif
76 #ifndef _FILEDLGHELPER_HXX
77 #include <sfx2/filedlghelper.hxx>
78 #endif
79 #ifndef _DBAUI_DBADMIN_HXX_
80 #include "dbadmin.hxx"
81 #endif
82 #ifndef _DBAUI_DBADMIN_HRC_
83 #include "dbadmin.hrc"
84 #endif
85 #ifndef _COMPHELPER_TYPES_HXX_
86 #include <comphelper/types.hxx>
87 #endif
88 #ifndef _VCL_STDTEXT_HXX
89 #include <vcl/stdtext.hxx>
90 #endif
91 #ifndef _DBAUI_SQLMESSAGE_HXX_
92 #include "sqlmessage.hxx"
93 #endif
94 #ifndef _DBAUI_ODBC_CONFIG_HXX_
95 #include "odbcconfig.hxx"
96 #endif
97 #ifndef _DBAUI_DSSELECT_HXX_
98 #include "dsselect.hxx"
99 #endif
100 #ifndef SVTOOLS_FILENOTATION_HXX_
101 #include <svtools/filenotation.hxx>
102 #endif
103 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
104 #include "dbustrings.hrc"
105 #endif
106 #ifndef _COM_SUN_STAR_UI_DIALOGS_XFOLDERPICKER_HPP_
107 #include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
108 #endif
109 #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
110 #include <com/sun/star/sdbc/XRow.hpp>
111 #endif
112 #ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
113 #include <com/sun/star/awt/XWindow.hpp>
114 #endif
115 // #106016# ------------------------------------
116 #ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
117 #include <com/sun/star/task/XInteractionHandler.hpp>
118 #endif
119 #ifndef _COM_SUN_STAR_TASK_XPROGRESSHANDLER_HPP_
120 #include <com/sun/star/ucb/XProgressHandler.hpp>
121 #endif
122 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
123 #include <com/sun/star/sdbc/XConnection.hpp>
124 #endif
125 #ifndef DBAUI_TOOLS_HXX
126 #include "UITools.hxx"
127 #endif
128 #ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
129 #include <unotools/localfilehelper.hxx>
130 #endif
131 #ifndef _UNOTOOLS_UCBHELPER_HXX
132 #include <unotools/ucbhelper.hxx>
133 #endif
134 #ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX
135 #include <ucbhelper/commandenvironment.hxx>
136 #endif
137 #ifndef DBAUI_FILEPICKER_INTERACTION_HXX
138 #include "finteraction.hxx"
139 #endif
140 #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
141 #include <connectivity/CommonTools.hxx>
142 #endif
143 #ifndef _URLOBJ_HXX
144 #include <tools/urlobj.hxx>
145 #endif
146 #ifndef _SFX_DOCFILT_HACK_HXX
147 #include <sfx2/docfilt.hxx>
148 #endif
149 #ifndef _SV_MNEMONIC_HXX
150 #include <vcl/mnemonic.hxx>
151 #endif
153 //.........................................................................
154 namespace dbaui
156 //.........................................................................
157 using namespace ::com::sun::star::uno;
158 using namespace ::com::sun::star::ucb;
159 using namespace ::com::sun::star::ui::dialogs;
160 using namespace ::com::sun::star::sdbc;
161 using namespace ::com::sun::star::beans;
162 using namespace ::com::sun::star::lang;
163 using namespace ::com::sun::star::container;
164 using namespace ::dbtools;
165 using namespace ::svt;
169 OGenericAdministrationPage* OConnectionTabPageSetup::CreateDbaseTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
171 OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_DBASE, _rAttrSet, STR_DBASE_HELPTEXT, STR_DBASE_HEADERTEXT, STR_DBASE_PATH_OR_FILE);
172 oDBWizardPage->FreeResource();
173 return oDBWizardPage;
177 OGenericAdministrationPage* OConnectionTabPageSetup::CreateMSAccessTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
179 OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_MSACCESS, _rAttrSet, STR_MSACCESS_HELPTEXT, STR_MSACCESS_HEADERTEXT, STR_MSACCESS_MDB_FILE);
180 oDBWizardPage->FreeResource();
181 return oDBWizardPage;
184 OGenericAdministrationPage* OConnectionTabPageSetup::CreateAdabasTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
186 OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_ADABAS, _rAttrSet, STR_ADABAS_HELPTEXT, STR_ADABAS_HEADERTEXT, STR_ADABAS_DATABASE_NAME);
187 oDBWizardPage->FreeResource();
188 return oDBWizardPage;
191 OGenericAdministrationPage* OConnectionTabPageSetup::CreateADOTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
193 OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_ADO, _rAttrSet, STR_ADO_HELPTEXT, STR_ADO_HEADERTEXT, STR_COMMONURL);
194 oDBWizardPage->FreeResource();
195 return oDBWizardPage;
198 OGenericAdministrationPage* OConnectionTabPageSetup::CreateODBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
200 OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_ODBC, _rAttrSet, STR_ODBC_HELPTEXT, STR_ODBC_HEADERTEXT, STR_NAME_OF_ODBC_DATASOURCE);
201 oDBWizardPage->FreeResource();
202 return oDBWizardPage;
205 OGenericAdministrationPage* OConnectionTabPageSetup::CreateUserDefinedTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
207 OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_USERDEFINED, _rAttrSet, USHRT_MAX, USHRT_MAX, STR_COMMONURL);
208 oDBWizardPage->FreeResource();
209 return oDBWizardPage;
213 //========================================================================
214 //= OConnectionTabPageSetup
215 //========================================================================
216 DBG_NAME(OConnectionTabPageSetup)
217 OConnectionTabPageSetup::OConnectionTabPageSetup(Window* pParent, USHORT _rId, const SfxItemSet& _rCoreAttrs, USHORT _nHelpTextResId, USHORT _nHeaderResId, USHORT _nUrlResId)
218 :OConnectionHelper(pParent, ModuleRes(_rId), _rCoreAttrs)
219 ,m_bUserGrabFocus(sal_True)
220 ,m_aFT_HelpText(this, ModuleRes(FT_AUTOWIZARDHELPTEXT))
222 DBG_CTOR(OConnectionTabPageSetup, NULL);
224 if ( USHRT_MAX != _nHelpTextResId )
226 String sHelpText = String(ModuleRes(_nHelpTextResId));
227 m_aFT_HelpText.SetText(sHelpText);
229 else
230 m_aFT_HelpText.Hide();
233 if ( USHRT_MAX != _nHeaderResId )
234 SetHeaderText(FT_AUTOWIZARDHEADER, _nHeaderResId);
236 if ( USHRT_MAX != _nUrlResId )
238 String sLabelText = String(ModuleRes(_nUrlResId));
239 m_aFT_Connection.SetText(sLabelText);
240 if ( USHRT_MAX == _nHelpTextResId )
242 Point aPos = m_aFT_HelpText.GetPosPixel();
243 Point aFTPos = m_aFT_Connection.GetPosPixel();
244 Point aEDPos = m_aConnectionURL.GetPosPixel();
245 Point aPBPos = m_aPB_Connection.GetPosPixel();
247 aEDPos.Y() = aPos.Y() + aEDPos.Y() - aFTPos.Y();
248 aPBPos.Y() = aPos.Y() + aPBPos.Y() - aFTPos.Y();
249 aFTPos.Y() = aPos.Y();
250 m_aFT_Connection.SetPosPixel(aFTPos);
251 m_aConnectionURL.SetPosPixel(aEDPos);
252 m_aPB_Connection.SetPosPixel(aPBPos);
255 else
256 m_aFT_Connection.Hide();
258 m_aConnectionURL.SetModifyHdl(LINK(this, OConnectionTabPageSetup, OnEditModified));
260 SetRoadmapStateValue(sal_False);
263 // -----------------------------------------------------------------------
264 OConnectionTabPageSetup::~OConnectionTabPageSetup()
266 DBG_DTOR(OConnectionTabPageSetup,NULL);
269 // -----------------------------------------------------------------------
270 void OConnectionTabPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
272 m_eType = m_pAdminDialog->getDatasourceType(_rSet);
273 // special handling for oracle, this can only happen
274 // if the user enters the same url as used for Oracle and we are on the JDBC path
275 //! TODO
276 //if ( ::dbaccess::DST_ORACLE_JDBC == m_eType )
277 // m_eType = ::dbaccess::DST_JDBC;
279 OConnectionHelper::implInitControls(_rSet, _bSaveValue);
281 //! TODO
282 //if ( m_eType >= ::dbaccess::DST_USERDEFINE1 )
284 // String sDisplayName = m_pCollection->getTypeDisplayName(m_eType);
285 // FixedText* ppTextControls[] ={&m_aFT_Connection};
286 // for (size_t i = 0; i < sizeof(ppTextControls)/sizeof(ppTextControls[0]); ++i)
287 // {
288 // ppTextControls[i]->SetText(sDisplayName);
289 // }
292 callModifiedHdl();
294 // -----------------------------------------------------------------------
295 sal_Bool OConnectionTabPageSetup::commitPage( CommitPageReason /*_eReason*/ )
297 return commitURL();
300 // -----------------------------------------------------------------------
301 sal_Bool OConnectionTabPageSetup::FillItemSet(SfxItemSet& _rSet)
303 sal_Bool bChangedSomething = sal_False;
304 fillString(_rSet,&m_aConnectionURL, DSID_CONNECTURL, bChangedSomething);
305 return bChangedSomething;
307 // -----------------------------------------------------------------------
308 bool OConnectionTabPageSetup::checkTestConnection()
310 return !m_aConnectionURL.IsVisible() || (m_aConnectionURL.GetTextNoPrefix().Len() != 0);
313 // -----------------------------------------------------------------------
314 IMPL_LINK(OConnectionTabPageSetup, OnEditModified, Edit*, /*_pEdit*/)
316 SetRoadmapStateValue(checkTestConnection());
317 callModifiedHdl();
318 return 0L;
320 //.........................................................................
321 } // namespace dbaui
322 //.........................................................................