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