tdf#141678 Set class name alignment.
[LibreOffice.git] / include / connectivity / TTableHelper.hxx
blobba32ba7e9b80d6321e6b51d09efb08086fa55b6a
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 .
20 #ifndef INCLUDED_CONNECTIVITY_TTABLEHELPER_HXX
21 #define INCLUDED_CONNECTIVITY_TTABLEHELPER_HXX
23 #include <memory>
24 #include <sal/config.h>
26 #include <map>
28 #include <connectivity/dbtoolsdllapi.hxx>
29 #include <connectivity/sdbcx/VTable.hxx>
31 namespace com::sun::star::sdbc { class XConnection; }
32 namespace com::sun::star::sdb::tools { class XIndexAlteration; }
33 namespace com::sun::star::sdb::tools { class XKeyAlteration; }
34 namespace com::sun::star::sdb::tools { class XTableAlteration; }
35 namespace com::sun::star::sdb::tools { class XTableRename; }
36 namespace connectivity::sdbcx { struct KeyProperties; }
38 namespace connectivity
40 typedef sal_Int32 OrdinalPosition;
41 struct ColumnDesc
43 OUString sName;
44 OUString aField6;
45 OUString sField12; // REMARKS
46 OUString sField13;
47 sal_Int32 nField5
48 , nField7
49 , nField9
50 , nField11;
52 OrdinalPosition nOrdinalPosition;
54 ColumnDesc( const OUString& _rName
55 , sal_Int32 _nField5
56 , const OUString& _aField6
57 , sal_Int32 _nField7
58 , sal_Int32 _nField9
59 , sal_Int32 _nField11
60 , const OUString& _sField12
61 , const OUString& _sField13
62 ,OrdinalPosition _nPosition )
63 :sName( _rName )
64 ,aField6(_aField6)
65 ,sField12(_sField12)
66 ,sField13(_sField13)
67 ,nField5(_nField5)
68 ,nField7(_nField7)
69 ,nField9(_nField9)
70 ,nField11(_nField11)
71 ,nOrdinalPosition( _nPosition )
75 typedef connectivity::sdbcx::OTable OTable_TYPEDEF;
77 typedef std::map<OUString, std::shared_ptr<sdbcx::KeyProperties>> TKeyMap;
79 struct OTableHelperImpl;
81 class OOO_DLLPUBLIC_DBTOOLS OTableHelper : public OTable_TYPEDEF
83 ::std::unique_ptr<OTableHelperImpl> m_pImpl;
85 void refreshPrimaryKeys(::std::vector< OUString>& _rKeys);
86 void refreshForeignKeys(::std::vector< OUString>& _rKeys);
88 protected:
89 /** creates the column collection for the table
90 @param _rNames
91 The column names.
93 virtual sdbcx::OCollection* createColumns(const ::std::vector< OUString>& _rNames) = 0;
95 /** creates the key collection for the table
96 @param _rNames
97 The key names.
99 virtual sdbcx::OCollection* createKeys(const ::std::vector< OUString>& _rNames) = 0;
101 /** creates the index collection for the table
102 @param _rNames
103 The index names.
105 virtual sdbcx::OCollection* createIndexes(const ::std::vector< OUString>& _rNames) = 0;
107 /** this function is called upon disposing the component
109 virtual void SAL_CALL disposing() override;
111 /** The default returns "RENAME TABLE " or "RENAME VIEW " depending on the type.
113 * \return The start of the rename statement.
115 virtual OUString getRenameStart() const;
117 virtual ~OTableHelper() override;
119 public:
120 virtual void refreshColumns() override;
121 virtual void refreshKeys() override;
122 virtual void refreshIndexes() override;
124 const ColumnDesc* getColumnDescription(const OUString& _sName) const;
126 public:
127 OTableHelper( sdbcx::OCollection* _pTables,
128 const css::uno::Reference< css::sdbc::XConnection >& _xConnection,
129 bool _bCase);
130 OTableHelper( sdbcx::OCollection* _pTables,
131 const css::uno::Reference< css::sdbc::XConnection >& _xConnection,
132 bool _bCase,
133 const OUString& Name,
134 const OUString& Type,
135 const OUString& Description = OUString(),
136 const OUString& SchemaName = OUString(),
137 const OUString& CatalogName = OUString()
140 virtual css::uno::Reference< css::sdbc::XDatabaseMetaData> getMetaData() const override;
141 css::uno::Reference< css::sdbc::XConnection> const & getConnection() const;
143 // XRename
144 virtual void SAL_CALL rename( const OUString& newName ) override;
146 // XAlterTable
147 virtual void SAL_CALL alterColumnByIndex( sal_Int32 index, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override;
148 // XNamed
149 virtual OUString SAL_CALL getName() override;
151 // helper method to get key properties
152 std::shared_ptr<sdbcx::KeyProperties> getKeyProperties(const OUString& _sName) const;
153 void addKey(const OUString& _sName,const std::shared_ptr<sdbcx::KeyProperties>& _aKeyProperties);
155 virtual OUString getTypeCreatePattern() const;
157 css::uno::Reference< css::sdb::tools::XTableRename> const & getRenameService() const;
158 css::uno::Reference< css::sdb::tools::XTableAlteration> const & getAlterService() const;
159 css::uno::Reference< css::sdb::tools::XKeyAlteration> const & getKeyService() const;
160 css::uno::Reference< css::sdb::tools::XIndexAlteration> const & getIndexService() const;
163 #endif // INCLUDED_CONNECTIVITY_TTABLEHELPER_HXX
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */