Line data Source code
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 CONNECTIVITY_MYSQL_TABLE_HXX
21 : #define CONNECTIVITY_MYSQL_TABLE_HXX
22 :
23 : #include "connectivity/TTableHelper.hxx"
24 : #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
25 : #include <comphelper/IdPropArrayHelper.hxx>
26 :
27 : namespace connectivity
28 : {
29 : namespace mysql
30 : {
31 :
32 : OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp);
33 :
34 : class OMySQLTable;
35 : typedef ::comphelper::OIdPropertyArrayUsageHelper< OMySQLTable > OMySQLTable_PROP;
36 0 : class OMySQLTable : public OTableHelper
37 : ,public OMySQLTable_PROP
38 : {
39 : sal_Int32 m_nPrivileges; // we have to set our privileges by our own
40 :
41 : /** executes the statmenmt.
42 : @param _rStatement
43 : The statement to execute.
44 : */
45 : void executeStatement(const OUString& _rStatement );
46 : protected:
47 :
48 : /** creates the column collection for the table
49 : @param _rNames
50 : The column names.
51 : */
52 : virtual sdbcx::OCollection* createColumns(const TStringVector& _rNames) SAL_OVERRIDE;
53 :
54 : /** creates the key collection for the table
55 : @param _rNames
56 : The key names.
57 : */
58 : virtual sdbcx::OCollection* createKeys(const TStringVector& _rNames) SAL_OVERRIDE;
59 :
60 : /** creates the index collection for the table
61 : @param _rNames
62 : The index names.
63 : */
64 : virtual sdbcx::OCollection* createIndexes(const TStringVector& _rNames) SAL_OVERRIDE;
65 :
66 : /** Returns always "RENAME TABLE " even for views.
67 : *
68 : * \return The start of the rename statement.
69 : * @see http://dev.mysql.com/doc/refman/5.1/de/rename-table.html
70 : */
71 : virtual OUString getRenameStart() const SAL_OVERRIDE;
72 :
73 : /** used to implement the creation of the array helper which is shared amongst all instances of the class.
74 : This method needs to be implemented in derived classes.
75 : <BR>
76 : The method gets called with s_aMutex acquired.
77 : <BR>
78 : as long as IPropertyArrayHelper has no virtual destructor, the implementation of ~OPropertyArrayUsageHelper
79 : assumes that you created an ::cppu::OPropertyArrayHelper when deleting s_pProps.
80 : @return an pointer to the newly created array helper. Must not be NULL.
81 : */
82 : virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const SAL_OVERRIDE;
83 : virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() SAL_OVERRIDE;
84 :
85 : public:
86 : OMySQLTable( sdbcx::OCollection* _pTables,
87 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection);
88 : OMySQLTable( sdbcx::OCollection* _pTables,
89 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
90 : const OUString& _Name,
91 : const OUString& _Type,
92 : const OUString& _Description = OUString(),
93 : const OUString& _SchemaName = OUString(),
94 : const OUString& _CatalogName = OUString(),
95 : sal_Int32 _nPrivileges = 0
96 : );
97 :
98 : // ODescriptor
99 : virtual void construct() SAL_OVERRIDE;
100 : // com::sun::star::lang::XUnoTunnel
101 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 : static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
103 :
104 : // XAlterTable
105 : virtual void SAL_CALL alterColumnByName( const 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, std::exception) SAL_OVERRIDE;
106 : /** returns the ALTER TABLE XXX statement
107 : */
108 : OUString getAlterTableColumnPart();
109 :
110 : // some methods to alter table structures
111 : void alterColumnType(sal_Int32 nNewType,const OUString& _rColName,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDescriptor);
112 : void alterDefaultValue(const OUString& _sNewDefault,const OUString& _rColName);
113 : void dropDefaultValue(const OUString& _sNewDefault);
114 :
115 : virtual OUString getTypeCreatePattern() const SAL_OVERRIDE;
116 : };
117 : }
118 : }
119 : #endif // CONNECTIVITY_MYSQL_TABLE_HXX
120 :
121 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|