LibreOffice Module dbaccess (master) 1
TokenWriter.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 "commontypes.hxx"
22
23#include <com/sun/star/awt/FontDescriptor.hpp>
24#include <com/sun/star/sdbc/XResultSet.hpp>
25#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
26#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
27#include <com/sun/star/sdbc/XRow.hpp>
28#include <com/sun/star/lang/XEventListener.hpp>
29#include <com/sun/star/container/XIndexAccess.hpp>
30#include <com/sun/star/sdbcx/XRowLocate.hpp>
31#include <com/sun/star/uno/XComponentContext.hpp>
32#include <com/sun/star/util/XNumberFormatter.hpp>
33
36#include <vcl/weld.hxx>
37
38namespace com::sun::star {
39 namespace sdbc{
40 class XRowUpdate;
41 }
42}
43
44class SvStream;
45
46namespace dbaui
47{
48 // ODatabaseImportExport base class for import/export
49 class ODatabaseExport;
50 class ODatabaseImportExport : public ::cppu::WeakImplHelper< css::lang::XEventListener>
51 {
52 protected:
53 css::uno::Sequence< css::uno::Any> m_aSelection;
56 css::awt::FontDescriptor m_aFont;
57 css::uno::Reference< css::beans::XPropertySet > m_xObject; // table/query
59 css::uno::Reference< css::sdbc::XResultSet > m_xResultSet;
60 css::uno::Reference< css::sdbc::XRow > m_xRow;
61 css::uno::Reference< css::sdbcx::XRowLocate > m_xRowLocate;
62 css::uno::Reference< css::sdbc::XResultSetMetaData > m_xResultSetMetaData;
63 css::uno::Reference< css::container::XIndexAccess > m_xRowSetColumns;
64 css::uno::Reference< css::util::XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier
65 css::uno::Reference< css::uno::XComponentContext > m_xContext;
66
67 OUString m_sName;
68
69 //for transfor the tablename
71
73 sal_Int32 m_nCommandType;
75
76 rtl_TextEncoding m_eDestEnc;
79
80 // export data
82 const css::uno::Reference< css::uno::XComponentContext >& _rM,
83 const css::uno::Reference< css::util::XNumberFormatter >& _rxNumberF);
84
85 // import data
87 const css::uno::Reference< css::util::XNumberFormatter >& _rxNumberF,
88 const css::uno::Reference< css::uno::XComponentContext >& _rM);
89
90 virtual ~ODatabaseImportExport() override;
91
92 virtual void initialize();
93 public:
94 void setStream(SvStream* _pStream){ m_pStream = _pStream; }
95
96 //for set the tablename
97 void setSTableName(const OUString &_sTableName){ m_sDefaultTableName = _sTableName; }
98
99 virtual bool Write(); // Export
100 virtual bool Read(); // Import
101
102 void initialize(const svx::ODataAccessDescriptor& _aDataDescriptor);
103 void dispose();
104
105 void enableCheckOnly() { m_bCheckOnly = true; }
106 bool isCheckEnabled() const { return m_bCheckOnly; }
107
108 private:
109 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
110 void impl_initFromDescriptor( const svx::ODataAccessDescriptor& _aDataDescriptor, bool _bPlusDefaultInit );
111 };
112
113 // RTF Import and Export
114
116 {
117 void appendRow(OString const * pHorzChar,sal_Int32 _nColumnCount,sal_Int32& k,sal_Int32& kk);
118 public:
119 // export data
121 const css::uno::Reference< css::uno::XComponentContext >& _rM,
122 const css::uno::Reference< css::util::XNumberFormatter >& _rxNumberF)
123 : ODatabaseImportExport(_aDataDescriptor,_rM,_rxNumberF) {};
124
125 // import data
126 ORTFImportExport( const SharedConnection& _rxConnection,
127 const css::uno::Reference< css::util::XNumberFormatter >& _rxNumberF,
128 const css::uno::Reference< css::uno::XComponentContext >& _rM)
129 : ODatabaseImportExport(_rxConnection,_rxNumberF,_rM)
130 {}
131
132 virtual bool Write() override;
133 virtual bool Read() override;
134 };
135 // HTML Import and Export
136 #define SBA_HTML_FONTSIZES 7
137 const sal_Int16 nIndentMax = 23;
139 {
140 static const sal_Int16 nCellSpacing;
141 static const char sIndentSource[];
143 sal_Int16 m_nIndent;
144 #if OSL_DEBUG_LEVEL > 0
146 #endif
147
148 void WriteHeader();
149 void WriteBody();
150 void WriteTables();
151 void WriteCell( sal_Int32 nFormat,sal_Int32 nWidthPixel,sal_Int32 nHeightPixel,const char* pChar,const OUString& rValue,const char* pHtmlTag);
152 void IncIndent( sal_Int16 nVal );
153 const char* GetIndentStr() const { return sIndent; }
154 void FontOn();
155 inline void FontOff();
156
157 public:
158 // export data
160 const css::uno::Reference< css::uno::XComponentContext >& _rM,
161 const css::uno::Reference< css::util::XNumberFormatter >& _rxNumberF);
162 // import data
163 OHTMLImportExport( const SharedConnection& _rxConnection,
164 const css::uno::Reference< css::util::XNumberFormatter >& _rxNumberF,
165 const css::uno::Reference< css::uno::XComponentContext >& _rM)
166 : ODatabaseImportExport(_rxConnection,_rxNumberF,_rM)
167 , m_nIndent(0)
168 {}
169
170 virtual bool Write() override;
171 virtual bool Read() override;
172
173 };
174 // normal RowSet Import and Export
175
177 {
178 std::vector<sal_Int32> m_aColumnMapping;
179 std::vector<sal_Int32> m_aColumnTypes;
180 css::uno::Reference< css::sdbc::XResultSetUpdate > m_xTargetResultSetUpdate;
181 css::uno::Reference< css::sdbc::XRowUpdate > m_xTargetRowUpdate;
182 css::uno::Reference< css::sdbc::XResultSetMetaData > m_xTargetResultSetMetaData;
185
186 bool insertNewRow();
187 protected:
188 virtual void initialize() override;
189
190 public:
191 // export data
193 const css::uno::Reference< css::sdbc::XResultSetUpdate >& xResultSetUpdate,
194 const svx::ODataAccessDescriptor& aDataDescriptor,
195 const css::uno::Reference< css::uno::XComponentContext >& rM);
196
197 virtual bool Write() override;
198 virtual bool Read() override;
199
200 private:
202 };
203
204}
205
206/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::container::XIndexAccess > m_xRowSetColumns
Definition: TokenWriter.hxx:63
css::uno::Sequence< css::uno::Any > m_aSelection
Definition: TokenWriter.hxx:53
virtual ~ODatabaseImportExport() override
void impl_initFromDescriptor(const svx::ODataAccessDescriptor &_aDataDescriptor, bool _bPlusDefaultInit)
ODatabaseImportExport(SharedConnection _xConnection, const css::uno::Reference< css::util::XNumberFormatter > &_rxNumberF, const css::uno::Reference< css::uno::XComponentContext > &_rM)
css::uno::Reference< css::sdbc::XResultSet > m_xResultSet
Definition: TokenWriter.hxx:59
css::uno::Reference< css::sdbcx::XRowLocate > m_xRowLocate
Definition: TokenWriter.hxx:61
css::awt::FontDescriptor m_aFont
Definition: TokenWriter.hxx:56
void setStream(SvStream *_pStream)
Definition: TokenWriter.hxx:94
css::uno::Reference< css::sdbc::XResultSetMetaData > m_xResultSetMetaData
Definition: TokenWriter.hxx:62
rtl_TextEncoding m_eDestEnc
Definition: TokenWriter.hxx:76
SharedConnection m_xConnection
Definition: TokenWriter.hxx:58
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
ODatabaseImportExport(const svx::ODataAccessDescriptor &_aDataDescriptor, const css::uno::Reference< css::uno::XComponentContext > &_rM, const css::uno::Reference< css::util::XNumberFormatter > &_rxNumberF)
css::uno::Reference< css::util::XNumberFormatter > m_xFormatter
Definition: TokenWriter.hxx:64
css::uno::Reference< css::beans::XPropertySet > m_xObject
Definition: TokenWriter.hxx:57
void setSTableName(const OUString &_sTableName)
Definition: TokenWriter.hxx:97
css::uno::Reference< css::sdbc::XRow > m_xRow
Definition: TokenWriter.hxx:60
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: TokenWriter.hxx:65
char sIndent[nIndentMax+1]
OHTMLImportExport(const SharedConnection &_rxConnection, const css::uno::Reference< css::util::XNumberFormatter > &_rxNumberF, const css::uno::Reference< css::uno::XComponentContext > &_rM)
void WriteCell(sal_Int32 nFormat, sal_Int32 nWidthPixel, sal_Int32 nHeightPixel, const char *pChar, const OUString &rValue, const char *pHtmlTag)
const char * GetIndentStr() const
OHTMLImportExport(const svx::ODataAccessDescriptor &_aDataDescriptor, const css::uno::Reference< css::uno::XComponentContext > &_rM, const css::uno::Reference< css::util::XNumberFormatter > &_rxNumberF)
void IncIndent(sal_Int16 nVal)
static const sal_Int16 nCellSpacing
static const char sIndentSource[]
virtual bool Read() override
virtual bool Write() override
virtual bool Read() override
virtual bool Write() override
ORTFImportExport(const svx::ODataAccessDescriptor &_aDataDescriptor, const css::uno::Reference< css::uno::XComponentContext > &_rM, const css::uno::Reference< css::util::XNumberFormatter > &_rxNumberF)
void appendRow(OString const *pHorzChar, sal_Int32 _nColumnCount, sal_Int32 &k, sal_Int32 &kk)
ORTFImportExport(const SharedConnection &_rxConnection, const css::uno::Reference< css::util::XNumberFormatter > &_rxNumberF, const css::uno::Reference< css::uno::XComponentContext > &_rM)
virtual void initialize() override
Definition: RowSetDrop.cxx:56
css::uno::Reference< css::sdbc::XResultSetUpdate > m_xTargetResultSetUpdate
css::uno::Reference< css::sdbc::XRowUpdate > m_xTargetRowUpdate
std::vector< sal_Int32 > m_aColumnTypes
virtual bool Write() override
Definition: RowSetDrop.cxx:95
virtual bool Read() override
Definition: RowSetDrop.cxx:100
std::vector< sal_Int32 > m_aColumnMapping
ORowSetImportExport(weld::Window *pParent, const css::uno::Reference< css::sdbc::XResultSetUpdate > &xResultSetUpdate, const svx::ODataAccessDescriptor &aDataDescriptor, const css::uno::Reference< css::uno::XComponentContext > &rM)
Definition: RowSetDrop.cxx:43
css::uno::Reference< css::sdbc::XResultSetMetaData > m_xTargetResultSetMetaData
const sal_Int16 nIndentMax