1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_connectivity.hxx"
30 #include "NResultSetMetaData.hxx"
31 #include "NDatabaseMetaData.hxx"
32 #include "connectivity/dbexception.hxx"
33 #include <com/sun/star/sdbc/DataType.hpp>
35 #include "resource/evoab2_res.hrc"
37 using namespace connectivity::evoab
;
38 using namespace com::sun::star::uno
;
39 using namespace com::sun::star::lang
;
40 using namespace com::sun::star::sdbc
;
42 OEvoabResultSetMetaData::OEvoabResultSetMetaData(const ::rtl::OUString
& _aTableName
)
43 : m_aTableName(_aTableName
),
48 // -------------------------------------------------------------------------
49 OEvoabResultSetMetaData::~OEvoabResultSetMetaData()
52 // -------------------------------------------------------------------------
53 void OEvoabResultSetMetaData::setEvoabFields(const ::vos::ORef
<connectivity::OSQLColumns
> &xColumns
) throw(SQLException
)
55 OSQLColumns::Vector::const_iterator aIter
;
56 static const ::rtl::OUString
aName(::rtl::OUString::createFromAscii("Name"));
58 for (aIter
= xColumns
->get().begin(); aIter
!= xColumns
->get().end(); ++aIter
)
60 ::rtl::OUString aFieldName
;
62 (*aIter
)->getPropertyValue(aName
) >>= aFieldName
;
63 guint nFieldNumber
= findEvoabField(aFieldName
);
64 if (nFieldNumber
== (guint
)-1)
66 connectivity::SharedResources aResource
;
67 const ::rtl::OUString
sError( aResource
.getResourceStringWithSubstitution(
68 STR_INVALID_COLUMNNAME
,
69 "$columnname$", aFieldName
71 ::dbtools::throwGenericSQLException( sError
, *this );
73 m_aEvoabFields
.push_back(nFieldNumber
);
77 // -------------------------------------------------------------------------
78 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::getColumnDisplaySize( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
)
82 // -------------------------------------------------------------------------
83 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::getColumnType( sal_Int32 nColumnNum
) throw(SQLException
, RuntimeException
)
85 sal_uInt32 nField
= m_aEvoabFields
[nColumnNum
- 1];
86 return evoab::getFieldType (nField
);
88 // -------------------------------------------------------------------------
89 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::getColumnCount( ) throw(SQLException
, RuntimeException
)
91 return m_aEvoabFields
.size();
93 // -------------------------------------------------------------------------
94 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isCaseSensitive( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
)
98 // -------------------------------------------------------------------------
99 ::rtl::OUString SAL_CALL
OEvoabResultSetMetaData::getSchemaName( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
)
101 return ::rtl::OUString();
103 // -------------------------------------------------------------------------
104 ::rtl::OUString SAL_CALL
OEvoabResultSetMetaData::getColumnName( sal_Int32 nColumnNum
) throw(SQLException
, RuntimeException
)
106 sal_uInt32 nField
= m_aEvoabFields
[nColumnNum
- 1];
107 return evoab::getFieldName( nField
);
109 // -------------------------------------------------------------------------
110 ::rtl::OUString SAL_CALL
OEvoabResultSetMetaData::getColumnTypeName( sal_Int32 nColumnNum
) throw(SQLException
, RuntimeException
)
112 sal_uInt32 nField
= m_aEvoabFields
[nColumnNum
- 1];
113 return evoab::getFieldTypeName( nField
);
115 // -------------------------------------------------------------------------
116 ::rtl::OUString SAL_CALL
OEvoabResultSetMetaData::getColumnLabel( sal_Int32 nColumnNum
) throw(SQLException
, RuntimeException
)
118 sal_uInt32 nField
= m_aEvoabFields
[nColumnNum
- 1];
119 const ColumnProperty
*pSpecs
= getField(nField
);
120 GParamSpec
*pSpec
= pSpecs
->pField
;
121 rtl::OUString aLabel
;
124 aLabel
= rtl::OStringToOUString( g_param_spec_get_nick( (GParamSpec
*) pSpec
),
125 RTL_TEXTENCODING_UTF8
);
128 // -------------------------------------------------------------------------
129 ::rtl::OUString SAL_CALL
OEvoabResultSetMetaData::getColumnServiceName( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
)
131 return ::rtl::OUString();
133 // -------------------------------------------------------------------------
134 ::rtl::OUString SAL_CALL
OEvoabResultSetMetaData::getTableName( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
)
136 return m_aTableName
;//::rtl::OUString::createFromAscii("TABLE");
138 // -------------------------------------------------------------------------
139 ::rtl::OUString SAL_CALL
OEvoabResultSetMetaData::getCatalogName( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
)
141 return ::rtl::OUString();
143 // -------------------------------------------------------------------------
145 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isCurrency( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
)
149 // -------------------------------------------------------------------------
150 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isAutoIncrement( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
)
154 // -------------------------------------------------------------------------
155 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isSigned( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
)
159 // -------------------------------------------------------------------------
160 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::getPrecision( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
)
164 // -----------------------------------------------------------------------------
165 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::getScale( sal_Int32
/*nColumnNum*/ ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
169 // -------------------------------------------------------------------------
170 sal_Int32 SAL_CALL
OEvoabResultSetMetaData::isNullable( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
)
174 // -------------------------------------------------------------------------
175 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isSearchable( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
)
179 // -------------------------------------------------------------------------
180 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isReadOnly( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
)
184 // -------------------------------------------------------------------------
185 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isDefinitelyWritable( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
)
189 // -------------------------------------------------------------------------
190 sal_Bool SAL_CALL
OEvoabResultSetMetaData::isWritable( sal_Int32
/*nColumnNum*/ ) throw(SQLException
, RuntimeException
)
194 // -------------------------------------------------------------------------