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