2004-10-27 11:58:48 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 13:29:34 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-10-27 11:58:48 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2004-10-27 11:58:48 +00:00
|
|
|
*
|
2008-04-10 13:29:34 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-10-27 11:58:48 +00:00
|
|
|
*
|
2008-04-10 13:29:34 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-10-27 11:58:48 +00:00
|
|
|
*
|
2008-04-10 13:29:34 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2004-10-27 11:58:48 +00:00
|
|
|
*
|
2008-04-10 13:29:34 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2004-10-27 11:58:48 +00:00
|
|
|
*
|
2008-04-10 13:29:34 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2004-10-27 11:58:48 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 06:05:02 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_dbaccess.hxx"
|
|
|
|
|
2004-10-27 11:58:48 +00:00
|
|
|
#include "ConnectionPageSetup.hxx"
|
|
|
|
#include "AutoControls.hrc"
|
|
|
|
#include "dbadminsetup.hrc"
|
|
|
|
#include "dbu_dlg.hrc"
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/itemset.hxx>
|
2009-10-06 07:38:24 +02:00
|
|
|
#include <unotools/pathoptions.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/stritem.hxx>
|
|
|
|
#include <svl/eitem.hxx>
|
|
|
|
#include <svl/intitem.hxx>
|
2004-10-27 11:58:48 +00:00
|
|
|
#include "dsitems.hxx"
|
|
|
|
#include "dbaccess_helpid.hrc"
|
|
|
|
#include "localresaccess.hxx"
|
|
|
|
#include <osl/process.h>
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#include <sfx2/filedlghelper.hxx>
|
|
|
|
#include "dbadmin.hxx"
|
|
|
|
#include "dbadmin.hrc"
|
|
|
|
#include <comphelper/types.hxx>
|
|
|
|
#include <vcl/stdtext.hxx>
|
|
|
|
#include "sqlmessage.hxx"
|
|
|
|
#include "odbcconfig.hxx"
|
|
|
|
#include "dsselect.hxx"
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/filenotation.hxx>
|
2004-10-27 11:58:48 +00:00
|
|
|
#include "dbustrings.hrc"
|
|
|
|
#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XRow.hpp>
|
|
|
|
#include <com/sun/star/awt/XWindow.hpp>
|
|
|
|
// #106016# ------------------------------------
|
|
|
|
#include <com/sun/star/task/XInteractionHandler.hpp>
|
|
|
|
#include <com/sun/star/ucb/XProgressHandler.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XConnection.hpp>
|
|
|
|
#include "UITools.hxx"
|
|
|
|
#include <unotools/localfilehelper.hxx>
|
|
|
|
#include <unotools/ucbhelper.hxx>
|
|
|
|
#include <ucbhelper/commandenvironment.hxx>
|
|
|
|
#include "finteraction.hxx"
|
|
|
|
#include <connectivity/CommonTools.hxx>
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#include <sfx2/docfilt.hxx>
|
|
|
|
#include <vcl/mnemonic.hxx>
|
|
|
|
|
|
|
|
//.........................................................................
|
|
|
|
namespace dbaui
|
|
|
|
{
|
|
|
|
//.........................................................................
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::ucb;
|
|
|
|
using namespace ::com::sun::star::ui::dialogs;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::dbtools;
|
|
|
|
using namespace ::svt;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OGenericAdministrationPage* OConnectionTabPageSetup::CreateDbaseTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
|
|
|
|
{
|
|
|
|
OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_DBASE, _rAttrSet, STR_DBASE_HELPTEXT, STR_DBASE_HEADERTEXT, STR_DBASE_PATH_OR_FILE);
|
|
|
|
oDBWizardPage->FreeResource();
|
|
|
|
return oDBWizardPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OGenericAdministrationPage* OConnectionTabPageSetup::CreateMSAccessTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
|
|
|
|
{
|
|
|
|
OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_MSACCESS, _rAttrSet, STR_MSACCESS_HELPTEXT, STR_MSACCESS_HEADERTEXT, STR_MSACCESS_MDB_FILE);
|
|
|
|
oDBWizardPage->FreeResource();
|
|
|
|
return oDBWizardPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
OGenericAdministrationPage* OConnectionTabPageSetup::CreateAdabasTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
|
|
|
|
{
|
|
|
|
OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_ADABAS, _rAttrSet, STR_ADABAS_HELPTEXT, STR_ADABAS_HEADERTEXT, STR_ADABAS_DATABASE_NAME);
|
|
|
|
oDBWizardPage->FreeResource();
|
|
|
|
return oDBWizardPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
OGenericAdministrationPage* OConnectionTabPageSetup::CreateADOTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
|
|
|
|
{
|
|
|
|
OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_ADO, _rAttrSet, STR_ADO_HELPTEXT, STR_ADO_HEADERTEXT, STR_COMMONURL);
|
|
|
|
oDBWizardPage->FreeResource();
|
|
|
|
return oDBWizardPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
OGenericAdministrationPage* OConnectionTabPageSetup::CreateODBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
|
|
|
|
{
|
|
|
|
OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_ODBC, _rAttrSet, STR_ODBC_HELPTEXT, STR_ODBC_HEADERTEXT, STR_NAME_OF_ODBC_DATASOURCE);
|
|
|
|
oDBWizardPage->FreeResource();
|
|
|
|
return oDBWizardPage;
|
|
|
|
}
|
|
|
|
|
2005-01-21 16:12:18 +00:00
|
|
|
OGenericAdministrationPage* OConnectionTabPageSetup::CreateUserDefinedTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
|
|
|
|
{
|
|
|
|
OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_USERDEFINED, _rAttrSet, USHRT_MAX, USHRT_MAX, STR_COMMONURL);
|
|
|
|
oDBWizardPage->FreeResource();
|
|
|
|
return oDBWizardPage;
|
|
|
|
}
|
|
|
|
|
2004-10-27 11:58:48 +00:00
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
//= OConnectionTabPageSetup
|
|
|
|
//========================================================================
|
|
|
|
DBG_NAME(OConnectionTabPageSetup)
|
2006-06-20 02:02:51 +00:00
|
|
|
OConnectionTabPageSetup::OConnectionTabPageSetup(Window* pParent, USHORT _rId, const SfxItemSet& _rCoreAttrs, USHORT _nHelpTextResId, USHORT _nHeaderResId, USHORT _nUrlResId)
|
2004-10-27 11:58:48 +00:00
|
|
|
:OConnectionHelper(pParent, ModuleRes(_rId), _rCoreAttrs)
|
|
|
|
,m_bUserGrabFocus(sal_True)
|
2007-04-26 06:56:11 +00:00
|
|
|
,m_aFT_HelpText(this, ModuleRes(FT_AUTOWIZARDHELPTEXT))
|
2004-10-27 11:58:48 +00:00
|
|
|
{
|
|
|
|
DBG_CTOR(OConnectionTabPageSetup, NULL);
|
2005-01-21 16:12:18 +00:00
|
|
|
|
|
|
|
if ( USHRT_MAX != _nHelpTextResId )
|
|
|
|
{
|
|
|
|
String sHelpText = String(ModuleRes(_nHelpTextResId));
|
|
|
|
m_aFT_HelpText.SetText(sHelpText);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_aFT_HelpText.Hide();
|
|
|
|
|
|
|
|
|
|
|
|
if ( USHRT_MAX != _nHeaderResId )
|
2007-05-10 09:22:01 +00:00
|
|
|
SetHeaderText(FT_AUTOWIZARDHEADER, _nHeaderResId);
|
2005-01-21 16:12:18 +00:00
|
|
|
|
|
|
|
if ( USHRT_MAX != _nUrlResId )
|
|
|
|
{
|
|
|
|
String sLabelText = String(ModuleRes(_nUrlResId));
|
|
|
|
m_aFT_Connection.SetText(sLabelText);
|
|
|
|
if ( USHRT_MAX == _nHelpTextResId )
|
|
|
|
{
|
|
|
|
Point aPos = m_aFT_HelpText.GetPosPixel();
|
|
|
|
Point aFTPos = m_aFT_Connection.GetPosPixel();
|
2009-02-16 07:31:09 +00:00
|
|
|
Point aEDPos = m_aConnectionURL.GetPosPixel();
|
2005-01-21 16:12:18 +00:00
|
|
|
Point aPBPos = m_aPB_Connection.GetPosPixel();
|
|
|
|
|
|
|
|
aEDPos.Y() = aPos.Y() + aEDPos.Y() - aFTPos.Y();
|
|
|
|
aPBPos.Y() = aPos.Y() + aPBPos.Y() - aFTPos.Y();
|
|
|
|
aFTPos.Y() = aPos.Y();
|
|
|
|
m_aFT_Connection.SetPosPixel(aFTPos);
|
2009-02-16 07:31:09 +00:00
|
|
|
m_aConnectionURL.SetPosPixel(aEDPos);
|
2005-01-21 16:12:18 +00:00
|
|
|
m_aPB_Connection.SetPosPixel(aPBPos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_aFT_Connection.Hide();
|
|
|
|
|
2009-02-16 07:31:09 +00:00
|
|
|
m_aConnectionURL.SetModifyHdl(LINK(this, OConnectionTabPageSetup, OnEditModified));
|
2004-10-27 11:58:48 +00:00
|
|
|
|
|
|
|
SetRoadmapStateValue(sal_False);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
OConnectionTabPageSetup::~OConnectionTabPageSetup()
|
|
|
|
{
|
|
|
|
DBG_DTOR(OConnectionTabPageSetup,NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void OConnectionTabPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
|
|
|
|
{
|
2005-03-10 15:47:39 +00:00
|
|
|
m_eType = m_pAdminDialog->getDatasourceType(_rSet);
|
|
|
|
// special handling for oracle, this can only happen
|
|
|
|
// if the user enters the same url as used for Oracle and we are on the JDBC path
|
2009-07-03 12:24:35 +00:00
|
|
|
//! TODO
|
|
|
|
//if ( ::dbaccess::DST_ORACLE_JDBC == m_eType )
|
|
|
|
// m_eType = ::dbaccess::DST_JDBC;
|
2005-03-10 15:47:39 +00:00
|
|
|
|
2004-10-27 11:58:48 +00:00
|
|
|
OConnectionHelper::implInitControls(_rSet, _bSaveValue);
|
2005-03-10 15:47:39 +00:00
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
//! TODO
|
|
|
|
//if ( m_eType >= ::dbaccess::DST_USERDEFINE1 )
|
|
|
|
//{
|
|
|
|
// String sDisplayName = m_pCollection->getTypeDisplayName(m_eType);
|
|
|
|
// FixedText* ppTextControls[] ={&m_aFT_Connection};
|
|
|
|
// for (size_t i = 0; i < sizeof(ppTextControls)/sizeof(ppTextControls[0]); ++i)
|
|
|
|
// {
|
|
|
|
// ppTextControls[i]->SetText(sDisplayName);
|
|
|
|
// }
|
|
|
|
//}
|
2004-10-27 11:58:48 +00:00
|
|
|
|
2005-01-21 16:12:18 +00:00
|
|
|
callModifiedHdl();
|
2004-10-27 11:58:48 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------
|
2010-05-25 10:17:24 +02:00
|
|
|
sal_Bool OConnectionTabPageSetup::commitPage( ::svt::WizardTypes::CommitPageReason /*_eReason*/ )
|
2004-10-27 11:58:48 +00:00
|
|
|
{
|
|
|
|
return commitURL();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
sal_Bool OConnectionTabPageSetup::FillItemSet(SfxItemSet& _rSet)
|
|
|
|
{
|
|
|
|
sal_Bool bChangedSomething = sal_False;
|
2009-02-16 07:31:09 +00:00
|
|
|
fillString(_rSet,&m_aConnectionURL, DSID_CONNECTURL, bChangedSomething);
|
2004-10-27 11:58:48 +00:00
|
|
|
return bChangedSomething;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
bool OConnectionTabPageSetup::checkTestConnection()
|
|
|
|
{
|
2009-02-16 07:31:09 +00:00
|
|
|
return !m_aConnectionURL.IsVisible() || (m_aConnectionURL.GetTextNoPrefix().Len() != 0);
|
2004-10-27 11:58:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2006-06-20 02:02:51 +00:00
|
|
|
IMPL_LINK(OConnectionTabPageSetup, OnEditModified, Edit*, /*_pEdit*/)
|
2004-10-27 11:58:48 +00:00
|
|
|
{
|
|
|
|
SetRoadmapStateValue(checkTestConnection());
|
|
|
|
callModifiedHdl();
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
//.........................................................................
|
|
|
|
} // namespace dbaui
|
|
|
|
//.........................................................................
|
|
|
|
|
|
|
|
|