1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2e2212a7SAndrew Rist  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2e2212a7SAndrew Rist  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19*2e2212a7SAndrew Rist  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
25cdf0e10cSrcweir #define DBAUI_WIZ_COPYTABLEDIALOG_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
28cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp>
29cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp>
30cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
31cdf0e10cSrcweir #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
32cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
33cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
34cdf0e10cSrcweir #include "TypeInfo.hxx"
35cdf0e10cSrcweir #include <vcl/button.hxx>
36cdf0e10cSrcweir #include <svtools/wizdlg.hxx>
37cdf0e10cSrcweir #include "DExport.hxx"
38cdf0e10cSrcweir #include "WTabPage.hxx"
39cdf0e10cSrcweir #include "FieldDescriptions.hxx"
40cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
41cdf0e10cSrcweir #include <com/sun/star/sdbcx/XKeysSupplier.hpp>
42cdf0e10cSrcweir #include <com/sun/star/task/XInteractionHandler.hpp>
43cdf0e10cSrcweir #include <vcl/lstbox.hxx>
44cdf0e10cSrcweir #include <functional>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir namespace dbaui
47cdf0e10cSrcweir {
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 	typedef ::std::unary_function< ::rtl::OUString,bool> TColumnFindFunctorType;
50cdf0e10cSrcweir 	class TColumnFindFunctor : public TColumnFindFunctorType
51cdf0e10cSrcweir 	{
52cdf0e10cSrcweir 	public:
53cdf0e10cSrcweir 		virtual bool operator()(const ::rtl::OUString& _sColumnName) const = 0;
54cdf0e10cSrcweir 	};
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 	class TExportColumnFindFunctor : public TColumnFindFunctor
57cdf0e10cSrcweir 	{
58cdf0e10cSrcweir 		ODatabaseExport::TColumns* m_pColumns;
59cdf0e10cSrcweir 	public:
TExportColumnFindFunctor(ODatabaseExport::TColumns * _pColumns)60cdf0e10cSrcweir 		TExportColumnFindFunctor(ODatabaseExport::TColumns* _pColumns)
61cdf0e10cSrcweir 		{
62cdf0e10cSrcweir 			m_pColumns = _pColumns;
63cdf0e10cSrcweir 		}
operator ()(const::rtl::OUString & _sColumnName) const64cdf0e10cSrcweir 		inline bool operator()(const ::rtl::OUString& _sColumnName)	const
65cdf0e10cSrcweir 		{
66cdf0e10cSrcweir 			return m_pColumns->find(_sColumnName) != m_pColumns->end();
67cdf0e10cSrcweir 		}
68cdf0e10cSrcweir 	};
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	class TMultiListBoxEntryFindFunctor : public TColumnFindFunctor
71cdf0e10cSrcweir 	{
72cdf0e10cSrcweir 		::comphelper::TStringMixEqualFunctor m_aCase;
73cdf0e10cSrcweir 		::std::vector< ::rtl::OUString>* m_pVector;
74cdf0e10cSrcweir 	public:
TMultiListBoxEntryFindFunctor(::std::vector<::rtl::OUString> * _pVector,const::comphelper::TStringMixEqualFunctor & _aCase)75cdf0e10cSrcweir 		TMultiListBoxEntryFindFunctor(::std::vector< ::rtl::OUString>* _pVector,
76cdf0e10cSrcweir 									const ::comphelper::TStringMixEqualFunctor& _aCase)
77cdf0e10cSrcweir 			:m_aCase(_aCase)
78cdf0e10cSrcweir 			,m_pVector(_pVector)
79cdf0e10cSrcweir 		{
80cdf0e10cSrcweir 		}
operator ()(const::rtl::OUString & _sColumnName) const81cdf0e10cSrcweir 		inline bool operator()(const ::rtl::OUString& _sColumnName)	const
82cdf0e10cSrcweir 		{
83cdf0e10cSrcweir 			return ::std::find_if(m_pVector->begin(),m_pVector->end(),
84cdf0e10cSrcweir 				::std::bind2nd(m_aCase, _sColumnName)) != m_pVector->end();
85cdf0e10cSrcweir 		}
86cdf0e10cSrcweir     };
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	// ========================================================
89cdf0e10cSrcweir 	// ICopyTableSourceObject
90cdf0e10cSrcweir 	// ========================================================
91cdf0e10cSrcweir     /** interface to an object to copy to another DB, using the OCopyTableWizard
92cdf0e10cSrcweir 
93cdf0e10cSrcweir         when the wizard is used to copy an object to another DB, it usually requires
94cdf0e10cSrcweir         a sdbcx-level or sdb-level object (a css.sdbcx.Table or css.sdb.Query, that is).
95cdf0e10cSrcweir 
96cdf0e10cSrcweir         However, to also support copying tables from sdbc-level connections, we allow to
97cdf0e10cSrcweir         work with the object name only. This implies some less features (like copying the
98cdf0e10cSrcweir         UI settings of a table is not done), but still allows to copy definition and data.
99cdf0e10cSrcweir     */
100cdf0e10cSrcweir     class ICopyTableSourceObject
101cdf0e10cSrcweir     {
102cdf0e10cSrcweir     public:
103cdf0e10cSrcweir         /// retrieves the fully qualified name of the object to copy
104cdf0e10cSrcweir         virtual ::rtl::OUString     getQualifiedObjectName() const = 0;
105cdf0e10cSrcweir         /// determines whether the object is a view
106cdf0e10cSrcweir         virtual bool                isView() const = 0;
107cdf0e10cSrcweir         /** copies the UI settings of the object to the given target object. Might be
108cdf0e10cSrcweir             ignored by implementations which do not have Ui settings.
109cdf0e10cSrcweir         */
110cdf0e10cSrcweir         virtual void                copyUISettingsTo( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ) const = 0;
111cdf0e10cSrcweir         /// retrieves the column names of the to-be-copied object
112cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
113cdf0e10cSrcweir                                     getColumnNames() const = 0;
114cdf0e10cSrcweir         /// retrieves the names of the primary keys of the to-be-copied object
115cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
116cdf0e10cSrcweir                                     getPrimaryKeyColumnNames() const = 0;
117cdf0e10cSrcweir         /// creates a OFieldDescription for the given column of the to-be-copied object
118cdf0e10cSrcweir         virtual OFieldDescription*  createFieldDescription( const ::rtl::OUString& _rColumnName ) const = 0;
119cdf0e10cSrcweir         /// returns the SELECT statement which can be used to retrieve the data of the to-be-copied object
120cdf0e10cSrcweir         virtual ::rtl::OUString     getSelectStatement() const = 0;
121cdf0e10cSrcweir 
122cdf0e10cSrcweir         /** copies the filter and sorting
123cdf0e10cSrcweir         *
124cdf0e10cSrcweir         * \return
125cdf0e10cSrcweir         */
126cdf0e10cSrcweir         virtual void                copyFilterAndSortingTo(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ) const = 0;
127cdf0e10cSrcweir 
128cdf0e10cSrcweir         /** returns the prepared statement which can be used to retrieve the data of the to-be-copied object
129cdf0e10cSrcweir 
130cdf0e10cSrcweir             The default implementation of this method will simply prepare a statement with the return value
131cdf0e10cSrcweir             of ->getSelectStatement.
132cdf0e10cSrcweir         */
133cdf0e10cSrcweir         virtual ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XPreparedStatement >
134cdf0e10cSrcweir                                     getPreparedSelectStatement() const = 0;
135cdf0e10cSrcweir 
136cdf0e10cSrcweir         virtual ~ICopyTableSourceObject();
137cdf0e10cSrcweir     };
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	// ========================================================
140cdf0e10cSrcweir 	// ObjectCopySource
141cdf0e10cSrcweir 	// ========================================================
142cdf0e10cSrcweir     class ObjectCopySource : public ICopyTableSourceObject
143cdf0e10cSrcweir     {
144cdf0e10cSrcweir     private:
145cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >         m_xConnection;
146cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >   m_xMetaData;
147cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >       m_xObject;
148cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >   m_xObjectPSI;
149cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >    m_xObjectColumns;
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     public:
152cdf0e10cSrcweir         ObjectCopySource(
153cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
154cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject
155cdf0e10cSrcweir         );
156cdf0e10cSrcweir 
157cdf0e10cSrcweir         // ICopyTableSourceObject overridables
158cdf0e10cSrcweir         virtual ::rtl::OUString     getQualifiedObjectName() const;
159cdf0e10cSrcweir         virtual bool                isView() const;
160cdf0e10cSrcweir         virtual void                copyUISettingsTo( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ) const;
161cdf0e10cSrcweir         virtual void                copyFilterAndSortingTo(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ) const;
162cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
163cdf0e10cSrcweir                                     getColumnNames() const;
164cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
165cdf0e10cSrcweir                                     getPrimaryKeyColumnNames() const;
166cdf0e10cSrcweir         virtual OFieldDescription*  createFieldDescription( const ::rtl::OUString& _rColumnName ) const;
167cdf0e10cSrcweir         virtual ::rtl::OUString     getSelectStatement() const;
168cdf0e10cSrcweir         virtual ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XPreparedStatement >
169cdf0e10cSrcweir                                     getPreparedSelectStatement() const;
170cdf0e10cSrcweir     };
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 	// ========================================================
173cdf0e10cSrcweir 	// NamedTableCopySource
174cdf0e10cSrcweir 	// ========================================================
175cdf0e10cSrcweir     class NamedTableCopySource : public ICopyTableSourceObject
176cdf0e10cSrcweir     {
177cdf0e10cSrcweir     private:
178cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >         m_xConnection;
179cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >   m_xMetaData;
180cdf0e10cSrcweir         ::rtl::OUString                                                                 m_sTableName;
181cdf0e10cSrcweir         ::rtl::OUString                                                                 m_sTableCatalog;
182cdf0e10cSrcweir         ::rtl::OUString                                                                 m_sTableSchema;
183cdf0e10cSrcweir         ::rtl::OUString                                                                 m_sTableBareName;
184cdf0e10cSrcweir         ::std::vector< OFieldDescription >                                              m_aColumnInfo;
185cdf0e10cSrcweir         ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XPreparedStatement >         m_xStatement;
186cdf0e10cSrcweir 
187cdf0e10cSrcweir     public:
188cdf0e10cSrcweir         NamedTableCopySource(
189cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
190cdf0e10cSrcweir             const ::rtl::OUString& _rTableName
191cdf0e10cSrcweir         );
192cdf0e10cSrcweir 
193cdf0e10cSrcweir         // ICopyTableSourceObject overridables
194cdf0e10cSrcweir         virtual ::rtl::OUString     getQualifiedObjectName() const;
195cdf0e10cSrcweir         virtual bool                isView() const;
196cdf0e10cSrcweir         virtual void                copyUISettingsTo( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ) const;
197cdf0e10cSrcweir         virtual void                copyFilterAndSortingTo(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ) const;
198cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
199cdf0e10cSrcweir                                     getColumnNames() const;
200cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
201cdf0e10cSrcweir                                     getPrimaryKeyColumnNames() const;
202cdf0e10cSrcweir         virtual OFieldDescription*  createFieldDescription( const ::rtl::OUString& _rColumnName ) const;
203cdf0e10cSrcweir         virtual ::rtl::OUString     getSelectStatement() const;
204cdf0e10cSrcweir         virtual ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XPreparedStatement >
205cdf0e10cSrcweir                                     getPreparedSelectStatement() const;
206cdf0e10cSrcweir 
207cdf0e10cSrcweir     private:
208cdf0e10cSrcweir         void    impl_ensureColumnInfo_throw();
209cdf0e10cSrcweir         ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XPreparedStatement >
210cdf0e10cSrcweir                 impl_ensureStatement_throw();
211cdf0e10cSrcweir     };
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 	// ========================================================
214cdf0e10cSrcweir 	// Wizard Dialog
215cdf0e10cSrcweir 	// ========================================================
216cdf0e10cSrcweir 	class OCopyTableWizard : public WizardDialog
217cdf0e10cSrcweir 	{
218cdf0e10cSrcweir 		friend class		OWizColumnSelect;
219cdf0e10cSrcweir 		friend class		OWizTypeSelect;
220cdf0e10cSrcweir 		friend class		OWizTypeSelectControl;
221cdf0e10cSrcweir 		friend class		OCopyTable;
222cdf0e10cSrcweir 		friend class		OWizNameMatching;
223cdf0e10cSrcweir 
224cdf0e10cSrcweir     public:
225cdf0e10cSrcweir 		DECLARE_STL_MAP(::rtl::OUString,::rtl::OUString,::comphelper::UStringMixLess,TNameMapping);
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 		enum Wizard_Button_Style
228cdf0e10cSrcweir 		{
229cdf0e10cSrcweir 			WIZARD_NEXT,
230cdf0e10cSrcweir 			WIZARD_PREV,
231cdf0e10cSrcweir 			WIZARD_FINISH,
232cdf0e10cSrcweir 
233cdf0e10cSrcweir             WIZARD_NONE
234cdf0e10cSrcweir 		};
235cdf0e10cSrcweir 
236cdf0e10cSrcweir     private:
237cdf0e10cSrcweir 		ODatabaseExport::TColumns		m_vDestColumns; // contains the columns
238cdf0e10cSrcweir 		ODatabaseExport::TColumnVector	m_aDestVec;		// the order to insert the columns
239cdf0e10cSrcweir 		ODatabaseExport::TColumns		m_vSourceColumns;
240cdf0e10cSrcweir 		ODatabaseExport::TColumnVector	m_vSourceVec;
241cdf0e10cSrcweir 
242cdf0e10cSrcweir         HelpButton              m_pbHelp;
243cdf0e10cSrcweir 		CancelButton			m_pbCancel;
244cdf0e10cSrcweir 		PushButton				m_pbPrev;
245cdf0e10cSrcweir 		PushButton				m_pbNext;
246cdf0e10cSrcweir 		OKButton				m_pbFinish;
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 		OTypeInfoMap				            m_aTypeInfo;
249cdf0e10cSrcweir 		::std::vector<OTypeInfoMap::iterator>   m_aTypeInfoIndex;
250cdf0e10cSrcweir 		OTypeInfoMap				            m_aDestTypeInfo;
251cdf0e10cSrcweir 		::std::vector<OTypeInfoMap::iterator>   m_aDestTypeInfoIndex;
252cdf0e10cSrcweir 		TNameMapping				            m_mNameMapping;
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 		ODatabaseExport::TPositions	            m_vColumnPos;
255cdf0e10cSrcweir 		::std::vector<sal_Int32>	            m_vColumnTypes;
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >			m_xDestConnection;
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 		const ICopyTableSourceObject&                                                   m_rSourceObject;
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >	m_xFormatter;
262cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xFactory;
263cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler>  m_xInteractionHandler;
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 		String					m_sTypeNames;		// these type names are the ones out of the resource file
266cdf0e10cSrcweir 		sal_uInt32				m_nPageCount;
267cdf0e10cSrcweir 		sal_Bool				m_bDeleteSourceColumns;
268cdf0e10cSrcweir         bool                    m_bInterConnectionCopy;    // are we copying between different connections?
269cdf0e10cSrcweir 
270cdf0e10cSrcweir         ::com::sun::star::lang::Locale	m_aLocale;
271cdf0e10cSrcweir 		::rtl::OUString					m_sName;	// for a table the name is composed
272cdf0e10cSrcweir 		::rtl::OUString 				m_sSourceName;
273cdf0e10cSrcweir 		::rtl::OUString					m_aKeyName;
274cdf0e10cSrcweir 		TOTypeInfoSP					m_pTypeInfo; // default type
275cdf0e10cSrcweir 		sal_Bool						m_bAddPKFirstTime;
276cdf0e10cSrcweir         sal_Int16                       m_nOperation;
277cdf0e10cSrcweir 		Wizard_Button_Style	            m_ePressed;
278cdf0e10cSrcweir 		sal_Bool			            m_bCreatePrimaryKeyColumn;
279cdf0e10cSrcweir         sal_Bool                        m_bUseHeaderLine;
280cdf0e10cSrcweir 
281cdf0e10cSrcweir     private:
282cdf0e10cSrcweir 		DECL_LINK( ImplPrevHdl	, PushButton* );
283cdf0e10cSrcweir 		DECL_LINK( ImplNextHdl	, PushButton* );
284cdf0e10cSrcweir 		DECL_LINK( ImplOKHdl	, OKButton* );
285cdf0e10cSrcweir 		DECL_LINK( ImplActivateHdl, WizardDialog* );
286cdf0e10cSrcweir 		sal_Bool CheckColumns(sal_Int32& _rnBreakPos);
287cdf0e10cSrcweir         void loadData( const ICopyTableSourceObject& _rSourceObject,
288cdf0e10cSrcweir                        ODatabaseExport::TColumns& _rColumns,
289cdf0e10cSrcweir                        ODatabaseExport::TColumnVector& _rColVector );
290cdf0e10cSrcweir         void construct();
291cdf0e10cSrcweir 		// need for table creation
292cdf0e10cSrcweir 		void appendColumns( ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier>& _rxColSup, const ODatabaseExport::TColumnVector* _pVec, sal_Bool _bKeyColumns = sal_False ) const;
293cdf0e10cSrcweir 		void appendKey(::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XKeysSupplier>& _rxSup,const ODatabaseExport::TColumnVector* _pVec) const;
294cdf0e10cSrcweir 		// checks if the type is supported in the destination database
295cdf0e10cSrcweir 		sal_Bool supportsType(sal_Int32 _nDataType,sal_Int32& _rNewDataType);
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 		void    impl_loadSourceData();
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 	public:
300cdf0e10cSrcweir 		// used for copy tables or queries
301cdf0e10cSrcweir 		OCopyTableWizard(
302cdf0e10cSrcweir             Window * pParent,
303cdf0e10cSrcweir             const ::rtl::OUString& _rDefaultName,
304cdf0e10cSrcweir             sal_Int16 _nOperation,
305cdf0e10cSrcweir 			const ICopyTableSourceObject&                                                           _rSourceObject,
306cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >&			_xSourceConnection,
307cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >&			_xConnection,
308cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
309cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler>&   _xInteractionHandler
310cdf0e10cSrcweir         );
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 		// used for importing rtf/html sources
313cdf0e10cSrcweir 		OCopyTableWizard(
314cdf0e10cSrcweir             Window* pParent,
315cdf0e10cSrcweir             const ::rtl::OUString& _rDefaultName,
316cdf0e10cSrcweir             sal_Int16 _nOperation,
317cdf0e10cSrcweir             const ODatabaseExport::TColumns& _rDestColumns,
318cdf0e10cSrcweir             const ODatabaseExport::TColumnVector& _rSourceColVec,
319cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
320cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >&	_xFormatter,
321cdf0e10cSrcweir             TypeSelectionPageFactory _pTypeSelectionPageFactory,
322cdf0e10cSrcweir             SvStream& _rTypeSelectionPageArg,
323cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM
324cdf0e10cSrcweir         );
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 		virtual ~OCopyTableWizard();
327cdf0e10cSrcweir 
328cdf0e10cSrcweir 		virtual long		DeactivatePage();
GetOKButton()329cdf0e10cSrcweir 		OKButton&			GetOKButton() { return m_pbFinish; }
GetPressedButton() const330cdf0e10cSrcweir 		Wizard_Button_Style GetPressedButton() const { return m_ePressed; }
331cdf0e10cSrcweir 		void				EnableButton(Wizard_Button_Style eStyle,sal_Bool bEnable);
332cdf0e10cSrcweir 		void				AddWizardPage(OWizardPage* pPage); // Page wird von OCopyTableWizard gel�scht
333cdf0e10cSrcweir 		void				RemoveWizardPage(OWizardPage* pPage); // Page goes again to user
334cdf0e10cSrcweir 		void				CheckButtons(); // checks which button can be disabled, enabled
335cdf0e10cSrcweir 
336cdf0e10cSrcweir 		// returns a vector where the position of a column and if the column is in the selection
337cdf0e10cSrcweir 		// when not the value is COLUMN_POSITION_NOT_FOUND == (sal_uInt32)-1
GetColumnPositions() const338cdf0e10cSrcweir 		ODatabaseExport::TPositions	GetColumnPositions()	const { return m_vColumnPos; }
GetColumnTypes() const339cdf0e10cSrcweir 		::std::vector<sal_Int32>	GetColumnTypes()		const { return m_vColumnTypes; }
UseHeaderLine() const340cdf0e10cSrcweir         sal_Bool                    UseHeaderLine()         const { return m_bUseHeaderLine; }
setUseHeaderLine(sal_Bool _bUseHeaderLine)341cdf0e10cSrcweir         void                        setUseHeaderLine(sal_Bool _bUseHeaderLine) { m_bUseHeaderLine = _bUseHeaderLine; }
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 		void insertColumn(sal_Int32 _nPos,OFieldDescription* _pField);
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 		/** replaces a field description with another one. The name must not be known so far.
346cdf0e10cSrcweir 			@param	_nPos
347cdf0e10cSrcweir 				The pos inside the vector, 0 based.
348cdf0e10cSrcweir 			@param	_pField
349cdf0e10cSrcweir 				The field to set.
350cdf0e10cSrcweir 			@param	_sOldName
351cdf0e10cSrcweir 				The name of column to be replaced.
352cdf0e10cSrcweir 		*/
353cdf0e10cSrcweir 		void replaceColumn(sal_Int32 _nPos,OFieldDescription* _pField,const ::rtl::OUString& _sOldName);
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 		/** returns whether a primary key should be created in the target database
356cdf0e10cSrcweir 		*/
357cdf0e10cSrcweir 		sal_Bool		shouldCreatePrimaryKey() const;
358cdf0e10cSrcweir         void            setCreatePrimaryKey( bool _bDoCreate, const ::rtl::OUString& _rSuggestedName );
359cdf0e10cSrcweir 
360cdf0e10cSrcweir         static bool     supportsPrimaryKey( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection );
supportsPrimaryKey() const361cdf0e10cSrcweir         bool            supportsPrimaryKey() const { return supportsPrimaryKey( m_xDestConnection ); }
362cdf0e10cSrcweir 
363cdf0e10cSrcweir         static bool     supportsViews( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection );
supportsViews() const364cdf0e10cSrcweir         bool            supportsViews() const { return supportsViews( m_xDestConnection ); }
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 		/** returns the name of the primary key
367cdf0e10cSrcweir 			@return
368cdf0e10cSrcweir 				The name of the primary key.
369cdf0e10cSrcweir 		*/
getPrimaryKeyName() const370cdf0e10cSrcweir 		::rtl::OUString	getPrimaryKeyName() const { return m_aKeyName; }
371cdf0e10cSrcweir 
getTypeInfo(sal_Int32 _nPos) const372cdf0e10cSrcweir 		TOTypeInfoSP		getTypeInfo(sal_Int32 _nPos)		const { return m_aTypeInfoIndex[_nPos]->second; }
getTypeInfo() const373cdf0e10cSrcweir 		const OTypeInfoMap*	getTypeInfo()						const { return &m_aTypeInfo; }
374cdf0e10cSrcweir 
getDestTypeInfo(sal_Int32 _nPos) const375cdf0e10cSrcweir 		TOTypeInfoSP		getDestTypeInfo(sal_Int32 _nPos)	const { return m_aDestTypeInfoIndex[_nPos]->second; }
getDestTypeInfo() const376cdf0e10cSrcweir 		const OTypeInfoMap*	getDestTypeInfo()					const { return &m_aDestTypeInfo; }
377cdf0e10cSrcweir 
GetLocale() const378cdf0e10cSrcweir 		::com::sun::star::lang::Locale	GetLocale() const { return m_aLocale; }
GetFormatter() const379cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > GetFormatter() const { return m_xFormatter; }
GetFactory() const380cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> GetFactory() const { return m_xFactory; }
381cdf0e10cSrcweir 
getSourceColumns() const382cdf0e10cSrcweir 		const ODatabaseExport::TColumns*		getSourceColumns() const{ return &m_vSourceColumns; }
getSrcVector() const383cdf0e10cSrcweir 		const ODatabaseExport::TColumnVector*	getSrcVector() const	{ return &m_vSourceVec; }
getDestColumns()384cdf0e10cSrcweir 		ODatabaseExport::TColumns*				getDestColumns()		{ return &m_vDestColumns; }
getDestVector() const385cdf0e10cSrcweir 		const ODatabaseExport::TColumnVector*	getDestVector() const	{ return &m_aDestVec; }
getName() const386cdf0e10cSrcweir 		::rtl::OUString	getName() const { return m_sName; }
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 		/** clears the dest vectors
389cdf0e10cSrcweir 		*/
390cdf0e10cSrcweir 		void clearDestColumns();
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createTable();
393cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createView() const;
394cdf0e10cSrcweir 		sal_Int32 getMaxColumnNameLength() const;
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 		void setOperation( const sal_Int16 _nOperation );
397cdf0e10cSrcweir 		sal_Int16 getOperation() const;
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 		::rtl::OUString convertColumnName(	const TColumnFindFunctor&	_rCmpFunctor,
400cdf0e10cSrcweir 											const ::rtl::OUString&	_sColumnName,
401cdf0e10cSrcweir 											const ::rtl::OUString&	_sExtraChars,
402cdf0e10cSrcweir 											sal_Int32				_nMaxNameLen);
403cdf0e10cSrcweir 		TOTypeInfoSP convertType(const TOTypeInfoSP&_pType,sal_Bool& _bNotConvert);
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 		::rtl::OUString createUniqueName(const ::rtl::OUString& _sName);
406cdf0e10cSrcweir 
407cdf0e10cSrcweir 		// displays a error message that a column type is not supported
408cdf0e10cSrcweir 		void showColumnTypeNotSupported(const ::rtl::OUString& _rColumnName);
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 		void removeColumnNameFromNameMap(const ::rtl::OUString& _sName);
411cdf0e10cSrcweir         void showError(const ::rtl::OUString& _sErrorMesage);
412cdf0e10cSrcweir         void showError(const ::com::sun::star::uno::Any& _aError);
413cdf0e10cSrcweir 	};
414cdf0e10cSrcweir }
415cdf0e10cSrcweir 
416cdf0e10cSrcweir #endif // DBAUI_WIZ_COPYTABLEDIALOG_HXX
417