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 .
22 #include "TableDeco.hxx"
23 #include <definitioncolumn.hxx>
24 #include "dbastrings.hrc"
25 #include "core_resource.hxx"
26 #include "core_resource.hrc"
27 #include <tools/debug.hxx>
28 #include <osl/diagnose.h>
30 #include <cppuhelper/typeprovider.hxx>
31 #include <comphelper/enumhelper.hxx>
32 #include <comphelper/container.hxx>
33 #include <comphelper/sequence.hxx>
34 #include <comphelper/property.hxx>
35 #include <comphelper/types.hxx>
36 #include <com/sun/star/util/XRefreshListener.hpp>
37 #include <com/sun/star/sdbc/XConnection.hpp>
38 #include <com/sun/star/sdbc/XRow.hpp>
39 #include <com/sun/star/sdbcx/Privilege.hpp>
40 #include <com/sun/star/beans/PropertyAttribute.hpp>
41 #include <connectivity/dbtools.hxx>
42 #include <connectivity/dbexception.hxx>
43 #include <comphelper/extract.hxx>
44 #include "ContainerMediator.hxx"
46 using namespace dbaccess
;
47 using namespace ::com::sun::star::uno
;
48 using namespace ::com::sun::star::util
;
49 using namespace ::com::sun::star::lang
;
50 using namespace ::com::sun::star::beans
;
51 using namespace ::com::sun::star::sdbc
;
52 using namespace ::com::sun::star::sdbcx
;
53 using namespace ::com::sun::star::container
;
54 using namespace ::osl
;
55 using namespace ::comphelper
;
56 using namespace ::dbtools
;
57 using namespace ::cppu
;
61 ODBTableDecorator::ODBTableDecorator( const Reference
< XConnection
>& _rxConnection
, const Reference
< XColumnsSupplier
>& _rxNewTable
,
62 const Reference
< XNumberFormatsSupplier
>& _rxNumberFormats
, const Reference
< XNameAccess
>& _xColumnDefinitions
) throw(SQLException
)
63 :OTableDescriptor_BASE(m_aMutex
)
64 ,ODataSettings(OTableDescriptor_BASE::rBHelper
)
65 ,m_xTable(_rxNewTable
)
66 ,m_xColumnDefinitions(_xColumnDefinitions
)
67 ,m_xConnection( _rxConnection
)
68 ,m_xMetaData( _rxConnection
.is() ? _rxConnection
->getMetaData() : Reference
< XDatabaseMetaData
>() )
69 ,m_xNumberFormats( _rxNumberFormats
)
73 ODataSettings::registerPropertiesFor(this);
76 ODBTableDecorator::~ODBTableDecorator()
82 Sequence
< sal_Int8
> ODBTableDecorator::getImplementationId() throw (RuntimeException
, std::exception
)
84 return css::uno::Sequence
<sal_Int8
>();
88 void SAL_CALL
ODBTableDecorator::disposing()
90 OPropertySetHelper::disposing();
91 OTableDescriptor_BASE::disposing();
93 MutexGuard
aGuard(m_aMutex
);
96 m_xColumnDefinitions
= NULL
;
97 m_xNumberFormats
= NULL
;
99 m_pColumns
->disposing();
100 m_xColumnMediator
= NULL
;
103 sal_Bool SAL_CALL
ODBTableDecorator::convertFastPropertyValue(
104 Any
& rConvertedValue
,
108 throw (::com::sun::star::lang::IllegalArgumentException
)
113 case PROPERTY_ID_PRIVILEGES
:
114 case PROPERTY_ID_FILTER
:
115 case PROPERTY_ID_ORDER
:
116 case PROPERTY_ID_APPLYFILTER
:
117 case PROPERTY_ID_FONT
:
118 case PROPERTY_ID_ROW_HEIGHT
:
119 case PROPERTY_ID_TEXTCOLOR
:
120 case PROPERTY_ID_TEXTLINECOLOR
:
121 case PROPERTY_ID_TEXTEMPHASIS
:
122 case PROPERTY_ID_TEXTRELIEF
:
123 case PROPERTY_ID_FONTCHARWIDTH
:
124 case PROPERTY_ID_FONTCHARSET
:
125 case PROPERTY_ID_FONTFAMILY
:
126 case PROPERTY_ID_FONTHEIGHT
:
127 case PROPERTY_ID_FONTKERNING
:
128 case PROPERTY_ID_FONTNAME
:
129 case PROPERTY_ID_FONTORIENTATION
:
130 case PROPERTY_ID_FONTPITCH
:
131 case PROPERTY_ID_FONTSLANT
:
132 case PROPERTY_ID_FONTSTRIKEOUT
:
133 case PROPERTY_ID_FONTSTYLENAME
:
134 case PROPERTY_ID_FONTUNDERLINE
:
135 case PROPERTY_ID_FONTWEIGHT
:
136 case PROPERTY_ID_FONTWIDTH
:
137 case PROPERTY_ID_FONTWORDLINEMODE
:
138 case PROPERTY_ID_FONTTYPE
:
139 bRet
= ODataSettings::convertFastPropertyValue(rConvertedValue
, rOldValue
,nHandle
,rValue
);
145 getFastPropertyValue(aValue
,nHandle
);
146 bRet
= ::comphelper::tryPropertyValue(rConvertedValue
,rOldValue
,rValue
,aValue
,::cppu::UnoType
<OUString
>::get());
148 break; // we assume that it works
153 void ODBTableDecorator::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle
, const Any
& _rValue
) throw (Exception
, std::exception
)
157 case PROPERTY_ID_PRIVILEGES
:
158 SAL_WARN("dbaccess", "Property is readonly!");
160 case PROPERTY_ID_FILTER
:
161 case PROPERTY_ID_ORDER
:
162 case PROPERTY_ID_APPLYFILTER
:
163 case PROPERTY_ID_FONT
:
164 case PROPERTY_ID_ROW_HEIGHT
:
165 case PROPERTY_ID_TEXTCOLOR
:
166 case PROPERTY_ID_TEXTLINECOLOR
:
167 case PROPERTY_ID_TEXTEMPHASIS
:
168 case PROPERTY_ID_TEXTRELIEF
:
169 case PROPERTY_ID_FONTCHARWIDTH
:
170 case PROPERTY_ID_FONTCHARSET
:
171 case PROPERTY_ID_FONTFAMILY
:
172 case PROPERTY_ID_FONTHEIGHT
:
173 case PROPERTY_ID_FONTKERNING
:
174 case PROPERTY_ID_FONTNAME
:
175 case PROPERTY_ID_FONTORIENTATION
:
176 case PROPERTY_ID_FONTPITCH
:
177 case PROPERTY_ID_FONTSLANT
:
178 case PROPERTY_ID_FONTSTRIKEOUT
:
179 case PROPERTY_ID_FONTSTYLENAME
:
180 case PROPERTY_ID_FONTUNDERLINE
:
181 case PROPERTY_ID_FONTWEIGHT
:
182 case PROPERTY_ID_FONTWIDTH
:
183 case PROPERTY_ID_FONTWORDLINEMODE
:
184 case PROPERTY_ID_FONTTYPE
:
186 ODataSettings::setFastPropertyValue_NoBroadcast(_nHandle
, _rValue
);
188 case PROPERTY_ID_CATALOGNAME
:
190 Reference
<XPropertySet
> xProp(m_xTable
,UNO_QUERY
);
191 xProp
->setPropertyValue(PROPERTY_CATALOGNAME
,_rValue
);
194 case PROPERTY_ID_SCHEMANAME
:
196 Reference
<XPropertySet
> xProp(m_xTable
,UNO_QUERY
);
197 xProp
->setPropertyValue(PROPERTY_SCHEMANAME
,_rValue
);
200 case PROPERTY_ID_NAME
:
202 Reference
<XPropertySet
> xProp(m_xTable
,UNO_QUERY
);
203 xProp
->setPropertyValue(PROPERTY_NAME
,_rValue
);
206 case PROPERTY_ID_DESCRIPTION
:
208 Reference
<XPropertySet
> xProp(m_xTable
,UNO_QUERY
);
209 xProp
->setPropertyValue(PROPERTY_DESCRIPTION
,_rValue
);
212 case PROPERTY_ID_TYPE
:
214 Reference
<XPropertySet
> xProp(m_xTable
,UNO_QUERY
);
215 xProp
->setPropertyValue(PROPERTY_TYPE
,_rValue
);
221 void ODBTableDecorator::getFastPropertyValue(Any
& _rValue
, sal_Int32 _nHandle
) const
226 case PROPERTY_ID_PRIVILEGES
:
228 if ( -1 == m_nPrivileges
)
230 Reference
<XPropertySet
> xProp(m_xTable
,UNO_QUERY
);
231 Reference
<XPropertySetInfo
> xInfo
= xProp
->getPropertySetInfo();
232 if ( xInfo
->hasPropertyByName(PROPERTY_PRIVILEGES
) )
234 _rValue
<<= m_nPrivileges
;
240 case PROPERTY_ID_FILTER
:
241 case PROPERTY_ID_ORDER
:
242 case PROPERTY_ID_APPLYFILTER
:
243 case PROPERTY_ID_FONT
:
244 case PROPERTY_ID_ROW_HEIGHT
:
245 case PROPERTY_ID_TEXTCOLOR
:
246 case PROPERTY_ID_TEXTLINECOLOR
:
247 case PROPERTY_ID_TEXTEMPHASIS
:
248 case PROPERTY_ID_TEXTRELIEF
:
249 case PROPERTY_ID_FONTCHARWIDTH
:
250 case PROPERTY_ID_FONTCHARSET
:
251 case PROPERTY_ID_FONTFAMILY
:
252 case PROPERTY_ID_FONTHEIGHT
:
253 case PROPERTY_ID_FONTKERNING
:
254 case PROPERTY_ID_FONTNAME
:
255 case PROPERTY_ID_FONTORIENTATION
:
256 case PROPERTY_ID_FONTPITCH
:
257 case PROPERTY_ID_FONTSLANT
:
258 case PROPERTY_ID_FONTSTRIKEOUT
:
259 case PROPERTY_ID_FONTSTYLENAME
:
260 case PROPERTY_ID_FONTUNDERLINE
:
261 case PROPERTY_ID_FONTWEIGHT
:
262 case PROPERTY_ID_FONTWIDTH
:
263 case PROPERTY_ID_FONTWORDLINEMODE
:
264 case PROPERTY_ID_FONTTYPE
:
265 ODataSettings::getFastPropertyValue(_rValue
, _nHandle
);
267 case PROPERTY_ID_CATALOGNAME
:
269 Reference
<XPropertySet
> xProp(m_xTable
,UNO_QUERY
);
270 _rValue
= xProp
->getPropertyValue(PROPERTY_CATALOGNAME
);
273 case PROPERTY_ID_SCHEMANAME
:
275 Reference
<XPropertySet
> xProp(m_xTable
,UNO_QUERY
);
276 _rValue
= xProp
->getPropertyValue(PROPERTY_SCHEMANAME
);
279 case PROPERTY_ID_NAME
:
281 Reference
<XPropertySet
> xProp(m_xTable
,UNO_QUERY
);
282 _rValue
= xProp
->getPropertyValue(PROPERTY_NAME
);
285 case PROPERTY_ID_DESCRIPTION
:
287 Reference
<XPropertySet
> xProp(m_xTable
,UNO_QUERY
);
288 _rValue
= xProp
->getPropertyValue(PROPERTY_DESCRIPTION
);
291 case PROPERTY_ID_TYPE
:
293 Reference
<XPropertySet
> xProp(m_xTable
,UNO_QUERY
);
294 _rValue
= xProp
->getPropertyValue(PROPERTY_TYPE
);
298 SAL_WARN("dbaccess", "Invalid Handle for table");
302 void ODBTableDecorator::construct()
304 bool bNotFound
= true;
305 Reference
<XPropertySet
> xProp(m_xTable
,UNO_QUERY
);
308 Reference
<XPropertySetInfo
> xInfo
= xProp
->getPropertySetInfo();
309 bNotFound
= !xInfo
->hasPropertyByName(PROPERTY_PRIVILEGES
);
312 registerProperty(PROPERTY_PRIVILEGES
, PROPERTY_ID_PRIVILEGES
, PropertyAttribute::BOUND
| PropertyAttribute::READONLY
,
313 &m_nPrivileges
, ::cppu::UnoType
<sal_Int32
>::get());
316 ::cppu::IPropertyArrayHelper
* ODBTableDecorator::createArrayHelper(sal_Int32
/*_nId*/) const
318 Reference
<XPropertySet
> xProp(m_xTable
,UNO_QUERY
);
319 Reference
<XPropertySetInfo
> xInfo
= xProp
->getPropertySetInfo();
321 Sequence
< Property
> aTableProps
= xInfo
->getProperties();
322 Property
* pIter
= aTableProps
.getArray();
323 Property
* pEnd
= pIter
+ aTableProps
.getLength();
324 for (;pIter
!= pEnd
; ++pIter
)
326 if (pIter
->Name
== PROPERTY_CATALOGNAME
)
327 pIter
->Handle
= PROPERTY_ID_CATALOGNAME
;
328 else if (pIter
->Name
== PROPERTY_SCHEMANAME
)
329 pIter
->Handle
= PROPERTY_ID_SCHEMANAME
;
330 else if (pIter
->Name
== PROPERTY_NAME
)
331 pIter
->Handle
= PROPERTY_ID_NAME
;
332 else if (pIter
->Name
== PROPERTY_DESCRIPTION
)
333 pIter
->Handle
= PROPERTY_ID_DESCRIPTION
;
334 else if (pIter
->Name
== PROPERTY_TYPE
)
335 pIter
->Handle
= PROPERTY_ID_TYPE
;
336 else if (pIter
->Name
== PROPERTY_PRIVILEGES
)
337 pIter
->Handle
= PROPERTY_ID_PRIVILEGES
;
340 describeProperties(aTableProps
);
342 return new ::cppu::OPropertyArrayHelper(aTableProps
);
345 ::cppu::IPropertyArrayHelper
& SAL_CALL
ODBTableDecorator::getInfoHelper()
347 Reference
<XPropertySet
> xProp(m_xTable
,UNO_QUERY
);
349 Reference
<XPropertySetInfo
> xInfo
= xProp
->getPropertySetInfo();
350 bool bIsDescriptor
= (xInfo
->getPropertyByName(PROPERTY_NAME
).Attributes
& PropertyAttribute::READONLY
) == 0;
352 return *ODBTableDecorator_PROP::getArrayHelper( bIsDescriptor
? 0 : 1 );
354 // TODO: this is a HACK, and prone to errors
355 // The OIdPropertyArrayUsageHelper is intended for classes where there exists a known, limited
356 // number of different property set infos (distinguished by the ID), all implemented by this very
358 // However, in this case here we have an unknown, potentially unlimited number of different
359 // property set infos: Depending on the table for which we act as decorator, different property
364 IMPLEMENT_SERVICE_INFO1(ODBTableDecorator
, "com.sun.star.sdb.dbaccess.ODBTableDecorator", SERVICE_SDBCX_TABLE
)
366 Any SAL_CALL
ODBTableDecorator::queryInterface( const Type
& rType
) throw(RuntimeException
, std::exception
)
371 aRet
= m_xTable
->queryInterface(rType
);
373 { // now we know that our table supports this type so we return ourself
374 aRet
= OTableDescriptor_BASE::queryInterface(rType
);
376 aRet
= ODataSettings::queryInterface(rType
);
383 Sequence
< Type
> SAL_CALL
ODBTableDecorator::getTypes( ) throw(RuntimeException
, std::exception
)
385 Reference
<XTypeProvider
> xTypes(m_xTable
,UNO_QUERY
);
386 OSL_ENSURE(xTypes
.is(),"Table must be a TypePropvider!");
387 return xTypes
->getTypes();
391 void SAL_CALL
ODBTableDecorator::rename( const OUString
& _rNewName
) throw(SQLException
, ElementExistException
, RuntimeException
, std::exception
)
393 ::osl::MutexGuard
aGuard(m_aMutex
);
394 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper
.bDisposed
);
395 Reference
<XRename
> xRename(m_xTable
,UNO_QUERY
);
398 xRename
->rename(_rNewName
);
400 else // not supported
401 throw SQLException(DBACORE_RESSTRING(RID_STR_NO_TABLE_RENAME
),*this,SQLSTATE_GENERAL
,1000,Any() );
405 void SAL_CALL
ODBTableDecorator::alterColumnByName( const OUString
& _rName
, const Reference
< XPropertySet
>& _rxDescriptor
) throw(SQLException
, NoSuchElementException
, RuntimeException
, std::exception
)
407 ::osl::MutexGuard
aGuard(m_aMutex
);
408 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper
.bDisposed
);
409 Reference
<XAlterTable
> xAlter(m_xTable
,UNO_QUERY
);
412 xAlter
->alterColumnByName(_rName
,_rxDescriptor
);
415 throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_ALTER_BY_NAME
),*this,SQLSTATE_GENERAL
,1000,Any() );
417 m_pColumns
->refresh();
420 void SAL_CALL
ODBTableDecorator::alterColumnByIndex( sal_Int32 _nIndex
, const Reference
< XPropertySet
>& _rxDescriptor
) throw(SQLException
, IndexOutOfBoundsException
, RuntimeException
, std::exception
)
422 ::osl::MutexGuard
aGuard(m_aMutex
);
423 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper
.bDisposed
);
424 Reference
<XAlterTable
> xAlter(m_xTable
,UNO_QUERY
);
427 xAlter
->alterColumnByIndex(_nIndex
,_rxDescriptor
);
429 m_pColumns
->refresh();
431 else // not supported
432 throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_ALTER_BY_INDEX
),*this,SQLSTATE_GENERAL
,1000,Any() );
435 Reference
< XNameAccess
> ODBTableDecorator::getIndexes() throw (RuntimeException
, std::exception
)
437 ::osl::MutexGuard
aGuard(m_aMutex
);
438 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper
.bDisposed
);
439 return Reference
< XIndexesSupplier
>(m_xTable
,UNO_QUERY
)->getIndexes();
442 Reference
< XIndexAccess
> ODBTableDecorator::getKeys() throw (RuntimeException
, std::exception
)
444 ::osl::MutexGuard
aGuard(m_aMutex
);
445 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper
.bDisposed
);
446 return Reference
< XKeysSupplier
>(m_xTable
,UNO_QUERY
)->getKeys();
449 Reference
< XNameAccess
> ODBTableDecorator::getColumns() throw (RuntimeException
, std::exception
)
451 ::osl::MutexGuard
aGuard(m_aMutex
);
452 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper
.bDisposed
);
460 OUString SAL_CALL
ODBTableDecorator::getName() throw(RuntimeException
, std::exception
)
462 ::osl::MutexGuard
aGuard(m_aMutex
);
463 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper
.bDisposed
);
464 Reference
<XNamed
> xName(m_xTable
,UNO_QUERY
);
465 OSL_ENSURE(xName
.is(),"Table should support the XNamed interface");
466 return xName
->getName();
469 sal_Int64 SAL_CALL
ODBTableDecorator::getSomething( const Sequence
< sal_Int8
>& rId
) throw(RuntimeException
, std::exception
)
471 if (rId
.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId
.getConstArray(), 16 ) )
472 return reinterpret_cast<sal_Int64
>(this);
475 Reference
<XUnoTunnel
> xTunnel(m_xTable
,UNO_QUERY
);
477 nRet
= xTunnel
->getSomething(rId
);
481 Sequence
< sal_Int8
> ODBTableDecorator::getUnoTunnelImplementationId()
483 static ::cppu::OImplementationId
* pId
= 0;
486 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
489 static ::cppu::OImplementationId aId
;
493 return pId
->getImplementationId();
496 void ODBTableDecorator::fillPrivileges() const
498 // somebody is asking for the privileges and we do not know them, yet
502 Reference
<XPropertySet
> xProp(m_xTable
,UNO_QUERY
);
505 if ( xProp
->getPropertySetInfo()->hasPropertyByName(PROPERTY_PRIVILEGES
) )
507 xProp
->getPropertyValue(PROPERTY_PRIVILEGES
) >>= m_nPrivileges
;
509 if ( m_nPrivileges
== 0 ) // second chance
511 OUString sCatalog
,sSchema
,sName
;
512 xProp
->getPropertyValue(PROPERTY_CATALOGNAME
) >>= sCatalog
;
513 xProp
->getPropertyValue(PROPERTY_SCHEMANAME
) >>= sSchema
;
514 xProp
->getPropertyValue(PROPERTY_NAME
) >>= sName
;
515 m_nPrivileges
= ::dbtools::getTablePrivileges(getMetaData(),sCatalog
,sSchema
, sName
);
519 catch(const SQLException
& e
)
522 SAL_WARN("dbaccess", "ODBTableDecorator::ODBTableDecorator : could not collect the privileges !");
526 Reference
< XPropertySet
> SAL_CALL
ODBTableDecorator::createDataDescriptor( ) throw (RuntimeException
, std::exception
)
528 ::osl::MutexGuard
aGuard(m_aMutex
);
529 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper
.bDisposed
);
531 Reference
< XDataDescriptorFactory
> xFactory( m_xTable
, UNO_QUERY
);
532 OSL_ENSURE( xFactory
.is(), "ODBTableDecorator::createDataDescriptor: invalid table!" );
533 Reference
< XColumnsSupplier
> xColsSupp
;
535 xColsSupp
.set(xFactory
->createDataDescriptor(), css::uno::UNO_QUERY
);
537 return new ODBTableDecorator(
545 Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
ODBTableDecorator::getPropertySetInfo( ) throw(RuntimeException
, std::exception
)
547 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
550 void ODBTableDecorator::refreshColumns()
552 ::osl::MutexGuard
aGuard(m_aMutex
);
553 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper
.bDisposed
);
555 ::std::vector
< OUString
> aVector
;
557 Reference
<XNameAccess
> xNames
;
560 xNames
= m_xTable
->getColumns();
563 Sequence
< OUString
> aNames
= xNames
->getElementNames();
564 const OUString
* pIter
= aNames
.getConstArray();
565 const OUString
* pEnd
= pIter
+ aNames
.getLength();
566 for(;pIter
!= pEnd
;++pIter
)
567 aVector
.push_back(*pIter
);
572 OColumns
* pCol
= new OColumns(*this,m_aMutex
,xNames
,m_xMetaData
.is() && m_xMetaData
->supportsMixedCaseQuotedIdentifiers(),aVector
,
574 m_xMetaData
.is() && m_xMetaData
->supportsAlterTableWithAddColumn(),
575 m_xMetaData
.is() && m_xMetaData
->supportsAlterTableWithDropColumn());
577 pCol
->setParent(*this);
578 OContainerMediator
* pMediator
= new OContainerMediator( pCol
, m_xColumnDefinitions
, m_xConnection
);
579 m_xColumnMediator
= pMediator
;
580 pCol
->setMediator( pMediator
);
584 m_pColumns
->reFill(aVector
);
587 OColumn
* ODBTableDecorator::createColumn(const OUString
& _rName
) const
589 OColumn
* pReturn
= NULL
;
591 Reference
<XNameAccess
> xNames
;
594 xNames
= m_xTable
->getColumns();
596 if ( xNames
.is() && xNames
->hasByName(_rName
) )
598 Reference
<XPropertySet
> xProp(xNames
->getByName(_rName
),UNO_QUERY
);
600 Reference
<XPropertySet
> xColumnDefintion
;
601 if ( m_xColumnDefinitions
.is() && m_xColumnDefinitions
->hasByName(_rName
))
602 xColumnDefintion
.set(m_xColumnDefinitions
->getByName(_rName
),UNO_QUERY
);
604 pReturn
= new OTableColumnWrapper( xProp
, xColumnDefintion
, false );
610 void ODBTableDecorator::columnAppended( const Reference
< XPropertySet
>& /*_rxSourceDescriptor*/ )
615 void ODBTableDecorator::columnDropped(const OUString
& _sName
)
617 Reference
<XDrop
> xDrop(m_xColumnDefinitions
,UNO_QUERY
);
618 if ( xDrop
.is() && m_xColumnDefinitions
->hasByName(_sName
) )
619 xDrop
->dropByName(_sName
);
622 Reference
< XPropertySet
> ODBTableDecorator::createColumnDescriptor()
624 Reference
<XDataDescriptorFactory
> xNames
;
626 xNames
.set(m_xTable
->getColumns(),UNO_QUERY
);
627 Reference
< XPropertySet
> xRet
;
629 xRet
= new OTableColumnDescriptorWrapper( xNames
->createDataDescriptor(), false, true );
633 void SAL_CALL
ODBTableDecorator::acquire() throw()
635 OTableDescriptor_BASE::acquire();
638 void SAL_CALL
ODBTableDecorator::release() throw()
640 OTableDescriptor_BASE::release();
643 void SAL_CALL
ODBTableDecorator::setName( const OUString
& /*aName*/ ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
645 throwFunctionNotSupportedRuntimeException( "XNamed::setName", *this );
648 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */