1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_DBACCESS_SOURCE_CORE_INC_TABLEDECO_HXX
21 #define INCLUDED_DBACCESS_SOURCE_CORE_INC_TABLEDECO_HXX
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"
39 #include <connectivity/CommonTools.hxx>
40 #include <connectivity/sdbcx/IRefreshable.hxx>
41 #include <comphelper/IdPropArrayHelper.hxx>
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
;
55 class ODBTableDecorator
;
56 typedef ::comphelper::OIdPropertyArrayUsageHelper
< ODBTableDecorator
> ODBTableDecorator_PROP
;
58 class ODBTableDecorator
:public comphelper::OBaseMutex
59 ,public OTableDescriptor_BASE
60 ,public ODataSettings
//ODataSettings_Base
61 ,public IColumnFactory
62 ,public ::connectivity::sdbcx::IRefreshableColumns
63 ,public ODBTableDecorator_PROP
65 void fillPrivileges() const;
67 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XContainerListener
> m_xColumnMediator
;
68 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbcx::XColumnsSupplier
> m_xTable
;
69 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> m_xColumnDefinitions
;
70 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> m_xConnection
;
71 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDatabaseMetaData
> m_xMetaData
;
72 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatsSupplier
> m_xNumberFormats
;
75 mutable sal_Int32 m_nPrivileges
;
77 ::connectivity::sdbcx::OCollection
* m_pColumns
;
80 virtual OColumn
* createColumn(const OUString
& _rName
) const SAL_OVERRIDE
;
81 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> createColumnDescriptor() SAL_OVERRIDE
;
82 virtual void columnAppended( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxSourceDescriptor
) SAL_OVERRIDE
;
83 virtual void columnDropped(const OUString
& _sName
) SAL_OVERRIDE
;
85 virtual void refreshColumns() SAL_OVERRIDE
;
87 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper(sal_Int32 _nId
) const SAL_OVERRIDE
;
88 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() SAL_OVERRIDE
;
91 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
92 ::com::sun::star::uno::Any
& rConvertedValue
,
93 ::com::sun::star::uno::Any
& rOldValue
,
95 const ::com::sun::star::uno::Any
& rValue
)
96 throw (::com::sun::star::lang::IllegalArgumentException
) SAL_OVERRIDE
;
97 virtual void SAL_CALL
getFastPropertyValue(::com::sun::star::uno::Any
& rValue
, sal_Int32 nHandle
) const SAL_OVERRIDE
;
98 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
100 const ::com::sun::star::uno::Any
& rValue
103 throw (::com::sun::star::uno::Exception
, std::exception
) SAL_OVERRIDE
;
105 virtual ~ODBTableDecorator();
107 /** constructs a wrapper supporting the com.sun.star.sdb.Table service.
110 the connection the table belongs to. Must not be <NULL/>
112 the table from the driver can be <NULL/>
115 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConn
,
116 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbcx::XColumnsSupplier
>& _rxTable
,
117 const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatsSupplier
>& _rxNumberFormats
,
118 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>& _rxColumnDefinitions
119 ) throw(::com::sun::star::sdbc::SQLException
);
122 virtual void construct();
125 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
126 virtual void SAL_CALL
acquire() throw() SAL_OVERRIDE
;
127 virtual void SAL_CALL
release() throw() SAL_OVERRIDE
;
129 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
130 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
133 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
135 // ::com::sun::star::lang::XServiceInfo
136 DECLARE_SERVICE_INFO();
138 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
139 // ::com::sun::star::sdbcx::XRename,
140 virtual void SAL_CALL
rename( const OUString
& _rNewName
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::container::ElementExistException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
142 // ::com::sun::star::sdbcx::XAlterTable,
143 virtual void SAL_CALL
alterColumnByName( const 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
, std::exception
) SAL_OVERRIDE
;
144 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
, std::exception
) SAL_OVERRIDE
;
147 virtual OUString SAL_CALL
getName() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
148 virtual void SAL_CALL
setName( const OUString
& aName
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
149 // com::sun::star::lang::XUnoTunnel
150 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
;
151 static ::com::sun::star::uno::Sequence
< sal_Int8
> getUnoTunnelImplementationId();
153 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDatabaseMetaData
> getMetaData() const { return m_xMetaData
; }
154 ::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
>(); }
157 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL
getColumns( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
159 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
> SAL_CALL
getKeys( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
161 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL
getIndexes( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
162 // XDataDescriptorFactory
163 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> SAL_CALL
createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
166 using ODataSettings::getFastPropertyValue
;
169 #endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_TABLEDECO_HXX
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */