Update ooo320-m1
[ooovba.git] / dbaccess / source / core / inc / column.hxx
blobc42b7b7d00c77c9b09f55d1d1f482a0de09fde54
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: column.hxx,v $
10 * $Revision: 1.30 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DBA_COREAPI_COLUMN_HXX_
32 #define _DBA_COREAPI_COLUMN_HXX_
34 #include <hash_map>
36 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_
40 #include <com/sun/star/container/XNamed.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
43 #include <com/sun/star/sdbc/XResultSet.hpp>
44 #endif
45 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
46 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
47 #endif
48 #ifndef _COM_SUN_STAR_LANG_WRAPPEDTARGETEXCEPTION_HPP_
49 #include <com/sun/star/lang/WrappedTargetException.hpp>
50 #endif
51 #ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_
52 #include <com/sun/star/container/XEnumerationAccess.hpp>
53 #endif
54 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
55 #include <com/sun/star/container/XNameAccess.hpp>
56 #endif
57 #ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
58 #include <com/sun/star/container/XIndexAccess.hpp>
59 #endif
60 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
61 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
62 #endif
63 #ifndef _COM_SUN_STAR_IO_IOEXCEPTION_HPP_
64 #include <com/sun/star/io/IOException.hpp>
65 #endif
66 #ifndef _COM_SUN_STAR_IO_XOBJECTOUTPUTSTREAM_HPP_
67 #include <com/sun/star/io/XObjectOutputStream.hpp>
68 #endif
69 #ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_
70 #include <com/sun/star/io/XObjectInputStream.hpp>
71 #endif
72 #ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
73 #include <com/sun/star/sdbcx/XAppend.hpp>
74 #endif
75 #ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_
76 #include <com/sun/star/sdbcx/XDrop.hpp>
77 #endif
78 #ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
79 #include <com/sun/star/lang/XUnoTunnel.hpp>
80 #endif
81 #ifndef _OSL_DIAGNOSE_H_
82 #include <osl/diagnose.h>
83 #endif
84 #ifndef _CPPUHELPER_COMPBASE3_HXX_
85 #include <cppuhelper/compbase3.hxx>
86 #endif
87 #ifndef _CPPUHELPER_IMPLBASE1_HXX_
88 #include <cppuhelper/implbase1.hxx>
89 #endif
90 #ifndef _CPPUHELPER_COMPBASE4_HXX_
91 #include <cppuhelper/compbase4.hxx>
92 #endif
93 #ifndef _CPPUHELPER_PROPSHLP_HXX
94 #include <cppuhelper/propshlp.hxx>
95 #endif
96 #ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
97 #include <comphelper/proparrhlp.hxx>
98 #endif
99 #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
100 #include <connectivity/CommonTools.hxx>
101 #endif
102 #ifndef _COMPHELPER_BROADCASTHELPER_HXX_
103 #include <comphelper/broadcasthelper.hxx>
104 #endif
105 #ifndef CONNECTIVITY_COLUMNSHELPER_HXX
106 #include <connectivity/TColumnsHelper.hxx>
107 #endif
108 #ifndef _CONNECTIVITY_FILE_VALUE_HXX_
109 #include <connectivity/FValue.hxx>
110 #endif
111 #ifndef _CONNECTIVITY_SDBCX_IREFRESHABLE_HXX_
112 #include <connectivity/sdbcx/IRefreshable.hxx>
113 #endif
114 #ifndef _COMPHELPER_STLTYPES_HXX_
115 #include <comphelper/stl_types.hxx>
116 #endif
117 #ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
118 #include <com/sun/star/container/XChild.hpp>
119 #endif
121 namespace dbaccess
124 //************************************************************
125 // OColumn
126 //************************************************************
127 typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::lang::XServiceInfo,
128 ::com::sun::star::container::XNamed,
129 ::com::sun::star::lang::XUnoTunnel > OColumnBase;
131 //------------------------------------------------------------
132 class OColumn :public comphelper::OBaseMutex
133 ,public OColumnBase
134 ,public ::cppu::OPropertySetHelper
137 friend class OColumns;
139 protected:
140 ::rtl::OUString m_sName;
142 protected:
143 OColumn();
145 public:
146 virtual ~OColumn();
148 // com::sun::star::lang::XTypeProvider
149 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
150 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) = 0;
152 // com::sun::star::uno::XInterface
153 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
154 virtual void SAL_CALL acquire() throw();
155 virtual void SAL_CALL release() throw();
157 // com::sun::star::beans::XPropertySet
158 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
160 // ::cppu::OPropertySetHelper
161 virtual void SAL_CALL getFastPropertyValue(
162 ::com::sun::star::uno::Any& rValue,
163 sal_Int32 nHandle
164 ) const;
165 virtual sal_Bool SAL_CALL convertFastPropertyValue(
166 ::com::sun::star::uno::Any & rConvertedValue,
167 ::com::sun::star::uno::Any & rOldValue,
168 sal_Int32 nHandle,
169 const ::com::sun::star::uno::Any& rValue )
170 throw (::com::sun::star::lang::IllegalArgumentException);
171 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
172 sal_Int32 nHandle,
173 const ::com::sun::star::uno::Any& rValue
175 throw (::com::sun::star::uno::Exception);
177 // com::sun::star::lang::XUnoTunnel
178 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
179 static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
181 // cppu::OComponentHelper
182 virtual void SAL_CALL disposing(void);
184 // ::com::sun::star::lang::XServiceInfo
185 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
186 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
187 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
189 // XNamed
190 virtual ::rtl::OUString SAL_CALL getName( ) throw(::com::sun::star::uno::RuntimeException);
191 virtual void SAL_CALL setName( const ::rtl::OUString& _rName ) throw(::com::sun::star::uno::RuntimeException);
193 virtual void fireValueChange(const ::connectivity::ORowSetValue& _rOldValue);
195 protected:
196 using ::cppu::OPropertySetHelper::getFastPropertyValue;
199 //************************************************************
200 // OColumnSettings
201 //************************************************************
202 class OColumnSettings
204 // <properties>
205 ::com::sun::star::uno::Any m_aWidth; // sal_Int32 or void
206 ::com::sun::star::uno::Any m_aFormatKey; // sal_Int32 or void
207 ::com::sun::star::uno::Any m_aRelativePosition; // sal_Int32 or void
208 ::com::sun::star::uno::Any m_aAlignment; // sal_Int32 (::com::sun::star::awt::TextAlign) or void
209 ::com::sun::star::uno::Any m_aHelpText; // the description of the column which is visible in the helptext of the column
210 ::com::sun::star::uno::Any m_aControlDefault; // the default value which should be displayed as by a control when moving to a new row
211 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
212 m_xControlModel;
214 sal_Bool m_bHidden;
215 // </properties>
217 // Setting of values
218 public:
219 OColumnSettings();
220 virtual ~OColumnSettings();
222 sal_Bool SAL_CALL convertFastPropertyValue(
223 ::com::sun::star::uno::Any & rConvertedValue,
224 ::com::sun::star::uno::Any & rOldValue,
225 sal_Int32 nHandle,
226 const ::com::sun::star::uno::Any& rValue )
227 throw (::com::sun::star::lang::IllegalArgumentException);
228 void SAL_CALL setFastPropertyValue_NoBroadcast(
229 sal_Int32 nHandle,
230 const ::com::sun::star::uno::Any& rValue
232 throw (::com::sun::star::uno::Exception);
233 void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
235 // com::sun::star::lang::XUnoTunnel
236 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
237 static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
239 public:
241 /** check if the persistent settings have their default value
243 sal_Bool isDefaulted() const;
246 //============================================================
247 //= IColumnFactory - used by OColumns for creating new columns
248 //============================================================
249 class SAL_NO_VTABLE IColumnFactory
251 public:
252 /** creates a OColumn object which should represent the column with a given name
254 virtual OColumn*
255 createColumn( const ::rtl::OUString& _rName ) const = 0;
257 /** creates a column descriptor object.
259 A column descriptor object is used to append new columns to the collection. If such an append
260 actually happened, columnAppended is called afterwards.
262 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor() = 0;
264 /** notifies that a column, created from a column descriptor, has been appended
266 virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor ) = 0;
268 /** notifies that a column with a given name has been dropped
270 virtual void columnDropped( const ::rtl::OUString& _sName ) = 0;
273 //============================================================
274 //= OColumns
275 //= general columns map, could be used for readonly access
276 //= no appending and dropping is supported
277 //============================================================
278 typedef ::std::hash_map<rtl::OUString, OColumn*, ::comphelper::UStringMixHash, ::comphelper::UStringMixEqual> OColumnMap;
279 typedef ::std::vector<OColumn*> OColumnArray;
281 class OContainerMediator;
282 typedef ::cppu::ImplHelper1< ::com::sun::star::container::XChild > TXChild;
283 typedef connectivity::OColumnsHelper OColumns_BASE;
284 //------------------------------------------------------------
285 class OColumns : public OColumns_BASE
286 ,public TXChild
288 OContainerMediator* m_pMediator;
290 protected:
291 // comes from the driver can be null
292 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xDrvColumns;
293 ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface > m_xParent;
294 IColumnFactory* m_pColFactoryImpl;
295 ::connectivity::sdbcx::IRefreshableColumns* m_pRefreshColumns;
297 sal_Bool m_bInitialized : 1;
298 sal_Bool m_bAddColumn : 1;
299 sal_Bool m_bDropColumn : 1;
301 virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
302 virtual connectivity::sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
303 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
304 virtual connectivity::sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
305 virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
307 public:
308 connectivity::sdbcx::ObjectType createBaseObject(const ::rtl::OUString& _rName)
310 return OColumns_BASE::createObject(_rName);
312 /** flag which determines whether the container is filled or not
314 inline sal_Bool isInitialized() const { return m_bInitialized; }
315 inline void setInitialized() {m_bInitialized = sal_True;}
316 inline void setMediator(OContainerMediator* _pMediator) { m_pMediator = _pMediator; }
318 public:
319 /** constructs an empty container without configuration location.
320 @param rParent the parent object. This instance will be used for refcounting, so the parent
321 cannot die before the container does.
322 @param _rMutex the mutex of the parent.
323 @param _bCaseSensitive the initial case sensitivity flag
324 @see setCaseSensitive
326 OColumns(
327 ::cppu::OWeakObject& _rParent,
328 ::osl::Mutex& _rMutex,
329 sal_Bool _bCaseSensitive,
330 const ::std::vector< ::rtl::OUString>& _rVector,
331 IColumnFactory* _pColFactory,
332 ::connectivity::sdbcx::IRefreshableColumns* _pRefresh,
333 sal_Bool _bAddColumn = sal_False,
334 sal_Bool _bDropColumn = sal_False,
335 sal_Bool _bUseHardRef = sal_True);
337 OColumns(
338 ::cppu::OWeakObject& _rParent,
339 ::osl::Mutex& _rMutex,
340 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxDrvColumns,
341 sal_Bool _bCaseSensitive,
342 const ::std::vector< ::rtl::OUString> &_rVector,
343 IColumnFactory* _pColFactory,
344 ::connectivity::sdbcx::IRefreshableColumns* _pRefresh,
345 sal_Bool _bAddColumn = sal_False,
346 sal_Bool _bDropColumn = sal_False,
347 sal_Bool _bUseHardRef = sal_True);
348 virtual ~OColumns();
350 //XInterface
351 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
352 virtual void SAL_CALL acquire() throw() { OColumns_BASE::acquire(); }
353 virtual void SAL_CALL release() throw() { OColumns_BASE::release(); }
354 //XTypeProvider
355 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
357 // ::com::sun::star::lang::XServiceInfo
358 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
359 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
360 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
362 // ::com::sun::star::container::XChild
363 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException);
364 virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
366 void append(const ::rtl::OUString& rName, OColumn*);
367 void clearColumns();
368 // only the name is identical to ::cppu::OComponentHelper
369 virtual void SAL_CALL disposing(void);
371 private:
372 using OColumns_BASE::setParent;
375 #endif // _DBA_COREAPI_COLUMN_HXX_