Use COMReference to handle COM pointers in CreateShortcut
[LibreOffice.git] / dbaccess / source / core / inc / TableDeco.hxx
blob289bfe5cd0bfd5c78820f20f611c55d5686c8f01
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <memory>
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/lang/XUnoTunnel.hpp>
32 #include <com/sun/star/sdbc/XConnection.hpp>
33 #include <cppuhelper/compbase.hxx>
34 #include "datasettings.hxx"
35 #include "column.hxx"
37 #include <connectivity/CommonTools.hxx>
38 #include <connectivity/sdbcx/IRefreshable.hxx>
39 #include <comphelper/IdPropArrayHelper.hxx>
41 namespace dbaccess
43 typedef ::cppu::WeakComponentImplHelper< css::sdbcx::XColumnsSupplier,
44 css::sdbcx::XKeysSupplier,
45 css::container::XNamed,
46 css::lang::XServiceInfo,
47 css::sdbcx::XDataDescriptorFactory,
48 css::sdbcx::XIndexesSupplier,
49 css::sdbcx::XRename,
50 css::lang::XUnoTunnel,
51 css::sdbcx::XAlterTable> OTableDescriptor_BASE;
52 // OTables
53 class ODBTableDecorator;
54 typedef ::comphelper::OIdPropertyArrayUsageHelper< ODBTableDecorator > ODBTableDecorator_PROP;
56 class ODBTableDecorator :public cppu::BaseMutex
57 ,public OTableDescriptor_BASE
58 ,public ODataSettings //ODataSettings_Base
59 ,public IColumnFactory
60 ,public ::connectivity::sdbcx::IRefreshableColumns
61 ,public ODBTableDecorator_PROP
63 void fillPrivileges() const;
64 rtl::Reference< OContainerMediator > m_xColumnMediator;
65 css::uno::Reference< css::sdbcx::XColumnsSupplier > m_xTable;
66 css::uno::Reference< css::container::XNameAccess > m_xColumnDefinitions;
67 css::uno::Reference< css::sdbc::XConnection > m_xConnection;
68 css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xMetaData;
69 css::uno::Reference< css::util::XNumberFormatsSupplier > m_xNumberFormats;
71 // <properties>
72 mutable sal_Int32 m_nPrivileges;
73 // </properties>
74 // note: this thing uses the ref-count of "this", see OCollection::acquire()!
75 std::unique_ptr<::connectivity::sdbcx::OCollection> m_pColumns;
77 protected:
78 // IColumnFactory
79 virtual rtl::Reference<OColumn> createColumn(const OUString& _rName) const override;
80 virtual css::uno::Reference< css::beans::XPropertySet > createColumnDescriptor() override;
81 virtual void columnAppended( const css::uno::Reference< css::beans::XPropertySet >& _rxSourceDescriptor ) override;
82 virtual void columnDropped(const OUString& _sName) override;
84 virtual void refreshColumns() override;
86 virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 _nId) const override;
87 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
89 // OPropertySetHelper
90 virtual sal_Bool SAL_CALL convertFastPropertyValue(
91 css::uno::Any & rConvertedValue,
92 css::uno::Any & rOldValue,
93 sal_Int32 nHandle,
94 const css::uno::Any& rValue ) override;
95 virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue, sal_Int32 nHandle) const override;
96 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
97 sal_Int32 nHandle,
98 const css::uno::Any& rValue
99 ) override;
101 virtual ~ODBTableDecorator() override;
102 public:
103 /** constructs a wrapper supporting the com.sun.star.sdb.Table service.
105 @param _rxConn
106 the connection the table belongs to. Must not be <NULL/>
107 @param _rxTable
108 the table from the driver can be <NULL/>
109 @throws css::sdbc::SQLException
111 ODBTableDecorator(
112 const css::uno::Reference< css::sdbc::XConnection >& _rxConn,
113 const css::uno::Reference< css::sdbcx::XColumnsSupplier >& _rxTable,
114 const css::uno::Reference< css::util::XNumberFormatsSupplier >& _rxNumberFormats,
115 const css::uno::Reference< css::container::XNameAccess >& _rxColumnDefinitions
118 // ODescriptor
119 void construct();
121 //XInterface
122 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
123 virtual void SAL_CALL acquire() noexcept override;
124 virtual void SAL_CALL release() noexcept override;
125 //XTypeProvider
126 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
127 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
129 // OComponentHelper
130 virtual void SAL_CALL disposing() override;
132 // css::lang::XServiceInfo
133 DECLARE_SERVICE_INFO();
134 // XPropertySet
135 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
136 // css::sdbcx::XRename,
137 virtual void SAL_CALL rename( const OUString& _rNewName ) override;
139 // css::sdbcx::XAlterTable,
140 virtual void SAL_CALL alterColumnByName( const OUString& _rName, const css::uno::Reference< css::beans::XPropertySet >& _rxDescriptor ) override;
141 virtual void SAL_CALL alterColumnByIndex( sal_Int32 _nIndex, const css::uno::Reference< css::beans::XPropertySet >& _rxDescriptor ) override;
143 // XNamed
144 virtual OUString SAL_CALL getName() override;
145 virtual void SAL_CALL setName( const OUString& aName ) override;
146 // css::lang::XUnoTunnel
147 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
148 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
150 // XColumnsSupplier
151 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns( ) override;
152 // XKeysSupplier
153 virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getKeys( ) override;
154 // XIndexesSupplier
155 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getIndexes( ) override;
156 // XDataDescriptorFactory
157 virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor( ) override;
159 protected:
160 using ODataSettings::getFastPropertyValue;
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */