1*2e2212a7SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2e2212a7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2e2212a7SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2e2212a7SAndrew Rist * distributed with this work for additional information 6*2e2212a7SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2e2212a7SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2e2212a7SAndrew Rist * "License"); you may not use this file except in compliance 9*2e2212a7SAndrew Rist * with the License. You may obtain a copy of the License at 10*2e2212a7SAndrew Rist * 11*2e2212a7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2e2212a7SAndrew Rist * 13*2e2212a7SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2e2212a7SAndrew Rist * software distributed under the License is distributed on an 15*2e2212a7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2e2212a7SAndrew Rist * KIND, either express or implied. See the License for the 17*2e2212a7SAndrew Rist * specific language governing permissions and limitations 18*2e2212a7SAndrew Rist * under the License. 19*2e2212a7SAndrew Rist * 20*2e2212a7SAndrew Rist *************************************************************/ 21*2e2212a7SAndrew Rist 22*2e2212a7SAndrew Rist 23cdf0e10cSrcweir #ifndef DBAUI_TYPEINFO_HXX 24cdf0e10cSrcweir #define DBAUI_TYPEINFO_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifndef _RTL_USTRING_HXX_ 28cdf0e10cSrcweir #include <rtl/ustring.hxx> 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ 31cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp> 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_COLUMNSEARCH_HPP_ 34cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnSearch.hpp> 35cdf0e10cSrcweir #endif 36cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ 37cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnValue.hpp> 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 40cdf0e10cSrcweir #include <map> 41cdf0e10cSrcweir 42cdf0e10cSrcweir 43cdf0e10cSrcweir 44cdf0e10cSrcweir namespace dbaui 45cdf0e10cSrcweir { 46cdf0e10cSrcweir //======================================================================== 47cdf0e10cSrcweir // Anhand dieser Ids werden die sprachabhaengigen ::rtl::OUString aus der Resource geholt 48cdf0e10cSrcweir const sal_uInt16 TYPE_UNKNOWN = 0; 49cdf0e10cSrcweir const sal_uInt16 TYPE_TEXT = 1; 50cdf0e10cSrcweir const sal_uInt16 TYPE_NUMERIC = 2; 51cdf0e10cSrcweir const sal_uInt16 TYPE_DATETIME = 3; 52cdf0e10cSrcweir const sal_uInt16 TYPE_DATE = 4; 53cdf0e10cSrcweir const sal_uInt16 TYPE_TIME = 5; 54cdf0e10cSrcweir const sal_uInt16 TYPE_BOOL = 6; 55cdf0e10cSrcweir const sal_uInt16 TYPE_CURRENCY = 7; 56cdf0e10cSrcweir const sal_uInt16 TYPE_MEMO = 8; 57cdf0e10cSrcweir const sal_uInt16 TYPE_COUNTER = 9; 58cdf0e10cSrcweir const sal_uInt16 TYPE_IMAGE = 10; 59cdf0e10cSrcweir const sal_uInt16 TYPE_CHAR = 11; 60cdf0e10cSrcweir const sal_uInt16 TYPE_DECIMAL = 12; 61cdf0e10cSrcweir const sal_uInt16 TYPE_BINARY = 13; 62cdf0e10cSrcweir const sal_uInt16 TYPE_VARBINARY = 14; 63cdf0e10cSrcweir const sal_uInt16 TYPE_BIGINT = 15; 64cdf0e10cSrcweir const sal_uInt16 TYPE_DOUBLE = 16; 65cdf0e10cSrcweir const sal_uInt16 TYPE_FLOAT = 17; 66cdf0e10cSrcweir const sal_uInt16 TYPE_REAL = 18; 67cdf0e10cSrcweir const sal_uInt16 TYPE_INTEGER = 19; 68cdf0e10cSrcweir const sal_uInt16 TYPE_SMALLINT = 20; 69cdf0e10cSrcweir const sal_uInt16 TYPE_TINYINT = 21; 70cdf0e10cSrcweir const sal_uInt16 TYPE_SQLNULL = 22; 71cdf0e10cSrcweir const sal_uInt16 TYPE_OBJECT = 23; 72cdf0e10cSrcweir const sal_uInt16 TYPE_DISTINCT = 24; 73cdf0e10cSrcweir const sal_uInt16 TYPE_STRUCT = 25; 74cdf0e10cSrcweir const sal_uInt16 TYPE_ARRAY = 26; 75cdf0e10cSrcweir const sal_uInt16 TYPE_BLOB = 27; 76cdf0e10cSrcweir const sal_uInt16 TYPE_CLOB = 28; 77cdf0e10cSrcweir const sal_uInt16 TYPE_REF = 29; 78cdf0e10cSrcweir const sal_uInt16 TYPE_OTHER = 30; 79cdf0e10cSrcweir const sal_uInt16 TYPE_BIT = 31; 80cdf0e10cSrcweir 81cdf0e10cSrcweir class OTypeInfo 82cdf0e10cSrcweir { 83cdf0e10cSrcweir public: 84cdf0e10cSrcweir ::rtl::OUString aUIName; // the name which is the user see (a combination of resource text and aTypeName) 85cdf0e10cSrcweir ::rtl::OUString aTypeName; // Name des Types in der Datenbank 86cdf0e10cSrcweir ::rtl::OUString aLiteralPrefix; // Prefix zum Quoten 87cdf0e10cSrcweir ::rtl::OUString aLiteralSuffix; // Suffix zum Quoten 88cdf0e10cSrcweir ::rtl::OUString aCreateParams; // Parameter zum Erstellen 89cdf0e10cSrcweir ::rtl::OUString aLocalTypeName; 90cdf0e10cSrcweir 91cdf0e10cSrcweir sal_Int32 nPrecision; // Laenge des Types 92cdf0e10cSrcweir sal_Int32 nType; // Datenbanktyp 93cdf0e10cSrcweir 94cdf0e10cSrcweir sal_Int16 nMaximumScale; // Nachkommastellen 95cdf0e10cSrcweir sal_Int16 nMinimumScale; // Min Nachkommastellen 96cdf0e10cSrcweir 97cdf0e10cSrcweir sal_Int16 nSearchType; // kann nach dem Typen gesucht werden 98cdf0e10cSrcweir 99cdf0e10cSrcweir 100cdf0e10cSrcweir sal_Bool bCurrency : 1, // Waehrung 101cdf0e10cSrcweir bAutoIncrement : 1, // Ist es ein automatisch incrementierendes Feld 102cdf0e10cSrcweir bNullable : 1, // Kann das Feld NULL annehmen 103cdf0e10cSrcweir bCaseSensitive : 1, // Ist der Type Casesensitive 104cdf0e10cSrcweir bUnsigned : 1; // Ist der Type Unsigned 105cdf0e10cSrcweir OTypeInfo()106cdf0e10cSrcweir OTypeInfo() 107cdf0e10cSrcweir :nPrecision(0) 108cdf0e10cSrcweir ,nType(::com::sun::star::sdbc::DataType::OTHER) 109cdf0e10cSrcweir ,nMaximumScale(0) 110cdf0e10cSrcweir ,nMinimumScale(0) 111cdf0e10cSrcweir ,nSearchType(::com::sun::star::sdbc::ColumnSearch::FULL) 112cdf0e10cSrcweir ,bCurrency(sal_False) 113cdf0e10cSrcweir ,bAutoIncrement(sal_False) 114cdf0e10cSrcweir ,bNullable(sal_True) 115cdf0e10cSrcweir ,bCaseSensitive(sal_False) 116cdf0e10cSrcweir ,bUnsigned(sal_False) 117cdf0e10cSrcweir {} operator ==(const OTypeInfo & lh) const118cdf0e10cSrcweir sal_Bool operator == (const OTypeInfo& lh) const { return lh.nType == nType; } operator !=(const OTypeInfo & lh) const119cdf0e10cSrcweir sal_Bool operator != (const OTypeInfo& lh) const { return lh.nType != nType; } getDBName() const120cdf0e10cSrcweir inline ::rtl::OUString getDBName() const { return aTypeName; } 121cdf0e10cSrcweir 122cdf0e10cSrcweir }; 123cdf0e10cSrcweir 124cdf0e10cSrcweir typedef ::boost::shared_ptr<OTypeInfo> TOTypeInfoSP; 125cdf0e10cSrcweir typedef ::std::multimap<sal_Int32,TOTypeInfoSP> OTypeInfoMap; 126cdf0e10cSrcweir /** return the most suitable typeinfo for a requested type 127cdf0e10cSrcweir @param _rTypeInfo contains a map of type to typeinfo 128cdf0e10cSrcweir @param _nType the requested type 129cdf0e10cSrcweir @param _sTypeName the typename 130cdf0e10cSrcweir @param _sCreateParams the create params 131cdf0e10cSrcweir @param _nPrecision the precision 132cdf0e10cSrcweir @param _nScale the scale 133cdf0e10cSrcweir @param _bAutoIncrement if it is a auto increment 134cdf0e10cSrcweir @param _brForceToType true when type was found which has some differenes 135cdf0e10cSrcweir */ 136cdf0e10cSrcweir TOTypeInfoSP getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo, 137cdf0e10cSrcweir sal_Int32 _nType, 138cdf0e10cSrcweir const ::rtl::OUString& _sTypeName, 139cdf0e10cSrcweir const ::rtl::OUString& _sCreateParams, 140cdf0e10cSrcweir sal_Int32 _nPrecision, 141cdf0e10cSrcweir sal_Int32 _nScale, 142cdf0e10cSrcweir sal_Bool _bAutoIncrement, 143cdf0e10cSrcweir sal_Bool& _brForceToType); 144cdf0e10cSrcweir } 145cdf0e10cSrcweir 146cdf0e10cSrcweir #endif // DBAUI_TYPEINFO_HXX 147cdf0e10cSrcweir 148cdf0e10cSrcweir 149