build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / include / connectivity / TTableHelper.hxx
blob847094bf709b46c12cd121a29692636b203da78c
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 <sal/config.h>
25 #include <map>
27 #include <connectivity/dbtoolsdllapi.hxx>
28 #include <connectivity/sdbcx/VTable.hxx>
29 #include <connectivity/sdbcx/VKey.hxx>
30 #include <connectivity/StdTypeDefs.hxx>
31 #include <com/sun/star/sdb/tools/XTableRename.hpp>
32 #include <com/sun/star/sdb/tools/XTableAlteration.hpp>
33 #include <com/sun/star/sdb/tools/XKeyAlteration.hpp>
34 #include <com/sun/star/sdb/tools/XIndexAlteration.hpp>
36 namespace connectivity
38 typedef sal_Int32 OrdinalPosition;
39 struct ColumnDesc
41 OUString sName;
42 OUString aField6;
43 OUString sField12; // REMARKS
44 OUString sField13;
45 sal_Int32 nField5
46 , nField7
47 , nField9
48 , nField11;
50 OrdinalPosition nOrdinalPosition;
52 ColumnDesc( const OUString& _rName
53 , sal_Int32 _nField5
54 , const OUString& _aField6
55 , sal_Int32 _nField7
56 , sal_Int32 _nField9
57 , sal_Int32 _nField11
58 , const OUString& _sField12
59 , const OUString& _sField13
60 ,OrdinalPosition _nPosition )
61 :sName( _rName )
62 ,aField6(_aField6)
63 ,sField12(_sField12)
64 ,sField13(_sField13)
65 ,nField5(_nField5)
66 ,nField7(_nField7)
67 ,nField9(_nField9)
68 ,nField11(_nField11)
69 ,nOrdinalPosition( _nPosition )
73 typedef connectivity::sdbcx::OTable OTable_TYPEDEF;
75 typedef std::map<OUString, std::shared_ptr<sdbcx::KeyProperties>> TKeyMap;
77 struct OTableHelperImpl;
79 class OOO_DLLPUBLIC_DBTOOLS OTableHelper : public OTable_TYPEDEF
81 ::std::unique_ptr<OTableHelperImpl> m_pImpl;
83 void refreshPrimaryKeys(TStringVector& _rKeys);
84 void refreshForeignKeys(TStringVector& _rKeys);
86 protected:
87 /** creates the column collection for the table
88 @param _rNames
89 The column names.
91 virtual sdbcx::OCollection* createColumns(const TStringVector& _rNames) = 0;
93 /** creates the key collection for the table
94 @param _rNames
95 The key names.
97 virtual sdbcx::OCollection* createKeys(const TStringVector& _rNames) = 0;
99 /** creates the index collection for the table
100 @param _rNames
101 The index names.
103 virtual sdbcx::OCollection* createIndexes(const TStringVector& _rNames) = 0;
105 /** this function is called upon disposing the component
107 virtual void SAL_CALL disposing() override;
109 /** The default returns "RENAME TABLE " or "RENAME VIEW " depending on the type.
111 * \return The start of the rename statement.
113 virtual OUString getRenameStart() const;
115 virtual ~OTableHelper() override;
117 public:
118 virtual void refreshColumns() override;
119 virtual void refreshKeys() override;
120 virtual void refreshIndexes() override;
122 const ColumnDesc* getColumnDescription(const OUString& _sName) const;
124 public:
125 OTableHelper( sdbcx::OCollection* _pTables,
126 const css::uno::Reference< css::sdbc::XConnection >& _xConnection,
127 bool _bCase);
128 OTableHelper( sdbcx::OCollection* _pTables,
129 const css::uno::Reference< css::sdbc::XConnection >& _xConnection,
130 bool _bCase,
131 const OUString& Name,
132 const OUString& Type,
133 const OUString& Description = OUString(),
134 const OUString& SchemaName = OUString(),
135 const OUString& CatalogName = OUString()
138 virtual css::uno::Reference< css::sdbc::XDatabaseMetaData> getMetaData() const override;
139 css::uno::Reference< css::sdbc::XConnection> getConnection() const;
141 // XRename
142 virtual void SAL_CALL rename( const OUString& newName ) throw(css::sdbc::SQLException, css::container::ElementExistException, css::uno::RuntimeException, std::exception) override;
144 // XAlterTable
145 virtual void SAL_CALL alterColumnByIndex( sal_Int32 index, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) throw(css::sdbc::SQLException, css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) override;
146 // XNamed
147 virtual OUString SAL_CALL getName() throw(css::uno::RuntimeException, std::exception) override;
149 // helper method to get key properties
150 std::shared_ptr<sdbcx::KeyProperties> getKeyProperties(const OUString& _sName) const;
151 void addKey(const OUString& _sName,const std::shared_ptr<sdbcx::KeyProperties>& _aKeyProperties);
153 virtual OUString getTypeCreatePattern() const;
155 css::uno::Reference< css::sdb::tools::XTableRename> getRenameService() const;
156 css::uno::Reference< css::sdb::tools::XTableAlteration> getAlterService() const;
157 css::uno::Reference< css::sdb::tools::XKeyAlteration> getKeyService() const;
158 css::uno::Reference< css::sdb::tools::XIndexAlteration> getIndexService() const;
161 #endif // INCLUDED_CONNECTIVITY_TTABLEHELPER_HXX
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */