1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_TOKENWRITER_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_INC_TOKENWRITER_HXX
22 #include "DExport.hxx"
23 #include "moduledbu.hxx"
24 #include "commontypes.hxx"
26 #include <com/sun/star/awt/FontDescriptor.hpp>
27 #include <com/sun/star/sdbc/XResultSet.hpp>
28 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
29 #include <com/sun/star/sdbc/XRow.hpp>
30 #include <com/sun/star/lang/XEventListener.hpp>
31 #include <com/sun/star/frame/XModel.hpp>
32 #include <com/sun/star/beans/PropertyValue.hpp>
33 #include <com/sun/star/sdb/CommandType.hpp>
34 #include <com/sun/star/sdbcx/XRowLocate.hpp>
35 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <cppuhelper/implbase.hxx>
38 #include <svx/dataaccessdescriptor.hxx>
40 namespace com
{ namespace sun
{ namespace star
{
50 // ODatabaseImportExport base class for import/export
51 class ODatabaseExport
;
52 typedef ::cppu::WeakImplHelper
< css::lang::XEventListener
> ODatabaseImportExport_BASE
;
53 class ODatabaseImportExport
: public ODatabaseImportExport_BASE
56 void impl_initializeRowMember_throw();
59 css::lang::Locale m_aLocale
;
60 css::uno::Sequence
< css::uno::Any
> m_aSelection
;
61 bool m_bBookmarkSelection
;
63 css::awt::FontDescriptor m_aFont
;
64 css::uno::Reference
< css::beans::XPropertySet
> m_xObject
; // table/query
65 SharedConnection m_xConnection
;
66 css::uno::Reference
< css::sdbc::XResultSet
> m_xResultSet
;
67 css::uno::Reference
< css::sdbc::XRow
> m_xRow
;
68 css::uno::Reference
< css::sdbcx::XRowLocate
> m_xRowLocate
;
69 css::uno::Reference
< css::sdbc::XResultSetMetaData
> m_xResultSetMetaData
;
70 css::uno::Reference
< css::container::XIndexAccess
> m_xRowSetColumns
;
71 css::uno::Reference
< css::util::XNumberFormatter
> m_xFormatter
; // a number formatter working with the connection's NumberFormatsSupplier
72 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
76 //for transfor the tablename
77 OUString m_sDefaultTableName
;
79 OUString m_sDataSourceName
;
80 sal_Int32 m_nCommandType
;
81 bool m_bNeedToReInitialize
;
83 ODatabaseExport
* m_pReader
;
84 sal_Int32
* m_pRowMarker
; // if set, then copy only these rows
85 rtl_TextEncoding m_eDestEnc
;
90 ODatabaseImportExport( const svx::ODataAccessDescriptor
& _aDataDescriptor
,
91 const css::uno::Reference
< css::uno::XComponentContext
>& _rM
,
92 const css::uno::Reference
< css::util::XNumberFormatter
>& _rxNumberF
,
93 const OUString
& rExchange
= OUString());
96 ODatabaseImportExport( const SharedConnection
& _rxConnection
,
97 const css::uno::Reference
< css::util::XNumberFormatter
>& _rxNumberF
,
98 const css::uno::Reference
< css::uno::XComponentContext
>& _rM
);
100 virtual ~ODatabaseImportExport();
102 virtual void initialize();
104 void setStream(SvStream
* _pStream
){ m_pStream
= _pStream
; }
106 //for set the tablename
107 void setSTableName(const OUString
&_sTableName
){ m_sDefaultTableName
= _sTableName
; }
109 virtual bool Write(); // Export
110 virtual bool Read(); // Import
112 void initialize(const svx::ODataAccessDescriptor
& _aDataDescriptor
);
115 void enableCheckOnly() { m_bCheckOnly
= true; }
116 bool isCheckEnabled() const { return m_bCheckOnly
; }
119 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) throw(css::uno::RuntimeException
, std::exception
) override
;
120 void impl_initFromDescriptor( const svx::ODataAccessDescriptor
& _aDataDescriptor
, bool _bPlusDefaultInit
);
123 // RTF Import and Export
125 class ORTFImportExport
: public ODatabaseImportExport
127 void appendRow(OString
* pHorzChar
,sal_Int32 _nColumnCount
,sal_Int32
& k
,sal_Int32
& kk
);
130 ORTFImportExport( const svx::ODataAccessDescriptor
& _aDataDescriptor
,
131 const css::uno::Reference
< css::uno::XComponentContext
>& _rM
,
132 const css::uno::Reference
< css::util::XNumberFormatter
>& _rxNumberF
,
133 const OUString
& rExchange
= OUString())
134 : ODatabaseImportExport(_aDataDescriptor
,_rM
,_rxNumberF
,rExchange
) {};
137 ORTFImportExport( const SharedConnection
& _rxConnection
,
138 const css::uno::Reference
< css::util::XNumberFormatter
>& _rxNumberF
,
139 const css::uno::Reference
< css::uno::XComponentContext
>& _rM
)
140 : ODatabaseImportExport(_rxConnection
,_rxNumberF
,_rM
)
143 virtual bool Write() override
;
144 virtual bool Read() override
;
146 // HTML Import and Export
147 #define SBA_HTML_FONTSIZES 7
148 const sal_Int16 nIndentMax
= 23;
149 class OHTMLImportExport
: public ODatabaseImportExport
151 // default HtmlFontSz[1-7]
152 static const sal_Int16 nDefaultFontSize
[SBA_HTML_FONTSIZES
];
153 // HtmlFontSz[1-7] in s*3.ini [user]
154 static sal_Int16 nFontSize
[SBA_HTML_FONTSIZES
];
155 static const sal_Int16 nCellSpacing
;
156 static const char sIndentSource
[];
157 char sIndent
[nIndentMax
+1];
159 #if OSL_DEBUG_LEVEL > 0
166 void WriteCell( sal_Int32 nFormat
,sal_Int32 nWidthPixel
,sal_Int32 nHeightPixel
,const char* pChar
,const OUString
& rValue
,const char* pHtmlTag
);
167 void IncIndent( sal_Int16 nVal
);
168 const char* GetIndentStr() { return sIndent
; }
170 inline void FontOff();
174 OHTMLImportExport( const svx::ODataAccessDescriptor
& _aDataDescriptor
,
175 const css::uno::Reference
< css::uno::XComponentContext
>& _rM
,
176 const css::uno::Reference
< css::util::XNumberFormatter
>& _rxNumberF
,
177 const OUString
& rExchange
= OUString());
179 OHTMLImportExport( const SharedConnection
& _rxConnection
,
180 const css::uno::Reference
< css::util::XNumberFormatter
>& _rxNumberF
,
181 const css::uno::Reference
< css::uno::XComponentContext
>& _rM
)
182 : ODatabaseImportExport(_rxConnection
,_rxNumberF
,_rM
)
186 virtual bool Write() override
;
187 virtual bool Read() override
;
190 // normal RowSet Import and Export
192 class ORowSetImportExport
: public ODatabaseImportExport
194 OModuleClient m_aModuleClient
;
195 ::std::vector
<sal_Int32
> m_aColumnMapping
;
196 ::std::vector
<sal_Int32
> m_aColumnTypes
;
197 css::uno::Reference
< css::sdbc::XResultSetUpdate
> m_xTargetResultSetUpdate
;
198 css::uno::Reference
< css::sdbc::XRowUpdate
> m_xTargetRowUpdate
;
199 css::uno::Reference
< css::sdbc::XResultSetMetaData
> m_xTargetResultSetMetaData
;
200 VclPtr
<vcl::Window
> m_pParent
;
201 bool m_bAlreadyAsked
;
205 virtual void initialize() override
;
209 ORowSetImportExport(vcl::Window
* _pParent
,
210 const css::uno::Reference
< css::sdbc::XResultSetUpdate
>& _xResultSetUpdate
,
211 const svx::ODataAccessDescriptor
& _aDataDescriptor
,
212 const css::uno::Reference
< css::uno::XComponentContext
>& _rM
,
213 const OUString
& rExchange
= OUString());
215 virtual bool Write() override
;
216 virtual bool Read() override
;
219 using ODatabaseImportExport::initialize
;
223 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_TOKENWRITER_HXX
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */