LibreOffice Module dbaccess (master) 1
DExport.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#pragma once
20
21#include <sal/config.h>
22
23#include <com/sun/star/sdbc/SQLException.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/lang/Locale.hpp>
28#include <com/sun/star/util/Date.hpp>
29#include <com/sun/star/uno/XComponentContext.hpp>
30#include <map>
31#include <vector>
33#include "TypeInfo.hxx"
34#include "WTypeSelect.hxx"
35#include "commontypes.hxx"
36#include "IUpdateHelper.hxx"
37
38namespace com::sun::star {
39 namespace awt{
40 struct FontDescriptor;
41 }
42 namespace sdbc{
43 class XPreparedStatement;
44 class XDatabaseMetaData;
45 }
46}
47
48#define COLUMN_POSITION_NOT_FOUND (sal_Int32(-1))
49
51namespace dbaui
52{
53 class OFieldDescription;
55 {
56 public:
57 typedef std::map<OUString, OFieldDescription*, ::comphelper::UStringMixLess> TColumns;
58 typedef std::vector<TColumns::const_iterator> TColumnVector;
59 typedef std::vector< std::pair<sal_Int32,sal_Int32> > TPositions;
60
61 protected:
63 std::vector<sal_Int32> m_vColumnTypes;
64 std::vector<sal_Int32> m_vColumnSize;
65 std::vector<sal_Int16> m_vNumberFormat;
66 css::lang::Locale m_aLocale;
67
70
71 css::uno::Reference< css::beans::XPropertySet > m_xTable;
72 css::uno::Reference< css::container::XNameAccess> m_xTables;
74
75 std::shared_ptr<IUpdateHelper> m_pUpdateHelper;
76 css::uno::Reference< css::util::XNumberFormatter > m_xFormatter;
77 css::uno::Reference< css::uno::XComponentContext> m_xContext;
78 css::util::Date m_aNullDate;
79
84
85 OUString m_sTextToken;
86 OUString m_sNumToken;
90 sal_Int32 m_nColumnPos;
91 sal_Int32 m_nRows;
92 sal_Int32 m_nRowCount;
93 bool m_bError;
94 bool m_bInTbl;
95 bool m_bHead;
101
102
105
106 void CreateDefaultColumn(const OUString& _rColumnName);
107 sal_Int16 CheckString(const OUString& aToken, sal_Int16 _nOldNumberFormat);
108 void adjustFormat();
109 void eraseTokens();
111 void createRowSet();
112 void showErrorDialog(const css::sdbc::SQLException& e);
113 void ensureFormatter();
114
123 bool executeWizard( const OUString& _sTableName,
124 const css::uno::Any& _aTextColor,
125 const css::awt::FontDescriptor& _rFont);
126
127 virtual ~ODatabaseExport();
128
129 public:
131 const SharedConnection& _rxConnection,
132 const css::uno::Reference< css::util::XNumberFormatter >& _rxNumberF,
133 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
134 SvStream& _rInputStream
135 );
136
137 // required for automatic type recognition
139 sal_Int32 nRows,
140 TPositions&& _rColumnPositions,
141 const css::uno::Reference< css::util::XNumberFormatter >& _rxNumberF,
142 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
143 const TColumnVector* rList,
144 const OTypeInfoMap* _pInfoMap,
145 bool _bAutoIncrementEnabled,
146 SvStream& _rInputStream
147 );
148
149 void SetColumnTypes(const TColumnVector* rList,const OTypeInfoMap* _pInfoMap);
150
151 void SetTableName(const OUString &_sTableName){ m_sDefaultTableName = _sTableName ; }
152
153 void enableCheckOnly() { m_bCheckOnly = true; }
154 bool isCheckEnabled() const { return m_bCheckOnly; }
155
156 static css::uno::Reference< css::sdbc::XPreparedStatement > createPreparedStatement( const css::uno::Reference< css::sdbc::XDatabaseMetaData>& _xMetaData
157 ,const css::uno::Reference< css::beans::XPropertySet>& _xDestTable
158 ,const TPositions& _rvColumnPositions);
159 };
160}
161
162/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvNumberFormatter * m_pFormatter
Definition: DExport.hxx:80
sal_Int16 CheckString(const OUString &aToken, sal_Int16 _nOldNumberFormat)
Definition: DExport.cxx:385
TColumns m_aDestColumns
container for new created columns
Definition: DExport.hxx:68
sal_Int32 m_nRows
number of rows to be searched
Definition: DExport.hxx:91
bool isCheckEnabled() const
Definition: DExport.hxx:154
OUString m_sDefaultTableName
for saving the selected tablename
Definition: DExport.hxx:83
std::map< OUString, OFieldDescription *, ::comphelper::UStringMixLess > TColumns
Definition: DExport.hxx:57
static css::uno::Reference< css::sdbc::XPreparedStatement > createPreparedStatement(const css::uno::Reference< css::sdbc::XDatabaseMetaData > &_xMetaData, const css::uno::Reference< css::beans::XPropertySet > &_xDestTable, const TPositions &_rvColumnPositions)
Definition: DExport.cxx:781
void SetTableName(const OUString &_sTableName)
Definition: DExport.hxx:151
OUString m_sTextToken
cell content
Definition: DExport.hxx:85
void CreateDefaultColumn(const OUString &_rColumnName)
Definition: DExport.cxx:605
css::uno::Reference< css::container::XNameAccess > m_xTables
container
Definition: DExport.hxx:72
ODatabaseExport(const SharedConnection &_rxConnection, const css::uno::Reference< css::util::XNumberFormatter > &_rxNumberF, const css::uno::Reference< css::uno::XComponentContext > &_rxContext, SvStream &_rInputStream)
TColumnVector m_vDestVector
Definition: DExport.hxx:69
bool m_bDontAskAgain
if there is an error when pasting, don't show it again
Definition: DExport.hxx:96
css::uno::Reference< css::util::XNumberFormatter > m_xFormatter
a number formatter working with the connection's NumberFormatsSupplier
Definition: DExport.hxx:76
virtual ~ODatabaseExport()
Definition: DExport.cxx:263
bool m_bError
error and termination code
Definition: DExport.hxx:93
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: DExport.hxx:77
std::vector< sal_Int16 > m_vNumberFormat
Definition: DExport.hxx:65
std::vector< std::pair< sal_Int32, sal_Int32 > > TPositions
Definition: DExport.hxx:59
std::shared_ptr< IUpdateHelper > m_pUpdateHelper
Definition: DExport.hxx:75
std::vector< sal_Int32 > m_vColumnSize
Definition: DExport.hxx:64
sal_Int32 m_nColumnPos
current column position
Definition: DExport.hxx:90
const OTypeInfoMap * m_pInfoMap
Definition: DExport.hxx:89
css::util::Date m_aNullDate
Definition: DExport.hxx:78
bool m_bInTbl
true, if parser is in RTF table
Definition: DExport.hxx:94
OUString m_sNumToken
SDNUM value.
Definition: DExport.hxx:86
sal_Int32 m_nRowCount
current count of rows
Definition: DExport.hxx:92
css::uno::Reference< css::beans::XPropertySet > m_xTable
dest table
Definition: DExport.hxx:71
bool executeWizard(const OUString &_sTableName, const css::uno::Any &_aTextColor, const css::awt::FontDescriptor &_rFont)
executeWizard calls a wizard to create/append data
Definition: DExport.cxx:661
bool m_bFoundTable
set to true when a table was found
Definition: DExport.hxx:98
ODatabaseExport(sal_Int32 nRows, TPositions &&_rColumnPositions, const css::uno::Reference< css::util::XNumberFormatter > &_rxNumberF, const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const TColumnVector *rList, const OTypeInfoMap *_pInfoMap, bool _bAutoIncrementEnabled, SvStream &_rInputStream)
bool m_bIsAutoIncrement
if PKey is set by user
Definition: DExport.hxx:97
void showErrorDialog(const css::sdbc::SQLException &e)
Definition: DExport.cxx:725
css::lang::Locale m_aLocale
Definition: DExport.hxx:66
virtual TypeSelectionPageFactory getTypeSelectionPageFactory()=0
void SetColumnTypes(const TColumnVector *rList, const OTypeInfoMap *_pInfoMap)
Definition: DExport.cxx:530
std::vector< sal_Int32 > m_vColumnTypes
ColumnTypes for faster access.
Definition: DExport.hxx:63
TOTypeInfoSP m_pTypeInfo
contains the default type
Definition: DExport.hxx:87
void insertValueIntoColumn()
Definition: DExport.cxx:272
bool m_bHead
true, if the header hasn't been read yet
Definition: DExport.hxx:95
std::vector< TColumns::const_iterator > TColumnVector
Definition: DExport.hxx:58
SvStream & m_rInputStream
Definition: DExport.hxx:81
TPositions m_vColumnPositions
columns to be used
Definition: DExport.hxx:62
const TColumnVector * m_pColumnList
Definition: DExport.hxx:88
SharedConnection m_xConnection
dest conn
Definition: DExport.hxx:73
std::unique_ptr< OWizTypeSelect >(* TypeSelectionPageFactory)(weld::Container *, OCopyTableWizard *, SvStream &)
std::multimap< sal_Int32, TOTypeInfoSP > OTypeInfoMap
Definition: TypeInfo.hxx:100
std::shared_ptr< OTypeInfo > TOTypeInfoSP
Definition: TypeInfo.hxx:99