xref: /AOO41X/main/dbaccess/source/ui/misc/WCPage.cxx (revision 96de54900b79e13b861fbc62cbf36018b54e21b7)
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
10cdf0e10cSrcweir  *
11*96de5490SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
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 #include "WCPage.hxx"
28cdf0e10cSrcweir #include "WCopyTable.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #ifndef DBACCESS_SOURCE_UI_MISC_DEFAULTOBJECTNAMECHECK_HXX
31cdf0e10cSrcweir #include "defaultobjectnamecheck.hxx"
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX
34cdf0e10cSrcweir #include <tools/debug.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef _DBA_DBACCESS_HELPID_HRC_
37cdf0e10cSrcweir #include "dbaccess_helpid.hrc"
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #ifndef _DBU_MISC_HRC_
40cdf0e10cSrcweir #include "dbu_misc.hrc"
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #ifndef DBAUI_WIZARD_PAGES_HRC
43cdf0e10cSrcweir #include "WizardPages.hrc"
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
46cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp>
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
49cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp>
50cdf0e10cSrcweir #endif
51cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
52cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
55cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
56cdf0e10cSrcweir #endif
57cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
58cdf0e10cSrcweir #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
59cdf0e10cSrcweir #endif
60cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_APPLICATION_COPYTABLEOPERATION_HPP_
61cdf0e10cSrcweir #include <com/sun/star/sdb/application/CopyTableOperation.hpp>
62cdf0e10cSrcweir #endif
63cdf0e10cSrcweir #ifndef _SV_MSGBOX_HXX
64cdf0e10cSrcweir #include <vcl/msgbox.hxx>
65cdf0e10cSrcweir #endif
66cdf0e10cSrcweir #ifndef _DBHELPER_DBEXCEPTION_HXX_
67cdf0e10cSrcweir #include <connectivity/dbexception.hxx>
68cdf0e10cSrcweir #endif
69cdf0e10cSrcweir #ifndef _CONNECTIVITY_DBTOOLS_HXX_
70cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
71cdf0e10cSrcweir #endif
72cdf0e10cSrcweir #ifndef DBAUI_TOOLS_HXX
73cdf0e10cSrcweir #include "UITools.hxx"
74cdf0e10cSrcweir #endif
75cdf0e10cSrcweir #ifndef _DBAUI_MODULE_DBU_HXX_
76cdf0e10cSrcweir #include "moduledbu.hxx"
77cdf0e10cSrcweir #endif
78cdf0e10cSrcweir #ifndef _CPPUHELPER_EXC_HLP_HXX_
79cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx>
80cdf0e10cSrcweir #endif
81cdf0e10cSrcweir 
82cdf0e10cSrcweir using namespace ::dbaui;
83cdf0e10cSrcweir using namespace ::dbtools;
84cdf0e10cSrcweir using namespace ::com::sun::star::uno;
85cdf0e10cSrcweir using namespace ::com::sun::star::beans;
86cdf0e10cSrcweir using namespace ::com::sun::star::container;
87cdf0e10cSrcweir using namespace ::com::sun::star::util;
88cdf0e10cSrcweir using namespace ::com::sun::star::sdb;
89cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
90cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir namespace CopyTableOperation = ::com::sun::star::sdb::application::CopyTableOperation;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir //========================================================================
95cdf0e10cSrcweir // Klasse OCopyTable
96cdf0e10cSrcweir //========================================================================
DBG_NAME(OCopyTable)97cdf0e10cSrcweir DBG_NAME(OCopyTable)
98cdf0e10cSrcweir //------------------------------------------------------------------------
99cdf0e10cSrcweir OCopyTable::OCopyTable( Window * pParent )
100cdf0e10cSrcweir 	:OWizardPage( pParent, ModuleRes(TAB_WIZ_COPYTABLE) )
101cdf0e10cSrcweir 	,m_ftTableName(			this, ModuleRes( FT_TABLENAME		) )
102cdf0e10cSrcweir 	,m_edTableName(			this, ModuleRes( ET_TABLENAME		) )
103cdf0e10cSrcweir     ,m_aFL_Options(         this, ModuleRes( FL_OPTIONS         ) )
104cdf0e10cSrcweir 	,m_aRB_DefData(			this, ModuleRes( RB_DEFDATA			) )
105cdf0e10cSrcweir 	,m_aRB_Def(				this, ModuleRes( RB_DEF				) )
106cdf0e10cSrcweir 	,m_aRB_View(			this, ModuleRes( RB_VIEW			) )
107cdf0e10cSrcweir     ,m_aRB_AppendData(	    this, ModuleRes( RB_APPENDDATA	    ) )
108cdf0e10cSrcweir     ,m_aCB_UseHeaderLine(	this, ModuleRes( CB_USEHEADERLINE	) )
109cdf0e10cSrcweir 	,m_aCB_PrimaryColumn(	this, ModuleRes( CB_PRIMARY_COLUMN	) )
110cdf0e10cSrcweir 	,m_aFT_KeyName(			this, ModuleRes( FT_KEYNAME			) )
111cdf0e10cSrcweir 	,m_edKeyName(			this, ModuleRes( ET_KEYNAME			) )
112cdf0e10cSrcweir 	,m_pPage2(NULL)
113cdf0e10cSrcweir 	,m_pPage3(NULL)
114cdf0e10cSrcweir     ,m_bUseHeaderAllowed(sal_True)
115cdf0e10cSrcweir {
116cdf0e10cSrcweir 	DBG_CTOR(OCopyTable,NULL);
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	m_edTableName.SetMaxTextLen( EDIT_NOLIMIT );
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 	if ( m_pParent->m_xDestConnection.is() )
121cdf0e10cSrcweir 	{
122cdf0e10cSrcweir 		if ( !m_pParent->supportsViews() )
123cdf0e10cSrcweir 			m_aRB_View.Disable();
124cdf0e10cSrcweir 
125cdf0e10cSrcweir         m_aCB_UseHeaderLine.Check(sal_True);
126cdf0e10cSrcweir 		m_bPKeyAllowed = m_pParent->supportsPrimaryKey();
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 		m_aCB_PrimaryColumn.Enable(m_bPKeyAllowed);
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 		m_aRB_AppendData.SetClickHdl(	LINK( this, OCopyTable, AppendDataClickHdl	) );
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 		m_aRB_DefData.SetClickHdl(		LINK( this, OCopyTable, RadioChangeHdl		) );
133cdf0e10cSrcweir 		m_aRB_Def.SetClickHdl(			LINK( this, OCopyTable, RadioChangeHdl		) );
134cdf0e10cSrcweir 		m_aRB_View.SetClickHdl(			LINK( this, OCopyTable, RadioChangeHdl		) );
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 		m_aCB_PrimaryColumn.SetClickHdl(LINK( this, OCopyTable, KeyClickHdl         ) );
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 		m_aFT_KeyName.Enable(sal_False);
139cdf0e10cSrcweir 		m_edKeyName.Enable(sal_False);
140cdf0e10cSrcweir         ::rtl::OUString sKeyName(RTL_CONSTASCII_USTRINGPARAM("ID"));
141cdf0e10cSrcweir 		sKeyName = m_pParent->createUniqueName(sKeyName);
142cdf0e10cSrcweir 		m_edKeyName.SetText(sKeyName);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 		sal_Int32 nMaxLen = m_pParent->getMaxColumnNameLength();
145cdf0e10cSrcweir 		m_edKeyName.SetMaxTextLen(nMaxLen ? (xub_StrLen)nMaxLen : EDIT_NOLIMIT);
146cdf0e10cSrcweir 	}
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	FreeResource();
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	SetText(String(ModuleRes(STR_COPYTABLE_TITLE_COPY)));
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir //------------------------------------------------------------------------
~OCopyTable()154cdf0e10cSrcweir OCopyTable::~OCopyTable()
155cdf0e10cSrcweir {
156cdf0e10cSrcweir 	DBG_DTOR(OCopyTable,NULL);
157cdf0e10cSrcweir }
158cdf0e10cSrcweir //------------------------------------------------------------------------
159cdf0e10cSrcweir IMPL_LINK( OCopyTable, AppendDataClickHdl, Button*, /*pButton*/ )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir 	DBG_CHKTHIS(OCopyTable,NULL);
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	SetAppendDataRadio();
164cdf0e10cSrcweir 	return 0;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir //--------dyf ADD
SetAppendDataRadio()167cdf0e10cSrcweir void OCopyTable::SetAppendDataRadio()
168cdf0e10cSrcweir {
169cdf0e10cSrcweir 	m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,sal_True);
170cdf0e10cSrcweir 	m_aFT_KeyName.Enable(sal_False);
171cdf0e10cSrcweir 	m_aCB_PrimaryColumn.Enable(sal_False);
172cdf0e10cSrcweir 	m_edKeyName.Enable(sal_False);
173cdf0e10cSrcweir 	m_pParent->setOperation(CopyTableOperation::AppendData);
174cdf0e10cSrcweir }
175cdf0e10cSrcweir 
176cdf0e10cSrcweir //--------add end
177cdf0e10cSrcweir //------------------------------------------------------------------------
IMPL_LINK(OCopyTable,RadioChangeHdl,Button *,pButton)178cdf0e10cSrcweir IMPL_LINK( OCopyTable, RadioChangeHdl, Button*, pButton )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir 	DBG_CHKTHIS(OCopyTable,NULL);
181cdf0e10cSrcweir 	m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,pButton != &m_aRB_View);
182cdf0e10cSrcweir 	sal_Bool bKey = m_bPKeyAllowed && pButton != &m_aRB_View;
183cdf0e10cSrcweir 	m_aFT_KeyName.Enable(bKey && m_aCB_PrimaryColumn.IsChecked());
184cdf0e10cSrcweir 	m_edKeyName.Enable(bKey && m_aCB_PrimaryColumn.IsChecked());
185cdf0e10cSrcweir 	m_aCB_PrimaryColumn.Enable(bKey);
186cdf0e10cSrcweir     m_aCB_UseHeaderLine.Enable(m_bUseHeaderAllowed && IsOptionDefData());
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 	// set typ what to do
189cdf0e10cSrcweir 	if( IsOptionDefData() )
190cdf0e10cSrcweir 		m_pParent->setOperation( CopyTableOperation::CopyDefinitionAndData );
191cdf0e10cSrcweir 	else if( IsOptionDef() )
192cdf0e10cSrcweir 		m_pParent->setOperation( CopyTableOperation::CopyDefinitionOnly );
193cdf0e10cSrcweir 	else if( IsOptionView() )
194cdf0e10cSrcweir 		m_pParent->setOperation( CopyTableOperation::CreateAsView );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 	return 0;
197cdf0e10cSrcweir }
198cdf0e10cSrcweir //------------------------------------------------------------------------
199cdf0e10cSrcweir IMPL_LINK( OCopyTable, KeyClickHdl, Button*, /*pButton*/ )
200cdf0e10cSrcweir {
201cdf0e10cSrcweir 	DBG_CHKTHIS(OCopyTable,NULL);
202cdf0e10cSrcweir 	m_edKeyName.Enable(m_aCB_PrimaryColumn.IsChecked());
203cdf0e10cSrcweir 	m_aFT_KeyName.Enable(m_aCB_PrimaryColumn.IsChecked());
204cdf0e10cSrcweir 	return 0;
205cdf0e10cSrcweir }
206cdf0e10cSrcweir //------------------------------------------------------------------------
LeavePage()207cdf0e10cSrcweir sal_Bool OCopyTable::LeavePage()
208cdf0e10cSrcweir {
209cdf0e10cSrcweir 	DBG_CHKTHIS(OCopyTable,NULL);
210cdf0e10cSrcweir 	m_pParent->m_bCreatePrimaryKeyColumn	= (m_bPKeyAllowed && m_aCB_PrimaryColumn.IsEnabled()) ? m_aCB_PrimaryColumn.IsChecked() : sal_False;
211cdf0e10cSrcweir 	m_pParent->m_aKeyName				    = m_pParent->m_bCreatePrimaryKeyColumn ? m_edKeyName.GetText() : String();
212cdf0e10cSrcweir     m_pParent->setUseHeaderLine( m_aCB_UseHeaderLine.IsChecked() );
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 	// first check if the table already exists in the database
215cdf0e10cSrcweir 	if(	m_pParent->getOperation() != CopyTableOperation::AppendData )
216cdf0e10cSrcweir 	{
217cdf0e10cSrcweir         m_pParent->clearDestColumns();
218cdf0e10cSrcweir         DynamicTableOrQueryNameCheck aNameCheck( m_pParent->m_xDestConnection, CommandType::TABLE );
219cdf0e10cSrcweir         SQLExceptionInfo aErrorInfo;
220cdf0e10cSrcweir         if ( !aNameCheck.isNameValid( m_edTableName.GetText(), aErrorInfo ) )
221cdf0e10cSrcweir         {
222cdf0e10cSrcweir             aErrorInfo.append( SQLExceptionInfo::SQL_CONTEXT, String( ModuleRes( STR_SUGGEST_APPEND_TABLE_DATA ) ) );
223cdf0e10cSrcweir             m_pParent->showError(aErrorInfo.get());
224cdf0e10cSrcweir 
225cdf0e10cSrcweir             return sal_False;
226cdf0e10cSrcweir         }
227cdf0e10cSrcweir 
228cdf0e10cSrcweir         // have to check the length of the table name
229cdf0e10cSrcweir 		Reference< XDatabaseMetaData > xMeta = m_pParent->m_xDestConnection->getMetaData();
230cdf0e10cSrcweir 		::rtl::OUString sCatalog;
231cdf0e10cSrcweir 		::rtl::OUString sSchema;
232cdf0e10cSrcweir 		::rtl::OUString sTable;
233cdf0e10cSrcweir 		::dbtools::qualifiedNameComponents(	xMeta,
234cdf0e10cSrcweir 											m_edTableName.GetText(),
235cdf0e10cSrcweir 											sCatalog,
236cdf0e10cSrcweir 											sSchema,
237cdf0e10cSrcweir 											sTable,
238cdf0e10cSrcweir 											::dbtools::eInDataManipulation);
239cdf0e10cSrcweir 		sal_Int32 nMaxLength = xMeta->getMaxTableNameLength();
240cdf0e10cSrcweir 		if ( nMaxLength && sTable.getLength() > nMaxLength )
241cdf0e10cSrcweir 		{
242cdf0e10cSrcweir             String sError(ModuleRes(STR_INVALID_TABLE_NAME_LENGTH));
243cdf0e10cSrcweir 			m_pParent->showError(sError);
244cdf0e10cSrcweir 			return sal_False;
245cdf0e10cSrcweir 		}
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 		// now we have to check if the name of the primary key already exists
248cdf0e10cSrcweir 		if (	m_pParent->m_bCreatePrimaryKeyColumn
249cdf0e10cSrcweir 			&&	m_pParent->m_aKeyName != m_pParent->createUniqueName(m_pParent->m_aKeyName) )
250cdf0e10cSrcweir 		{
251cdf0e10cSrcweir 			String aInfoString( ModuleRes(STR_WIZ_PKEY_ALREADY_DEFINED) );
252cdf0e10cSrcweir 			aInfoString += String(' ');
253cdf0e10cSrcweir 			aInfoString += String(m_pParent->m_aKeyName);
254cdf0e10cSrcweir 			m_pParent->showError(aInfoString);
255cdf0e10cSrcweir 			return sal_False;
256cdf0e10cSrcweir 		}
257cdf0e10cSrcweir 	}
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 	if ( !m_edTableName.GetSavedValue().Equals(m_edTableName.GetText()) )
260cdf0e10cSrcweir 	{ // table exists and name has changed
261cdf0e10cSrcweir 		if ( m_pParent->getOperation() == CopyTableOperation::AppendData )
262cdf0e10cSrcweir 		{
263cdf0e10cSrcweir 			if(!checkAppendData())
264cdf0e10cSrcweir 				return sal_False;
265cdf0e10cSrcweir 		}
266cdf0e10cSrcweir 		else if ( m_nOldOperation == CopyTableOperation::AppendData )
267cdf0e10cSrcweir 		{
268cdf0e10cSrcweir 			m_edTableName.SaveValue();
269cdf0e10cSrcweir 			return LeavePage();
270cdf0e10cSrcweir 		}
271cdf0e10cSrcweir 	}
272cdf0e10cSrcweir 	else
273cdf0e10cSrcweir 	{ // table exist and is not new or doesn't exist and so on
274cdf0e10cSrcweir 		if ( CopyTableOperation::AppendData == m_pParent->getOperation() )
275cdf0e10cSrcweir 		{
276cdf0e10cSrcweir 			if( !checkAppendData() )
277cdf0e10cSrcweir 				return sal_False;
278cdf0e10cSrcweir 		}
279cdf0e10cSrcweir 	}
280cdf0e10cSrcweir 	m_pParent->m_sName = m_edTableName.GetText();
281cdf0e10cSrcweir 	m_edTableName.SaveValue();
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 	if(!m_pParent->m_sName.getLength())
284cdf0e10cSrcweir 	{
285cdf0e10cSrcweir         String sError(ModuleRes(STR_INVALID_TABLE_NAME));
286cdf0e10cSrcweir         m_pParent->showError(sError);
287cdf0e10cSrcweir 		return sal_False;
288cdf0e10cSrcweir 	}
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 	return sal_True;
291cdf0e10cSrcweir }
292cdf0e10cSrcweir //------------------------------------------------------------------------
ActivatePage()293cdf0e10cSrcweir void OCopyTable::ActivatePage()
294cdf0e10cSrcweir {
295cdf0e10cSrcweir 	DBG_CHKTHIS(OCopyTable,NULL);
296cdf0e10cSrcweir 	m_pParent->GetOKButton().Enable( sal_True );
297cdf0e10cSrcweir 	m_nOldOperation = m_pParent->getOperation();
298cdf0e10cSrcweir 	m_edTableName.GrabFocus();
299cdf0e10cSrcweir     m_aCB_UseHeaderLine.Check(m_pParent->UseHeaderLine());
300cdf0e10cSrcweir }
301cdf0e10cSrcweir //------------------------------------------------------------------------
GetTitle() const302cdf0e10cSrcweir String OCopyTable::GetTitle() const
303cdf0e10cSrcweir {
304cdf0e10cSrcweir 	DBG_CHKTHIS(OCopyTable,NULL);
305cdf0e10cSrcweir 	return String(ModuleRes(STR_WIZ_TABLE_COPY));
306cdf0e10cSrcweir }
307cdf0e10cSrcweir //------------------------------------------------------------------------
Reset()308cdf0e10cSrcweir void OCopyTable::Reset()
309cdf0e10cSrcweir {
310cdf0e10cSrcweir 	DBG_CHKTHIS(OCopyTable,NULL);
311cdf0e10cSrcweir 	m_bFirstTime = sal_False;
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 	m_edTableName.SetText( m_pParent->m_sName );
314cdf0e10cSrcweir 	m_edTableName.SaveValue();
315cdf0e10cSrcweir }
316cdf0e10cSrcweir //------------------------------------------------------------------------
checkAppendData()317cdf0e10cSrcweir sal_Bool OCopyTable::checkAppendData()
318cdf0e10cSrcweir {
319cdf0e10cSrcweir 	DBG_CHKTHIS(OCopyTable,NULL);
320cdf0e10cSrcweir 	m_pParent->clearDestColumns();
321cdf0e10cSrcweir     Reference< XPropertySet > xTable;
322cdf0e10cSrcweir 	Reference< XTablesSupplier > xSup( m_pParent->m_xDestConnection, UNO_QUERY );
323cdf0e10cSrcweir 	Reference<XNameAccess> xTables;
324cdf0e10cSrcweir 	if(xSup.is())
325cdf0e10cSrcweir 		xTables = xSup->getTables();
326cdf0e10cSrcweir 	if(xTables.is() && xTables->hasByName(m_edTableName.GetText()))
327cdf0e10cSrcweir 	{
328cdf0e10cSrcweir         const ODatabaseExport::TColumnVector* pSrcColumns = m_pParent->getSrcVector();
329cdf0e10cSrcweir         const sal_uInt32 nSrcSize = pSrcColumns->size();
330cdf0e10cSrcweir         m_pParent->m_vColumnPos.resize( nSrcSize, ODatabaseExport::TPositions::value_type( COLUMN_POSITION_NOT_FOUND, COLUMN_POSITION_NOT_FOUND ) );
331cdf0e10cSrcweir 	    m_pParent->m_vColumnTypes.resize( nSrcSize , COLUMN_POSITION_NOT_FOUND );
332cdf0e10cSrcweir 
333cdf0e10cSrcweir         // set new destination
334cdf0e10cSrcweir 		xTables->getByName( m_edTableName.GetText() ) >>= xTable;
335cdf0e10cSrcweir         ObjectCopySource aTableCopySource( m_pParent->m_xDestConnection, xTable );
336cdf0e10cSrcweir 		m_pParent->loadData( aTableCopySource, m_pParent->m_vDestColumns, m_pParent->m_aDestVec );
337cdf0e10cSrcweir 		// #90027#
338cdf0e10cSrcweir 		const ODatabaseExport::TColumnVector* pDestColumns			= m_pParent->getDestVector();
339cdf0e10cSrcweir 		ODatabaseExport::TColumnVector::const_iterator aDestIter	= pDestColumns->begin();
340cdf0e10cSrcweir         ODatabaseExport::TColumnVector::const_iterator aDestEnd	    = pDestColumns->end();
341cdf0e10cSrcweir 		const sal_uInt32 nDestSize = pDestColumns->size();
342cdf0e10cSrcweir 		sal_Bool bNotConvert;
343cdf0e10cSrcweir         sal_uInt32 i = 0;
344cdf0e10cSrcweir 		for(sal_Int32 nPos = 1;aDestIter != aDestEnd && i < nDestSize && i < nSrcSize;++aDestIter,++nPos,++i)
345cdf0e10cSrcweir 		{
346cdf0e10cSrcweir 			bNotConvert = sal_True;
347cdf0e10cSrcweir 			m_pParent->m_vColumnPos[i] = ODatabaseExport::TPositions::value_type(nPos,nPos);
348cdf0e10cSrcweir 			TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getSpecialTypeInfo(),bNotConvert);
349cdf0e10cSrcweir 			if ( !bNotConvert )
350cdf0e10cSrcweir 			{
351cdf0e10cSrcweir 				m_pParent->showColumnTypeNotSupported((*aDestIter)->first);
352cdf0e10cSrcweir 				return sal_False;
353cdf0e10cSrcweir 			}
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 			if ( pTypeInfo.get() )
356cdf0e10cSrcweir 				m_pParent->m_vColumnTypes[i] = pTypeInfo->nType;
357cdf0e10cSrcweir 			else
358cdf0e10cSrcweir 				m_pParent->m_vColumnTypes[i] = DataType::VARCHAR;
359cdf0e10cSrcweir 		}
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 	}
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 	if ( !xTable.is() )
364cdf0e10cSrcweir 	{
365cdf0e10cSrcweir         String sError(ModuleRes(STR_INVALID_TABLE_NAME));
366cdf0e10cSrcweir         m_pParent->showError(sError);
367cdf0e10cSrcweir 		return sal_False;
368cdf0e10cSrcweir 	}
369cdf0e10cSrcweir 	return sal_True;
370cdf0e10cSrcweir }
371cdf0e10cSrcweir // -----------------------------------------------------------------------------
setCreatePrimaryKey(bool _bDoCreate,const::rtl::OUString & _rSuggestedName)372cdf0e10cSrcweir void OCopyTable::setCreatePrimaryKey( bool _bDoCreate, const ::rtl::OUString& _rSuggestedName )
373cdf0e10cSrcweir {
374cdf0e10cSrcweir     bool bCreatePK = m_bPKeyAllowed && _bDoCreate;
375cdf0e10cSrcweir     m_aCB_PrimaryColumn.Check( bCreatePK );
376cdf0e10cSrcweir     m_edKeyName.SetText( _rSuggestedName );
377cdf0e10cSrcweir 
378cdf0e10cSrcweir     m_aFT_KeyName.Enable( bCreatePK );
379cdf0e10cSrcweir 	m_edKeyName.Enable( bCreatePK );
380cdf0e10cSrcweir }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir // -----------------------------------------------------------------------------
383cdf0e10cSrcweir //---dyf add 2006/7/10
setCreateStyleAction()384cdf0e10cSrcweir void OCopyTable::setCreateStyleAction()
385cdf0e10cSrcweir {
386cdf0e10cSrcweir 	// reselect the last action before
387cdf0e10cSrcweir 	switch(m_pParent->getOperation())
388cdf0e10cSrcweir 	{
389cdf0e10cSrcweir 		case CopyTableOperation::CopyDefinitionAndData:
390cdf0e10cSrcweir 			m_aRB_DefData.Check(sal_True);
391cdf0e10cSrcweir             RadioChangeHdl(&m_aRB_DefData);
392cdf0e10cSrcweir 			break;
393cdf0e10cSrcweir 		case CopyTableOperation::CopyDefinitionOnly:
394cdf0e10cSrcweir 			m_aRB_Def.Check(sal_True);
395cdf0e10cSrcweir             RadioChangeHdl(&m_aRB_Def);
396cdf0e10cSrcweir 			break;
397cdf0e10cSrcweir 		case CopyTableOperation::AppendData:
398cdf0e10cSrcweir 			m_aRB_AppendData.Check(sal_True);
399cdf0e10cSrcweir 			SetAppendDataRadio();
400cdf0e10cSrcweir 			break;
401cdf0e10cSrcweir 		case CopyTableOperation::CreateAsView:
402cdf0e10cSrcweir 			if ( m_aRB_View.IsEnabled() )
403cdf0e10cSrcweir 			{
404cdf0e10cSrcweir 				m_aRB_View.Check(sal_True);
405cdf0e10cSrcweir                 RadioChangeHdl(&m_aRB_View);
406cdf0e10cSrcweir 			}
407cdf0e10cSrcweir 			else
408cdf0e10cSrcweir             {
409cdf0e10cSrcweir 				m_aRB_DefData.Check(sal_True);
410cdf0e10cSrcweir                 RadioChangeHdl(&m_aRB_DefData);
411cdf0e10cSrcweir             }
412cdf0e10cSrcweir 	}
413cdf0e10cSrcweir }
414cdf0e10cSrcweir //---add end
415