1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: column.cxx,v $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #ifndef _DBA_COREAPI_COLUMN_HXX_
37 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
38 #include "dbastrings.hrc"
40 #ifndef _DBA_CORE_RESOURCE_HXX_
41 #include "core_resource.hxx"
43 #ifndef _DBA_CORE_RESOURCE_HRC_
44 #include "core_resource.hrc"
46 #ifndef _DBASHARED_APITOOLS_HXX_
47 #include "apitools.hxx"
49 #ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
50 #include <com/sun/star/sdbc/ColumnValue.hpp>
52 #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
53 #include <cppuhelper/typeprovider.hxx>
55 #ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
56 #include <com/sun/star/sdbc/DataType.hpp>
58 #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
59 #include <com/sun/star/lang/DisposedException.hpp>
61 #ifndef _COMPHELPER_SEQUENCE_HXX_
62 #include <comphelper/sequence.hxx>
64 #ifndef _COMPHELPER_PROPERTY_HXX_
65 #include <comphelper/property.hxx>
67 #ifndef _COMPHELPER_ENUMHELPER_HXX_
68 #include <comphelper/enumhelper.hxx>
70 #ifndef _COMPHELPER_TYPES_HXX_
71 #include <comphelper/types.hxx>
73 #ifndef _COMPHELPER_EXTRACT_HXX_
74 #include <comphelper/extract.hxx>
76 #ifndef _OSL_DIAGNOSE_H_
77 #include <osl/diagnose.h>
79 #ifndef _COMPHELPER_SEQSTREAM_HXX
80 #include <comphelper/seqstream.hxx>
82 #ifndef _COMPHELPER_BASIC_IO_HXX_
83 #include <comphelper/basicio.hxx>
85 #ifndef _TOOLS_DEBUG_HXX
86 #include <tools/debug.hxx>
88 #ifndef CONNECTIVITY_TABLEHELPER_HXX
89 #include <connectivity/TTableHelper.hxx>
91 #ifndef _DBACORE_DEFINITIONCOLUMN_HXX_
92 #include "definitioncolumn.hxx"
94 #ifndef _CONNECTIVITY_DBTOOLS_HXX_
95 #include <connectivity/dbtools.hxx>
97 #ifndef _DBHELPER_DBEXCEPTION_HXX_
98 #include <connectivity/dbexception.hxx>
100 #ifndef DBA_CONTAINERMEDIATOR_HXX
101 #include "ContainerMediator.hxx"
103 #ifndef DBACORE_SDBCORETOOLS_HXX
104 #include "sdbcoretools.hxx"
109 using namespace dbaccess
;
110 using namespace connectivity
;
111 using namespace connectivity
;
112 using namespace ::com::sun::star::sdbc
;
113 using namespace ::com::sun::star::sdbcx
;
114 using namespace ::com::sun::star::beans
;
115 using namespace ::com::sun::star::uno
;
116 using namespace ::com::sun::star::lang
;
117 using namespace ::com::sun::star::awt
;
118 using namespace ::com::sun::star::io
;
119 using namespace ::com::sun::star::container
;
120 using namespace ::com::sun::star::util
;
121 using namespace ::osl
;
122 using namespace ::comphelper
;
123 using namespace ::cppu
;
127 //============================================================
129 //============================================================
130 //--------------------------------------------------------------------------
132 :OColumnBase(m_aMutex
)
133 , OPropertySetHelper(OColumnBase::rBHelper
)
135 DBG_CTOR(OColumn
, NULL
);
138 //--------------------------------------------------------------------------
141 DBG_DTOR(OColumn
, NULL
);
144 // com::sun::star::lang::XTypeProvider
145 //--------------------------------------------------------------------------
146 Sequence
< Type
> OColumn::getTypes() throw (RuntimeException
)
148 OTypeCollection
aTypes(::getCppuType( (const Reference
< XPropertySet
> *)0 ),
149 ::getCppuType( (const Reference
< XMultiPropertySet
> *)0 ),
150 OColumnBase::getTypes());
151 return aTypes
.getTypes();
154 // com::sun::star::uno::XInterface
155 //--------------------------------------------------------------------------
156 Any
OColumn::queryInterface( const Type
& rType
) throw (RuntimeException
)
158 Any aIface
= OColumnBase::queryInterface( rType
);
159 if (!aIface
.hasValue())
160 aIface
= ::cppu::queryInterface(
162 static_cast< XPropertySet
* >( this ),
163 static_cast< XMultiPropertySet
* >( this ));
168 //--------------------------------------------------------------------------
169 void OColumn::acquire() throw()
171 OColumnBase::acquire();
174 //--------------------------------------------------------------------------
175 void OColumn::release() throw()
177 OColumnBase::release();
180 // ::com::sun::star::lang::XServiceInfo
181 //------------------------------------------------------------------------------
182 rtl::OUString
OColumn::getImplementationName( ) throw(RuntimeException
)
184 return rtl::OUString::createFromAscii("com.sun.star.sdb.OColumn");
187 //------------------------------------------------------------------------------
188 sal_Bool
OColumn::supportsService( const ::rtl::OUString
& _rServiceName
) throw (RuntimeException
)
190 return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName
, sal_True
).getLength() != 0;
193 //------------------------------------------------------------------------------
194 Sequence
< ::rtl::OUString
> OColumn::getSupportedServiceNames( ) throw (RuntimeException
)
196 Sequence
< ::rtl::OUString
> aSNS( 1 );
197 aSNS
[0] = SERVICE_SDBCX_COLUMN
;
202 //------------------------------------------------------------------------------
203 void OColumn::disposing()
205 OPropertySetHelper::disposing();
208 // com::sun::star::beans::XPropertySet
209 //------------------------------------------------------------------------------
210 Reference
< XPropertySetInfo
> OColumn::getPropertySetInfo() throw (RuntimeException
)
212 return createPropertySetInfo( getInfoHelper() ) ;
215 //------------------------------------------------------------------------------
216 void OColumn::getFastPropertyValue( Any
& rValue
, sal_Int32 nHandle
) const
220 case PROPERTY_ID_NAME
:
226 //------------------------------------------------------------------------------
227 sal_Bool
OColumn::convertFastPropertyValue(
228 Any
& rConvertedValue
,
232 throw (IllegalArgumentException
)
234 sal_Bool bModified
= sal_False
;
237 case PROPERTY_ID_NAME
:
238 bModified
= ::comphelper::tryPropertyValue(rConvertedValue
, rOldValue
, rValue
, m_sName
);
244 //------------------------------------------------------------------------------
245 void OColumn::setFastPropertyValue_NoBroadcast(
253 case PROPERTY_ID_NAME
:
254 OSL_ENSURE(rValue
.getValueType().equals(::getCppuType(static_cast< ::rtl::OUString
* >(NULL
))),
255 "OColumn::setFastPropertyValue_NoBroadcast(NAME) : invalid value !");
261 //--------------------------------------------------------------------------
262 Sequence
< sal_Int8
> OColumn::getUnoTunnelImplementationId()
264 static ::cppu::OImplementationId
* pId
= 0;
267 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
270 static ::cppu::OImplementationId aId
;
274 return pId
->getImplementationId();
277 // com::sun::star::lang::XUnoTunnel
278 //------------------------------------------------------------------
279 sal_Int64
OColumn::getSomething( const Sequence
< sal_Int8
> & rId
) throw (RuntimeException
)
281 if (rId
.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId
.getConstArray(), 16 ) )
282 return reinterpret_cast<sal_Int64
>(this);
286 // -----------------------------------------------------------------------------
287 ::rtl::OUString SAL_CALL
OColumn::getName( ) throw(::com::sun::star::uno::RuntimeException
)
291 // -----------------------------------------------------------------------------
292 void SAL_CALL
OColumn::setName( const ::rtl::OUString
& _rName
) throw(::com::sun::star::uno::RuntimeException
)
296 // -----------------------------------------------------------------------------
297 void OColumn::fireValueChange(const ::connectivity::ORowSetValue
& /*_rOldValue*/)
299 DBG_ERROR( "OColumn::fireValueChange: not implemented!" );
301 // -----------------------------------------------------------------------------
302 //============================================================
304 //============================================================
305 DBG_NAME( OColumnSettings
)
306 //------------------------------------------------------------------------------
307 OColumnSettings::OColumnSettings()
308 :m_bHidden(sal_False
)
310 DBG_CTOR( OColumnSettings
, NULL
);
313 //------------------------------------------------------------------------------
314 OColumnSettings::~OColumnSettings()
316 DBG_DTOR( OColumnSettings
, NULL
);
319 // com::sun::star::lang::XUnoTunnel
320 //------------------------------------------------------------------
321 sal_Int64
OColumnSettings::getSomething( const Sequence
< sal_Int8
> & rId
) throw (RuntimeException
)
323 if ( ( rId
.getLength() == 16 )
324 && ( 0 == rtl_compareMemory( getUnoTunnelImplementationId().getConstArray(), rId
.getConstArray(), 16 ) )
326 return reinterpret_cast< sal_Int64
>( this );
331 //--------------------------------------------------------------------------
332 Sequence
< sal_Int8
> OColumnSettings::getUnoTunnelImplementationId()
334 static ::cppu::OImplementationId
* pId
= 0;
337 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
340 static ::cppu::OImplementationId aId
;
344 return pId
->getImplementationId();
347 //------------------------------------------------------------------------------
348 void OColumnSettings::getFastPropertyValue( Any
& rValue
, sal_Int32 nHandle
) const
352 case PROPERTY_ID_ALIGN
:
353 rValue
= m_aAlignment
;
355 case PROPERTY_ID_NUMBERFORMAT
:
356 rValue
= m_aFormatKey
;
358 case PROPERTY_ID_RELATIVEPOSITION
:
359 rValue
= m_aRelativePosition
;
361 case PROPERTY_ID_WIDTH
:
364 case PROPERTY_ID_HIDDEN
:
365 rValue
.setValue(&m_bHidden
, getBooleanCppuType());
367 case PROPERTY_ID_CONTROLMODEL
:
368 rValue
<<= m_xControlModel
;
370 case PROPERTY_ID_HELPTEXT
:
371 rValue
= m_aHelpText
;
373 case PROPERTY_ID_CONTROLDEFAULT
:
374 rValue
= m_aControlDefault
;
379 //------------------------------------------------------------------------------
380 sal_Bool
OColumnSettings::convertFastPropertyValue(
381 Any
& rConvertedValue
,
385 throw (IllegalArgumentException
)
387 sal_Bool bModified
= sal_False
;
390 case PROPERTY_ID_ALIGN
:
391 bModified
= !uno_type_equalData(
392 const_cast< void* >( m_aAlignment
.getValue() ), m_aAlignment
.getValueType().getTypeLibType(),
393 const_cast< void* >( rValue
.getValue() ), rValue
.getValueType().getTypeLibType(),
394 reinterpret_cast< uno_QueryInterfaceFunc
>( cpp_queryInterface
),
395 reinterpret_cast< uno_ReleaseFunc
>( cpp_release
)
399 rConvertedValue
= rValue
;
400 rOldValue
= m_aAlignment
;
403 case PROPERTY_ID_WIDTH
:
404 bModified
= ::comphelper::tryPropertyValue(rConvertedValue
, rOldValue
, rValue
, m_aWidth
,
405 ::getCppuType(static_cast< sal_Int32
* >(NULL
)));
407 case PROPERTY_ID_HIDDEN
:
408 bModified
= ::comphelper::tryPropertyValue(rConvertedValue
, rOldValue
, rValue
, m_bHidden
);
410 case PROPERTY_ID_RELATIVEPOSITION
:
411 bModified
= ::comphelper::tryPropertyValue(rConvertedValue
, rOldValue
, rValue
, m_aRelativePosition
,
412 ::getCppuType(static_cast< sal_Int32
* >(NULL
)));
414 case PROPERTY_ID_NUMBERFORMAT
:
415 bModified
= ::comphelper::tryPropertyValue(rConvertedValue
, rOldValue
, rValue
, m_aFormatKey
,
416 ::getCppuType(static_cast< sal_Int32
* >(NULL
)));
418 case PROPERTY_ID_CONTROLMODEL
:
420 Reference
< XPropertySet
> xTest
;
421 if (!::cppu::extractInterface(xTest
, rValue
))
422 throw IllegalArgumentException();
423 if (xTest
.get() != m_xControlModel
.get())
425 bModified
= sal_True
;
426 rOldValue
<<= m_xControlModel
;
427 rConvertedValue
<<= rValue
;
431 case PROPERTY_ID_HELPTEXT
:
432 bModified
= ::comphelper::tryPropertyValue(rConvertedValue
, rOldValue
, rValue
, m_aHelpText
,
433 ::getCppuType(static_cast< ::rtl::OUString
* >(NULL
)));
435 case PROPERTY_ID_CONTROLDEFAULT
:
436 bModified
= rValue
!= m_aControlDefault
;
439 rConvertedValue
= rValue
;
440 rOldValue
= m_aControlDefault
;
447 //------------------------------------------------------------------------------
448 void OColumnSettings::setFastPropertyValue_NoBroadcast(
456 case PROPERTY_ID_ALIGN
:
458 if ( rValue
.hasValue() )
460 sal_Int32 nAlign
= 0;
462 // copy the data from the to-be-set value
464 static_cast< void* >( &nAlign
), ::getCppuType(static_cast< sal_Int32
* >(NULL
)).getTypeLibType(),
465 const_cast< void* >( rValue
.getValue() ), rValue
.getValueType().getTypeLibType(),
466 reinterpret_cast< uno_QueryInterfaceFunc
>( cpp_queryInterface
),
467 reinterpret_cast< uno_AcquireFunc
>( cpp_acquire
),
468 reinterpret_cast< uno_ReleaseFunc
>( cpp_release
) );
470 OSL_ENSURE( bSuccess
,
471 "OPropertyStateContainer::setFastPropertyValue_NoBroadcast : ooops .... the value could not be assigned!");
473 m_aAlignment
<<= nAlign
;
476 m_aAlignment
= rValue
;
480 case PROPERTY_ID_WIDTH
:
481 OSL_ENSURE(!rValue
.hasValue() || rValue
.getValueType().equals(::getCppuType(static_cast< sal_Int32
* >(NULL
))),
482 "OColumnSettings::setFastPropertyValue_NoBroadcast(WIDTH) : invalid value !");
485 case PROPERTY_ID_NUMBERFORMAT
:
486 OSL_ENSURE(!rValue
.hasValue() || rValue
.getValueType().equals(::getCppuType(static_cast< sal_Int32
* >(NULL
))),
487 "OColumnSettings::setFastPropertyValue_NoBroadcast(NUMBERFORMAT) : invalid value !");
488 m_aFormatKey
= rValue
;
490 case PROPERTY_ID_RELATIVEPOSITION
:
491 OSL_ENSURE(!rValue
.hasValue() || rValue
.getValueType().equals(::getCppuType(static_cast< sal_Int32
* >(NULL
))),
492 "OColumnSettings::setFastPropertyValue_NoBroadcast(ID_RELATIVEPOSITION) : invalid value !");
493 m_aRelativePosition
= rValue
;
495 case PROPERTY_ID_HIDDEN
:
496 OSL_ENSURE(rValue
.getValueType().equals(::getBooleanCppuType()),
497 "OColumnSettings::setFastPropertyValue_NoBroadcast(HIDDEN) : invalid value !");
498 m_bHidden
= ::comphelper::getBOOL(rValue
);
500 case PROPERTY_ID_HELPTEXT
:
501 OSL_ENSURE(!rValue
.hasValue() || rValue
.getValueType().equals(::getCppuType(static_cast< ::rtl::OUString
* >(NULL
))),
502 "OColumnSettings::setFastPropertyValue_NoBroadcast(ID_RELATIVEPOSITION) : invalid value !");
503 m_aHelpText
= rValue
;
505 case PROPERTY_ID_CONTROLDEFAULT
:
506 m_aControlDefault
= rValue
;
512 //------------------------------------------------------------------------------
513 sal_Bool
OColumnSettings::isDefaulted() const
515 return !m_aAlignment
.hasValue()
516 && !m_aWidth
.hasValue()
517 && !m_aFormatKey
.hasValue()
518 && !m_aRelativePosition
.hasValue()
519 && !m_aHelpText
.hasValue()
520 && !m_aControlDefault
.hasValue()
525 //============================================================
527 //============================================================
530 //--------------------------------------------------------------------------
531 OColumns::OColumns(::cppu::OWeakObject
& _rParent
,
532 ::osl::Mutex
& _rMutex
,
533 sal_Bool _bCaseSensitive
,const ::std::vector
< ::rtl::OUString
> &_rVector
,
534 IColumnFactory
* _pColFactory
,
535 ::connectivity::sdbcx::IRefreshableColumns
* _pRefresh
,
536 sal_Bool _bAddColumn
,
537 sal_Bool _bDropColumn
,
538 sal_Bool _bUseHardRef
)
539 : OColumns_BASE(_rParent
,_bCaseSensitive
,_rMutex
,_rVector
,_bUseHardRef
)
542 ,m_pColFactoryImpl(_pColFactory
)
543 ,m_pRefreshColumns(_pRefresh
)
544 ,m_bInitialized(sal_False
)
545 ,m_bAddColumn(_bAddColumn
)
546 ,m_bDropColumn(_bDropColumn
)
548 DBG_CTOR(OColumns
, NULL
);
550 // -------------------------------------------------------------------------
551 OColumns::OColumns(::cppu::OWeakObject
& _rParent
, ::osl::Mutex
& _rMutex
,
552 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>& _rxDrvColumns
,
553 sal_Bool _bCaseSensitive
,const ::std::vector
< ::rtl::OUString
> &_rVector
,
554 IColumnFactory
* _pColFactory
,
555 ::connectivity::sdbcx::IRefreshableColumns
* _pRefresh
,
556 sal_Bool _bAddColumn
,
557 sal_Bool _bDropColumn
,
558 sal_Bool _bUseHardRef
)
559 : OColumns_BASE(_rParent
,_bCaseSensitive
,_rMutex
,_rVector
,_bUseHardRef
)
561 ,m_xDrvColumns(_rxDrvColumns
)
562 ,m_pColFactoryImpl(_pColFactory
)
563 ,m_pRefreshColumns(_pRefresh
)
564 ,m_bInitialized(sal_False
)
565 ,m_bAddColumn(_bAddColumn
)
566 ,m_bDropColumn(_bDropColumn
)
568 DBG_CTOR(OColumns
, NULL
);
570 //--------------------------------------------------------------------------
571 OColumns::~OColumns()
573 DBG_DTOR(OColumns
, NULL
);
577 //------------------------------------------------------------------------------
578 rtl::OUString
OColumns::getImplementationName( ) throw(RuntimeException
)
580 return rtl::OUString::createFromAscii("com.sun.star.sdb.OColumns");
583 //------------------------------------------------------------------------------
584 sal_Bool
OColumns::supportsService( const ::rtl::OUString
& _rServiceName
) throw (RuntimeException
)
586 return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName
, sal_True
).getLength() != 0;
589 //------------------------------------------------------------------------------
590 Sequence
< ::rtl::OUString
> OColumns::getSupportedServiceNames( ) throw (RuntimeException
)
592 Sequence
< ::rtl::OUString
> aSNS( 1 );
593 aSNS
[0] = SERVICE_SDBCX_CONTAINER
;
597 //------------------------------------------------------------------
598 void OColumns::append( const ::rtl::OUString
& _rName
, OColumn
* _pColumn
)
600 MutexGuard
aGuard(m_rMutex
);
602 OSL_ENSURE( _pColumn
, "OColumns::append: invalid column!" );
603 OSL_ENSURE( !m_pElements
->exists( _rName
),"OColumns::append: Column already exists");
605 _pColumn
->m_sName
= _rName
;
607 // now really insert the column
608 insertElement( _rName
, _pColumn
);
611 //------------------------------------------------------------------
612 void OColumns::clearColumns()
614 MutexGuard
aGuard(m_rMutex
);
618 // -----------------------------------------------------------------------------
619 void SAL_CALL
OColumns::disposing(void)
621 MutexGuard
aGuard(m_rMutex
);
622 m_xDrvColumns
= NULL
;
624 m_pColFactoryImpl
= NULL
;
625 OColumns_BASE::disposing();
628 // -------------------------------------------------------------------------
629 void OColumns::impl_refresh() throw(::com::sun::star::uno::RuntimeException
)
631 if (m_pRefreshColumns
)
632 m_pRefreshColumns
->refreshColumns();
635 // -------------------------------------------------------------------------
636 connectivity::sdbcx::ObjectType
OColumns::createObject(const ::rtl::OUString
& _rName
)
638 OSL_ENSURE(m_pColFactoryImpl
, "OColumns::createObject: no column factory!");
640 connectivity::sdbcx::ObjectType xRet
;
641 if ( m_pColFactoryImpl
)
643 xRet
= m_pColFactoryImpl
->createColumn(_rName
);
644 Reference
<XChild
> xChild(xRet
,UNO_QUERY
);
646 xChild
->setParent(static_cast<XChild
*>(static_cast<TXChild
*>(this)));
649 Reference
<XPropertySet
> xDest(xRet
,UNO_QUERY
);
650 if ( m_pMediator
&& xDest
.is() )
651 m_pMediator
->notifyElementCreated(_rName
,xDest
);
655 // -------------------------------------------------------------------------
656 Reference
< XPropertySet
> OColumns::createDescriptor()
658 if ( m_pColFactoryImpl
)
660 Reference
<XPropertySet
> xRet
= m_pColFactoryImpl
->createColumnDescriptor();
661 Reference
<XChild
> xChild(xRet
,UNO_QUERY
);
663 xChild
->setParent(static_cast<XChild
*>(static_cast<TXChild
*>(this)));
667 return Reference
< XPropertySet
>();
669 // -------------------------------------------------------------------------
670 Any SAL_CALL
OColumns::queryInterface( const Type
& rType
) throw(RuntimeException
)
673 if(m_xDrvColumns
.is())
675 aRet
= m_xDrvColumns
->queryInterface(rType
);
676 if ( aRet
.hasValue() )
677 aRet
= OColumns_BASE::queryInterface( rType
);
678 if ( !aRet
.hasValue() )
679 aRet
= TXChild::queryInterface( rType
);
682 else if(!m_pTable
|| (m_pTable
&& !m_pTable
->isNew()))
684 if(!m_bAddColumn
&& rType
== getCppuType( (Reference
<XAppend
>*)0))
686 if(!m_bDropColumn
&& rType
== getCppuType( (Reference
<XDrop
>*)0))
690 aRet
= OColumns_BASE::queryInterface( rType
);
691 if ( !aRet
.hasValue() )
692 aRet
= TXChild::queryInterface( rType
);
695 // -------------------------------------------------------------------------
696 Sequence
< Type
> SAL_CALL
OColumns::getTypes( ) throw(RuntimeException
)
698 sal_Bool bAppendFound
= sal_False
,bDropFound
= sal_False
;
701 Type aAppendType
= getCppuType( (Reference
<XAppend
>*)0);
702 Type aDropType
= getCppuType( (Reference
<XDrop
>*)0);
703 if(m_xDrvColumns
.is())
705 Reference
<XTypeProvider
> xTypes(m_xDrvColumns
,UNO_QUERY
);
706 Sequence
< Type
> aTypes(xTypes
->getTypes());
708 Sequence
< Type
> aSecTypes(OColumns_BASE::getTypes());
711 const Type
* pBegin
= aTypes
.getConstArray();
712 const Type
* pEnd
= pBegin
+ aTypes
.getLength();
713 for (;pBegin
!= pEnd
; ++pBegin
)
715 if(aAppendType
== *pBegin
)
716 bAppendFound
= sal_True
;
717 else if(aDropType
== *pBegin
)
718 bDropFound
= sal_True
;
720 nSize
= (bDropFound
? (bAppendFound
? 0 : 1) : (bAppendFound
? 1 : 2));
724 nSize
= ((m_pTable
&& m_pTable
->isNew()) ? 0 :
726 (m_bAddColumn
? 0 : 1) : (m_bAddColumn
? 1 : 2))));
727 bDropFound
= (m_pTable
&& m_pTable
->isNew()) || m_bDropColumn
;
728 bAppendFound
= (m_pTable
&& m_pTable
->isNew()) || m_bAddColumn
;
730 Sequence
< Type
> aTypes(::comphelper::concatSequences(OColumns_BASE::getTypes(),TXChild::getTypes()));
731 Sequence
< Type
> aRet(aTypes
.getLength() - nSize
);
733 const Type
* pBegin
= aTypes
.getConstArray();
734 const Type
* pEnd
= pBegin
+ aTypes
.getLength();
735 for(sal_Int32 i
=0;pBegin
!= pEnd
;++pBegin
)
737 if(*pBegin
!= aAppendType
&& *pBegin
!= aDropType
)
738 aRet
.getArray()[i
++] = *pBegin
;
739 else if(bDropFound
&& *pBegin
== aDropType
)
740 aRet
.getArray()[i
++] = *pBegin
;
741 else if(bAppendFound
&& *pBegin
== aAppendType
)
742 aRet
.getArray()[i
++] = *pBegin
;
746 // -------------------------------------------------------------------------
748 sdbcx::ObjectType
OColumns::appendObject( const ::rtl::OUString
& _rForName
, const Reference
< XPropertySet
>& descriptor
)
750 sdbcx::ObjectType xReturn
;
752 Reference
< XAppend
> xAppend( m_xDrvColumns
, UNO_QUERY
);
755 xAppend
->appendByDescriptor(descriptor
);
756 xReturn
= createObject( _rForName
);
758 else if ( m_pTable
&& !m_pTable
->isNew() )
761 xReturn
= OColumns_BASE::appendObject( _rForName
, descriptor
);
763 ::dbtools::throwGenericSQLException( DBA_RES( RID_STR_NO_COLUMN_ADD
), static_cast<XChild
*>(static_cast<TXChild
*>(this)) );
766 xReturn
= cloneDescriptor( descriptor
);
768 if ( m_pColFactoryImpl
)
769 m_pColFactoryImpl
->columnAppended( descriptor
);
771 ::dbaccess::notifyDataSourceModified(m_xParent
,sal_True
);
775 // -------------------------------------------------------------------------
777 void OColumns::dropObject(sal_Int32 _nPos
,const ::rtl::OUString _sElementName
)
779 Reference
< XDrop
> xDrop( m_xDrvColumns
, UNO_QUERY
);
782 xDrop
->dropByName( _sElementName
);
784 else if ( m_pTable
&& !m_pTable
->isNew() )
787 OColumns_BASE::dropObject(_nPos
,_sElementName
);
789 ::dbtools::throwGenericSQLException( DBA_RES( RID_STR_NO_COLUMN_DROP
), static_cast<XChild
*>(static_cast<TXChild
*>(this)) );
792 if ( m_pColFactoryImpl
)
793 m_pColFactoryImpl
->columnDropped(_sElementName
);
795 ::dbaccess::notifyDataSourceModified(m_xParent
,sal_True
);
797 // -----------------------------------------------------------------------------
799 Reference
< XInterface
> SAL_CALL
OColumns::getParent( ) throw (RuntimeException
)
801 ::osl::MutexGuard
aGuard(m_rMutex
);
804 // -----------------------------------------------------------------------------
805 void SAL_CALL
OColumns::setParent( const Reference
< XInterface
>& _xParent
) throw (NoSupportException
, RuntimeException
)
807 ::osl::MutexGuard
aGuard(m_rMutex
);
808 m_xParent
= _xParent
;
810 // -----------------------------------------------------------------------------