Bump version to 5.0-14
[LibreOffice.git] / dbaccess / source / ui / inc / TokenWriter.hxx
blobd1b87f0ddc7062f71039944daa2d36c189885552
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/implbase1.hxx>
38 #include <tools/stream.hxx>
39 #include <svx/dataaccessdescriptor.hxx>
41 namespace com { namespace sun { namespace star {
42 namespace sdbc{
43 class XRowUpdate;
45 }}}
47 namespace dbaui
49 // ODatabaseImportExport base class for import/export
50 class ODatabaseExport;
51 typedef ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener> ODatabaseImportExport_BASE;
52 class ODatabaseImportExport : public ODatabaseImportExport_BASE
54 private:
55 void impl_initializeRowMember_throw();
57 protected:
58 ::com::sun::star::lang::Locale m_aLocale;
59 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> m_aSelection;
60 bool m_bBookmarkSelection;
61 SvStream* m_pStream;
62 ::com::sun::star::awt::FontDescriptor m_aFont;
63 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xObject; // table/query
64 SharedConnection m_xConnection;
65 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xResultSet;
66 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > m_xRow;
67 ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XRowLocate > m_xRowLocate;
68 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xResultSetMetaData;
69 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_xRowSetColumns;
70 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier
71 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
73 OUString m_sName;
75 //for transfor the tablename
76 OUString m_sDefaultTableName;
78 OUString m_sDataSourceName;
79 sal_Int32 m_nCommandType;
80 bool m_bNeedToReInitialize;
82 ODatabaseExport* m_pReader;
83 sal_Int32* m_pRowMarker; // if set, then copy only these rows
84 rtl_TextEncoding m_eDestEnc;
85 bool m_bInInitialize;
86 bool m_bCheckOnly;
88 // export data
89 ODatabaseImportExport( const svx::ODataAccessDescriptor& _aDataDescriptor,
90 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rM,
91 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
92 const OUString& rExchange = OUString());
94 // import data
95 ODatabaseImportExport( const SharedConnection& _rxConnection,
96 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
97 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rM);
99 virtual ~ODatabaseImportExport();
101 virtual void initialize();
102 public:
103 void setStream(SvStream* _pStream){ m_pStream = _pStream; }
105 //for set the tablename
106 void setSTableName(const OUString &_sTableName){ m_sDefaultTableName = _sTableName; }
108 virtual bool Write(); // Export
109 virtual bool Read(); // Import
111 void initialize(const svx::ODataAccessDescriptor& _aDataDescriptor);
112 void dispose();
114 void enableCheckOnly() { m_bCheckOnly = true; }
115 bool isCheckEnabled() const { return m_bCheckOnly; }
117 private:
118 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 void impl_initFromDescriptor( const svx::ODataAccessDescriptor& _aDataDescriptor, bool _bPlusDefaultInit );
122 // RTF Import and Export
124 class ORTFImportExport : public ODatabaseImportExport
126 void appendRow(OString* pHorzChar,sal_Int32 _nColumnCount,sal_Int32& k,sal_Int32& kk);
127 public:
128 // export data
129 ORTFImportExport( const svx::ODataAccessDescriptor& _aDataDescriptor,
130 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rM,
131 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
132 const OUString& rExchange = OUString())
133 : ODatabaseImportExport(_aDataDescriptor,_rM,_rxNumberF,rExchange) {};
135 // import data
136 ORTFImportExport( const SharedConnection& _rxConnection,
137 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
138 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rM)
139 : ODatabaseImportExport(_rxConnection,_rxNumberF,_rM)
142 virtual bool Write() SAL_OVERRIDE;
143 virtual bool Read() SAL_OVERRIDE;
145 // HTML Import and Export
146 #define SBA_HTML_FONTSIZES 7
147 const sal_Int16 nIndentMax = 23;
148 class OHTMLImportExport : public ODatabaseImportExport
150 // default HtmlFontSz[1-7]
151 static const sal_Int16 nDefaultFontSize[SBA_HTML_FONTSIZES];
152 // HtmlFontSz[1-7] in s*3.ini [user]
153 static sal_Int16 nFontSize[SBA_HTML_FONTSIZES];
154 static const sal_Int16 nCellSpacing;
155 static const char sIndentSource[];
156 char sIndent[nIndentMax+1];
157 sal_Int16 m_nIndent;
158 #if OSL_DEBUG_LEVEL > 0
159 bool m_bCheckFont;
160 #endif
162 void WriteHeader();
163 void WriteBody();
164 void WriteTables();
165 void WriteCell( sal_Int32 nFormat,sal_Int32 nWidthPixel,sal_Int32 nHeightPixel,const char* pChar,const OUString& rValue,const char* pHtmlTag);
166 void IncIndent( sal_Int16 nVal );
167 const char* GetIndentStr() { return sIndent; }
168 void FontOn();
169 inline void FontOff();
171 public:
172 // export data
173 OHTMLImportExport( const svx::ODataAccessDescriptor& _aDataDescriptor,
174 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rM,
175 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
176 const OUString& rExchange = OUString());
177 // import data
178 OHTMLImportExport( const SharedConnection& _rxConnection,
179 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
180 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rM)
181 : ODatabaseImportExport(_rxConnection,_rxNumberF,_rM)
182 , m_nIndent(0)
185 virtual bool Write() SAL_OVERRIDE;
186 virtual bool Read() SAL_OVERRIDE;
189 // normal RowSet Import and Export
191 class ORowSetImportExport : public ODatabaseImportExport
193 OModuleClient m_aModuleClient;
194 ::std::vector<sal_Int32> m_aColumnMapping;
195 ::std::vector<sal_Int32> m_aColumnTypes;
196 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > m_xTargetResultSetUpdate;
197 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate > m_xTargetRowUpdate;
198 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xTargetResultSetMetaData;
199 VclPtr<vcl::Window> m_pParent;
200 bool m_bAlreadyAsked;
202 bool insertNewRow();
203 protected:
204 virtual void initialize() SAL_OVERRIDE;
206 public:
207 // export data
208 ORowSetImportExport(vcl::Window* _pParent,
209 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate >& _xResultSetUpdate,
210 const svx::ODataAccessDescriptor& _aDataDescriptor,
211 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rM,
212 const OUString& rExchange = OUString());
214 // import data
215 ORowSetImportExport(const SharedConnection& _rxConnection,
216 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rM)
217 : ODatabaseImportExport(_rxConnection,NULL,_rM)
220 virtual bool Write() SAL_OVERRIDE;
221 virtual bool Read() SAL_OVERRIDE;
223 private:
224 using ODatabaseImportExport::initialize;
228 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_TOKENWRITER_HXX
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */