1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _DBACORE_DEFINITIONCOLUMN_HXX_ 24 #define _DBACORE_DEFINITIONCOLUMN_HXX_ 25 26 #include "apitools.hxx" 27 #include "column.hxx" 28 #include "columnsettings.hxx" 29 30 #include <com/sun/star/sdbc/DataType.hpp> 31 #include <com/sun/star/sdbc/ColumnValue.hpp> 32 #include <com/sun/star/container/XChild.hpp> 33 34 #include <comphelper/IdPropArrayHelper.hxx> 35 #include <comphelper/uno3.hxx> 36 #include <cppuhelper/implbase1.hxx> 37 38 39 namespace dbaccess 40 { 41 42 typedef ::cppu::ImplHelper1< ::com::sun::star::container::XChild > TXChild; 43 // ========================================================================= 44 //= OTableColumnDescriptor 45 // ========================================================================= 46 /** 47 * provides the properties for description. A descriptor could be used to create a new table column. 48 */ 49 class OTableColumnDescriptor : public OColumn 50 ,public OColumnSettings 51 ,public ::comphelper::OPropertyArrayUsageHelper < OTableColumnDescriptor > 52 ,public TXChild 53 { 54 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent; 55 const bool m_bActAsDescriptor; 56 57 protected: 58 // <properties> 59 rtl::OUString m_aTypeName; 60 rtl::OUString m_aDescription; 61 rtl::OUString m_aDefaultValue; 62 rtl::OUString m_aAutoIncrementValue; 63 sal_Int32 m_nType; 64 sal_Int32 m_nPrecision; 65 sal_Int32 m_nScale; 66 sal_Int32 m_nIsNullable; 67 sal_Bool m_bAutoIncrement; 68 sal_Bool m_bRowVersion; 69 sal_Bool m_bCurrency; 70 // </properties> 71 72 public: OTableColumnDescriptor(const bool _bActAsDescriptor)73 OTableColumnDescriptor( const bool _bActAsDescriptor ) 74 :OColumn( !_bActAsDescriptor ) 75 ,m_bActAsDescriptor( _bActAsDescriptor ) 76 ,m_nType( ::com::sun::star::sdbc::DataType::SQLNULL ) 77 ,m_nPrecision( 0 ) 78 ,m_nScale( 0 ) 79 ,m_nIsNullable( ::com::sun::star::sdbc::ColumnValue::NULLABLE_UNKNOWN ) 80 ,m_bAutoIncrement( sal_False ) 81 ,m_bRowVersion( sal_False ) 82 ,m_bCurrency( sal_False ) 83 { 84 impl_registerProperties(); 85 } 86 87 DECLARE_XINTERFACE( ) 88 89 // com::sun::star::lang::XTypeProvider 90 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(); 91 92 // ::com::sun::star::lang::XServiceInfo 93 virtual ::rtl::OUString SAL_CALL getImplementationName( ); 94 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ); 95 96 // ::com::sun::star::container::XChild 97 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ); 98 virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ); 99 100 // ::comphelper::OPropertyArrayUsageHelper 101 virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; 102 103 // ::cppu::OPropertySetHelper 104 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 105 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ); 106 107 private: 108 void impl_registerProperties(); 109 }; 110 111 // ========================================================================= 112 // = OTableColumn 113 // ========================================================================= 114 class OTableColumn; 115 typedef ::comphelper::OPropertyArrayUsageHelper < OTableColumn > OTableColumn_PBase; 116 /** describes a column of a table 117 */ 118 class OTableColumn :public OTableColumnDescriptor 119 ,public OTableColumn_PBase 120 { 121 protected: 122 virtual ~OTableColumn(); 123 124 public: 125 OTableColumn(const ::rtl::OUString& _rName); 126 127 // XTypeProvider 128 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(); 129 130 // XServiceInfo 131 virtual ::rtl::OUString SAL_CALL getImplementationName( ); 132 133 // OPropertyArrayUsageHelper 134 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 135 virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; 136 }; 137 138 // ========================================================================= 139 // = OQueryColumn 140 // ========================================================================= 141 class OQueryColumn; 142 typedef ::comphelper::OPropertyArrayUsageHelper< OQueryColumn > OQueryColumn_PBase; 143 /** a column of a Query, with additional information obtained from parsing the query statement 144 */ 145 class OQueryColumn :public OTableColumnDescriptor 146 ,public OQueryColumn_PBase 147 { 148 // <properties> 149 ::rtl::OUString m_sCatalogName; 150 ::rtl::OUString m_sSchemaName; 151 ::rtl::OUString m_sTableName; 152 ::rtl::OUString m_sRealName; 153 ::rtl::OUString m_sLabel; 154 // </properties> 155 156 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xOriginalTableColumn; 157 158 protected: 159 ~OQueryColumn(); 160 161 public: 162 OQueryColumn( 163 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxParserColumn, 164 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, 165 const ::rtl::OUString i_sLabel 166 ); 167 168 // XTypeProvider 169 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(); 170 171 // XServiceInfo 172 virtual ::rtl::OUString SAL_CALL getImplementationName( ); 173 174 // *Property* 175 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 176 virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; 177 virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; 178 179 private: 180 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > 181 impl_determineOriginalTableColumn( 182 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection 183 ); 184 185 using ::cppu::OPropertySetHelper::getFastPropertyValue; 186 }; 187 188 // ========================================================================= 189 // = OColumnWrapper 190 // ========================================================================= 191 /** 192 * describes all properties for a columns of a table. Only the view parts are provided 193 * directly, all the other parts are derived from a driver implementation 194 */ 195 class OColumnWrapper :public OColumn 196 { 197 protected: 198 // definition which is provided by a driver! 199 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > 200 m_xAggregate; 201 202 sal_Int32 m_nColTypeID; 203 204 protected: 205 OColumnWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rCol, const bool _bNameIsReadOnly ); 206 virtual ~OColumnWrapper(); 207 208 public: 209 virtual void SAL_CALL getFastPropertyValue( 210 ::com::sun::star::uno::Any& rValue, 211 sal_Int32 nHandle 212 ) const; 213 virtual sal_Bool SAL_CALL convertFastPropertyValue( 214 ::com::sun::star::uno::Any & rConvertedValue, 215 ::com::sun::star::uno::Any & rOldValue, 216 sal_Int32 nHandle, 217 const ::com::sun::star::uno::Any& rValue ); 218 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 219 sal_Int32 nHandle, 220 const ::com::sun::star::uno::Any& rValue 221 ); 222 223 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ); 224 225 protected: 226 ::rtl::OUString impl_getPropertyNameFromHandle( const sal_Int32 _nHandle ) const; 227 228 protected: 229 using OColumn::getFastPropertyValue; 230 }; 231 232 // ========================================================================= 233 // = OTableColumnDescriptorWrapper 234 // ========================================================================= 235 /** 236 * provides the properties for description. A descriptor could be used to create a new table column. 237 */ 238 class OTableColumnDescriptorWrapper :public OColumnWrapper 239 ,public OColumnSettings 240 ,public ::comphelper::OIdPropertyArrayUsageHelper < OTableColumnDescriptorWrapper > 241 { 242 const bool m_bPureWrap; 243 const bool m_bIsDescriptor; 244 245 public: 246 OTableColumnDescriptorWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rCol, 247 const bool _bPureWrap, const bool _bIsDescriptor ); 248 249 // com::sun::star::lang::XTypeProvider 250 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(); 251 252 // ::com::sun::star::lang::XServiceInfo 253 virtual ::rtl::OUString SAL_CALL getImplementationName( ); 254 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ); 255 256 // OIdPropertyArrayUsageHelper 257 virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const; 258 259 // cppu::OPropertySetHelper 260 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 261 virtual void SAL_CALL getFastPropertyValue( 262 ::com::sun::star::uno::Any& rValue, 263 sal_Int32 nHandle 264 ) const; 265 virtual sal_Bool SAL_CALL convertFastPropertyValue( 266 ::com::sun::star::uno::Any & rConvertedValue, 267 ::com::sun::star::uno::Any & rOldValue, 268 sal_Int32 nHandle, 269 const ::com::sun::star::uno::Any& rValue ); 270 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 271 sal_Int32 nHandle, 272 const ::com::sun::star::uno::Any& rValue 273 ); 274 275 protected: 276 using OColumnWrapper::getFastPropertyValue; 277 }; 278 279 // ========================================================================= 280 // = OTableColumnWrapper 281 // ========================================================================= 282 /** 283 * describes all properties for a columns of a table. Only the view parts are provided 284 * directly, all the other parts are derived from a driver implementation 285 */ 286 class OTableColumnWrapper :public OTableColumnDescriptorWrapper 287 ,public ::comphelper::OIdPropertyArrayUsageHelper < OTableColumnWrapper > 288 { 289 protected: 290 ~OTableColumnWrapper(); 291 292 public: 293 OTableColumnWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rCol, 294 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rColDefintion, 295 const bool _bPureWrap ); 296 297 // ::com::sun::star::lang::XTypeProvider 298 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(); 299 300 // ::com::sun::star::lang::XServiceInfo 301 virtual ::rtl::OUString SAL_CALL getImplementationName( ); 302 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ); 303 304 // OIdPropertyArrayUsageHelper 305 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 306 virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const; 307 }; 308 } 309 #endif // _DBACORE_DEFINITIONCOLUMN_HXX_ 310