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