tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / dbaccess / source / ui / inc / TokenWriter.hxx
blobb82bd71a5feb1d50ba4464cc241cb5e1ec5afca6
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 #pragma once
21 #include "commontypes.hxx"
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>
34 #include <cppuhelper/implbase.hxx>
35 #include <svx/dataaccessdescriptor.hxx>
36 #include <vcl/weld.hxx>
38 namespace com::sun::star {
39 namespace sdbc{
40 class XRowUpdate;
44 class SvStream;
46 namespace dbaui
48 // ODatabaseImportExport base class for import/export
49 class ODatabaseExport;
50 class ODatabaseImportExport : public ::cppu::WeakImplHelper< css::lang::XEventListener>
52 protected:
53 css::uno::Sequence< css::uno::Any> m_aSelection;
54 bool m_bBookmarkSelection;
55 SvStream* m_pStream;
56 css::awt::FontDescriptor m_aFont;
57 css::uno::Reference< css::beans::XPropertySet > m_xObject; // table/query
58 SharedConnection m_xConnection;
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;
67 OUString m_sName;
69 //for transfor the tablename
70 OUString m_sDefaultTableName;
72 OUString m_sDataSourceName;
73 sal_Int32 m_nCommandType;
74 bool m_bNeedToReInitialize;
76 rtl_TextEncoding m_eDestEnc;
77 bool m_bInInitialize;
78 bool m_bCheckOnly;
80 // export data
81 ODatabaseImportExport( const svx::ODataAccessDescriptor& _aDataDescriptor,
82 const css::uno::Reference< css::uno::XComponentContext >& _rM,
83 const css::uno::Reference< css::util::XNumberFormatter >& _rxNumberF);
85 // import data
86 ODatabaseImportExport( SharedConnection _xConnection,
87 const css::uno::Reference< css::util::XNumberFormatter >& _rxNumberF,
88 const css::uno::Reference< css::uno::XComponentContext >& _rM);
90 virtual ~ODatabaseImportExport() override;
92 virtual void initialize();
93 public:
94 void setStream(SvStream* _pStream){ m_pStream = _pStream; }
96 //for set the tablename
97 void setSTableName(const OUString &_sTableName){ m_sDefaultTableName = _sTableName; }
99 virtual bool Write(); // Export
100 virtual bool Read(); // Import
102 void initialize(const svx::ODataAccessDescriptor& _aDataDescriptor);
103 void dispose();
105 void enableCheckOnly() { m_bCheckOnly = true; }
106 bool isCheckEnabled() const { return m_bCheckOnly; }
108 private:
109 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
110 void impl_initFromDescriptor( const svx::ODataAccessDescriptor& _aDataDescriptor, bool _bPlusDefaultInit );
113 // RTF Import and Export
115 class ORTFImportExport : public ODatabaseImportExport
117 void appendRow(OString const * pHorzChar,sal_Int32 _nColumnCount,sal_Int32& k,sal_Int32& kk);
118 public:
119 // export data
120 ORTFImportExport( const svx::ODataAccessDescriptor& _aDataDescriptor,
121 const css::uno::Reference< css::uno::XComponentContext >& _rM,
122 const css::uno::Reference< css::util::XNumberFormatter >& _rxNumberF)
123 : ODatabaseImportExport(_aDataDescriptor,_rM,_rxNumberF) {};
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)
132 virtual bool Write() override;
133 virtual bool Read() override;
135 // HTML Import and Export
136 #define SBA_HTML_FONTSIZES 7
137 const sal_Int16 nIndentMax = 23;
138 class OHTMLImportExport : public ODatabaseImportExport
140 static const sal_Int16 nCellSpacing;
141 static const char sIndentSource[];
142 char sIndent[nIndentMax+1];
143 sal_Int16 m_nIndent;
144 #if OSL_DEBUG_LEVEL > 0
145 bool m_bCheckFont;
146 #endif
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();
157 public:
158 // export data
159 OHTMLImportExport( const svx::ODataAccessDescriptor& _aDataDescriptor,
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)
170 virtual bool Write() override;
171 virtual bool Read() override;
174 // normal RowSet Import and Export
176 class ORowSetImportExport : public ODatabaseImportExport
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;
183 weld::Window* m_pParent;
184 bool m_bAlreadyAsked;
186 bool insertNewRow();
187 protected:
188 virtual void initialize() override;
190 public:
191 // export data
192 ORowSetImportExport(weld::Window* pParent,
193 const css::uno::Reference< css::sdbc::XResultSetUpdate >& xResultSetUpdate,
194 const svx::ODataAccessDescriptor& aDataDescriptor,
195 const css::uno::Reference< css::uno::XComponentContext >& rM);
197 virtual bool Write() override;
198 virtual bool Read() override;
200 private:
201 using ODatabaseImportExport::initialize;
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */