1*caf5cd79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*caf5cd79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*caf5cd79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*caf5cd79SAndrew Rist  * distributed with this work for additional information
6*caf5cd79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*caf5cd79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*caf5cd79SAndrew Rist  * "License"); you may not use this file except in compliance
9*caf5cd79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*caf5cd79SAndrew Rist  *
11*caf5cd79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*caf5cd79SAndrew Rist  *
13*caf5cd79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*caf5cd79SAndrew Rist  * software distributed under the License is distributed on an
15*caf5cd79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*caf5cd79SAndrew Rist  * KIND, either express or implied.  See the License for the
17*caf5cd79SAndrew Rist  * specific language governing permissions and limitations
18*caf5cd79SAndrew Rist  * under the License.
19*caf5cd79SAndrew Rist  *
20*caf5cd79SAndrew Rist  *************************************************************/
21*caf5cd79SAndrew Rist 
22*caf5cd79SAndrew Rist 
23cdf0e10cSrcweir #ifndef _CONNECTIVITY_PCOLUMN_HXX_
24cdf0e10cSrcweir #define _CONNECTIVITY_PCOLUMN_HXX_
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "connectivity/dbtoolsdllapi.hxx"
27cdf0e10cSrcweir #include "connectivity/sdbcx/VColumn.hxx"
28cdf0e10cSrcweir #include "connectivity/CommonTools.hxx"
29cdf0e10cSrcweir #include <vos/ref.hxx>
30cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
31cdf0e10cSrcweir #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
32cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
33cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir namespace connectivity
36cdf0e10cSrcweir {
37cdf0e10cSrcweir 	namespace parse
38cdf0e10cSrcweir 	{
39cdf0e10cSrcweir 		class OParseColumn;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 		typedef sdbcx::OColumn OParseColumn_BASE;
42cdf0e10cSrcweir         typedef ::comphelper::OPropertyArrayUsageHelper<OParseColumn> OParseColumn_PROP;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 		class OOO_DLLPUBLIC_DBTOOLS OParseColumn :
45cdf0e10cSrcweir             public OParseColumn_BASE, public OParseColumn_PROP
46cdf0e10cSrcweir 		{
47cdf0e10cSrcweir 			::rtl::OUString	m_aRealName;
48cdf0e10cSrcweir 			::rtl::OUString m_aTableName;
49cdf0e10cSrcweir             ::rtl::OUString m_sLabel;
50cdf0e10cSrcweir 			sal_Bool		m_bFunction;
51cdf0e10cSrcweir 			sal_Bool		m_bDbasePrecisionChanged;
52cdf0e10cSrcweir 			sal_Bool		m_bAggregateFunction;
53cdf0e10cSrcweir             sal_Bool        m_bIsSearchable;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 		protected:
56cdf0e10cSrcweir 			virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
57cdf0e10cSrcweir 			virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 			virtual ~OParseColumn();
60cdf0e10cSrcweir 		public:
61cdf0e10cSrcweir             OParseColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn,sal_Bool _bCase);
62cdf0e10cSrcweir 			OParseColumn(const ::rtl::OUString& _Name,
63cdf0e10cSrcweir 					const ::rtl::OUString& _TypeName,
64cdf0e10cSrcweir 					const ::rtl::OUString& _DefaultValue,
65cdf0e10cSrcweir                     const ::rtl::OUString& _Description,
66cdf0e10cSrcweir 					sal_Int32		_IsNullable,
67cdf0e10cSrcweir 					sal_Int32		_Precision,
68cdf0e10cSrcweir 					sal_Int32		_Scale,
69cdf0e10cSrcweir 					sal_Int32		_Type,
70cdf0e10cSrcweir 					sal_Bool		_IsAutoIncrement,
71cdf0e10cSrcweir 					sal_Bool		_IsCurrency,
72cdf0e10cSrcweir 					sal_Bool		_bCase);
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 			virtual void construct();
75cdf0e10cSrcweir 
setRealName(const::rtl::OUString & _rName)76cdf0e10cSrcweir 			void setRealName(const ::rtl::OUString& _rName)  { m_aRealName  = _rName; }
setLabel(const::rtl::OUString & i_sLabel)77cdf0e10cSrcweir             void setLabel(const ::rtl::OUString& i_sLabel)   { m_sLabel  = i_sLabel; }
setTableName(const::rtl::OUString & _rName)78cdf0e10cSrcweir 			void setTableName(const ::rtl::OUString& _rName) { m_aTableName = _rName; }
setFunction(sal_Bool _bFunction)79cdf0e10cSrcweir 			void setFunction(sal_Bool _bFunction)			 { m_bFunction	= _bFunction; }
setAggregateFunction(sal_Bool _bFunction)80cdf0e10cSrcweir 			void setAggregateFunction(sal_Bool _bFunction)	 { m_bAggregateFunction	= _bFunction; }
setIsSearchable(sal_Bool _bIsSearchable)81cdf0e10cSrcweir             void setIsSearchable( sal_Bool _bIsSearchable )  { m_bIsSearchable = _bIsSearchable; }
setDbasePrecisionChanged(sal_Bool _bDbasePrecisionChanged)82cdf0e10cSrcweir 			void setDbasePrecisionChanged(sal_Bool _bDbasePrecisionChanged)	{ m_bDbasePrecisionChanged = _bDbasePrecisionChanged; }
83cdf0e10cSrcweir 
getRealName() const84cdf0e10cSrcweir 			::rtl::OUString getRealName()   const { return  m_aRealName; }
getLabel() const85cdf0e10cSrcweir             ::rtl::OUString getLabel()      const { return  m_sLabel; }
getTableName() const86cdf0e10cSrcweir 			::rtl::OUString getTableName()  const { return  m_aTableName; }
getFunction() const87cdf0e10cSrcweir 			sal_Bool		getFunction()   const { return  m_bFunction; }
getDbasePrecisionChanged() const88cdf0e10cSrcweir 			sal_Bool		getDbasePrecisionChanged()	const { return  m_bDbasePrecisionChanged; }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir         public:
91cdf0e10cSrcweir             /** creates a collection of OParseColumn, as described by a result set meta data instance.
92cdf0e10cSrcweir             */
93cdf0e10cSrcweir             static ::vos::ORef< OSQLColumns >
94cdf0e10cSrcweir                 createColumnsForResultSet(
95cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData >& _rxResMetaData,
96cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMetaData,
97cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& i_xQueryColumns
98cdf0e10cSrcweir                 );
99cdf0e10cSrcweir 
100cdf0e10cSrcweir             DECLARE_STL_USTRINGACCESS_MAP(int,StringMap);
101cdf0e10cSrcweir             /** creates a single OParseColumn, as described by a result set meta data instance.
102cdf0e10cSrcweir                 The column names are unique.
103cdf0e10cSrcweir             */
104cdf0e10cSrcweir             static OParseColumn*
105cdf0e10cSrcweir                 createColumnForResultSet(
106cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData >& _rxResMetaData,
107cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMetaData,
108cdf0e10cSrcweir                     sal_Int32 _nColumnPos,
109cdf0e10cSrcweir                     StringMap& _rColumns
110cdf0e10cSrcweir                 );
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 		private:
113cdf0e10cSrcweir 			using OParseColumn_BASE::createArrayHelper;
114cdf0e10cSrcweir 		};
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 		class OOrderColumn;
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 		typedef sdbcx::OColumn OOrderColumn_BASE;
119cdf0e10cSrcweir 		typedef ::comphelper::OPropertyArrayUsageHelper<OOrderColumn> OOrderColumn_PROP;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 		class OOO_DLLPUBLIC_DBTOOLS OOrderColumn :
122cdf0e10cSrcweir             public OOrderColumn_BASE, public OOrderColumn_PROP
123cdf0e10cSrcweir 		{
124cdf0e10cSrcweir             const   sal_Bool        m_bAscending;
125cdf0e10cSrcweir             const   ::rtl::OUString m_sTableName;
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 		protected:
128cdf0e10cSrcweir 			virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
129cdf0e10cSrcweir 			virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 			virtual ~OOrderColumn();
132cdf0e10cSrcweir 		public:
133cdf0e10cSrcweir             OOrderColumn(
134cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn,
135cdf0e10cSrcweir                 const ::rtl::OUString& i_rOriginatingTableName,
136cdf0e10cSrcweir                 sal_Bool _bCase,
137cdf0e10cSrcweir                 sal_Bool _bAscending
138cdf0e10cSrcweir             );
139cdf0e10cSrcweir 
140cdf0e10cSrcweir             OOrderColumn(
141cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn,
142cdf0e10cSrcweir                 sal_Bool _bCase,
143cdf0e10cSrcweir                 sal_Bool _bAscending
144cdf0e10cSrcweir             );
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 			virtual void construct();
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 			virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
149cdf0e10cSrcweir 		private:
150cdf0e10cSrcweir 			using OOrderColumn_BASE::createArrayHelper;
151cdf0e10cSrcweir 		};
152cdf0e10cSrcweir 	}
153cdf0e10cSrcweir }
154cdf0e10cSrcweir 
155cdf0e10cSrcweir #endif //_CONNECTIVITY_PCOLUMN_HXX_
156cdf0e10cSrcweir 
157