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 _DBA_CORE_TABLEDECORATOR_HXX_
21 #define _DBA_CORE_TABLEDECORATOR_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
;
54 //==========================================================================
56 //==========================================================================
57 class ODBTableDecorator
;
58 typedef ::comphelper::OIdPropertyArrayUsageHelper
< ODBTableDecorator
> ODBTableDecorator_PROP
;
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
67 void fillPrivileges() const;
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
;
77 mutable sal_Int32 m_nPrivileges
;
79 ::connectivity::sdbcx::OCollection
* m_pColumns
;
80 ::connectivity::sdbcx::OCollection
* m_pTables
;
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
);
88 virtual void refreshColumns();
90 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper(sal_Int32 _nId
) const;
91 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
94 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
95 ::com::sun::star::uno::Any
& rConvertedValue
,
96 ::com::sun::star::uno::Any
& rOldValue
,
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(
103 const ::com::sun::star::uno::Any
& rValue
106 throw (::com::sun::star::uno::Exception
);
108 virtual ~ODBTableDecorator();
110 /** constructs a wrapper supporting the com.sun.star.sdb.Table service.
113 the connection the table belongs to. Must not be <NULL/>
115 the table from the driver can be <NULL/>
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
);
127 virtual void construct();
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();
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
);
138 virtual void SAL_CALL
disposing(void);
140 // ::com::sun::star::lang::XServiceInfo
141 DECLARE_SERVICE_INFO();
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
);
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
);
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();
158 ::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
>(); }
162 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL
getColumns( ) throw (::com::sun::star::uno::RuntimeException
);
164 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
> SAL_CALL
getKeys( ) throw (::com::sun::star::uno::RuntimeException
);
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
);
171 using ODataSettings::getFastPropertyValue
;
174 #endif // _DBA_CORE_TABLEDECORATOR_HXX_
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */