xref: /aoo42x/main/dbaccess/source/ui/inc/TypeInfo.hxx (revision 2e2212a7)
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 DBAUI_TYPEINFO_HXX
24 #define DBAUI_TYPEINFO_HXX
25 
26 
27 #ifndef _RTL_USTRING_HXX_
28 #include <rtl/ustring.hxx>
29 #endif
30 #ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
31 #include <com/sun/star/sdbc/DataType.hpp>
32 #endif
33 #ifndef _COM_SUN_STAR_SDBC_COLUMNSEARCH_HPP_
34 #include <com/sun/star/sdbc/ColumnSearch.hpp>
35 #endif
36 #ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
37 #include <com/sun/star/sdbc/ColumnValue.hpp>
38 #endif
39 #include <boost/shared_ptr.hpp>
40 #include <map>
41 
42 
43 
44 namespace dbaui
45 {
46 //========================================================================
47 // Anhand dieser Ids werden die sprachabhaengigen ::rtl::OUString aus der Resource geholt
48 const sal_uInt16 TYPE_UNKNOWN	= 0;
49 const sal_uInt16 TYPE_TEXT		= 1;
50 const sal_uInt16 TYPE_NUMERIC	= 2;
51 const sal_uInt16 TYPE_DATETIME	= 3;
52 const sal_uInt16 TYPE_DATE		= 4;
53 const sal_uInt16 TYPE_TIME		= 5;
54 const sal_uInt16 TYPE_BOOL		= 6;
55 const sal_uInt16 TYPE_CURRENCY	= 7;
56 const sal_uInt16 TYPE_MEMO		= 8;
57 const sal_uInt16 TYPE_COUNTER	= 9;
58 const sal_uInt16 TYPE_IMAGE		= 10;
59 const sal_uInt16 TYPE_CHAR		= 11;
60 const sal_uInt16 TYPE_DECIMAL	= 12;
61 const sal_uInt16 TYPE_BINARY	= 13;
62 const sal_uInt16 TYPE_VARBINARY	= 14;
63 const sal_uInt16 TYPE_BIGINT	= 15;
64 const sal_uInt16 TYPE_DOUBLE	= 16;
65 const sal_uInt16 TYPE_FLOAT		= 17;
66 const sal_uInt16 TYPE_REAL		= 18;
67 const sal_uInt16 TYPE_INTEGER	= 19;
68 const sal_uInt16 TYPE_SMALLINT	= 20;
69 const sal_uInt16 TYPE_TINYINT	= 21;
70 const sal_uInt16 TYPE_SQLNULL	= 22;
71 const sal_uInt16 TYPE_OBJECT	= 23;
72 const sal_uInt16 TYPE_DISTINCT	= 24;
73 const sal_uInt16 TYPE_STRUCT	= 25;
74 const sal_uInt16 TYPE_ARRAY		= 26;
75 const sal_uInt16 TYPE_BLOB		= 27;
76 const sal_uInt16 TYPE_CLOB		= 28;
77 const sal_uInt16 TYPE_REF		= 29;
78 const sal_uInt16 TYPE_OTHER		= 30;
79 const sal_uInt16 TYPE_BIT		= 31;
80 
81 	class OTypeInfo
82 	{
83 	public:
84 		::rtl::OUString	aUIName;		// the name which is the user see (a combination of resource text and aTypeName)
85 		::rtl::OUString	aTypeName;		// Name des Types in der Datenbank
86 		::rtl::OUString	aLiteralPrefix; // Prefix zum Quoten
87 		::rtl::OUString	aLiteralSuffix; // Suffix zum Quoten
88 		::rtl::OUString	aCreateParams;  // Parameter zum Erstellen
89 		::rtl::OUString	aLocalTypeName;
90 
91 		sal_Int32		nPrecision;		// Laenge des Types
92         sal_Int32		nType;			// Datenbanktyp
93 
94 		sal_Int16		nMaximumScale;	// Nachkommastellen
95 		sal_Int16		nMinimumScale;  // Min Nachkommastellen
96 
97 		sal_Int16		nSearchType;	// kann nach dem Typen gesucht werden
98 
99 
100 		sal_Bool		bCurrency		: 1,	// Waehrung
101 						bAutoIncrement	: 1,	// Ist es ein automatisch incrementierendes Feld
102 						bNullable		: 1,	// Kann das Feld NULL annehmen
103 						bCaseSensitive	: 1,	// Ist der Type Casesensitive
104 						bUnsigned		: 1;	// Ist der Type Unsigned
105 
OTypeInfo()106 		OTypeInfo()
107                 :nPrecision(0)
108 				,nType(::com::sun::star::sdbc::DataType::OTHER)
109 				,nMaximumScale(0)
110 				,nMinimumScale(0)
111 				,nSearchType(::com::sun::star::sdbc::ColumnSearch::FULL)
112 				,bCurrency(sal_False)
113 				,bAutoIncrement(sal_False)
114 				,bNullable(sal_True)
115 				,bCaseSensitive(sal_False)
116 				,bUnsigned(sal_False)
117 		{}
operator ==(const OTypeInfo & lh) const118 		sal_Bool operator == (const OTypeInfo& lh) const { return lh.nType == nType; }
operator !=(const OTypeInfo & lh) const119 		sal_Bool operator != (const OTypeInfo& lh) const { return lh.nType != nType; }
getDBName() const120 		inline ::rtl::OUString	getDBName() const { return aTypeName; }
121 
122 	};
123 
124 	typedef ::boost::shared_ptr<OTypeInfo>			TOTypeInfoSP;
125 	typedef ::std::multimap<sal_Int32,TOTypeInfoSP>	OTypeInfoMap;
126 	/** return the most suitable typeinfo for a requested type
127 		@param	_rTypeInfo		contains a map of type to typeinfo
128 		@param	_nType			the requested type
129 		@param	_sTypeName		the typename
130 		@param	_sCreateParams	the create params
131 		@param	_nPrecision		the precision
132 		@param	_nScale			the	scale
133 		@param	_bAutoIncrement	if it is a auto increment
134 		@param	_brForceToType	true when type was found which has some differenes
135 	*/
136 	TOTypeInfoSP getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo,
137 							   sal_Int32 _nType,
138 							   const ::rtl::OUString& _sTypeName,
139 							   const ::rtl::OUString& _sCreateParams,
140 							   sal_Int32 _nPrecision,
141 							   sal_Int32 _nScale,
142 							   sal_Bool _bAutoIncrement,
143 							   sal_Bool& _brForceToType);
144 }
145 
146 #endif // DBAUI_TYPEINFO_HXX
147 
148 
149