merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / inc / TokenWriter.hxx
blobebd23bd3ecfc7fb5d942718ac19ef4010c45b797
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: TokenWriter.hxx,v $
10 * $Revision: 1.23 $
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_TOKENWRITER_HXX
31 #define DBAUI_TOKENWRITER_HXX
33 #ifndef DBAUI_DATABASEEXPORT_HXX
34 #include "DExport.hxx"
35 #endif
36 #ifndef _DBAUI_MODULE_DBU_HXX_
37 #include "moduledbu.hxx"
38 #endif
39 #ifndef _STREAM_HXX //autogen
40 #include <tools/stream.hxx>
41 #endif
42 #ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_
43 #include <com/sun/star/awt/FontDescriptor.hpp>
44 #endif
45 #ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
46 #include <com/sun/star/sdbc/XResultSet.hpp>
47 #endif
48 #ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_
49 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
50 #endif
51 #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
52 #include <com/sun/star/sdbc/XRow.hpp>
53 #endif
54 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
55 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
56 #endif
57 #ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_
58 #include <com/sun/star/lang/XEventListener.hpp>
59 #endif
60 #ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
61 #include <com/sun/star/frame/XModel.hpp>
62 #endif
63 #ifndef _CPPUHELPER_IMPLBASE1_HXX_
64 #include <cppuhelper/implbase1.hxx>
65 #endif
66 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
67 #include <com/sun/star/beans/PropertyValue.hpp>
68 #endif
69 #ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
70 #include <com/sun/star/sdb/CommandType.hpp>
71 #endif
72 #ifndef _SVX_DATACCESSDESCRIPTOR_HXX_
73 #include <svx/dataaccessdescriptor.hxx>
74 #endif
75 #ifndef _DBAUI_COMMON_TYPES_HXX_
76 #include "commontypes.hxx"
77 #endif
78 #include <memory>
80 namespace com { namespace sun { namespace star {
81 namespace sdbc{
82 class XRowUpdate;
84 }}}
86 namespace dbaui
88 // =========================================================================
89 // ODatabaseImportExport Basisklasse f"ur Import/Export
90 // =========================================================================
91 class ODatabaseExport;
92 typedef ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener> ODatabaseImportExport_BASE;
93 class ODatabaseImportExport : public ODatabaseImportExport_BASE
95 private:
96 void impl_initializeRowMember_throw();
98 protected:
99 ::com::sun::star::lang::Locale m_aLocale;
100 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> m_aSelection;
101 SvStream* m_pStream;
102 ::com::sun::star::awt::FontDescriptor m_aFont;
103 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xObject; // table/query
104 SharedConnection m_xConnection; //
105 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xResultSet; //
106 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > m_xRow; //
107 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xResultSetMetaData; //
108 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_xRowSetColumns;
109 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier
110 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xFactory;
112 ::rtl::OUString m_sName;
113 //dyf add 20070601
114 //for transfor the tablename
115 ::rtl::OUString m_sDefaultTableName;
116 //dyf add end
117 ::rtl::OUString m_sDataSourceName;
118 sal_Int32 m_nCommandType;
119 bool m_bNeedToReInitialize;
121 #if defined UNX
122 static const char __FAR_DATA sNewLine;
123 #else
124 static const char __FAR_DATA sNewLine[];
125 #endif
127 ODatabaseExport* m_pReader;
128 sal_Int32* m_pRowMarker; // wenn gesetzt, dann nur diese Rows kopieren
129 rtl_TextEncoding m_eDestEnc;
130 sal_Bool m_bInInitialize;
131 sal_Bool m_bCheckOnly;
133 // export data
134 ODatabaseImportExport( const ::svx::ODataAccessDescriptor& _aDataDescriptor,
135 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
136 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
137 const String& rExchange = String());
139 // import data
140 ODatabaseImportExport( const SharedConnection& _rxConnection,
141 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
142 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM);
144 virtual ~ODatabaseImportExport();
146 virtual void initialize();
147 public:
148 void setStream(SvStream* _pStream){ m_pStream = _pStream; }
150 //dyf add 20070601
151 //for set the tablename
152 void setSTableName(const ::rtl::OUString &_sTableName){ m_sDefaultTableName = _sTableName; }
153 //dyf add end
155 virtual BOOL Write(); // Export
156 virtual BOOL Read(); // Import
158 void initialize(const ::svx::ODataAccessDescriptor& _aDataDescriptor);
159 void dispose();
161 void enableCheckOnly() { m_bCheckOnly = sal_True; }
162 sal_Bool isCheckEnabled() const { return m_bCheckOnly; }
165 private:
166 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
167 void impl_initFromDescriptor( const ::svx::ODataAccessDescriptor& _aDataDescriptor, bool _bPlusDefaultInit );
170 // =========================================================================
171 // RTF Im- und Export
172 // =========================================================================
174 class ORTFImportExport : public ODatabaseImportExport
176 void appendRow(::rtl::OString* pHorzChar,sal_Int32 _nColumnCount,sal_Int32& k,sal_Int32& kk);
177 public:
178 // export data
179 ORTFImportExport( const ::svx::ODataAccessDescriptor& _aDataDescriptor,
180 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
181 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
182 const String& rExchange = String())
183 : ODatabaseImportExport(_aDataDescriptor,_rM,_rxNumberF,rExchange) {};
185 // import data
186 ORTFImportExport( const SharedConnection& _rxConnection,
187 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
188 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM)
189 : ODatabaseImportExport(_rxConnection,_rxNumberF,_rM)
192 virtual BOOL Write();
193 virtual BOOL Read();
195 // =========================================================================
196 // HTML Im- und Export
197 // =========================================================================
198 #define SBA_HTML_FONTSIZES 7
199 const sal_Int16 nIndentMax = 23;
200 class OHTMLImportExport : public ODatabaseImportExport
202 // default HtmlFontSz[1-7]
203 static const sal_Int16 nDefaultFontSize[SBA_HTML_FONTSIZES];
204 // HtmlFontSz[1-7] in s*3.ini [user]
205 static sal_Int16 nFontSize[SBA_HTML_FONTSIZES];
206 static const sal_Int16 nCellSpacing;
207 static const char __FAR_DATA sIndentSource[];
208 char sIndent[nIndentMax+1];
209 sal_Int16 m_nIndent;
210 #ifdef DBG_UTIL
211 BOOL m_bCheckFont;
212 #endif
214 void WriteHeader();
215 void WriteBody();
216 void WriteTables();
217 void WriteCell( sal_Int32 nFormat,sal_Int32 nWidthPixel,sal_Int32 nHeightPixel,const char* pChar,const String& rValue,const char* pHtmlTag);
218 void IncIndent( sal_Int16 nVal );
219 const char* GetIndentStr() { return sIndent; }
220 void FontOn();
221 inline void FontOff();
223 public:
224 // export data
225 OHTMLImportExport( const ::svx::ODataAccessDescriptor& _aDataDescriptor,
226 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
227 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
228 const String& rExchange = String());
229 // import data
230 OHTMLImportExport( const SharedConnection& _rxConnection,
231 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
232 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM)
233 : ODatabaseImportExport(_rxConnection,_rxNumberF,_rM)
236 virtual BOOL Write();
237 virtual BOOL Read();
240 // =========================================================================
241 // normal RowSet Im- und Export
242 // =========================================================================
244 class ORowSetImportExport : public ODatabaseImportExport
246 OModuleClient m_aModuleClient;
247 ::std::vector<sal_Int32> m_aColumnMapping;
248 ::std::vector<sal_Int32> m_aColumnTypes;
249 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > m_xTargetResultSetUpdate; //
250 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate > m_xTargetRowUpdate; //
251 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xTargetResultSetMetaData; //
252 Window* m_pParent;
253 sal_Bool m_bAlreadyAsked;
255 sal_Bool insertNewRow();
256 protected:
257 virtual void initialize();
259 public:
260 // export data
261 ORowSetImportExport(Window* _pParent,
262 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate >& _xResultSetUpdate,
263 const ::svx::ODataAccessDescriptor& _aDataDescriptor,
264 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
265 const String& rExchange = String());
267 // import data
268 ORowSetImportExport(const SharedConnection& _rxConnection,
269 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM)
270 : ODatabaseImportExport(_rxConnection,NULL,_rM)
273 virtual BOOL Write();
274 virtual BOOL Read();
276 private:
277 using ODatabaseImportExport::initialize;
281 #endif // DBAUI_TOKENWRITER_HXX