Files
libreoffice/dbaccess/source/ui/inc/DExport.hxx

174 lines
8.0 KiB
C++
Raw Normal View History

2010-10-27 12:33:13 +01:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-06-14 17:39:53 +01:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2001-02-16 14:54:09 +00:00
#ifndef DBAUI_DATABASEEXPORT_HXX
#define DBAUI_DATABASEEXPORT_HXX
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/util/XNumberFormatter.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/lang/Locale.hpp>
2001-02-23 14:02:06 +00:00
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
CWS-TOOLING: integrate CWS dbaperf1 2009-04-02 09:12:25 +0200 oj r270372 : CWS-TOOLING: rebase CWS dbaperf1 to trunk@270033 (milestone: DEV300:m45) 2009-03-17 10:20:34 +0100 oj r269577 : add parameter 2009-03-17 10:20:05 +0100 oj r269576 : add parameter 2009-03-12 12:32:24 +0100 oj r269387 : add missing ++ 2009-03-11 12:53:35 +0100 oj r269315 : compile error 2009-03-06 08:52:11 +0100 oj r268968 : #i99264# remove duplicate code 2009-03-06 08:20:08 +0100 oj r268966 : add missingheader 2009-03-06 08:17:41 +0100 oj r268965 : add header 2009-03-06 08:15:07 +0100 oj r268964 : #i99708# remove duplicate code 2009-03-06 07:24:11 +0100 oj r268963 : #i99708# remove duplicate code 2009-03-06 07:22:24 +0100 oj r268962 : #i99708# use tenary operator 2009-03-06 07:19:21 +0100 oj r268961 : remove unused rtl_logs 2009-03-06 07:15:55 +0100 oj r268960 : #i99708# extract getLength from for loop 2009-03-06 07:15:35 +0100 oj r268959 : #i99708# extract getLength from for loop 2009-03-06 07:14:57 +0100 oj r268958 : remove unused rtl_logs 2009-03-06 07:13:01 +0100 oj r268957 : insert DBG_ helper 2009-03-06 07:12:17 +0100 oj r268956 : remove unused rtl_logs 2009-03-06 07:10:26 +0100 oj r268955 : remove unused rtl_logs 2009-03-06 07:04:51 +0100 oj r268954 : #i99708# use tenary operator 2009-03-05 12:04:46 +0100 oj r268895 : comment RTL_LOG out 2009-03-05 09:05:07 +0100 oj r268874 : add rtl logfile 2009-03-04 14:21:18 +0100 oj r268828 : #i99708# make static inplace and some method calls in for loop removed 2009-03-04 14:20:34 +0100 oj r268827 : #i99708# impl double check pattern for getInfohelper 2009-03-02 09:31:42 +0100 oj r268636 : add rtl logfile 2009-03-02 08:18:37 +0100 oj r268633 : add rtl logfile 2009-02-27 11:22:16 +0100 oj r268570 : #i99709# change algorithm for marking objects 2009-02-27 11:17:04 +0100 oj r268568 : #i99708# some improvements to load forms, controls faster and replacement of size() call with !empty() which is much faster 2009-02-24 10:09:35 +0100 sb r268383 : #i99290# no longer care to set a sensible context class loader for native threads attached to the VM 2009-02-23 13:44:04 +0100 oj r268354 : #i76606# seekrow changes 2009-02-23 12:27:30 +0100 oj r268349 : deleted 2009-02-20 15:14:23 +0100 oj r268325 : #i76606# some code changes 2009-02-19 14:15:25 +0100 oj r268284 : #i76606# use of simple prep stmt instead of full blown rowset, when source and dest connection are the same use insert into ... ( select ... ) 2009-02-19 11:27:55 +0100 oj r268265 : #i76606# insert some RTL_LOG and setObject impl 2009-02-18 14:45:37 +0100 oj r268222 : #i99363# insert RTL_LOG 2009-02-18 14:45:18 +0100 oj r268221 : #i99363# insert RTL_LOG 2009-02-18 11:14:54 +0100 oj r268207 : #i99363# call some impl_ methods to avoid duplicate cechCache calls 2009-02-18 11:10:47 +0100 oj r268206 : #i99363# make isCount inline 2009-02-18 10:33:22 +0100 oj r268203 : #i99363# use bookmarkable if available and inserted some RTL_LOG 2009-02-18 10:32:57 +0100 oj r268202 : #i99363# use bookmarkable if available and inserted some RTL_LOG 2009-02-17 07:29:05 +0100 oj r267843 : #i96897# remove some dll public 2009-02-16 15:01:04 +0100 oj r267816 : #i96897# remove some dll public 2009-02-16 14:25:53 +0100 oj r267810 : #i99264# remove duplicate code 2009-02-16 14:25:33 +0100 oj r267809 : #i99264# remove duplicate code 2009-02-16 14:24:59 +0100 oj r267808 : #i99264# remove duplicate code 2009-02-13 10:56:17 +0100 oj r267703 : #i99191# comment the contextclassloader 2009-02-13 10:32:40 +0100 oj r267700 : reduce call to resultset meta data 2009-02-13 10:27:31 +0100 oj r267699 : reduce call to resultset meta data 2009-02-13 10:27:08 +0100 oj r267698 : reduce call to resultset meta data
2009-04-23 10:42:05 +00:00
#include <com/sun/star/util/Date.hpp>
2001-02-16 14:54:09 +00:00
#include <vector>
#include <tools/string.hxx>
2001-02-23 14:02:06 +00:00
#include <comphelper/stl_types.hxx>
#include "TypeInfo.hxx"
#include "WTypeSelect.hxx"
#include "commontypes.hxx"
#include "IUpdateHelper.hxx"
2001-02-16 14:54:09 +00:00
namespace com { namespace sun { namespace star {
namespace awt{
struct FontDescriptor;
}
namespace sdbc{
class XPreparedStatement;
class XDatabaseMetaData;
}
}}}
2002-01-22 06:22:37 +00:00
#define COLUMN_POSITION_NOT_FOUND ((sal_Int32)-1)
class SvNumberFormatter;
2001-02-16 14:54:09 +00:00
namespace dbaui
{
2001-02-23 14:02:06 +00:00
class OFieldDescription;
2001-02-16 14:54:09 +00:00
class ODatabaseExport
{
2001-02-23 14:02:06 +00:00
public:
DECLARE_STL_MAP(OUString,OFieldDescription*,::comphelper::UStringMixLess,TColumns);
2002-05-23 10:10:43 +00:00
typedef ::std::vector<TColumns::const_iterator> TColumnVector;
typedef ::std::vector< ::std::pair<sal_Int32,sal_Int32> > TPositions;
2001-02-16 14:54:09 +00:00
protected:
TPositions m_vColumns; ///< columns to be used
::std::vector<sal_Int32> m_vColumnTypes; ///< ColumnTypes for faster access
2001-02-23 14:02:06 +00:00
::std::vector<sal_Int32> m_vColumnSize;
::std::vector<sal_Int16> m_vNumberFormat;
::com::sun::star::lang::Locale m_aLocale;
2001-02-16 14:54:09 +00:00
TColumns m_aDestColumns; ///< container for new created columns
TColumnVector m_vDestVector;
2001-02-23 14:02:06 +00:00
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTable; ///< dest table
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xTables; ///< container
SharedConnection m_xConnection; ///< dest conn
2001-02-16 14:54:09 +00:00
::boost::shared_ptr<IUpdateHelper> m_pUpdateHelper;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xResultSet;
::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; ///< a number formatter working with the connection's NumberFormatsSupplier
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xContext;
CWS-TOOLING: integrate CWS dbaperf1 2009-04-02 09:12:25 +0200 oj r270372 : CWS-TOOLING: rebase CWS dbaperf1 to trunk@270033 (milestone: DEV300:m45) 2009-03-17 10:20:34 +0100 oj r269577 : add parameter 2009-03-17 10:20:05 +0100 oj r269576 : add parameter 2009-03-12 12:32:24 +0100 oj r269387 : add missing ++ 2009-03-11 12:53:35 +0100 oj r269315 : compile error 2009-03-06 08:52:11 +0100 oj r268968 : #i99264# remove duplicate code 2009-03-06 08:20:08 +0100 oj r268966 : add missingheader 2009-03-06 08:17:41 +0100 oj r268965 : add header 2009-03-06 08:15:07 +0100 oj r268964 : #i99708# remove duplicate code 2009-03-06 07:24:11 +0100 oj r268963 : #i99708# remove duplicate code 2009-03-06 07:22:24 +0100 oj r268962 : #i99708# use tenary operator 2009-03-06 07:19:21 +0100 oj r268961 : remove unused rtl_logs 2009-03-06 07:15:55 +0100 oj r268960 : #i99708# extract getLength from for loop 2009-03-06 07:15:35 +0100 oj r268959 : #i99708# extract getLength from for loop 2009-03-06 07:14:57 +0100 oj r268958 : remove unused rtl_logs 2009-03-06 07:13:01 +0100 oj r268957 : insert DBG_ helper 2009-03-06 07:12:17 +0100 oj r268956 : remove unused rtl_logs 2009-03-06 07:10:26 +0100 oj r268955 : remove unused rtl_logs 2009-03-06 07:04:51 +0100 oj r268954 : #i99708# use tenary operator 2009-03-05 12:04:46 +0100 oj r268895 : comment RTL_LOG out 2009-03-05 09:05:07 +0100 oj r268874 : add rtl logfile 2009-03-04 14:21:18 +0100 oj r268828 : #i99708# make static inplace and some method calls in for loop removed 2009-03-04 14:20:34 +0100 oj r268827 : #i99708# impl double check pattern for getInfohelper 2009-03-02 09:31:42 +0100 oj r268636 : add rtl logfile 2009-03-02 08:18:37 +0100 oj r268633 : add rtl logfile 2009-02-27 11:22:16 +0100 oj r268570 : #i99709# change algorithm for marking objects 2009-02-27 11:17:04 +0100 oj r268568 : #i99708# some improvements to load forms, controls faster and replacement of size() call with !empty() which is much faster 2009-02-24 10:09:35 +0100 sb r268383 : #i99290# no longer care to set a sensible context class loader for native threads attached to the VM 2009-02-23 13:44:04 +0100 oj r268354 : #i76606# seekrow changes 2009-02-23 12:27:30 +0100 oj r268349 : deleted 2009-02-20 15:14:23 +0100 oj r268325 : #i76606# some code changes 2009-02-19 14:15:25 +0100 oj r268284 : #i76606# use of simple prep stmt instead of full blown rowset, when source and dest connection are the same use insert into ... ( select ... ) 2009-02-19 11:27:55 +0100 oj r268265 : #i76606# insert some RTL_LOG and setObject impl 2009-02-18 14:45:37 +0100 oj r268222 : #i99363# insert RTL_LOG 2009-02-18 14:45:18 +0100 oj r268221 : #i99363# insert RTL_LOG 2009-02-18 11:14:54 +0100 oj r268207 : #i99363# call some impl_ methods to avoid duplicate cechCache calls 2009-02-18 11:10:47 +0100 oj r268206 : #i99363# make isCount inline 2009-02-18 10:33:22 +0100 oj r268203 : #i99363# use bookmarkable if available and inserted some RTL_LOG 2009-02-18 10:32:57 +0100 oj r268202 : #i99363# use bookmarkable if available and inserted some RTL_LOG 2009-02-17 07:29:05 +0100 oj r267843 : #i96897# remove some dll public 2009-02-16 15:01:04 +0100 oj r267816 : #i96897# remove some dll public 2009-02-16 14:25:53 +0100 oj r267810 : #i99264# remove duplicate code 2009-02-16 14:25:33 +0100 oj r267809 : #i99264# remove duplicate code 2009-02-16 14:24:59 +0100 oj r267808 : #i99264# remove duplicate code 2009-02-13 10:56:17 +0100 oj r267703 : #i99191# comment the contextclassloader 2009-02-13 10:32:40 +0100 oj r267700 : reduce call to resultset meta data 2009-02-13 10:27:31 +0100 oj r267699 : reduce call to resultset meta data 2009-02-13 10:27:08 +0100 oj r267698 : reduce call to resultset meta data
2009-04-23 10:42:05 +00:00
::com::sun::star::util::Date m_aNullDate;
2001-02-16 14:54:09 +00:00
SvNumberFormatter* m_pFormatter;
SvStream& m_rInputStream;
/// for saving the selected tablename
OUString m_sDefaultTableName;
2011-02-27 22:55:22 +01:00
OUString m_sTextToken; ///< cell content
OUString m_sNumToken; ///< SDNUM value
OUString m_sValToken; ///< SDVAL value
TOTypeInfoSP m_pTypeInfo; ///< contains the default type
const TColumnVector* m_pColumnList;
const OTypeInfoMap* m_pInfoMap;
sal_Int32 m_nColumnPos; ///< current column position
sal_Int32 m_nRows; ///< number of rows to be searched
sal_Int32 m_nRowCount; ///< current count of rows
rtl_TextEncoding m_nDefToken; ///< language
sal_Bool m_bError; ///< error and termination code
sal_Bool m_bInTbl; ///< true, if parser is in RTF table
sal_Bool m_bHead; ///< true, if the header hasn't been read yet
sal_Bool m_bDontAskAgain;///< if there is an error when pasting, don't show it again
sal_Bool m_bIsAutoIncrement; ///< if PKey is set by user
sal_Bool m_bFoundTable; ///< set to true when a table was found
2002-05-28 07:08:11 +00:00
sal_Bool m_bCheckOnly;
bool m_bAppendFirstLine;
2001-02-16 14:54:09 +00:00
virtual sal_Bool CreateTable(int nToken) = 0;
virtual TypeSelectionPageFactory
getTypeSelectionPageFactory() = 0;
2002-01-22 06:22:37 +00:00
void CreateDefaultColumn(const OUString& _rColumnName);
sal_Int16 CheckString(const OUString& aToken, sal_Int16 _nOldNumberFormat);
void adjustFormat();
void eraseTokens();
void insertValueIntoColumn();
sal_Bool createRowSet();
void showErrorDialog(const ::com::sun::star::sdbc::SQLException& e);
void ensureFormatter();
2002-01-22 06:22:37 +00:00
/** executeWizard calls a wizard to create/append data
2002-01-22 06:22:37 +00:00
@param _sTableName the tablename
@param _aTextColor the text color of the new created table
@param _rFont the font of the new table
@return true when an error occurs
*/
sal_Bool executeWizard( const OUString& _sTableName,
const ::com::sun::star::uno::Any& _aTextColor,
const ::com::sun::star::awt::FontDescriptor& _rFont);
2001-02-16 14:54:09 +00:00
virtual ~ODatabaseExport();
2001-02-16 14:54:09 +00:00
public:
ODatabaseExport(
const SharedConnection& _rxConnection,
const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
const TColumnVector* rList,
const OTypeInfoMap* _pInfoMap,
SvStream& _rInputStream
);
// required for automatic type recognition
ODatabaseExport(
sal_Int32 nRows,
const TPositions& _rColumnPositions,
const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
const TColumnVector* rList,
const OTypeInfoMap* _pInfoMap,
sal_Bool _bAutoIncrementEnabled,
SvStream& _rInputStream
);
2001-02-16 14:54:09 +00:00
void SetColumnTypes(const TColumnVector* rList,const OTypeInfoMap* _pInfoMap);
inline void SetTableName(const OUString &_sTableName){ m_sDefaultTableName = _sTableName ; }
2001-11-23 13:51:40 +00:00
virtual void release() = 0;
2002-05-28 07:08:11 +00:00
void enableCheckOnly() { m_bCheckOnly = sal_True; }
sal_Bool isCheckEnabled() const { return m_bCheckOnly; }
static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > createPreparedStatment( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData
,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDestTable
,const TPositions& _rvColumns);
2001-02-16 14:54:09 +00:00
};
}
#endif
2001-02-16 14:54:09 +00:00
2010-10-27 12:33:13 +01:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */