/src/libreoffice/include/connectivity/TTableHelper.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #ifndef INCLUDED_CONNECTIVITY_TTABLEHELPER_HXX |
21 | | #define INCLUDED_CONNECTIVITY_TTABLEHELPER_HXX |
22 | | |
23 | | #include <memory> |
24 | | #include <sal/config.h> |
25 | | |
26 | | #include <map> |
27 | | |
28 | | #include <connectivity/dbtoolsdllapi.hxx> |
29 | | #include <connectivity/sdbcx/VTable.hxx> |
30 | | #include <utility> |
31 | | |
32 | | namespace com::sun::star::sdbc { class XConnection; } |
33 | | namespace com::sun::star::sdb::tools { class XIndexAlteration; } |
34 | | namespace com::sun::star::sdb::tools { class XKeyAlteration; } |
35 | | namespace com::sun::star::sdb::tools { class XTableAlteration; } |
36 | | namespace com::sun::star::sdb::tools { class XTableRename; } |
37 | | namespace connectivity::sdbcx { struct KeyProperties; } |
38 | | |
39 | | namespace connectivity |
40 | | { |
41 | | typedef sal_Int32 OrdinalPosition; |
42 | | struct ColumnDesc |
43 | | { |
44 | | OUString sName; |
45 | | OUString aField6; |
46 | | OUString sField12; // REMARKS |
47 | | OUString sField13; |
48 | | sal_Int32 nField5 |
49 | | , nField7 |
50 | | , nField9 |
51 | | , nField11; |
52 | | |
53 | | OrdinalPosition nOrdinalPosition; |
54 | | |
55 | | ColumnDesc( OUString _sName |
56 | | , sal_Int32 _nField5 |
57 | | , OUString _aField6 |
58 | | , sal_Int32 _nField7 |
59 | | , sal_Int32 _nField9 |
60 | | , sal_Int32 _nField11 |
61 | | , OUString _sField12 |
62 | | , OUString _sField13 |
63 | | ,OrdinalPosition _nPosition ) |
64 | 324k | :sName(std::move( _sName )) |
65 | 324k | ,aField6(std::move(_aField6)) |
66 | 324k | ,sField12(std::move(_sField12)) |
67 | 324k | ,sField13(std::move(_sField13)) |
68 | 324k | ,nField5(_nField5) |
69 | 324k | ,nField7(_nField7) |
70 | 324k | ,nField9(_nField9) |
71 | 324k | ,nField11(_nField11) |
72 | 324k | ,nOrdinalPosition( _nPosition ) |
73 | 324k | { |
74 | 324k | } |
75 | | }; |
76 | | typedef connectivity::sdbcx::OTable OTable_TYPEDEF; |
77 | | |
78 | | typedef std::map<OUString, std::shared_ptr<sdbcx::KeyProperties>> TKeyMap; |
79 | | |
80 | | struct OTableHelperImpl; |
81 | | |
82 | | class OOO_DLLPUBLIC_DBTOOLS OTableHelper : public OTable_TYPEDEF |
83 | | { |
84 | | ::std::unique_ptr<OTableHelperImpl> m_pImpl; |
85 | | |
86 | | void refreshPrimaryKeys(::std::vector< OUString>& _rKeys); |
87 | | void refreshForeignKeys(::std::vector< OUString>& _rKeys); |
88 | | |
89 | | protected: |
90 | | /** creates the column collection for the table |
91 | | @param _rNames |
92 | | The column names. |
93 | | */ |
94 | | virtual sdbcx::OCollection* createColumns(const ::std::vector< OUString>& _rNames) = 0; |
95 | | |
96 | | /** creates the key collection for the table |
97 | | @param _rNames |
98 | | The key names. |
99 | | */ |
100 | | virtual sdbcx::OCollection* createKeys(const ::std::vector< OUString>& _rNames) = 0; |
101 | | |
102 | | /** creates the index collection for the table |
103 | | @param _rNames |
104 | | The index names. |
105 | | */ |
106 | | virtual sdbcx::OCollection* createIndexes(const ::std::vector< OUString>& _rNames) = 0; |
107 | | |
108 | | /** this function is called upon disposing the component |
109 | | */ |
110 | | virtual void SAL_CALL disposing() override; |
111 | | |
112 | | /** The default returns "RENAME TABLE " or "RENAME VIEW " depending on the type. |
113 | | * |
114 | | * \return The start of the rename statement. |
115 | | */ |
116 | | virtual OUString getRenameStart() const; |
117 | | |
118 | | virtual ~OTableHelper() override; |
119 | | |
120 | | public: |
121 | | virtual void refreshColumns() override; |
122 | | virtual void refreshKeys() override; |
123 | | virtual void refreshIndexes() override; |
124 | | |
125 | | const ColumnDesc* getColumnDescription(const OUString& _sName) const; |
126 | | |
127 | | public: |
128 | | OTableHelper( sdbcx::OCollection* _pTables, |
129 | | const css::uno::Reference< css::sdbc::XConnection >& _xConnection, |
130 | | bool _bCase); |
131 | | OTableHelper( sdbcx::OCollection* _pTables, |
132 | | const css::uno::Reference< css::sdbc::XConnection >& _xConnection, |
133 | | bool _bCase, |
134 | | const OUString& Name, |
135 | | const OUString& Type, |
136 | | const OUString& Description = OUString(), |
137 | | const OUString& SchemaName = OUString(), |
138 | | const OUString& CatalogName = OUString() |
139 | | ); |
140 | | |
141 | | virtual css::uno::Reference< css::sdbc::XDatabaseMetaData> getMetaData() const override; |
142 | | css::uno::Reference< css::sdbc::XConnection> const & getConnection() const; |
143 | | |
144 | | // XRename |
145 | | virtual void SAL_CALL rename( const OUString& newName ) override; |
146 | | |
147 | | // XAlterTable |
148 | | virtual void SAL_CALL alterColumnByIndex( sal_Int32 index, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; |
149 | | // XNamed |
150 | | virtual OUString SAL_CALL getName() override; |
151 | | |
152 | | // To retrieve the table name only without the schema |
153 | | const OUString & getTableName(); |
154 | | |
155 | | // helper method to get key properties |
156 | | std::shared_ptr<sdbcx::KeyProperties> getKeyProperties(const OUString& _sName) const; |
157 | | void addKey(const OUString& _sName,const std::shared_ptr<sdbcx::KeyProperties>& _aKeyProperties); |
158 | | |
159 | | virtual OUString getTypeCreatePattern() const; |
160 | | |
161 | | css::uno::Reference< css::sdb::tools::XTableRename> const & getRenameService() const; |
162 | | css::uno::Reference< css::sdb::tools::XTableAlteration> const & getAlterService() const; |
163 | | css::uno::Reference< css::sdb::tools::XKeyAlteration> const & getKeyService() const; |
164 | | css::uno::Reference< css::sdb::tools::XIndexAlteration> const & getIndexService() const; |
165 | | }; |
166 | | } |
167 | | #endif // INCLUDED_CONNECTIVITY_TTABLEHELPER_HXX |
168 | | |
169 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |