1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_connectivity.hxx" 30 #include "connectivity/sdbcx/VKeyColumn.hxx" 31 #include "TConnection.hxx" 32 33 using namespace connectivity; 34 using namespace connectivity::sdbcx; 35 using namespace ::com::sun::star::beans; 36 using namespace ::com::sun::star::uno; 37 using namespace cppu; 38 // ----------------------------------------------------------------------------- 39 ::rtl::OUString SAL_CALL OKeyColumn::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) 40 { 41 if(isNew()) 42 return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VKeyColumnDescription"); 43 return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VKeyColumn"); 44 } 45 // ----------------------------------------------------------------------------- 46 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OKeyColumn::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) 47 { 48 ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1); 49 if(isNew()) 50 aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.KeyColumnDescription"); 51 else 52 aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.KeyColumn"); 53 54 return aSupported; 55 } 56 // ----------------------------------------------------------------------------- 57 sal_Bool SAL_CALL OKeyColumn::supportsService( const ::rtl::OUString& _rServiceName ) throw(::com::sun::star::uno::RuntimeException) 58 { 59 Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); 60 const ::rtl::OUString* pSupported = aSupported.getConstArray(); 61 const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); 62 for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported) 63 ; 64 65 return pSupported != pEnd; 66 } 67 // ------------------------------------------------------------------------- 68 OKeyColumn::OKeyColumn(sal_Bool _bCase) : OColumn(_bCase) 69 { 70 construct(); 71 } 72 // ------------------------------------------------------------------------- 73 OKeyColumn::OKeyColumn( const ::rtl::OUString& _ReferencedColumn, 74 const ::rtl::OUString& _Name, 75 const ::rtl::OUString& _TypeName, 76 const ::rtl::OUString& _DefaultValue, 77 sal_Int32 _IsNullable, 78 sal_Int32 _Precision, 79 sal_Int32 _Scale, 80 sal_Int32 _Type, 81 sal_Bool _IsAutoIncrement, 82 sal_Bool _IsRowVersion, 83 sal_Bool _IsCurrency, 84 sal_Bool _bCase 85 ) : OColumn(_Name, 86 _TypeName, 87 _DefaultValue, 88 ::rtl::OUString(), 89 _IsNullable, 90 _Precision, 91 _Scale, 92 _Type, 93 _IsAutoIncrement, 94 _IsRowVersion, 95 _IsCurrency, 96 _bCase) 97 , m_ReferencedColumn(_ReferencedColumn) 98 { 99 construct(); 100 } 101 // ------------------------------------------------------------------------- 102 OKeyColumn::~OKeyColumn() 103 { 104 } 105 // ----------------------------------------------------------------------------- 106 ::cppu::IPropertyArrayHelper* OKeyColumn::createArrayHelper( sal_Int32 /*_nId*/ ) const 107 { 108 return doCreateArrayHelper(); 109 } 110 // ----------------------------------------------------------------------------- 111 ::cppu::IPropertyArrayHelper& SAL_CALL OKeyColumn::getInfoHelper() 112 { 113 return *OKeyColumn_PROP::getArrayHelper(isNew() ? 1 : 0); 114 } 115 // ------------------------------------------------------------------------- 116 void OKeyColumn::construct() 117 { 118 sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY; 119 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RELATEDCOLUMN), PROPERTY_ID_RELATEDCOLUMN, nAttrib,&m_ReferencedColumn, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); 120 } 121 // ----------------------------------------------------------------------------- 122 123 124 125 126