1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _CONNECTIVITY_ODBC_ORESULTSETMETADATA_HXX_
30 #define _CONNECTIVITY_ODBC_ORESULTSETMETADATA_HXX_
32 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
33 #include <cppuhelper/implbase1.hxx>
34 #include "odbc/OFunctions.hxx"
35 #include "odbc/odbcbasedllapi.hxx"
39 #include "odbc/OConnection.hxx"
41 namespace connectivity
45 //**************************************************************
46 //************ Class: ResultSetMetaData
47 //**************************************************************
48 typedef ::cppu::WeakImplHelper1
< ::com::sun::star::sdbc::XResultSetMetaData
> OResultSetMetaData_BASE
;
50 class OOO_DLLPUBLIC_ODBCBASE OResultSetMetaData
:
51 public OResultSetMetaData_BASE
54 ::std::vector
<sal_Int32
> m_vMapping
; // when not every column is needed
55 ::std::map
<sal_Int32
,sal_Int32
> m_aColumnTypes
;
57 SQLHANDLE m_aStatementHandle
;
58 OConnection
* m_pConnection
;
59 sal_Int32 m_nColCount
;
60 sal_Bool m_bUseODBC2Types
;
62 ::rtl::OUString
getCharColAttrib(sal_Int32 column
,sal_Int32 ident
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
63 sal_Int32
getNumColAttrib(sal_Int32 column
,sal_Int32 ident
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
65 // A ctor that is needed for returning the object
66 OResultSetMetaData(OConnection
* _pConnection
, SQLHANDLE _pStmt
)
67 :m_aStatementHandle( _pStmt
)
68 ,m_pConnection(_pConnection
)
70 ,m_bUseODBC2Types(sal_False
)
72 OResultSetMetaData(OConnection
* _pConnection
, SQLHANDLE _pStmt
,const ::std::vector
<sal_Int32
> & _vMapping
)
73 :m_vMapping(_vMapping
)
74 ,m_aStatementHandle( _pStmt
)
75 ,m_pConnection(_pConnection
)
76 ,m_nColCount(_vMapping
.size()-1)
77 ,m_bUseODBC2Types(sal_False
)
79 virtual ~OResultSetMetaData();
82 static SQLLEN
getNumColAttrib(OConnection
* _pConnection
83 ,SQLHANDLE _aStatementHandle
84 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _xInterface
86 ,sal_Int32 ident
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
88 static SQLSMALLINT
getColumnODBCType(OConnection
* _pConnection
89 ,SQLHANDLE _aStatementHandle
90 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _xInterface
92 throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
94 inline oslGenericFunction
getOdbcFunction(sal_Int32 _nIndex
) const
96 return m_pConnection
->getOdbcFunction(_nIndex
);
98 // Avoid ambigous cast error from the compiler.
99 inline operator ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSetMetaData
> () throw()
102 virtual sal_Int32 SAL_CALL
getColumnCount( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
103 virtual sal_Bool SAL_CALL
isAutoIncrement( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
104 virtual sal_Bool SAL_CALL
isCaseSensitive( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
105 virtual sal_Bool SAL_CALL
isSearchable( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
106 virtual sal_Bool SAL_CALL
isCurrency( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
107 virtual sal_Int32 SAL_CALL
isNullable( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
108 virtual sal_Bool SAL_CALL
isSigned( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
109 virtual sal_Int32 SAL_CALL
getColumnDisplaySize( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
110 virtual ::rtl::OUString SAL_CALL
getColumnLabel( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
111 virtual ::rtl::OUString SAL_CALL
getColumnName( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
112 virtual ::rtl::OUString SAL_CALL
getSchemaName( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
113 virtual sal_Int32 SAL_CALL
getPrecision( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
114 virtual sal_Int32 SAL_CALL
getScale( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
115 virtual ::rtl::OUString SAL_CALL
getTableName( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
116 virtual ::rtl::OUString SAL_CALL
getCatalogName( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
117 virtual sal_Int32 SAL_CALL
getColumnType( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
118 virtual ::rtl::OUString SAL_CALL
getColumnTypeName( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
119 virtual sal_Bool SAL_CALL
isReadOnly( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
120 virtual sal_Bool SAL_CALL
isWritable( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
121 virtual sal_Bool SAL_CALL
isDefinitelyWritable( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
122 virtual ::rtl::OUString SAL_CALL
getColumnServiceName( sal_Int32 column
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
126 #endif // _CONNECTIVITY_ODBC_ORESULTSETMETADATA_HXX_
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */