2001-05-29 08:59:46 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 13:54:39 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-05-29 08:59:46 +00:00
|
|
|
*
|
2008-04-10 13:54:39 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2001-05-29 08:59:46 +00:00
|
|
|
*
|
2008-04-10 13:54:39 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-05-29 08:59:46 +00:00
|
|
|
*
|
2008-04-10 13:54:39 +00:00
|
|
|
* $RCSfile: generalpage.cxx,v $
|
|
|
|
* $Revision: 1.56 $
|
2001-05-29 08:59:46 +00:00
|
|
|
*
|
2008-04-10 13:54:39 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-05-29 08:59:46 +00:00
|
|
|
*
|
2008-04-10 13:54:39 +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.
|
2001-05-29 08:59:46 +00:00
|
|
|
*
|
2008-04-10 13:54:39 +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).
|
2001-05-29 08:59:46 +00:00
|
|
|
*
|
2008-04-10 13:54:39 +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.
|
2001-05-29 08:59:46 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 06:10:11 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_dbaccess.hxx"
|
|
|
|
|
2001-05-29 08:59:46 +00:00
|
|
|
#ifndef _DBAUI_GENERALPAGE_HXX_
|
|
|
|
#include "generalpage.hxx"
|
|
|
|
#endif
|
2003-06-04 11:26:07 +00:00
|
|
|
#ifndef _DBHELPER_DBEXCEPTION_HXX_
|
|
|
|
#include <connectivity/dbexception.hxx>
|
|
|
|
#endif
|
2002-08-19 07:01:32 +00:00
|
|
|
#ifndef _DBU_DLG_HRC_
|
|
|
|
#include "dbu_dlg.hrc"
|
2001-05-29 08:59:46 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _DBAUI_DBADMIN_HRC_
|
|
|
|
#include "dbadmin.hrc"
|
|
|
|
#endif
|
|
|
|
#ifndef _DBAUI_DATASOURCEITEMS_HXX_
|
|
|
|
#include "dsitems.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
|
|
|
|
#include "dbustrings.hrc"
|
|
|
|
#endif
|
|
|
|
#ifndef _DBAUI_DBADMIN_HXX_
|
|
|
|
#include "dbadmin.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _FILEDLGHELPER_HXX
|
|
|
|
#include <sfx2/filedlghelper.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _VCL_STDTEXT_HXX
|
|
|
|
#include <vcl/stdtext.hxx>
|
|
|
|
#endif
|
2003-03-19 16:57:12 +00:00
|
|
|
#ifndef _DBAUI_LOCALRESACCESS_HXX_
|
|
|
|
#include "localresaccess.hxx"
|
2001-05-29 08:59:46 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _SV_MSGBOX_HXX
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXSTRITEM_HXX
|
|
|
|
#include <svtools/stritem.hxx>
|
|
|
|
#endif
|
2001-07-31 15:02:21 +00:00
|
|
|
#ifndef _SV_WAITOBJ_HXX
|
|
|
|
#include <vcl/waitobj.hxx>
|
|
|
|
#endif
|
2001-05-29 08:59:46 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XDriverAccess.hpp>
|
|
|
|
#endif
|
2005-06-30 15:33:15 +00:00
|
|
|
#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
|
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
|
|
|
|
#include <com/sun/star/uno/Sequence.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
|
|
|
|
#include <com/sun/star/container/XNameAccess.hpp>
|
|
|
|
#endif
|
2004-08-02 14:49:03 +00:00
|
|
|
#ifndef DBAUI_DRIVERSETTINGS_HXX
|
|
|
|
#include "DriverSettings.hxx"
|
2003-04-01 13:02:04 +00:00
|
|
|
#endif
|
2004-03-17 09:45:52 +00:00
|
|
|
|
2001-05-29 08:59:46 +00:00
|
|
|
//.........................................................................
|
|
|
|
namespace dbaui
|
|
|
|
{
|
|
|
|
//.........................................................................
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
2005-06-30 15:33:15 +00:00
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
|
2001-05-29 08:59:46 +00:00
|
|
|
//=========================================================================
|
|
|
|
//= OGeneralPage
|
|
|
|
//=========================================================================
|
|
|
|
//-------------------------------------------------------------------------
|
2004-10-27 12:04:10 +00:00
|
|
|
OGeneralPage::OGeneralPage(Window* pParent, const SfxItemSet& _rItems, sal_Bool _bDBWizardMode)
|
2001-05-29 08:59:46 +00:00
|
|
|
:OGenericAdministrationPage(pParent, ModuleRes(PAGE_GENERAL), _rItems)
|
2007-04-26 07:00:27 +00:00
|
|
|
,m_aFTHeaderText (this, ModuleRes(FT_GENERALHEADERTEXT))
|
|
|
|
,m_aFTHelpText (this, ModuleRes(FT_GENERALHELPTEXT))
|
|
|
|
,m_aFT_DatasourceTypeHeader (this, ModuleRes(FT_DATASOURCEHEADER))
|
|
|
|
,m_aRB_CreateDatabase (this, ModuleRes(RB_CREATEDBDATABASE))
|
|
|
|
,m_aRB_OpenDocument (this, ModuleRes(RB_OPENEXISTINGDOC))
|
|
|
|
,m_aRB_GetExistingDatabase (this, ModuleRes(RB_GETEXISTINGDATABASE))
|
|
|
|
,m_aFT_DocListLabel (this, ModuleRes(FT_DOCLISTLABEL))
|
|
|
|
,m_pLB_DocumentList ( new OpenDocumentListBox( this, "com.sun.star.sdb.OfficeDatabaseDocument", ModuleRes( LB_DOCUMENTLIST ) ) )
|
|
|
|
,m_aPB_OpenDocument (this, "com.sun.star.sdb.OfficeDatabaseDocument", ModuleRes(PB_OPENDOCUMENT))
|
|
|
|
,m_aTypePreLabel (this, ModuleRes(FT_DATASOURCETYPE_PRE))
|
|
|
|
,m_aDatasourceTypeLabel (this, ModuleRes(FT_DATATYPE))
|
|
|
|
,m_pDatasourceType ( new ListBox(this, ModuleRes(LB_DATATYPE)))
|
|
|
|
,m_aFTDataSourceAppendix (this, ModuleRes(FT_DATATYPEAPPENDIX))
|
|
|
|
,m_aTypePostLabel (this, ModuleRes(FT_DATASOURCETYPE_POST))
|
|
|
|
,m_aSpecialMessage (this, ModuleRes(FT_SPECIAL_MESSAGE))
|
2006-06-20 02:07:54 +00:00
|
|
|
,m_DBWizardMode (_bDBWizardMode)
|
2007-04-26 07:00:27 +00:00
|
|
|
,m_sMySQLEntry (ModuleRes(STR_MYSQLENTRY))
|
2006-06-20 02:07:54 +00:00
|
|
|
,m_eOriginalCreationMode (eCreateNew)
|
2004-10-27 12:04:10 +00:00
|
|
|
,m_pCollection (NULL)
|
|
|
|
,m_eCurrentSelection (DST_UNKNOWN)
|
|
|
|
,m_eNotSupportedKnownType (DST_UNKNOWN)
|
2006-06-20 02:07:54 +00:00
|
|
|
,m_eLastMessage (smNone)
|
2004-10-27 12:04:10 +00:00
|
|
|
,m_bDisplayingInvalid (sal_False)
|
|
|
|
,m_bUserGrabFocus (sal_True)
|
2001-05-29 08:59:46 +00:00
|
|
|
{
|
|
|
|
// fill the listbox with the UI descriptions for the possible types
|
|
|
|
// and remember the respective DSN prefixes
|
|
|
|
FreeResource();
|
|
|
|
// extract the datasource type collection from the item set
|
|
|
|
DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rItems.GetItem(DSID_TYPECOLLECTION));
|
|
|
|
if (pCollectionItem)
|
|
|
|
m_pCollection = pCollectionItem->getCollection();
|
|
|
|
|
|
|
|
DBG_ASSERT(m_pCollection, "OGeneralPage::OGeneralPage : really need a DSN type collection !");
|
|
|
|
|
|
|
|
// do some knittings
|
2005-07-08 09:39:12 +00:00
|
|
|
m_pDatasourceType->SetSelectHdl(LINK(this, OGeneralPage, OnDatasourceTypeSelected));
|
2004-10-27 12:04:10 +00:00
|
|
|
m_aRB_CreateDatabase.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected));
|
|
|
|
m_aRB_GetExistingDatabase.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected));
|
2005-06-30 15:33:15 +00:00
|
|
|
m_aRB_OpenDocument.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected));
|
2004-10-27 12:04:10 +00:00
|
|
|
m_aRB_CreateDatabase.Check();
|
2005-06-30 15:33:15 +00:00
|
|
|
|
|
|
|
m_pLB_DocumentList->SetSelectHdl( LINK( this, OGeneralPage, OnDocumentSelected ) );
|
|
|
|
m_aPB_OpenDocument.SetClickHdl( LINK( this, OGeneralPage, OnOpenDocument ) );
|
2001-05-29 08:59:46 +00:00
|
|
|
}
|
2004-10-27 12:04:10 +00:00
|
|
|
|
2005-06-30 15:33:15 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
OGeneralPage::~OGeneralPage()
|
|
|
|
{
|
2005-07-08 09:39:12 +00:00
|
|
|
m_pDatasourceType.reset( NULL );
|
2005-06-30 15:33:15 +00:00
|
|
|
m_pLB_DocumentList.reset( NULL );
|
|
|
|
}
|
2004-10-27 12:04:10 +00:00
|
|
|
|
2005-10-24 07:31:44 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
struct DisplayedType
|
|
|
|
{
|
|
|
|
DATASOURCE_TYPE eType;
|
|
|
|
String sDisplayName;
|
|
|
|
|
|
|
|
DisplayedType( DATASOURCE_TYPE _eType, const String& _rDisplayName ) : eType( _eType ), sDisplayName( _rDisplayName ) { }
|
|
|
|
};
|
|
|
|
typedef ::std::vector< DisplayedType > DisplayedTypes;
|
|
|
|
|
|
|
|
struct DisplayedTypeLess : ::std::binary_function< DisplayedType, DisplayedType, bool >
|
|
|
|
{
|
|
|
|
bool operator() ( const DisplayedType& _rLHS, const DisplayedType& _rRHS )
|
|
|
|
{
|
|
|
|
return _rLHS.eType < _rRHS.eType;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2001-05-29 08:59:46 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void OGeneralPage::initializeTypeList()
|
|
|
|
{
|
2005-07-08 09:39:12 +00:00
|
|
|
m_pDatasourceType->Clear();
|
2001-05-29 08:59:46 +00:00
|
|
|
|
|
|
|
Reference< XDriverAccess > xDriverManager;
|
|
|
|
|
|
|
|
// get the driver manager, to ask it for all known URL prefixes
|
|
|
|
DBG_ASSERT(m_xORB.is(), "OGeneralPage::initializeTypeList: have no service factory!");
|
|
|
|
if (m_xORB.is())
|
|
|
|
{
|
2001-07-31 15:02:21 +00:00
|
|
|
{
|
|
|
|
// if the connection pool (resp. driver manager) may be expensive to load if it is accessed the first time,
|
|
|
|
// so display a wait cursor
|
|
|
|
WaitObject aWaitCursor(GetParent());
|
|
|
|
xDriverManager = Reference< XDriverAccess >(m_xORB->createInstance(SERVICE_SDBC_CONNECTIONPOOL), UNO_QUERY);
|
|
|
|
if (!xDriverManager.is())
|
|
|
|
xDriverManager = Reference< XDriverAccess >(m_xORB->createInstance(SERVICE_SDBC_DRIVERMANAGER), UNO_QUERY);
|
|
|
|
}
|
2001-05-29 08:59:46 +00:00
|
|
|
if (!xDriverManager.is())
|
|
|
|
ShowServiceNotAvailableError(GetParent(), String(SERVICE_SDBC_DRIVERMANAGER), sal_True);
|
|
|
|
}
|
|
|
|
|
2002-11-21 14:27:11 +00:00
|
|
|
if ( m_pCollection )
|
2001-05-29 08:59:46 +00:00
|
|
|
{
|
2005-10-24 07:31:44 +00:00
|
|
|
DisplayedTypes aDisplayedTypes;
|
|
|
|
|
2001-05-29 08:59:46 +00:00
|
|
|
for ( ODsnTypeCollection::TypeIterator aTypeLoop = m_pCollection->begin();
|
|
|
|
aTypeLoop != m_pCollection->end();
|
|
|
|
++aTypeLoop
|
|
|
|
)
|
|
|
|
{
|
|
|
|
DATASOURCE_TYPE eType = aTypeLoop.getType();
|
|
|
|
|
2002-11-21 14:27:11 +00:00
|
|
|
if ( xDriverManager.is() )
|
2001-05-29 08:59:46 +00:00
|
|
|
{ // we have a driver manager to check
|
|
|
|
::rtl::OUString sURLPrefix = m_pCollection->getDatasourcePrefix(eType);
|
|
|
|
if (!xDriverManager->getDriverByURL(sURLPrefix).is())
|
|
|
|
// we have no driver for this prefix
|
|
|
|
// -> omit it
|
|
|
|
continue;
|
|
|
|
}
|
2002-11-21 14:27:11 +00:00
|
|
|
String sDisplayName = aTypeLoop.getDisplayName();
|
2005-07-08 09:39:12 +00:00
|
|
|
if ( m_pDatasourceType->GetEntryPos( sDisplayName ) == LISTBOX_ENTRY_NOTFOUND )
|
2002-11-21 14:27:11 +00:00
|
|
|
{
|
2008-01-30 07:45:43 +00:00
|
|
|
if ( approveDataSourceType( eType, sDisplayName ) )
|
2005-10-24 07:31:44 +00:00
|
|
|
aDisplayedTypes.push_back( DisplayedTypes::value_type( eType, sDisplayName ) );
|
2002-11-21 14:27:11 +00:00
|
|
|
}
|
2001-05-29 08:59:46 +00:00
|
|
|
}
|
2005-10-24 07:31:44 +00:00
|
|
|
::std::sort( aDisplayedTypes.begin(), aDisplayedTypes.end(), DisplayedTypeLess() );
|
|
|
|
for ( DisplayedTypes::const_iterator loop = aDisplayedTypes.begin();
|
|
|
|
loop != aDisplayedTypes.end();
|
|
|
|
++loop
|
|
|
|
)
|
|
|
|
insertDatasourceTypeEntryData( loop->eType, loop->sDisplayName );
|
2001-05-29 08:59:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-27 12:04:10 +00:00
|
|
|
|
|
|
|
|
2001-05-29 08:59:46 +00:00
|
|
|
//-------------------------------------------------------------------------
|
2004-08-02 14:49:03 +00:00
|
|
|
void OGeneralPage::setParentTitle(DATASOURCE_TYPE _eSelectedType)
|
2001-05-29 08:59:46 +00:00
|
|
|
{
|
2004-10-27 12:04:10 +00:00
|
|
|
if (!m_DBWizardMode)
|
2001-05-29 08:59:46 +00:00
|
|
|
{
|
2004-10-27 12:04:10 +00:00
|
|
|
String sName = m_pCollection->getTypeDisplayName(_eSelectedType);
|
|
|
|
if ( m_pAdminDialog )
|
|
|
|
{
|
2006-05-04 07:42:14 +00:00
|
|
|
LocalResourceAccess aStringResAccess( PAGE_GENERAL, RSC_TABPAGE );
|
2007-04-26 07:00:27 +00:00
|
|
|
String sMessage = String(ModuleRes(STR_PARENTTITLE));
|
2004-10-27 12:04:10 +00:00
|
|
|
sMessage.SearchAndReplaceAscii("#",sName);
|
|
|
|
m_pAdminDialog->setTitle(sMessage);
|
|
|
|
}
|
2001-05-29 08:59:46 +00:00
|
|
|
}
|
|
|
|
}
|
2004-10-27 12:04:10 +00:00
|
|
|
|
2005-06-30 15:33:15 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
OGeneralPage::CreationMode OGeneralPage::GetDatabaseCreationMode() const
|
|
|
|
{
|
|
|
|
if ( m_aRB_CreateDatabase.IsChecked() )
|
|
|
|
return eCreateNew;
|
|
|
|
if ( m_aRB_GetExistingDatabase.IsChecked() )
|
|
|
|
return eConnectExternal;
|
|
|
|
return eOpenExisting;
|
2004-10-27 12:04:10 +00:00
|
|
|
}
|
|
|
|
|
2001-05-29 08:59:46 +00:00
|
|
|
//-------------------------------------------------------------------------
|
2004-08-02 14:49:03 +00:00
|
|
|
void OGeneralPage::GetFocus()
|
2001-05-29 08:59:46 +00:00
|
|
|
{
|
2004-08-02 14:49:03 +00:00
|
|
|
OGenericAdministrationPage::GetFocus();
|
2005-06-30 15:33:15 +00:00
|
|
|
if ( m_pLB_DocumentList.get() && m_pLB_DocumentList->IsEnabled() )
|
|
|
|
m_pLB_DocumentList->GrabFocus();
|
2005-07-08 09:39:12 +00:00
|
|
|
else if (m_pDatasourceType.get() && m_pDatasourceType->IsEnabled())
|
|
|
|
m_pDatasourceType->GrabFocus();
|
2001-05-29 08:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
2006-06-20 02:07:54 +00:00
|
|
|
void OGeneralPage::switchMessage(const DATASOURCE_TYPE _eType)
|
2001-05-29 08:59:46 +00:00
|
|
|
{
|
2002-11-21 14:27:11 +00:00
|
|
|
SPECIAL_MESSAGE eMessage = smNone;
|
2004-08-02 14:49:03 +00:00
|
|
|
if ( _eType == m_eNotSupportedKnownType )
|
2001-05-29 08:59:46 +00:00
|
|
|
{
|
2002-12-09 06:50:18 +00:00
|
|
|
eMessage = smUnsupportedType;
|
2001-05-29 08:59:46 +00:00
|
|
|
}
|
2002-11-21 14:27:11 +00:00
|
|
|
|
2001-05-29 08:59:46 +00:00
|
|
|
|
2002-11-21 14:27:11 +00:00
|
|
|
if ( eMessage != m_eLastMessage )
|
|
|
|
{
|
|
|
|
sal_uInt16 nResId = 0;
|
2006-06-20 02:07:54 +00:00
|
|
|
if ( smUnsupportedType == eMessage )
|
|
|
|
nResId = STR_UNSUPPORTED_DATASOURCE_TYPE;
|
2002-11-21 14:27:11 +00:00
|
|
|
String sMessage;
|
|
|
|
if ( nResId )
|
|
|
|
{
|
2006-05-04 07:42:14 +00:00
|
|
|
LocalResourceAccess aStringResAccess( PAGE_GENERAL, RSC_TABPAGE );
|
2007-04-26 07:00:27 +00:00
|
|
|
sMessage = String(ModuleRes(nResId));
|
2002-11-21 14:27:11 +00:00
|
|
|
}
|
|
|
|
m_aSpecialMessage.SetText(sMessage);
|
|
|
|
|
|
|
|
m_eLastMessage = eMessage;
|
|
|
|
}
|
2001-05-29 08:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void OGeneralPage::onTypeSelected(const DATASOURCE_TYPE _eType)
|
|
|
|
{
|
|
|
|
// the the new URL text as indicated by the selection history
|
2001-08-01 07:30:41 +00:00
|
|
|
implSetCurrentType( _eType );
|
2001-05-29 08:59:46 +00:00
|
|
|
|
2006-06-20 02:07:54 +00:00
|
|
|
switchMessage(_eType);
|
2001-05-29 08:59:46 +00:00
|
|
|
|
2002-11-21 14:27:11 +00:00
|
|
|
if ( m_aTypeSelectHandler.IsSet() )
|
2001-05-29 08:59:46 +00:00
|
|
|
m_aTypeSelectHandler.Call(this);
|
|
|
|
}
|
2004-10-27 12:04:10 +00:00
|
|
|
|
2001-05-29 08:59:46 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void OGeneralPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
|
|
|
|
{
|
|
|
|
initializeTypeList();
|
|
|
|
|
|
|
|
// first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
|
|
|
|
sal_Bool bValid, bReadonly;
|
|
|
|
getFlags(_rSet, bValid, bReadonly);
|
2004-10-27 12:04:10 +00:00
|
|
|
if (m_DBWizardMode)
|
|
|
|
{
|
|
|
|
m_aTypePreLabel.Hide();
|
|
|
|
m_aTypePostLabel.Hide();
|
|
|
|
m_aSpecialMessage.Hide();
|
|
|
|
SetControlFontWeight(&m_aFTHeaderText);
|
2005-06-30 15:33:15 +00:00
|
|
|
SetText(String());
|
|
|
|
|
2005-07-08 09:39:12 +00:00
|
|
|
m_pDatasourceType->SetPosPixel( MovePoint( m_aRB_GetExistingDatabase.GetPosPixel(), INDENT_BELOW_RADIO, 14 ) );
|
2005-06-30 15:33:15 +00:00
|
|
|
|
2007-11-21 14:57:53 +00:00
|
|
|
if ( !bValid || bReadonly )
|
|
|
|
{
|
|
|
|
m_aDatasourceTypeLabel.Enable( false );
|
|
|
|
m_pDatasourceType->Enable( false );
|
|
|
|
m_aFTDataSourceAppendix.Enable( false );
|
|
|
|
m_aPB_OpenDocument.Enable( false );
|
|
|
|
m_aFT_DocListLabel.Enable( false );
|
|
|
|
m_pLB_DocumentList->Enable( false );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_aControlDependencies.enableOnRadioCheck( m_aRB_GetExistingDatabase, m_aDatasourceTypeLabel, *m_pDatasourceType, m_aFTDataSourceAppendix );
|
|
|
|
m_aControlDependencies.enableOnRadioCheck( m_aRB_OpenDocument, m_aPB_OpenDocument, m_aFT_DocListLabel, *m_pLB_DocumentList );
|
|
|
|
}
|
2005-06-30 15:33:15 +00:00
|
|
|
|
|
|
|
m_pLB_DocumentList->SetDropDownLineCount( 20 );
|
|
|
|
if ( m_pLB_DocumentList->GetEntryCount() )
|
|
|
|
m_pLB_DocumentList->SelectEntryPos( 0 );
|
|
|
|
|
|
|
|
m_aDatasourceTypeLabel.Hide();
|
|
|
|
m_aFTDataSourceAppendix.Hide();
|
|
|
|
|
|
|
|
m_eOriginalCreationMode = GetDatabaseCreationMode();
|
2004-10-27 12:04:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_aFT_DatasourceTypeHeader.Hide();
|
|
|
|
m_aRB_CreateDatabase.Hide();
|
|
|
|
m_aRB_GetExistingDatabase.Hide();
|
2005-06-30 15:33:15 +00:00
|
|
|
m_aRB_OpenDocument.Hide();
|
|
|
|
m_aPB_OpenDocument.Hide();
|
|
|
|
m_aFT_DocListLabel.Hide();
|
|
|
|
m_pLB_DocumentList->Hide();
|
2004-10-27 12:04:10 +00:00
|
|
|
m_aFTHeaderText.Hide();
|
|
|
|
m_aFTHelpText.Hide();
|
|
|
|
m_aTypePreLabel.Enable(bValid);
|
|
|
|
m_aTypePostLabel.Enable(bValid);
|
|
|
|
m_aDatasourceTypeLabel.Enable(bValid);
|
2005-07-08 09:39:12 +00:00
|
|
|
m_pDatasourceType->Enable(bValid);
|
2004-10-27 12:04:10 +00:00
|
|
|
}
|
2001-05-29 08:59:46 +00:00
|
|
|
// if the selection is invalid, disable evrything
|
2004-08-02 14:49:03 +00:00
|
|
|
String sName,sConnectURL;
|
2001-05-29 08:59:46 +00:00
|
|
|
m_bDisplayingInvalid = !bValid;
|
2004-08-02 14:49:03 +00:00
|
|
|
if ( bValid )
|
2001-05-29 08:59:46 +00:00
|
|
|
{
|
|
|
|
// collect some items and some values
|
|
|
|
SFX_ITEMSET_GET(_rSet, pNameItem, SfxStringItem, DSID_NAME, sal_True);
|
2004-08-02 14:49:03 +00:00
|
|
|
SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
|
2001-05-29 08:59:46 +00:00
|
|
|
DBG_ASSERT(pUrlItem, "OGeneralPage::implInitControls : missing the type attribute !");
|
2004-08-02 14:49:03 +00:00
|
|
|
DBG_ASSERT(pNameItem, "OGeneralPage::implInitControls : missing the type attribute !");
|
2001-05-29 08:59:46 +00:00
|
|
|
sName = pNameItem->GetValue();
|
2004-08-02 14:49:03 +00:00
|
|
|
sConnectURL = pUrlItem->GetValue();
|
2001-05-29 08:59:46 +00:00
|
|
|
}
|
|
|
|
|
2001-08-01 07:30:41 +00:00
|
|
|
DATASOURCE_TYPE eOldSelection = m_eCurrentSelection;
|
|
|
|
m_eNotSupportedKnownType = DST_UNKNOWN;
|
|
|
|
implSetCurrentType( DST_UNKNOWN );
|
|
|
|
|
2001-05-29 08:59:46 +00:00
|
|
|
// compare the DSN prefix with the registered ones
|
|
|
|
String sDisplayName;
|
2001-08-01 07:30:41 +00:00
|
|
|
|
2001-05-29 08:59:46 +00:00
|
|
|
if (m_pCollection && bValid)
|
|
|
|
{
|
2001-08-01 07:30:41 +00:00
|
|
|
implSetCurrentType( m_pCollection->getType(sConnectURL) );
|
2001-05-29 08:59:46 +00:00
|
|
|
sDisplayName = m_pCollection->getTypeDisplayName(m_eCurrentSelection);
|
|
|
|
}
|
2008-01-30 07:45:43 +00:00
|
|
|
|
2001-05-29 08:59:46 +00:00
|
|
|
// select the correct datasource type
|
2008-01-30 07:45:43 +00:00
|
|
|
if ( approveDataSourceType( m_eCurrentSelection, sDisplayName )
|
|
|
|
&& ( LISTBOX_ENTRY_NOTFOUND == m_pDatasourceType->GetEntryPos( sDisplayName ) )
|
|
|
|
)
|
|
|
|
{ // this indicates it's really a type which is known in general, but not supported on the current platform
|
|
|
|
// show a message saying so
|
|
|
|
// eSpecialMessage = smUnsupportedType;
|
|
|
|
insertDatasourceTypeEntryData(m_eCurrentSelection, sDisplayName);
|
|
|
|
// remember this type so we can show the special message again if the user selects this
|
|
|
|
// type again (without changing the data source)
|
|
|
|
m_eNotSupportedKnownType = m_eCurrentSelection;
|
2001-05-29 08:59:46 +00:00
|
|
|
}
|
2008-01-30 07:45:43 +00:00
|
|
|
|
2004-10-27 12:04:10 +00:00
|
|
|
if (m_aRB_CreateDatabase.IsChecked() && m_DBWizardMode)
|
2005-06-30 15:33:15 +00:00
|
|
|
sDisplayName = m_pCollection->getTypeDisplayName(DST_JDBC);
|
2005-07-08 09:39:12 +00:00
|
|
|
m_pDatasourceType->SelectEntry(sDisplayName);
|
2001-08-01 07:30:41 +00:00
|
|
|
|
2001-05-29 08:59:46 +00:00
|
|
|
// notify our listener that our type selection has changed (if so)
|
2004-08-02 14:49:03 +00:00
|
|
|
if ( eOldSelection != m_eCurrentSelection )
|
2001-05-29 08:59:46 +00:00
|
|
|
{
|
2004-08-02 14:49:03 +00:00
|
|
|
setParentTitle(m_eCurrentSelection);
|
|
|
|
onTypeSelected(m_eCurrentSelection);
|
2001-05-29 08:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// a special message for the current page state
|
2006-06-20 02:07:54 +00:00
|
|
|
switchMessage(m_eCurrentSelection);
|
2004-10-27 12:04:10 +00:00
|
|
|
|
2004-08-02 14:49:03 +00:00
|
|
|
OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
|
|
|
|
}
|
2004-10-27 12:04:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
// For the databaseWizard we only have one entry for the MySQL Database,
|
|
|
|
// because we have a seperate tabpage to retrieve the respective datasource type
|
2008-01-30 07:45:43 +00:00
|
|
|
// (DST_MYSQL_ODBC || DST_MYSQL_JDBC). Therefore we use DST_MYSQL_JDBC as a temporary
|
2004-10-27 12:04:10 +00:00
|
|
|
// representative for all MySQl databases)
|
2008-01-30 07:45:43 +00:00
|
|
|
// Also, embedded databases (embedded HSQL, at the moment), are not to appear in the list of
|
|
|
|
// databases to connect to.
|
|
|
|
bool OGeneralPage::approveDataSourceType( DATASOURCE_TYPE eType, String& _inout_rDisplayName )
|
2004-10-27 12:04:10 +00:00
|
|
|
{
|
2008-01-30 07:45:43 +00:00
|
|
|
if ( m_DBWizardMode && ( eType == DST_MYSQL_JDBC ) )
|
|
|
|
_inout_rDisplayName = m_sMySQLEntry;
|
|
|
|
|
2008-03-05 16:00:34 +00:00
|
|
|
else if ( m_DBWizardMode && ( eType == DST_MYSQL_ODBC ) )
|
2008-01-30 07:45:43 +00:00
|
|
|
_inout_rDisplayName = String();
|
|
|
|
|
2008-03-05 16:00:34 +00:00
|
|
|
else if ( m_DBWizardMode && ( eType == DST_MYSQL_NATIVE ) )
|
|
|
|
_inout_rDisplayName = String();
|
|
|
|
|
|
|
|
else if ( eType == DST_EMBEDDED_HSQLDB )
|
2008-01-30 07:45:43 +00:00
|
|
|
_inout_rDisplayName = String();
|
|
|
|
|
|
|
|
return _inout_rDisplayName.Len() > 0;
|
2004-10-27 12:04:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-30 15:33:15 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2004-10-27 12:04:10 +00:00
|
|
|
void OGeneralPage::insertDatasourceTypeEntryData(DATASOURCE_TYPE _eType, String sDisplayName)
|
|
|
|
{
|
2005-06-30 15:33:15 +00:00
|
|
|
// insert a (temporary) entry
|
2005-07-08 09:39:12 +00:00
|
|
|
sal_uInt16 nPos = m_pDatasourceType->InsertEntry(sDisplayName);
|
|
|
|
m_pDatasourceType->SetEntryData(nPos, reinterpret_cast<void*>(_eType));
|
2004-10-27 12:04:10 +00:00
|
|
|
}
|
|
|
|
|
2004-08-02 14:49:03 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void OGeneralPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
|
|
|
|
{
|
|
|
|
_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aTypePreLabel));
|
|
|
|
_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aDatasourceTypeLabel));
|
|
|
|
_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aTypePostLabel));
|
|
|
|
_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aSpecialMessage));
|
2005-01-21 16:15:41 +00:00
|
|
|
_rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDataSourceAppendix));
|
2004-08-02 14:49:03 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void OGeneralPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
|
|
|
|
{
|
2005-07-08 09:39:12 +00:00
|
|
|
_rControlList.push_back(new OSaveValueWrapper<ListBox>(m_pDatasourceType.get()));
|
2001-05-29 08:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
2004-10-27 12:04:10 +00:00
|
|
|
SfxTabPage* OGeneralPage::Create(Window* _pParent, const SfxItemSet& _rAttrSet, sal_Bool _bWizardMode)
|
2001-05-29 08:59:46 +00:00
|
|
|
{
|
2004-10-27 12:04:10 +00:00
|
|
|
return ( new OGeneralPage( _pParent, _rAttrSet, _bWizardMode ) );
|
2001-05-29 08:59:46 +00:00
|
|
|
}
|
|
|
|
|
2001-08-01 07:30:41 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void OGeneralPage::implSetCurrentType( const DATASOURCE_TYPE _eType )
|
|
|
|
{
|
|
|
|
if ( _eType == m_eCurrentSelection )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_eCurrentSelection = _eType;
|
|
|
|
}
|
|
|
|
|
2001-05-29 08:59:46 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void OGeneralPage::Reset(const SfxItemSet& _rCoreAttrs)
|
|
|
|
{
|
2001-08-02 12:46:58 +00:00
|
|
|
// reset all locale data
|
2001-08-01 07:30:41 +00:00
|
|
|
implSetCurrentType( DST_UNKNOWN );
|
2001-05-29 08:59:46 +00:00
|
|
|
// this ensures that our type selection link will be called, even if the new is is the same as the
|
|
|
|
// current one
|
|
|
|
OGenericAdministrationPage::Reset(_rCoreAttrs);
|
2001-07-31 15:02:21 +00:00
|
|
|
}
|
|
|
|
|
2001-05-29 08:59:46 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
BOOL OGeneralPage::FillItemSet(SfxItemSet& _rCoreAttrs)
|
|
|
|
{
|
|
|
|
sal_Bool bChangedSomething = sal_False;
|
2005-06-30 15:33:15 +00:00
|
|
|
|
|
|
|
bool bCommitTypeSelection = true;
|
|
|
|
if ( m_DBWizardMode )
|
2001-05-29 08:59:46 +00:00
|
|
|
{
|
2005-06-30 15:33:15 +00:00
|
|
|
if ( m_aRB_CreateDatabase.IsChecked() )
|
|
|
|
{
|
|
|
|
_rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getDatasourcePrefix(DST_DBASE)));
|
|
|
|
bChangedSomething = sal_True;
|
|
|
|
bCommitTypeSelection = false;
|
|
|
|
}
|
|
|
|
else if ( m_aRB_OpenDocument.IsChecked() )
|
|
|
|
{
|
|
|
|
if ( m_aRB_OpenDocument.GetSavedValue() != m_aRB_OpenDocument.IsChecked() )
|
|
|
|
bChangedSomething = sal_True;
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
bCommitTypeSelection = false;
|
|
|
|
}
|
2001-05-29 08:59:46 +00:00
|
|
|
}
|
2005-06-30 15:33:15 +00:00
|
|
|
|
|
|
|
if ( bCommitTypeSelection )
|
2004-10-27 12:04:10 +00:00
|
|
|
{
|
2005-07-08 09:39:12 +00:00
|
|
|
USHORT nEntry = m_pDatasourceType->GetSelectEntryPos();
|
2005-10-05 13:46:12 +00:00
|
|
|
DATASOURCE_TYPE eSelectedType = static_cast<DATASOURCE_TYPE>(reinterpret_cast<sal_IntPtr>(m_pDatasourceType->GetEntryData(nEntry)));
|
2004-10-27 12:04:10 +00:00
|
|
|
if (m_DBWizardMode)
|
|
|
|
{
|
2005-07-08 09:39:12 +00:00
|
|
|
if ( ( m_pDatasourceType->GetSavedValue() != nEntry )
|
2005-06-30 15:33:15 +00:00
|
|
|
|| ( GetDatabaseCreationMode() != m_eOriginalCreationMode )
|
|
|
|
)
|
2004-10-27 12:04:10 +00:00
|
|
|
{
|
|
|
|
_rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getDatasourcePrefix(eSelectedType)));
|
|
|
|
bChangedSomething = sal_True;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
implSetCurrentType(eSelectedType);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-07-08 09:39:12 +00:00
|
|
|
if ( m_pDatasourceType->GetSavedValue() != nEntry)
|
2004-10-27 12:04:10 +00:00
|
|
|
{
|
|
|
|
_rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getDatasourcePrefix(eSelectedType)));
|
|
|
|
bChangedSomething = sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-05-29 08:59:46 +00:00
|
|
|
return bChangedSomething;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
IMPL_LINK(OGeneralPage, OnDatasourceTypeSelected, ListBox*, _pBox)
|
|
|
|
{
|
|
|
|
// get the type from the entry data
|
|
|
|
sal_Int16 nSelected = _pBox->GetSelectEntryPos();
|
2005-10-05 13:46:12 +00:00
|
|
|
DATASOURCE_TYPE eSelectedType = static_cast<DATASOURCE_TYPE>(reinterpret_cast<sal_IntPtr>(_pBox->GetEntryData(nSelected)));
|
2004-08-02 14:49:03 +00:00
|
|
|
|
|
|
|
setParentTitle(eSelectedType);
|
2001-05-29 08:59:46 +00:00
|
|
|
// let the impl method do all the stuff
|
|
|
|
onTypeSelected(eSelectedType);
|
|
|
|
// tell the listener we were modified
|
|
|
|
callModifiedHdl();
|
|
|
|
// outta here
|
|
|
|
return 0L;
|
|
|
|
}
|
2004-10-27 12:04:10 +00:00
|
|
|
|
2005-06-30 15:33:15 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
OGeneralPage::DocumentDescriptor OGeneralPage::GetSelectedDocument() const
|
2004-10-27 12:04:10 +00:00
|
|
|
{
|
2005-06-30 15:33:15 +00:00
|
|
|
DocumentDescriptor aDocument;
|
|
|
|
if ( m_aBrowsedDocument.sURL.Len() )
|
|
|
|
aDocument = m_aBrowsedDocument;
|
2004-10-27 12:04:10 +00:00
|
|
|
else
|
2005-06-30 15:33:15 +00:00
|
|
|
{
|
|
|
|
aDocument.sURL = m_pLB_DocumentList->GetSelectedDocumentURL();
|
|
|
|
aDocument.sFilter = m_pLB_DocumentList->GetSelectedDocumentFilter();
|
|
|
|
}
|
|
|
|
return aDocument;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
2006-06-20 02:07:54 +00:00
|
|
|
IMPL_LINK(OGeneralPage, OnSetupModeSelected, RadioButton*, /*_pBox*/)
|
2005-06-30 15:33:15 +00:00
|
|
|
{
|
2004-10-27 12:04:10 +00:00
|
|
|
if ( m_aCreationModeHandler.IsSet() )
|
|
|
|
m_aCreationModeHandler.Call(this);
|
2004-11-09 11:33:08 +00:00
|
|
|
return 1L;
|
2004-10-27 12:04:10 +00:00
|
|
|
}
|
2005-06-30 15:33:15 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
2006-06-20 02:07:54 +00:00
|
|
|
IMPL_LINK(OGeneralPage, OnDocumentSelected, ListBox*, /*_pBox*/)
|
2005-06-30 15:33:15 +00:00
|
|
|
{
|
|
|
|
m_aDocumentSelectionHandler.Call( this );
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
2006-06-20 02:07:54 +00:00
|
|
|
IMPL_LINK(OGeneralPage, OnOpenDocument, PushButton*, /*_pBox*/)
|
2005-06-30 15:33:15 +00:00
|
|
|
{
|
|
|
|
::sfx2::FileDialogHelper aFileDlg( WB_OPEN, ::String::CreateFromAscii("sdatabase") );
|
|
|
|
if ( aFileDlg.Execute() == ERRCODE_NONE )
|
|
|
|
{
|
|
|
|
m_aBrowsedDocument.sURL = aFileDlg.GetPath();
|
|
|
|
m_aBrowsedDocument.sFilter = String();
|
|
|
|
m_aChooseDocumentHandler.Call( this );
|
|
|
|
return 1L;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
2001-05-29 08:59:46 +00:00
|
|
|
//.........................................................................
|
|
|
|
} // namespace dbaui
|
|
|
|
//.........................................................................
|
|
|
|
|