1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TokenWriter.hxx,v $
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"
36 #ifndef _DBAUI_MODULE_DBU_HXX_
37 #include "moduledbu.hxx"
39 #ifndef _STREAM_HXX //autogen
40 #include <tools/stream.hxx>
42 #ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_
43 #include <com/sun/star/awt/FontDescriptor.hpp>
45 #ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
46 #include <com/sun/star/sdbc/XResultSet.hpp>
48 #ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_
49 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
51 #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
52 #include <com/sun/star/sdbc/XRow.hpp>
54 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
55 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
57 #ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_
58 #include <com/sun/star/lang/XEventListener.hpp>
60 #ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
61 #include <com/sun/star/frame/XModel.hpp>
63 #ifndef _CPPUHELPER_IMPLBASE1_HXX_
64 #include <cppuhelper/implbase1.hxx>
66 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
67 #include <com/sun/star/beans/PropertyValue.hpp>
69 #ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
70 #include <com/sun/star/sdb/CommandType.hpp>
72 #ifndef _SVX_DATACCESSDESCRIPTOR_HXX_
73 #include <svx/dataaccessdescriptor.hxx>
75 #ifndef _DBAUI_COMMON_TYPES_HXX_
76 #include "commontypes.hxx"
80 namespace com
{ namespace sun
{ namespace star
{
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
96 void impl_initializeRowMember_throw();
99 ::com::sun::star::lang::Locale m_aLocale
;
100 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> m_aSelection
;
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
;
114 //for transfor the tablename
115 ::rtl::OUString m_sDefaultTableName
;
117 ::rtl::OUString m_sDataSourceName
;
118 sal_Int32 m_nCommandType
;
119 bool m_bNeedToReInitialize
;
122 static const char __FAR_DATA sNewLine
;
124 static const char __FAR_DATA sNewLine
[];
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
;
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());
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();
148 void setStream(SvStream
* _pStream
){ m_pStream
= _pStream
; }
151 //for set the tablename
152 void setSTableName(const ::rtl::OUString
&_sTableName
){ m_sDefaultTableName
= _sTableName
; }
155 virtual BOOL
Write(); // Export
156 virtual BOOL
Read(); // Import
158 void initialize(const ::svx::ODataAccessDescriptor
& _aDataDescriptor
);
161 void enableCheckOnly() { m_bCheckOnly
= sal_True
; }
162 sal_Bool
isCheckEnabled() const { return m_bCheckOnly
; }
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
);
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
) {};
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();
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];
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
; }
221 inline void FontOff();
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());
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();
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
; //
253 sal_Bool m_bAlreadyAsked
;
255 sal_Bool
insertNewRow();
257 virtual void initialize();
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());
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();
277 using ODatabaseImportExport::initialize
;
281 #endif // DBAUI_TOKENWRITER_HXX