Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / dbaccess / source / ui / inc / DExport.hxx
blob57920e6173ef3e2d3cb6ad5ed38a073798e4f2d8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_DEXPORT_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_INC_DEXPORT_HXX
22 #include <com/sun/star/sdbc/XResultSet.hpp>
23 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
24 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <com/sun/star/util/XNumberFormatter.hpp>
26 #include <com/sun/star/container/XNameAccess.hpp>
27 #include <com/sun/star/container/XIndexAccess.hpp>
28 #include <com/sun/star/lang/Locale.hpp>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 #include <com/sun/star/util/Date.hpp>
31 #include <com/sun/star/uno/XComponentContext.hpp>
32 #include <map>
33 #include <vector>
34 #include <comphelper/stl_types.hxx>
35 #include "TypeInfo.hxx"
36 #include "WTypeSelect.hxx"
37 #include "commontypes.hxx"
38 #include "IUpdateHelper.hxx"
40 namespace com { namespace sun { namespace star {
41 namespace awt{
42 struct FontDescriptor;
44 namespace sdbc{
45 class XPreparedStatement;
46 class XDatabaseMetaData;
48 }}}
50 #define COLUMN_POSITION_NOT_FOUND ((sal_Int32)-1)
52 class SvNumberFormatter;
53 namespace dbaui
55 class OFieldDescription;
56 class ODatabaseExport
58 public:
59 typedef std::map<OUString, OFieldDescription*, ::comphelper::UStringMixLess> TColumns;
60 typedef ::std::vector<TColumns::const_iterator> TColumnVector;
61 typedef ::std::vector< ::std::pair<sal_Int32,sal_Int32> > TPositions;
63 protected:
64 TPositions m_vColumns; ///< columns to be used
65 ::std::vector<sal_Int32> m_vColumnTypes; ///< ColumnTypes for faster access
66 ::std::vector<sal_Int32> m_vColumnSize;
67 ::std::vector<sal_Int16> m_vNumberFormat;
68 css::lang::Locale m_aLocale;
70 TColumns m_aDestColumns; ///< container for new created columns
71 TColumnVector m_vDestVector;
73 css::uno::Reference< css::beans::XPropertySet > m_xTable; ///< dest table
74 css::uno::Reference< css::container::XNameAccess> m_xTables; ///< container
75 SharedConnection m_xConnection; ///< dest conn
77 std::shared_ptr<IUpdateHelper> m_pUpdateHelper;
78 css::uno::Reference< css::util::XNumberFormatter > m_xFormatter; ///< a number formatter working with the connection's NumberFormatsSupplier
79 css::uno::Reference< css::uno::XComponentContext> m_xContext;
80 css::util::Date m_aNullDate;
82 SvNumberFormatter* m_pFormatter;
83 SvStream& m_rInputStream;
84 /// for saving the selected tablename
85 OUString m_sDefaultTableName;
87 OUString m_sTextToken; ///< cell content
88 OUString m_sNumToken; ///< SDNUM value
89 OUString m_sValToken; ///< SDVAL value
90 TOTypeInfoSP m_pTypeInfo; ///< contains the default type
91 const TColumnVector* m_pColumnList;
92 const OTypeInfoMap* m_pInfoMap;
93 sal_Int32 m_nColumnPos; ///< current column position
94 sal_Int32 m_nRows; ///< number of rows to be searched
95 sal_Int32 m_nRowCount; ///< current count of rows
96 rtl_TextEncoding m_nDefToken; ///< language
97 bool m_bError; ///< error and termination code
98 bool m_bInTbl; ///< true, if parser is in RTF table
99 bool m_bHead; ///< true, if the header hasn't been read yet
100 bool m_bDontAskAgain;///< if there is an error when pasting, don't show it again
101 bool m_bIsAutoIncrement; ///< if PKey is set by user
102 bool m_bFoundTable; ///< set to true when a table was found
103 bool m_bCheckOnly;
104 bool m_bAppendFirstLine;
107 virtual bool CreateTable(int nToken) = 0;
108 virtual TypeSelectionPageFactory
109 getTypeSelectionPageFactory() = 0;
111 void CreateDefaultColumn(const OUString& _rColumnName);
112 sal_Int16 CheckString(const OUString& aToken, sal_Int16 _nOldNumberFormat);
113 void adjustFormat();
114 void eraseTokens();
115 void insertValueIntoColumn();
116 bool createRowSet();
117 void showErrorDialog(const css::sdbc::SQLException& e);
118 void ensureFormatter();
120 /** executeWizard calls a wizard to create/append data
122 @param _sTableName the tablename
123 @param _aTextColor the text color of the new created table
124 @param _rFont the font of the new table
126 @return true when an error occurs
128 bool executeWizard( const OUString& _sTableName,
129 const css::uno::Any& _aTextColor,
130 const css::awt::FontDescriptor& _rFont);
132 virtual ~ODatabaseExport();
134 public:
135 ODatabaseExport(
136 const SharedConnection& _rxConnection,
137 const css::uno::Reference< css::util::XNumberFormatter >& _rxNumberF,
138 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
139 const TColumnVector* rList,
140 const OTypeInfoMap* _pInfoMap,
141 SvStream& _rInputStream
144 // required for automatic type recognition
145 ODatabaseExport(
146 sal_Int32 nRows,
147 const TPositions& _rColumnPositions,
148 const css::uno::Reference< css::util::XNumberFormatter >& _rxNumberF,
149 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
150 const TColumnVector* rList,
151 const OTypeInfoMap* _pInfoMap,
152 bool _bAutoIncrementEnabled,
153 SvStream& _rInputStream
156 void SetColumnTypes(const TColumnVector* rList,const OTypeInfoMap* _pInfoMap);
158 inline void SetTableName(const OUString &_sTableName){ m_sDefaultTableName = _sTableName ; }
160 virtual void release() = 0;
162 void enableCheckOnly() { m_bCheckOnly = true; }
163 bool isCheckEnabled() const { return m_bCheckOnly; }
165 static css::uno::Reference< css::sdbc::XPreparedStatement > createPreparedStatment( const css::uno::Reference< css::sdbc::XDatabaseMetaData>& _xMetaData
166 ,const css::uno::Reference< css::beans::XPropertySet>& _xDestTable
167 ,const TPositions& _rvColumns);
171 #endif
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */