2001-02-23 14:07:41 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 15:09:17 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-02-23 14:07:41 +00:00
|
|
|
*
|
2005-09-08 15:09:17 +00:00
|
|
|
* $RCSfile: WCPage.cxx,v $
|
2001-02-23 14:07:41 +00:00
|
|
|
*
|
2007-04-26 07:02:09 +00:00
|
|
|
* $Revision: 1.29 $
|
2001-02-23 14:07:41 +00:00
|
|
|
*
|
2007-04-26 07:02:09 +00:00
|
|
|
* last change: $Author: rt $ $Date: 2007-04-26 08:02:09 $
|
2001-02-23 14:07:41 +00:00
|
|
|
*
|
2005-09-08 15:09:17 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2001-02-23 14:07:41 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-08 15:09:17 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2001-02-23 14:07:41 +00:00
|
|
|
*
|
2005-09-08 15:09:17 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2001-02-23 14:07:41 +00:00
|
|
|
*
|
2005-09-08 15:09:17 +00:00
|
|
|
* This library 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 for more details.
|
2001-02-23 14:07:41 +00:00
|
|
|
*
|
2005-09-08 15:09:17 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2001-02-23 14:07:41 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 06:14:20 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_dbaccess.hxx"
|
|
|
|
|
2001-02-23 14:07:41 +00:00
|
|
|
#ifndef DBAUI_WIZARD_CPAGE_HXX
|
|
|
|
#include "WCPage.hxx"
|
|
|
|
#endif
|
2006-07-10 14:36:35 +00:00
|
|
|
#ifndef DBACCESS_SOURCE_UI_MISC_DEFAULTOBJECTNAMECHECK_HXX
|
|
|
|
#include "defaultobjectnamecheck.hxx"
|
|
|
|
#endif
|
2001-02-23 14:07:41 +00:00
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DBAUI_MODULE_DBU_HXX_
|
|
|
|
#include "moduledbu.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _DBA_DBACCESS_HELPID_HRC_
|
|
|
|
#include "dbaccess_helpid.hrc"
|
|
|
|
#endif
|
2002-08-19 07:01:32 +00:00
|
|
|
#ifndef _DBU_MISC_HRC_
|
|
|
|
#include "dbu_misc.hrc"
|
2001-02-23 14:07:41 +00:00
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_WIZARD_PAGES_HRC
|
|
|
|
#include "WizardPages.hrc"
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XResultSet.hpp>
|
|
|
|
#endif
|
2006-07-10 14:36:35 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
|
|
|
|
#include <com/sun/star/sdb/CommandType.hpp>
|
|
|
|
#endif
|
2001-02-23 14:07:41 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XRow.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
|
|
|
|
#endif
|
2001-07-02 12:22:11 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
|
|
|
|
#endif
|
2001-02-23 14:07:41 +00:00
|
|
|
#ifndef _SV_MSGBOX_HXX
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#endif
|
2001-07-02 12:22:11 +00:00
|
|
|
#ifndef _DBHELPER_DBEXCEPTION_HXX_
|
|
|
|
#include <connectivity/dbexception.hxx>
|
|
|
|
#endif
|
2002-03-21 06:08:44 +00:00
|
|
|
#ifndef _CONNECTIVITY_DBTOOLS_HXX_
|
|
|
|
#include <connectivity/dbtools.hxx>
|
|
|
|
#endif
|
2001-07-02 12:22:11 +00:00
|
|
|
#ifndef DBAUI_TOOLS_HXX
|
|
|
|
#include "UITools.hxx"
|
|
|
|
#endif
|
2006-07-10 14:36:35 +00:00
|
|
|
#ifndef _CPPUHELPER_EXC_HLP_HXX_
|
|
|
|
#include <cppuhelper/exc_hlp.hxx>
|
|
|
|
#endif
|
2001-02-23 14:07:41 +00:00
|
|
|
|
|
|
|
using namespace ::dbaui;
|
2001-07-02 12:22:11 +00:00
|
|
|
using namespace ::dbtools;
|
2001-02-23 14:07:41 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::util;
|
2006-07-10 14:36:35 +00:00
|
|
|
using namespace ::com::sun::star::sdb;
|
2001-02-23 14:07:41 +00:00
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
//========================================================================
|
|
|
|
// Klasse OCopyTable
|
|
|
|
//========================================================================
|
2006-06-20 02:21:35 +00:00
|
|
|
DBG_NAME(OCopyTable)
|
2001-02-23 14:07:41 +00:00
|
|
|
//------------------------------------------------------------------------
|
2002-07-05 12:55:05 +00:00
|
|
|
OCopyTable::OCopyTable( Window * pParent, EImportMode atWhat, sal_Bool bIsView, OCopyTableWizard::Wizard_Create_Style nLastAction )
|
2001-02-23 14:07:41 +00:00
|
|
|
: OWizardPage( pParent, ModuleRes(TAB_WIZ_COPYTABLE) ),
|
2007-04-26 07:02:09 +00:00
|
|
|
m_ftTableName( this, ModuleRes( FT_TABLENAME ) ),
|
|
|
|
m_edTableName( this, ModuleRes( ET_TABLENAME ) ),
|
|
|
|
m_aFL_Options( this, ModuleRes( FL_OPTIONS ) ),
|
|
|
|
m_aRB_DefData( this, ModuleRes( RB_DEFDATA ) ),
|
|
|
|
m_aRB_Def( this, ModuleRes( RB_DEF ) ),
|
|
|
|
m_aRB_View( this, ModuleRes( RB_VIEW ) ),
|
|
|
|
m_aRB_AppendData( this, ModuleRes( RB_APPENDDATA ) ),
|
|
|
|
m_aCB_PrimaryColumn( this, ModuleRes( CB_PRIMARY_COLUMN ) ),
|
|
|
|
m_aFT_KeyName( this, ModuleRes( FT_KEYNAME ) ),
|
|
|
|
m_edKeyName( this, ModuleRes( ET_KEYNAME ) ),
|
2001-02-23 14:07:41 +00:00
|
|
|
m_pPage2(NULL),
|
|
|
|
m_pPage3(NULL),
|
2002-07-05 12:55:05 +00:00
|
|
|
m_bIsViewAllowed(bIsView)
|
2001-02-23 14:07:41 +00:00
|
|
|
{
|
|
|
|
DBG_CTOR(OCopyTable,NULL);
|
|
|
|
|
2002-03-21 06:08:44 +00:00
|
|
|
m_edTableName.SetMaxTextLen( EDIT_NOLIMIT );
|
|
|
|
|
2001-07-02 09:31:49 +00:00
|
|
|
if(m_pParent->m_xConnection.is())
|
2001-02-23 14:07:41 +00:00
|
|
|
{
|
2001-07-02 12:22:11 +00:00
|
|
|
// first we have to determine if we support views
|
2001-07-02 09:31:49 +00:00
|
|
|
Reference< XDatabaseMetaData > xMetaData(m_pParent->m_xConnection->getMetaData());
|
2001-07-02 12:22:11 +00:00
|
|
|
Reference< XViewsSupplier > xViewSups(m_pParent->m_xConnection,UNO_QUERY);
|
2006-10-12 12:40:35 +00:00
|
|
|
m_bIsViewAllowed = xViewSups.is();
|
|
|
|
if(!m_bIsViewAllowed)
|
2001-02-23 14:07:41 +00:00
|
|
|
{
|
2001-07-02 12:22:11 +00:00
|
|
|
try
|
2001-02-23 14:07:41 +00:00
|
|
|
{
|
2002-11-14 06:58:31 +00:00
|
|
|
const static ::rtl::OUString sVIEW = ::rtl::OUString::createFromAscii("VIEW");
|
2001-07-02 12:22:11 +00:00
|
|
|
Reference<XResultSet> xRs = xMetaData->getTableTypes();
|
2002-11-14 06:58:31 +00:00
|
|
|
if ( xRs.is() )
|
2001-02-23 14:07:41 +00:00
|
|
|
{
|
2001-07-02 12:22:11 +00:00
|
|
|
Reference<XRow> xRow(xRs,UNO_QUERY);
|
2002-11-14 06:58:31 +00:00
|
|
|
while ( xRs->next() )
|
2001-07-02 09:31:49 +00:00
|
|
|
{
|
2001-07-02 12:22:11 +00:00
|
|
|
::rtl::OUString sValue = xRow->getString(1);
|
2002-11-14 06:58:31 +00:00
|
|
|
if ( !xRow->wasNull() && sValue.equalsIgnoreAsciiCase(sVIEW) )
|
2001-07-02 12:22:11 +00:00
|
|
|
{
|
2002-11-14 06:58:31 +00:00
|
|
|
m_bIsViewAllowed = sal_True;
|
2001-07-02 12:22:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-07-02 09:31:49 +00:00
|
|
|
}
|
2001-02-23 14:07:41 +00:00
|
|
|
}
|
|
|
|
}
|
2006-07-10 14:36:35 +00:00
|
|
|
catch(const SQLException&)
|
2001-07-02 12:22:11 +00:00
|
|
|
{
|
2006-07-10 14:36:35 +00:00
|
|
|
::dbaui::showError( SQLExceptionInfo( ::cppu::getCaughtException() ), m_pParent, m_pParent->m_xFactory );
|
2001-07-02 12:22:11 +00:00
|
|
|
}
|
2001-07-02 09:31:49 +00:00
|
|
|
}
|
2001-02-23 14:07:41 +00:00
|
|
|
|
2002-07-05 12:55:05 +00:00
|
|
|
if ( !m_bIsViewAllowed || bIsView ) // if it is a view disable the view checkbox #100644# OJ
|
2001-07-02 09:31:49 +00:00
|
|
|
m_aRB_View.Disable();
|
2001-02-23 14:07:41 +00:00
|
|
|
|
2001-07-02 09:31:49 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
2001-07-02 12:22:11 +00:00
|
|
|
// do we support pkeys
|
2002-11-14 06:58:31 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
m_bPKeyAllowed = xMetaData->supportsCoreSQLGrammar();
|
|
|
|
}
|
|
|
|
catch(const SQLException&)
|
|
|
|
{
|
|
|
|
m_bPKeyAllowed = sal_False;
|
|
|
|
}
|
2001-02-23 14:07:41 +00:00
|
|
|
|
2001-07-02 09:31:49 +00:00
|
|
|
m_aCB_PrimaryColumn.Enable(m_bPKeyAllowed);
|
2001-02-23 14:07:41 +00:00
|
|
|
|
2001-07-02 12:22:11 +00:00
|
|
|
// reselect the last action before
|
2001-07-02 09:31:49 +00:00
|
|
|
switch(nLastAction)
|
|
|
|
{
|
|
|
|
case OCopyTableWizard::WIZARD_DEF_DATA:
|
2001-02-23 14:07:41 +00:00
|
|
|
m_aRB_DefData.Check(sal_True);
|
2001-07-02 09:31:49 +00:00
|
|
|
break;
|
|
|
|
case OCopyTableWizard::WIZARD_DEF:
|
|
|
|
m_aRB_Def.Check(sal_True);
|
|
|
|
break;
|
|
|
|
case OCopyTableWizard::WIZARD_APPEND_DATA:
|
|
|
|
m_aRB_AppendData.Check(sal_True);
|
|
|
|
m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,sal_False);
|
|
|
|
break;
|
|
|
|
case OCopyTableWizard::WIZARD_DEF_VIEW:
|
|
|
|
if(m_bIsViewAllowed)
|
|
|
|
{
|
|
|
|
m_aRB_View.Check(sal_True);
|
|
|
|
m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,sal_False);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_aRB_DefData.Check(sal_True);
|
|
|
|
}
|
|
|
|
m_aRB_AppendData.SetClickHdl( LINK( this, OCopyTable, AppendDataClickHdl ) );
|
2001-02-23 14:07:41 +00:00
|
|
|
|
2001-07-02 09:31:49 +00:00
|
|
|
m_aRB_DefData.SetClickHdl( LINK( this, OCopyTable, RadioChangeHdl ) );
|
|
|
|
m_aRB_Def.SetClickHdl( LINK( this, OCopyTable, RadioChangeHdl ) );
|
|
|
|
m_aRB_View.SetClickHdl( LINK( this, OCopyTable, RadioChangeHdl ) );
|
2001-02-23 14:07:41 +00:00
|
|
|
|
2001-07-02 09:31:49 +00:00
|
|
|
m_aCB_PrimaryColumn.SetClickHdl( LINK( this, OCopyTable, KeyClickHdl ) );
|
2001-02-23 14:07:41 +00:00
|
|
|
|
2001-07-02 09:31:49 +00:00
|
|
|
m_aFT_KeyName.Enable(sal_False);
|
|
|
|
m_edKeyName.Enable(sal_False);
|
2002-11-14 06:58:31 +00:00
|
|
|
|
|
|
|
::rtl::OUString sKeyName(::rtl::OUString::createFromAscii("ID"));
|
2002-12-10 08:19:22 +00:00
|
|
|
sKeyName = m_pParent->createUniqueName(sKeyName);
|
2002-11-14 06:58:31 +00:00
|
|
|
m_edKeyName.SetText(sKeyName);
|
|
|
|
|
2001-07-02 12:22:11 +00:00
|
|
|
sal_Int32 nMaxLen = m_pParent->getMaxColumnNameLength();
|
2001-07-02 09:31:49 +00:00
|
|
|
m_edKeyName.SetMaxTextLen(nMaxLen ? (xub_StrLen)nMaxLen : EDIT_NOLIMIT);
|
|
|
|
}
|
2001-02-23 14:07:41 +00:00
|
|
|
|
|
|
|
FreeResource();
|
|
|
|
|
|
|
|
if (MOVE != atWhat)
|
|
|
|
SetText(String(ModuleRes(STR_COPYTABLE_TITLE_COPY)));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetText(String(ModuleRes(STR_COPYTABLE_TITLE_MOVE)));
|
|
|
|
m_aRB_Def.Disable();
|
|
|
|
// beim Verschieben ist der Punkt "nur Definition" nicht zulaessig
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
OCopyTable::~OCopyTable()
|
|
|
|
{
|
|
|
|
DBG_DTOR(OCopyTable,NULL);
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
2006-06-20 02:21:35 +00:00
|
|
|
IMPL_LINK( OCopyTable, AppendDataClickHdl, Button*, /*pButton*/ )
|
2001-02-23 14:07:41 +00:00
|
|
|
{
|
2004-08-02 15:06:42 +00:00
|
|
|
DBG_CHKTHIS(OCopyTable,NULL);
|
2001-02-23 14:07:41 +00:00
|
|
|
m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,sal_True);
|
|
|
|
m_aFT_KeyName.Enable(sal_False);
|
|
|
|
m_aCB_PrimaryColumn.Enable(sal_False);
|
|
|
|
m_edKeyName.Enable(sal_False);
|
2001-07-02 12:22:11 +00:00
|
|
|
m_pParent->setCreateStyle(OCopyTableWizard::WIZARD_APPEND_DATA);
|
|
|
|
|
2001-02-23 14:07:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
IMPL_LINK( OCopyTable, RadioChangeHdl, Button*, pButton )
|
|
|
|
{
|
2004-08-02 15:06:42 +00:00
|
|
|
DBG_CHKTHIS(OCopyTable,NULL);
|
2001-02-23 14:07:41 +00:00
|
|
|
m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,pButton != &m_aRB_View);
|
|
|
|
sal_Bool bKey = m_bPKeyAllowed && pButton != &m_aRB_View;
|
|
|
|
m_aFT_KeyName.Enable(bKey && m_aCB_PrimaryColumn.IsChecked());
|
|
|
|
m_edKeyName.Enable(bKey && m_aCB_PrimaryColumn.IsChecked());
|
|
|
|
m_aCB_PrimaryColumn.Enable(bKey);
|
|
|
|
|
|
|
|
// set typ what to do
|
|
|
|
if( IsOptionDefData() )
|
2001-07-02 12:22:11 +00:00
|
|
|
m_pParent->setCreateStyle(OCopyTableWizard::WIZARD_DEF_DATA);
|
2001-02-23 14:07:41 +00:00
|
|
|
else if( IsOptionDef() )
|
2001-07-02 12:22:11 +00:00
|
|
|
m_pParent->setCreateStyle(OCopyTableWizard::WIZARD_DEF);
|
2001-02-23 14:07:41 +00:00
|
|
|
else if( IsOptionView() )
|
2001-07-02 12:22:11 +00:00
|
|
|
m_pParent->setCreateStyle(OCopyTableWizard::WIZARD_DEF_VIEW);
|
2001-02-23 14:07:41 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
2006-06-20 02:21:35 +00:00
|
|
|
IMPL_LINK( OCopyTable, KeyClickHdl, Button*, /*pButton*/ )
|
2001-02-23 14:07:41 +00:00
|
|
|
{
|
2004-08-02 15:06:42 +00:00
|
|
|
DBG_CHKTHIS(OCopyTable,NULL);
|
2001-02-23 14:07:41 +00:00
|
|
|
m_edKeyName.Enable(m_aCB_PrimaryColumn.IsChecked());
|
|
|
|
m_aFT_KeyName.Enable(m_aCB_PrimaryColumn.IsChecked());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
sal_Bool OCopyTable::LeavePage()
|
|
|
|
{
|
2004-08-02 15:06:42 +00:00
|
|
|
DBG_CHKTHIS(OCopyTable,NULL);
|
2001-02-23 14:07:41 +00:00
|
|
|
m_pParent->m_bCreatePrimaryColumn = (m_bPKeyAllowed && m_aCB_PrimaryColumn.IsEnabled()) ? m_aCB_PrimaryColumn.IsChecked() : sal_False;
|
2002-11-14 06:58:31 +00:00
|
|
|
m_pParent->m_aKeyName = m_pParent->m_bCreatePrimaryColumn ? m_edKeyName.GetText() : String();
|
2001-02-23 14:07:41 +00:00
|
|
|
|
2001-08-08 07:24:54 +00:00
|
|
|
// first check if the table already exists in the database
|
2001-07-02 12:22:11 +00:00
|
|
|
if( m_pParent->getCreateStyle() != OCopyTableWizard::WIZARD_APPEND_DATA )
|
2001-02-23 14:07:41 +00:00
|
|
|
{
|
2006-07-10 14:36:35 +00:00
|
|
|
DynamicTableOrQueryNameCheck aNameCheck( m_pParent->m_xConnection, CommandType::TABLE );
|
|
|
|
SQLExceptionInfo aErrorInfo;
|
|
|
|
if ( !aNameCheck.isNameValid( m_edTableName.GetText(), aErrorInfo ) )
|
2001-02-23 14:07:41 +00:00
|
|
|
{
|
2006-07-10 14:36:35 +00:00
|
|
|
aErrorInfo.append( SQLExceptionInfo::SQL_CONTEXT, String( ModuleRes( STR_SUGGEST_APPEND_TABLE_DATA ) ) );
|
|
|
|
::dbaui::showError( aErrorInfo, m_pParent, m_pParent->m_xFactory );
|
2001-02-23 14:07:41 +00:00
|
|
|
return sal_False;
|
|
|
|
}
|
2006-07-10 14:36:35 +00:00
|
|
|
|
|
|
|
// have to check the length of the table name
|
|
|
|
Reference<XDatabaseMetaData> xMeta = m_pParent->m_xConnection->getMetaData();
|
|
|
|
::rtl::OUString sCatalog;
|
|
|
|
::rtl::OUString sSchema;
|
|
|
|
::rtl::OUString sTable;
|
|
|
|
::dbtools::qualifiedNameComponents( xMeta,
|
|
|
|
m_edTableName.GetText(),
|
|
|
|
sCatalog,
|
|
|
|
sSchema,
|
|
|
|
sTable,
|
|
|
|
::dbtools::eInDataManipulation);
|
|
|
|
sal_Int32 nMaxLength = xMeta->getMaxTableNameLength();
|
|
|
|
if ( nMaxLength && sTable.getLength() > nMaxLength )
|
2002-03-21 06:08:44 +00:00
|
|
|
{
|
2006-07-10 14:36:35 +00:00
|
|
|
ErrorBox(this, ModuleRes(ERROR_INVALID_TABLE_NAME_LENGTH)).Execute();
|
|
|
|
return sal_False;
|
2002-03-21 06:08:44 +00:00
|
|
|
}
|
2002-11-14 06:58:31 +00:00
|
|
|
|
|
|
|
// now we have to check if the name of the primary key already exists
|
|
|
|
if ( m_pParent->m_bCreatePrimaryColumn
|
2002-12-10 08:19:22 +00:00
|
|
|
&& m_pParent->m_aKeyName != m_pParent->createUniqueName(m_pParent->m_aKeyName) )
|
2002-11-14 06:58:31 +00:00
|
|
|
{
|
|
|
|
String aInfoString( ModuleRes(STR_WIZ_PKEY_ALREADY_DEFINED) );
|
|
|
|
aInfoString += String(' ');
|
|
|
|
aInfoString += String(m_pParent->m_aKeyName);
|
|
|
|
InfoBox aNameInfoBox( this, aInfoString );
|
|
|
|
aNameInfoBox.Execute();
|
|
|
|
return sal_False;
|
|
|
|
}
|
2001-02-23 14:07:41 +00:00
|
|
|
}
|
|
|
|
|
2002-11-14 06:58:31 +00:00
|
|
|
if ( !m_edTableName.GetSavedValue().Equals(m_edTableName.GetText()) )
|
2001-08-08 07:24:54 +00:00
|
|
|
{ // table exists and name has changed
|
2002-11-14 06:58:31 +00:00
|
|
|
if ( m_pParent->getCreateStyle() == OCopyTableWizard::WIZARD_APPEND_DATA )
|
2001-02-23 14:07:41 +00:00
|
|
|
{
|
2001-12-07 12:12:29 +00:00
|
|
|
if(!checkAppendData())
|
2001-02-23 14:07:41 +00:00
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
else if(m_eOldStyle == OCopyTableWizard::WIZARD_APPEND_DATA)
|
|
|
|
{
|
2001-08-08 07:24:54 +00:00
|
|
|
m_pParent->m_xDestObject = NULL;
|
2001-07-02 12:22:11 +00:00
|
|
|
m_edTableName.SaveValue();
|
2001-02-23 14:07:41 +00:00
|
|
|
return LeavePage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // table exist and is not new or doesn't exist and so on
|
2006-06-20 02:21:35 +00:00
|
|
|
if ( OCopyTableWizard::WIZARD_APPEND_DATA == m_pParent->getCreateStyle() )
|
2001-02-23 14:07:41 +00:00
|
|
|
{
|
2006-06-20 02:21:35 +00:00
|
|
|
if( !checkAppendData() )
|
|
|
|
return sal_False;
|
2001-02-23 14:07:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
m_pParent->m_sName = m_edTableName.GetText();
|
|
|
|
m_edTableName.SaveValue();
|
|
|
|
|
|
|
|
if(!m_pParent->m_sName.getLength())
|
|
|
|
{
|
|
|
|
ErrorBox(this, ModuleRes(ERROR_INVALID_TABLE_NAME)).Execute();
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
void OCopyTable::ActivatePage()
|
|
|
|
{
|
2004-08-02 15:06:42 +00:00
|
|
|
DBG_CHKTHIS(OCopyTable,NULL);
|
2002-03-21 06:08:44 +00:00
|
|
|
m_pParent->GetOKButton().Enable( TRUE );
|
2001-07-02 12:22:11 +00:00
|
|
|
m_eOldStyle = m_pParent->getCreateStyle();
|
|
|
|
m_edTableName.GrabFocus();
|
2001-02-23 14:07:41 +00:00
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
2004-08-02 15:06:42 +00:00
|
|
|
String OCopyTable::GetTitle() const
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS(OCopyTable,NULL);
|
|
|
|
return String(ModuleRes(STR_WIZ_TABLE_COPY));
|
|
|
|
}
|
2001-02-23 14:07:41 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
void OCopyTable::Reset()
|
|
|
|
{
|
2004-08-02 15:06:42 +00:00
|
|
|
DBG_CHKTHIS(OCopyTable,NULL);
|
2001-02-23 14:07:41 +00:00
|
|
|
m_bFirstTime = sal_False;
|
|
|
|
|
2002-03-21 06:08:44 +00:00
|
|
|
m_edTableName.SetText( m_pParent->m_sName );
|
2001-02-23 14:07:41 +00:00
|
|
|
m_edTableName.SaveValue();
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
2001-12-07 12:12:29 +00:00
|
|
|
sal_Bool OCopyTable::checkAppendData()
|
|
|
|
{
|
2004-08-02 15:06:42 +00:00
|
|
|
DBG_CHKTHIS(OCopyTable,NULL);
|
2001-12-07 12:12:29 +00:00
|
|
|
m_pParent->clearDestColumns();
|
|
|
|
m_pParent->m_xDestObject = NULL;
|
|
|
|
Reference<XTablesSupplier > xSup(m_pParent->m_xConnection,UNO_QUERY);
|
|
|
|
Reference<XNameAccess> xTables;
|
|
|
|
if(xSup.is())
|
|
|
|
xTables = xSup->getTables();
|
|
|
|
if(xTables.is() && xTables->hasByName(m_edTableName.GetText()))
|
|
|
|
{
|
|
|
|
// set new destination
|
|
|
|
xTables->getByName(m_edTableName.GetText()) >>= m_pParent->m_xDestObject;
|
|
|
|
m_pParent->loadData(m_pParent->m_xDestObject,m_pParent->m_vDestColumns,m_pParent->m_aDestVec);
|
|
|
|
// #90027#
|
|
|
|
const ODatabaseExport::TColumnVector* pDestColumns = m_pParent->getDestVector();
|
|
|
|
ODatabaseExport::TColumnVector::const_iterator aDestIter = pDestColumns->begin();
|
|
|
|
m_pParent->m_vColumnPos.reserve(pDestColumns->size()+1);
|
|
|
|
m_pParent->m_vColumnTypes.reserve(pDestColumns->size()+1);
|
2003-03-19 16:57:12 +00:00
|
|
|
sal_Bool bNotConvert;
|
2001-12-07 12:12:29 +00:00
|
|
|
for(sal_Int32 nPos = 1;aDestIter != pDestColumns->end();++aDestIter,++nPos)
|
|
|
|
{
|
2003-04-01 13:29:56 +00:00
|
|
|
bNotConvert = sal_True;
|
2002-08-21 05:31:38 +00:00
|
|
|
m_pParent->m_vColumnPos.push_back( ODatabaseExport::TPositions::value_type(nPos,nPos) );
|
2003-04-02 14:37:28 +00:00
|
|
|
TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getTypeInfo(),bNotConvert);
|
2003-04-01 13:29:56 +00:00
|
|
|
if ( !bNotConvert )
|
|
|
|
{
|
|
|
|
m_pParent->showColumnTypeNotSupported((*aDestIter)->first);
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
2003-04-02 14:37:28 +00:00
|
|
|
if ( pTypeInfo.get() )
|
2001-12-07 12:12:29 +00:00
|
|
|
m_pParent->m_vColumnTypes.push_back(pTypeInfo->nType);
|
|
|
|
else
|
|
|
|
m_pParent->m_vColumnTypes.push_back(DataType::VARCHAR);
|
|
|
|
}
|
|
|
|
}
|
2003-03-19 16:57:12 +00:00
|
|
|
if ( !m_pParent->m_xDestObject.is() )
|
2001-12-07 12:12:29 +00:00
|
|
|
{
|
|
|
|
ErrorBox(this, ModuleRes(ERROR_INVALID_TABLE_NAME)).Execute();
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|