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_COLUMN_HXX
21 #define INCLUDED_DBACCESS_SOURCE_CORE_INC_COLUMN_HXX
23 #include "columnsettings.hxx"
25 #include <com/sun/star/container/XChild.hpp>
26 #include <com/sun/star/container/XEnumerationAccess.hpp>
27 #include <com/sun/star/container/XIndexAccess.hpp>
28 #include <com/sun/star/container/XNameAccess.hpp>
29 #include <com/sun/star/container/XNamed.hpp>
30 #include <com/sun/star/io/IOException.hpp>
31 #include <com/sun/star/io/XObjectInputStream.hpp>
32 #include <com/sun/star/io/XObjectOutputStream.hpp>
33 #include <com/sun/star/lang/WrappedTargetException.hpp>
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/lang/XUnoTunnel.hpp>
37 #include <com/sun/star/sdbc/XResultSet.hpp>
38 #include <com/sun/star/sdbcx/XAppend.hpp>
39 #include <com/sun/star/sdbcx/XDrop.hpp>
40 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
42 #include <comphelper/proparrhlp.hxx>
43 #include <comphelper/propertycontainer.hxx>
44 #include <connectivity/CommonTools.hxx>
45 #include <connectivity/FValue.hxx>
46 #include <connectivity/TColumnsHelper.hxx>
47 #include <connectivity/sdbcx/IRefreshable.hxx>
48 #include <cppuhelper/basemutex.hxx>
49 #include <cppuhelper/compbase.hxx>
50 #include <cppuhelper/implbase1.hxx>
51 #include <cppuhelper/propshlp.hxx>
52 #include <osl/diagnose.h>
60 typedef ::cppu::WeakComponentImplHelper
< css::lang::XServiceInfo
,
61 css::container::XNamed
64 class OColumn
:public cppu::BaseMutex
66 ,public ::comphelper::OPropertyContainer
67 ,public IPropertyContainer
// convenience for the derived class which also derive from OColumnSettings
69 friend class OColumns
;
77 OColumn( const bool _bNameIsReadOnly
);
80 virtual ~OColumn() override
;
82 // css::lang::XTypeProvider
83 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() throw (css::uno::RuntimeException
, std::exception
) override
;
84 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() throw (css::uno::RuntimeException
, std::exception
) override
= 0;
86 // css::uno::XInterface
87 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) throw (css::uno::RuntimeException
, std::exception
) override
;
88 virtual void SAL_CALL
acquire() throw() override
;
89 virtual void SAL_CALL
release() throw() override
;
91 // css::beans::XPropertySet
92 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(css::uno::RuntimeException
, std::exception
) override
;
94 // cppu::OComponentHelper
95 virtual void SAL_CALL
disposing() override
;
97 // css::lang::XServiceInfo
98 virtual OUString SAL_CALL
getImplementationName( ) throw(css::uno::RuntimeException
, std::exception
) override
;
99 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw(css::uno::RuntimeException
, std::exception
) override
;
100 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw(css::uno::RuntimeException
, std::exception
) override
;
103 virtual OUString SAL_CALL
getName( ) throw(css::uno::RuntimeException
, std::exception
) override
;
104 virtual void SAL_CALL
setName( const OUString
& _rName
) throw(css::uno::RuntimeException
, std::exception
) override
;
106 virtual void fireValueChange( const ::connectivity::ORowSetValue
& _rOldValue
);
109 // IPropertyContainer
110 virtual void registerProperty( const OUString
& _rName
, sal_Int32 _nHandle
, sal_Int32 _nAttributes
, void* _pPointerToMember
, const css::uno::Type
& _rMemberType
) override
;
111 virtual void registerMayBeVoidProperty( const OUString
& _rName
, sal_Int32 _nHandle
, sal_Int32 _nAttributes
, css::uno::Any
* _pPointerToMember
, const css::uno::Type
& _rExpectedType
) override
;
114 // IColumnFactory - used by OColumns for creating new columns
115 class SAL_NO_VTABLE IColumnFactory
118 /** creates a OColumn object which should represent the column with a given name
121 createColumn( const OUString
& _rName
) const = 0;
123 /** creates a column descriptor object.
125 A column descriptor object is used to append new columns to the collection. If such an append
126 actually happened, columnAppended is called afterwards.
128 virtual css::uno::Reference
< css::beans::XPropertySet
> createColumnDescriptor() = 0;
130 /** notifies that a column, created from a column descriptor, has been appended
132 virtual void columnAppended( const css::uno::Reference
< css::beans::XPropertySet
>& _rxSourceDescriptor
) = 0;
134 /** notifies that a column with a given name has been dropped
136 virtual void columnDropped( const OUString
& _sName
) = 0;
142 class OContainerMediator
;
143 typedef ::cppu::ImplHelper1
< css::container::XChild
> TXChild
;
144 typedef connectivity::OColumnsHelper OColumns_BASE
;
146 class OColumns
: public OColumns_BASE
149 OContainerMediator
* m_pMediator
;
152 // comes from the driver can be null
153 css::uno::Reference
< css::container::XNameAccess
> m_xDrvColumns
;
154 css::uno::WeakReference
< css::uno::XInterface
> m_xParent
;
155 IColumnFactory
* m_pColFactoryImpl
;
156 ::connectivity::sdbcx::IRefreshableColumns
* m_pRefreshColumns
;
158 bool m_bInitialized
: 1;
159 bool m_bAddColumn
: 1;
160 bool m_bDropColumn
: 1;
162 virtual void impl_refresh() throw(css::uno::RuntimeException
) override
;
163 virtual connectivity::sdbcx::ObjectType
createObject(const OUString
& _rName
) override
;
164 virtual css::uno::Reference
< css::beans::XPropertySet
> createDescriptor() override
;
165 virtual connectivity::sdbcx::ObjectType
appendObject( const OUString
& _rForName
, const css::uno::Reference
< css::beans::XPropertySet
>& descriptor
) override
;
166 virtual void dropObject(sal_Int32 _nPos
, const OUString
& _sElementName
) override
;
169 connectivity::sdbcx::ObjectType
createBaseObject(const OUString
& _rName
)
171 return OColumns_BASE::createObject(_rName
);
173 /** flag which determines whether the container is filled or not
175 inline bool isInitialized() const { return m_bInitialized
; }
176 inline void setInitialized() {m_bInitialized
= true;}
177 inline void setMediator(OContainerMediator
* _pMediator
) { m_pMediator
= _pMediator
; }
180 /** constructs an empty container without configuration location.
181 @param rParent the parent object. This instance will be used for refcounting, so the parent
182 cannot die before the container does.
183 @param _rMutex the mutex of the parent.
184 @param _bCaseSensitive the initial case sensitivity flag
185 @see setCaseSensitive
188 ::cppu::OWeakObject
& _rParent
,
189 ::osl::Mutex
& _rMutex
,
190 bool _bCaseSensitive
,
191 const ::std::vector
< OUString
>& _rVector
,
192 IColumnFactory
* _pColFactory
,
193 ::connectivity::sdbcx::IRefreshableColumns
* _pRefresh
,
194 bool _bAddColumn
= false,
195 bool _bDropColumn
= false,
196 bool _bUseHardRef
= true);
199 ::cppu::OWeakObject
& _rParent
,
200 ::osl::Mutex
& _rMutex
,
201 const css::uno::Reference
< css::container::XNameAccess
>& _rxDrvColumns
,
202 bool _bCaseSensitive
,
203 const ::std::vector
< OUString
> &_rVector
,
204 IColumnFactory
* _pColFactory
,
205 ::connectivity::sdbcx::IRefreshableColumns
* _pRefresh
,
206 bool _bAddColumn
= false,
207 bool _bDropColumn
= false,
208 bool _bUseHardRef
= true);
209 virtual ~OColumns() override
;
212 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) throw(css::uno::RuntimeException
, std::exception
) override
;
213 virtual void SAL_CALL
acquire() throw() override
{ OColumns_BASE::acquire(); }
214 virtual void SAL_CALL
release() throw() override
{ OColumns_BASE::release(); }
216 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) throw(css::uno::RuntimeException
, std::exception
) override
;
218 // css::lang::XServiceInfo
219 virtual OUString SAL_CALL
getImplementationName( ) throw(css::uno::RuntimeException
, std::exception
) override
;
220 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw(css::uno::RuntimeException
, std::exception
) override
;
221 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw(css::uno::RuntimeException
, std::exception
) override
;
223 // css::container::XChild
224 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getParent( ) throw (css::uno::RuntimeException
, std::exception
) override
;
225 virtual void SAL_CALL
setParent( const css::uno::Reference
< css::uno::XInterface
>& Parent
) throw (css::lang::NoSupportException
, css::uno::RuntimeException
, std::exception
) override
;
227 void append(const OUString
& rName
, OColumn
*);
229 // only the name is identical to ::cppu::OComponentHelper
230 virtual void SAL_CALL
disposing() override
;
233 using OColumns_BASE::setParent
;
236 #endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_COLUMN_HXX
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */