Branch data 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 _DBA_CORE_TABLEDECORATOR_HXX_
21 : : #define _DBA_CORE_TABLEDECORATOR_HXX_
22 : :
23 : : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
24 : : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
25 : : #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
26 : : #include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
27 : : #include <com/sun/star/sdbcx/XKeysSupplier.hpp>
28 : : #include <com/sun/star/sdbcx/XRename.hpp>
29 : : #include <com/sun/star/sdbcx/XAlterTable.hpp>
30 : : #include <com/sun/star/lang/XServiceInfo.hpp>
31 : : #include <com/sun/star/sdbc/XRow.hpp>
32 : : #include <com/sun/star/sdbc/XConnection.hpp>
33 : : #include <cppuhelper/compbase9.hxx>
34 : : #include <cppuhelper/implbase5.hxx>
35 : : #include "apitools.hxx"
36 : : #include "datasettings.hxx"
37 : : #include "column.hxx"
38 : :
39 : : #include <connectivity/CommonTools.hxx>
40 : : #include <connectivity/sdbcx/IRefreshable.hxx>
41 : : #include <comphelper/IdPropArrayHelper.hxx>
42 : :
43 : : namespace dbaccess
44 : : {
45 : : typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::sdbcx::XColumnsSupplier,
46 : : ::com::sun::star::sdbcx::XKeysSupplier,
47 : : ::com::sun::star::container::XNamed,
48 : : ::com::sun::star::lang::XServiceInfo,
49 : : ::com::sun::star::sdbcx::XDataDescriptorFactory,
50 : : ::com::sun::star::sdbcx::XIndexesSupplier,
51 : : ::com::sun::star::sdbcx::XRename,
52 : : ::com::sun::star::lang::XUnoTunnel,
53 : : ::com::sun::star::sdbcx::XAlterTable> OTableDescriptor_BASE;
54 : : //==========================================================================
55 : : //= OTables
56 : : //==========================================================================
57 : : class ODBTableDecorator;
58 : : typedef ::comphelper::OIdPropertyArrayUsageHelper< ODBTableDecorator > ODBTableDecorator_PROP;
59 : :
60 : : class ODBTableDecorator :public comphelper::OBaseMutex
61 : : ,public OTableDescriptor_BASE
62 : : ,public ODataSettings //ODataSettings_Base
63 : : ,public IColumnFactory
64 : : ,public ::connectivity::sdbcx::IRefreshableColumns
65 : : ,public ODBTableDecorator_PROP
66 : : {
67 : : void fillPrivileges() const;
68 : : protected:
69 : : ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener > m_xColumnMediator;
70 : : ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier > m_xTable;
71 : : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xColumnDefinitions;
72 : : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
73 : : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
74 : : ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > m_xNumberFormats;
75 : :
76 : : // <properties>
77 : : mutable sal_Int32 m_nPrivileges;
78 : : // </properties>
79 : : ::connectivity::sdbcx::OCollection* m_pColumns;
80 : : ::connectivity::sdbcx::OCollection* m_pTables;
81 : :
82 : : // IColumnFactory
83 : : virtual OColumn* createColumn(const ::rtl::OUString& _rName) const;
84 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor();
85 : : virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor );
86 : : virtual void columnDropped(const ::rtl::OUString& _sName);
87 : :
88 : : virtual void refreshColumns();
89 : :
90 : : virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 _nId) const;
91 : : virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
92 : :
93 : : // OPropertySetHelper
94 : : virtual sal_Bool SAL_CALL convertFastPropertyValue(
95 : : ::com::sun::star::uno::Any & rConvertedValue,
96 : : ::com::sun::star::uno::Any & rOldValue,
97 : : sal_Int32 nHandle,
98 : : const ::com::sun::star::uno::Any& rValue )
99 : : throw (::com::sun::star::lang::IllegalArgumentException);
100 : : virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const;
101 : : virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
102 : : sal_Int32 nHandle,
103 : : const ::com::sun::star::uno::Any& rValue
104 : : )
105 : :
106 : : throw (::com::sun::star::uno::Exception);
107 : :
108 : : virtual ~ODBTableDecorator();
109 : : public:
110 : : /** constructs a wrapper supporting the com.sun.star.sdb.Table service.
111 : :
112 : : @param _rxConn
113 : : the connection the table belongs to. Must not be <NULL/>
114 : : @param _rxTable
115 : : the table from the driver can be <NULL/>
116 : : */
117 : : ODBTableDecorator(
118 : : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn,
119 : : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier >& _rxTable,
120 : : const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& _rxNumberFormats,
121 : : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumnDefinitions
122 : : ) throw(::com::sun::star::sdbc::SQLException);
123 : :
124 : :
125 : :
126 : : // ODescriptor
127 : : virtual void construct();
128 : :
129 : : //XInterface
130 : : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
131 : : virtual void SAL_CALL acquire() throw();
132 : : virtual void SAL_CALL release() throw();
133 : : //XTypeProvider
134 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
135 : : virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
136 : :
137 : : // OComponentHelper
138 : : virtual void SAL_CALL disposing(void);
139 : :
140 : : // ::com::sun::star::lang::XServiceInfo
141 : : DECLARE_SERVICE_INFO();
142 : : // XPropertySet
143 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
144 : : // ::com::sun::star::sdbcx::XRename,
145 : : virtual void SAL_CALL rename( const ::rtl::OUString& _rNewName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
146 : :
147 : : // ::com::sun::star::sdbcx::XAlterTable,
148 : : virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDescriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
149 : : virtual void SAL_CALL alterColumnByIndex( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDescriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
150 : :
151 : : // XNamed
152 : : virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
153 : : virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
154 : : // com::sun::star::lang::XUnoTunnel
155 : : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
156 : : static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
157 : :
158 : 0 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() const { return m_xMetaData; }
159 : : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() const { return m_xMetaData.is() ? m_xMetaData->getConnection() : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>(); }
160 : :
161 : : // XColumnsSupplier
162 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw (::com::sun::star::uno::RuntimeException);
163 : : // XKeysSupplier
164 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getKeys( ) throw (::com::sun::star::uno::RuntimeException);
165 : : // XIndexesSupplier
166 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getIndexes( ) throw (::com::sun::star::uno::RuntimeException);
167 : : // XDataDescriptorFactory
168 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
169 : :
170 : : protected:
171 : : using ODataSettings::getFastPropertyValue;
172 : : };
173 : : }
174 : : #endif // _DBA_CORE_TABLEDECORATOR_HXX_
175 : :
176 : :
177 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|