1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef CONNECTIVITY_HSQLDB_TABLE_HXX 25 #define CONNECTIVITY_HSQLDB_TABLE_HXX 26 27 #include "connectivity/TTableHelper.hxx" 28 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> 29 #include <comphelper/IdPropArrayHelper.hxx> 30 31 namespace connectivity 32 { 33 namespace hsqldb 34 { 35 36 ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp); 37 38 class OHSQLTable; 39 typedef ::comphelper::OIdPropertyArrayUsageHelper< OHSQLTable > OHSQLTable_PROP; 40 class OHSQLTable : public OTableHelper 41 ,public OHSQLTable_PROP 42 { 43 sal_Int32 m_nPrivileges; // we have to set our privileges by our own 44 45 /** executes the statmenmt. 46 @param _rStatement 47 The statement to execute. 48 */ 49 void executeStatement(const ::rtl::OUString& _rStatement ); 50 protected: 51 52 /** creates the column collection for the table 53 @param _rNames 54 The column names. 55 */ 56 virtual sdbcx::OCollection* createColumns(const TStringVector& _rNames); 57 58 /** creates the key collection for the table 59 @param _rNames 60 The key names. 61 */ 62 virtual sdbcx::OCollection* createKeys(const TStringVector& _rNames); 63 64 /** creates the index collection for the table 65 @param _rNames 66 The index names. 67 */ 68 virtual sdbcx::OCollection* createIndexes(const TStringVector& _rNames); 69 70 /** used to implement the creation of the array helper which is shared amongst all instances of the class. 71 This method needs to be implemented in derived classes. 72 <BR> 73 The method gets called with s_aMutex acquired. 74 <BR> 75 as long as IPropertyArrayHelper has no virtual destructor, the implementation of ~OPropertyArrayUsageHelper 76 assumes that you created an ::cppu::OPropertyArrayHelper when deleting s_pProps. 77 @return an pointer to the newly created array helper. Must not be NULL. 78 */ 79 virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const; 80 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); 81 82 public: 83 OHSQLTable( sdbcx::OCollection* _pTables, 84 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection); 85 OHSQLTable( sdbcx::OCollection* _pTables, 86 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection, 87 const ::rtl::OUString& _Name, 88 const ::rtl::OUString& _Type, 89 const ::rtl::OUString& _Description = ::rtl::OUString(), 90 const ::rtl::OUString& _SchemaName = ::rtl::OUString(), 91 const ::rtl::OUString& _CatalogName = ::rtl::OUString(), 92 sal_Int32 _nPrivileges = 0 93 ); 94 95 // ODescriptor 96 virtual void construct(); 97 // com::sun::star::lang::XUnoTunnel 98 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); 99 static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); 100 101 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 102 //XTypeProvider 103 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); 104 // XAlterTable 105 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); 106 107 // XRename 108 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); 109 110 /** 111 returns the ALTER TABLE XXX COLUMN statement 112 */ 113 ::rtl::OUString getAlterTableColumnPart(); 114 115 // some methods to alter table structures 116 void alterColumnType(sal_Int32 nNewType,const ::rtl::OUString& _rColName,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDescriptor); 117 void alterDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName); 118 void dropDefaultValue(const ::rtl::OUString& _sNewDefault); 119 120 }; 121 } 122 } 123 #endif // CONNECTIVITY_HSQLDB_TABLE_HXX 124 125