xref: /trunk/main/connectivity/source/inc/hsqldb/HTable.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef CONNECTIVITY_HSQLDB_TABLE_HXX
29 #define CONNECTIVITY_HSQLDB_TABLE_HXX
30 
31 #include "connectivity/TTableHelper.hxx"
32 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
33 #include <comphelper/IdPropArrayHelper.hxx>
34 
35 namespace connectivity
36 {
37     namespace hsqldb
38     {
39 
40         ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp);
41 
42         class OHSQLTable;
43         typedef ::comphelper::OIdPropertyArrayUsageHelper< OHSQLTable > OHSQLTable_PROP;
44         class OHSQLTable :  public OTableHelper
45                             ,public OHSQLTable_PROP
46         {
47             sal_Int32 m_nPrivileges; // we have to set our privileges by our own
48 
49             /** executes the statmenmt.
50                 @param  _rStatement
51                     The statement to execute.
52                 */
53             void executeStatement(const ::rtl::OUString& _rStatement );
54         protected:
55 
56             /** creates the column collection for the table
57                 @param  _rNames
58                     The column names.
59             */
60             virtual sdbcx::OCollection* createColumns(const TStringVector& _rNames);
61 
62             /** creates the key collection for the table
63                 @param  _rNames
64                     The key names.
65             */
66             virtual sdbcx::OCollection* createKeys(const TStringVector& _rNames);
67 
68             /** creates the index collection for the table
69                 @param  _rNames
70                     The index names.
71             */
72             virtual sdbcx::OCollection* createIndexes(const TStringVector& _rNames);
73 
74             /** used to implement the creation of the array helper which is shared amongst all instances of the class.
75                 This method needs to be implemented in derived classes.
76                 <BR>
77                 The method gets called with s_aMutex acquired.
78                 <BR>
79                 as long as IPropertyArrayHelper has no virtual destructor, the implementation of ~OPropertyArrayUsageHelper
80                 assumes that you created an ::cppu::OPropertyArrayHelper when deleting s_pProps.
81                 @return                         an pointer to the newly created array helper. Must not be NULL.
82             */
83             virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const;
84             virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
85 
86         public:
87             OHSQLTable( sdbcx::OCollection* _pTables,
88                             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection);
89             OHSQLTable( sdbcx::OCollection* _pTables,
90                             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
91                             const ::rtl::OUString& _Name,
92                             const ::rtl::OUString& _Type,
93                             const ::rtl::OUString& _Description = ::rtl::OUString(),
94                             const ::rtl::OUString& _SchemaName = ::rtl::OUString(),
95                             const ::rtl::OUString& _CatalogName = ::rtl::OUString(),
96                             sal_Int32 _nPrivileges = 0
97                 );
98 
99             // ODescriptor
100             virtual void construct();
101             // com::sun::star::lang::XUnoTunnel
102             virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
103             static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
104 
105             virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
106             //XTypeProvider
107             virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
108             // XAlterTable
109             virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& colName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
110 
111             // XRename
112             virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
113 
114             /**
115                 returns the ALTER TABLE XXX COLUMN statement
116             */
117             ::rtl::OUString getAlterTableColumnPart();
118 
119             // some methods to alter table structures
120             void alterColumnType(sal_Int32 nNewType,const ::rtl::OUString& _rColName,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDescriptor);
121             void alterDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName);
122             void dropDefaultValue(const ::rtl::OUString& _sNewDefault);
123 
124         };
125     }
126 }
127 #endif // CONNECTIVITY_HSQLDB_TABLE_HXX
128 
129