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