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 * $RCSfile: OResultSetMetaData.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CONNECTIVITY_ODBC_ORESULTSETMETADATA_HXX_
32 #define _CONNECTIVITY_ODBC_ORESULTSETMETADATA_HXX_
34 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
35 #include <cppuhelper/implbase1.hxx>
36 #include "odbc/OFunctions.hxx"
37 #include "odbc/odbcbasedllapi.hxx"
41 #include "odbc/OConnection.hxx"
43 namespace connectivity
47 //**************************************************************
48 //************ Class: ResultSetMetaData
49 //**************************************************************
50 typedef ::cppu::WeakImplHelper1
< ::com::sun::star::sdbc::XResultSetMetaData
> OResultSetMetaData_BASE
;
52 class OOO_DLLPUBLIC_ODBCBASE OResultSetMetaData
:
53 public OResultSetMetaData_BASE
56 ::std::vector
<sal_Int32
> m_vMapping
; // when not every column is needed
57 ::std::map
<sal_Int32
,sal_Int32
> m_aColumnTypes
;
59 SQLHANDLE m_aStatementHandle
;
60 OConnection
* m_pConnection
;
61 sal_Int32 m_nColCount
;
62 sal_Bool m_bUseODBC2Types
;
64 ::rtl::OUString
getCharColAttrib(sal_Int32 column
,sal_Int32 ident
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
65 sal_Int32
getNumColAttrib(sal_Int32 column
,sal_Int32 ident
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
67 // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
68 OResultSetMetaData(OConnection
* _pConnection
, SQLHANDLE _pStmt
)
69 :m_aStatementHandle( _pStmt
)
70 ,m_pConnection(_pConnection
)
72 ,m_bUseODBC2Types(sal_False
)
74 OResultSetMetaData(OConnection
* _pConnection
, SQLHANDLE _pStmt
,const ::std::vector
<sal_Int32
> & _vMapping
)
75 :m_vMapping(_vMapping
)
76 ,m_aStatementHandle( _pStmt
)
77 ,m_pConnection(_pConnection
)
78 ,m_nColCount(_vMapping
.size()-1)
79 ,m_bUseODBC2Types(sal_False
)
81 virtual ~OResultSetMetaData();
84 static SQLLEN
getNumColAttrib(OConnection
* _pConnection
85 ,SQLHANDLE _aStatementHandle
86 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _xInterface
88 ,sal_Int32 ident
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
90 static SQLSMALLINT
getColumnODBCType(OConnection
* _pConnection
91 ,SQLHANDLE _aStatementHandle
92 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _xInterface
94 throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
96 inline oslGenericFunction
getOdbcFunction(sal_Int32 _nIndex
) const
98 return m_pConnection
->getOdbcFunction(_nIndex
);
100 /// Avoid ambigous cast error from the compiler.
101 inline operator ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSetMetaData
> () throw()
104 virtual sal_Int32 SAL_CALL
getColumnCount( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
105 virtual sal_Bool SAL_CALL
isAutoIncrement( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
106 virtual sal_Bool SAL_CALL
isCaseSensitive( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
107 virtual sal_Bool SAL_CALL
isSearchable( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
108 virtual sal_Bool SAL_CALL
isCurrency( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
109 virtual sal_Int32 SAL_CALL
isNullable( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
110 virtual sal_Bool SAL_CALL
isSigned( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
111 virtual sal_Int32 SAL_CALL
getColumnDisplaySize( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
112 virtual ::rtl::OUString SAL_CALL
getColumnLabel( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
113 virtual ::rtl::OUString SAL_CALL
getColumnName( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
114 virtual ::rtl::OUString SAL_CALL
getSchemaName( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
115 virtual sal_Int32 SAL_CALL
getPrecision( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
116 virtual sal_Int32 SAL_CALL
getScale( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
117 virtual ::rtl::OUString SAL_CALL
getTableName( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
118 virtual ::rtl::OUString SAL_CALL
getCatalogName( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
119 virtual sal_Int32 SAL_CALL
getColumnType( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
120 virtual ::rtl::OUString SAL_CALL
getColumnTypeName( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
121 virtual sal_Bool SAL_CALL
isReadOnly( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
122 virtual sal_Bool SAL_CALL
isWritable( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
123 virtual sal_Bool SAL_CALL
isDefinitelyWritable( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
124 virtual ::rtl::OUString SAL_CALL
getColumnServiceName( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
128 #endif // _CONNECTIVITY_ODBC_ORESULTSETMETADATA_HXX_