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