update dev300-m58
[ooovba.git] / dbaccess / source / ui / inc / DExport.hxx
blob9a02ebd5ac1887c682251441bc12289c3d58dfa5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DExport.hxx,v $
10 * $Revision: 1.21 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef DBAUI_DATABASEEXPORT_HXX
31 #define DBAUI_DATABASEEXPORT_HXX
33 #include <com/sun/star/sdbc/XResultSet.hpp>
34 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/util/XNumberFormatter.hpp>
37 #include <com/sun/star/container/XNameAccess.hpp>
38 #include <com/sun/star/container/XIndexAccess.hpp>
39 #include <com/sun/star/lang/Locale.hpp>
40 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 #include <com/sun/star/util/Date.hpp>
42 #include <vector>
43 #include <tools/string.hxx>
44 #include <comphelper/stl_types.hxx>
45 #include "TypeInfo.hxx"
46 #include "WTypeSelect.hxx"
47 #include "commontypes.hxx"
48 #include "IUpdateHelper.hxx"
49 #include "WTypeSelect.hxx"
51 namespace com { namespace sun { namespace star {
52 namespace awt{
53 struct FontDescriptor;
55 namespace sdbc{
56 class XPreparedStatement;
57 class XDatabaseMetaData;
59 }}}
61 #define COLUMN_POSITION_NOT_FOUND ((sal_Int32)-1)
63 class Window;
64 class SvNumberFormatter;
65 namespace dbaui
67 class OFieldDescription;
68 class OTypeInfo;
69 class OWizTypeSelect;
70 class ODatabaseExport
72 public:
73 DECLARE_STL_MAP(::rtl::OUString,OFieldDescription*,::comphelper::UStringMixLess,TColumns);
74 typedef ::std::vector<TColumns::const_iterator> TColumnVector;
75 typedef ::std::vector< ::std::pair<sal_Int32,sal_Int32> > TPositions;
77 protected:
78 TPositions m_vColumns; // Welche Spalten "ubernommen werden sollen
79 ::std::vector<sal_Int32> m_vColumnTypes; // FeldTypen f"ur schnelleren Zugriff
80 ::std::vector<sal_Int32> m_vColumnSize;
81 ::std::vector<sal_Int16> m_vNumberFormat;
82 ::com::sun::star::lang::Locale m_aLocale;
84 TColumns m_aDestColumns; // container for new created columns
85 TColumnVector m_vDestVector;
87 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTable; // dest table
88 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xTables; // container
89 SharedConnection m_xConnection; // dest conn
91 ::boost::shared_ptr<IUpdateHelper> m_pUpdateHelper;
92 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xResultSet; //
93 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier
94 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xFactory;
95 ::com::sun::star::util::Date m_aNullDate;
97 SvNumberFormatter* m_pFormatter;
98 SvStream& m_rInputStream;
99 //dyf add 2006/06/01
100 //for save the selected tablename
101 ::rtl::OUString m_sDefaultTableName;
102 //dyf add end
103 String m_sTextToken; // Zellen Inhalt
104 String m_sNumToken; /// SDNUM value
105 String m_sValToken; /// SDVAL value
106 TOTypeInfoSP m_pTypeInfo; // contains the default type
107 const TColumnVector* m_pColumnList;
108 const OTypeInfoMap* m_pInfoMap;
109 sal_Int32 m_nColumnPos; // aktuelle Spaltenposition
110 sal_Int32 m_nRows; // Anzahl der Zeilen die durchsucht werden sollen
111 sal_Int32 m_nRowCount; // current count of rows
112 rtl_TextEncoding m_nDefToken; // Sprache
113 sal_Bool m_bError; // Fehler und Abbruchstatus
114 sal_Bool m_bInTbl; // Ist gesetzt, wenn der Parser sich in der RTF Tabelle befindet
115 sal_Bool m_bHead; // ist true, wenn die Kopfzeile noch nicht gelesen wurde
116 sal_Bool m_bDontAskAgain;// Falls beim Einf"ugen ein Fehler auftritt, soll die Fehlermeldung nicht
117 sal_Bool m_bIsAutoIncrement; // if PKey is set by user
118 sal_Bool m_bFoundTable; // set to true when a table was found
119 sal_Bool m_bCheckOnly;
120 bool m_bAppendFirstLine;
123 virtual sal_Bool CreateTable(int nToken) = 0;
124 virtual TypeSelectionPageFactory
125 getTypeSelectionPageFactory() = 0;
127 void CreateDefaultColumn(const ::rtl::OUString& _rColumnName);
128 sal_Int16 CheckString(const String& aToken, sal_Int16 _nOldNumberFormat);
129 void adjustFormat();
130 void eraseTokens();
131 void insertValueIntoColumn();
132 sal_Bool createRowSet();
133 void showErrorDialog(const ::com::sun::star::sdbc::SQLException& e);
134 void ensureFormatter();
136 /** executeWizard calls a wizard to create/append data
137 @param _sTableName the tablename
138 @param _aTextColor the text color of the new created table
139 @param _rFont the font of the new table
141 @return true when an error occurs
143 sal_Bool executeWizard( const ::rtl::OUString& _sTableName,
144 const ::com::sun::star::uno::Any& _aTextColor,
145 const ::com::sun::star::awt::FontDescriptor& _rFont);
147 virtual ~ODatabaseExport();
148 public:
149 ODatabaseExport(
150 const SharedConnection& _rxConnection,
151 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
152 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
153 const TColumnVector* rList,
154 const OTypeInfoMap* _pInfoMap,
155 SvStream& _rInputStream
158 // wird f"ur auto. Typ-Erkennung gebraucht
159 ODatabaseExport(
160 sal_Int32 nRows,
161 const TPositions& _rColumnPositions,
162 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
163 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
164 const TColumnVector* rList,
165 const OTypeInfoMap* _pInfoMap,
166 sal_Bool _bAutoIncrementEnabled,
167 SvStream& _rInputStream
170 void SetColumnTypes(const TColumnVector* rList,const OTypeInfoMap* _pInfoMap);
172 //dyf add 20070601
173 inline void SetTableName(const ::rtl::OUString &_sTableName){ m_sDefaultTableName = _sTableName ; }
174 //dyf add end
176 virtual void release() = 0;
178 void enableCheckOnly() { m_bCheckOnly = sal_True; }
179 sal_Bool isCheckEnabled() const { return m_bCheckOnly; }
181 static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > createPreparedStatment( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData
182 ,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDestTable
183 ,const TPositions& _rvColumns);
187 #endif // DBAUI_DATABASEEXPORT_HXX