Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_CONNECTIVITY_PCOLUMN_HXX
20 : #define INCLUDED_CONNECTIVITY_PCOLUMN_HXX
21 :
22 : #include <sal/config.h>
23 :
24 : #include <map>
25 :
26 : #include <connectivity/dbtoolsdllapi.hxx>
27 : #include <connectivity/sdbcx/VColumn.hxx>
28 : #include <connectivity/CommonTools.hxx>
29 : #include <rtl/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 : OUString m_aRealName;
48 : OUString m_sLabel;
49 : bool m_bFunction;
50 : bool m_bDbasePrecisionChanged;
51 : bool m_bAggregateFunction;
52 : bool m_bIsSearchable;
53 :
54 : protected:
55 : virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const SAL_OVERRIDE;
56 : virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() SAL_OVERRIDE;
57 :
58 : virtual ~OParseColumn();
59 : public:
60 : OParseColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn, bool _bCase);
61 : OParseColumn(const OUString& _Name,
62 : const OUString& _TypeName,
63 : const OUString& _DefaultValue,
64 : const OUString& _Description,
65 : sal_Int32 _IsNullable,
66 : sal_Int32 _Precision,
67 : sal_Int32 _Scale,
68 : sal_Int32 _Type,
69 : bool _IsAutoIncrement,
70 : bool _IsCurrency,
71 : bool _bCase,
72 : const OUString& _CatalogName,
73 : const OUString& _SchemaName,
74 : const OUString& _TableName);
75 :
76 : virtual void construct() SAL_OVERRIDE;
77 :
78 0 : void setRealName(const OUString& _rName) { m_aRealName = _rName; }
79 0 : void setLabel(const OUString& i_sLabel) { m_sLabel = i_sLabel; }
80 0 : void setTableName(const OUString& _rName) { m_TableName = _rName; }
81 0 : void setFunction(bool _bFunction) { m_bFunction = _bFunction; }
82 0 : void setAggregateFunction(bool _bFunction) { m_bAggregateFunction = _bFunction; }
83 0 : void setIsSearchable( bool _bIsSearchable ) { m_bIsSearchable = _bIsSearchable; }
84 : void setDbasePrecisionChanged(bool _bDbasePrecisionChanged) { m_bDbasePrecisionChanged = _bDbasePrecisionChanged; }
85 :
86 0 : const OUString& getRealName() const { return m_aRealName; }
87 : const OUString& getLabel() const { return m_sLabel; }
88 : const OUString& getTableName() const { return m_TableName; }
89 : bool getFunction() const { return m_bFunction; }
90 : bool getDbasePrecisionChanged() const { return m_bDbasePrecisionChanged; }
91 :
92 : public:
93 : /** creates a collection of OParseColumn, as described by a result set meta data instance.
94 : */
95 : static ::rtl::Reference< OSQLColumns >
96 : createColumnsForResultSet(
97 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData >& _rxResMetaData,
98 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMetaData,
99 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& i_xQueryColumns
100 : );
101 :
102 : typedef std::map<OUString, int> StringMap;
103 : /** creates a single OParseColumn, as described by a result set meta data instance.
104 : The column names are unique.
105 : */
106 : static OParseColumn*
107 : createColumnForResultSet(
108 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData >& _rxResMetaData,
109 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMetaData,
110 : sal_Int32 _nColumnPos,
111 : StringMap& _rColumns
112 : );
113 :
114 : private:
115 : using OParseColumn_BASE::createArrayHelper;
116 : };
117 :
118 : class OOrderColumn;
119 :
120 : typedef sdbcx::OColumn OOrderColumn_BASE;
121 : typedef ::comphelper::OPropertyArrayUsageHelper<OOrderColumn> OOrderColumn_PROP;
122 :
123 : class OOO_DLLPUBLIC_DBTOOLS OOrderColumn :
124 : public OOrderColumn_BASE, public OOrderColumn_PROP
125 : {
126 : const sal_Bool m_bAscending;
127 :
128 : protected:
129 : virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const SAL_OVERRIDE;
130 : virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() SAL_OVERRIDE;
131 :
132 : virtual ~OOrderColumn();
133 : public:
134 : OOrderColumn(
135 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn,
136 : const OUString& i_rOriginatingTableName,
137 : bool _bCase,
138 : bool _bAscending
139 : );
140 :
141 : OOrderColumn(
142 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn,
143 : bool _bCase,
144 : bool _bAscending
145 : );
146 :
147 : virtual void construct() SAL_OVERRIDE;
148 :
149 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
150 : private:
151 : using OOrderColumn_BASE::createArrayHelper;
152 : };
153 : }
154 : }
155 :
156 : #endif // INCLUDED_CONNECTIVITY_PCOLUMN_HXX
157 :
158 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|