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 
24 #ifndef CONNECTIVITY_STATIC_DBTOOLS_SIMPLE_HXX
25 #define CONNECTIVITY_STATIC_DBTOOLS_SIMPLE_HXX
26 
27 #include <connectivity/virtualdbtools.hxx>
28 #include "refbase.hxx"
29 
30 //........................................................................
31 namespace connectivity
32 {
33 //........................................................................
34 
35 	//================================================================
36 	//= ODataAccessStaticTools
37 	//================================================================
38 	class ODataAccessStaticTools
39 			:public simple::IDataAccessTypeConversion
40 			,public simple::IDataAccessTools
41 			,public ORefBase
42 	{
43 	public:
44 		ODataAccessStaticTools();
45 
46 		// IDataAccessTypeConversion
47 		// ------------------------------------------------
48 		virtual ::com::sun::star::util::Date getStandardDate() const;
49 
50 		// ------------------------------------------------
51 		virtual double getValue(
52 			const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& _rxVariant,
53 			const ::com::sun::star::util::Date& rNullDate ) const;
54 
55 		// ------------------------------------------------
56 		virtual ::rtl::OUString getFormattedValue(
57 			const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxColumn,
58 			const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
59 			const ::com::sun::star::util::Date& _rNullDate,
60 			sal_Int32 _nKey,
61 			sal_Int16 _nKeyType) const;
62 
63 		// ------------------------------------------------
64 		virtual ::rtl::OUString getFormattedValue(
65 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxColumn,
66 			const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter>& _rxFormatter,
67 			const ::com::sun::star::lang::Locale& _rLocale,
68 			const ::com::sun::star::util::Date& _rNullDate
69 		) const;
70 
71 		// IDataAccessTools
72 		// ------------------------------------------------
73 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection_withFeedback(
74 			const ::rtl::OUString& _rDataSourceName,
75 			const ::rtl::OUString& _rUser,
76 			const ::rtl::OUString& _rPwd,
77 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory
78 		) const SAL_THROW ( (::com::sun::star::sdbc::SQLException) );
79 
80 		// ------------------------------------------------
81 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> connectRowset(
82 			const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet,
83 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory,
84 			sal_Bool _bSetAsActiveConnection
85 		) const SAL_THROW ( ( ::com::sun::star::sdbc::SQLException
86                             , ::com::sun::star::lang::WrappedTargetException
87                             , ::com::sun::star::uno::RuntimeException ) );
88 
89 		// ------------------------------------------------
90 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getRowSetConnection(
91 				const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet)
92 				const SAL_THROW ( (::com::sun::star::uno::RuntimeException) );
93 
94 		// ------------------------------------------------
95 		::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> getNumberFormats(
96 			const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConn,
97 			sal_Bool _bAllowDefault
98 		) const;
99 
100 		// ------------------------------------------------
101 		virtual sal_Int32  getDefaultNumberFormat(
102 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn,
103 			const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatTypes >& _rxTypes,
104 			const ::com::sun::star::lang::Locale& _rLocale
105 		) const;
106 
107 		// ------------------------------------------------
108 		virtual void TransferFormComponentProperties(
109 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxOld,
110 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxNew,
111 			const ::com::sun::star::lang::Locale& _rLocale
112 		) const;
113 
114 		// ------------------------------------------------
115 		virtual ::rtl::OUString quoteName(
116 			const ::rtl::OUString& _rQuote,
117 			const ::rtl::OUString& _rName
118 		) const;
119 
120 		// ------------------------------------------------
121 	    virtual ::rtl::OUString composeTableNameForSelect(
122             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
123 			const ::rtl::OUString& _rCatalog,
124 			const ::rtl::OUString& _rSchema,
125 			const ::rtl::OUString& _rName
126         ) const;
127 
128 		// ------------------------------------------------
129 	    virtual ::rtl::OUString composeTableNameForSelect(
130             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
131 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable
132         ) const;
133 
134 		// ------------------------------------------------
135 		virtual ::com::sun::star::sdb::SQLContext prependContextInfo(
136 			::com::sun::star::sdbc::SQLException& _rException,
137 			const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
138 			const ::rtl::OUString& _rContextDescription,
139 			const ::rtl::OUString& _rContextDetails
140 		) const;
141 
142 		// ------------------------------------------------
143 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > getDataSource(
144 			const ::rtl::OUString& _rsRegisteredName,
145 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory
146 		) const;
147 
148 		// ------------------------------------------------
149 		/** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::INSERT
150 			@param		_rxCursorSet	the property set
151 		*/
152 		virtual sal_Bool canInsert(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const;
153 
154 		// ------------------------------------------------
155 		/** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::UPDATE
156 			@param		_rxCursorSet	the property set
157 		*/
158 		virtual sal_Bool canUpdate(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const;
159 
160 		// ------------------------------------------------
161 		/** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::DELETE
162 			@param		_rxCursorSet	the property set
163 		*/
164 		virtual sal_Bool canDelete(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const;
165 
166 		// ------------------------------------------------
167 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
168 			getFieldsByCommandDescriptor(
169 				const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
170 				const sal_Int32 _nCommandType,
171 				const ::rtl::OUString& _rCommand,
172 				::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxKeepFieldsAlive,
173 				::dbtools::SQLExceptionInfo* _pErrorInfo = NULL
174 			)	SAL_THROW( ( ) );
175 
176 		// ------------------------------------------------
177 		virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
178 			getFieldNamesByCommandDescriptor(
179 				const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
180 				const sal_Int32 _nCommandType,
181 				const ::rtl::OUString& _rCommand,
182 				::dbtools::SQLExceptionInfo* _pErrorInfo = NULL
183 			)	SAL_THROW( ( ) );
184 
185 		// ------------------------------------------------
186         virtual bool isEmbeddedInDatabase(
187             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent,
188             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxActualConnection
189         );
190 
191         // disambiguate IReference
192 		// ------------------------------------------------
193 		virtual oslInterlockedCount SAL_CALL acquire();
194 		virtual oslInterlockedCount SAL_CALL release();
195 	};
196 
197 //........................................................................
198 }	// namespace connectivity
199 //........................................................................
200 
201 #endif // CONNECTIVITY_STATIC_DBTOOLS_SIMPLE_HXX
202 
203