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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_connectivity.hxx"
26 #include <connectivity/virtualdbtools.hxx>
27 #include "staticdbtools_s.hxx"
28 #include "connectivity/dbconversion.hxx"
29 #include <connectivity/dbtools.hxx>
30 #include <com/sun/star/sdb/SQLContext.hpp>
31 
32 //........................................................................
33 namespace connectivity
34 {
35 //........................................................................
36 
37 	using namespace ::com::sun::star::util;
38 	using namespace ::com::sun::star::uno;
39 	using namespace ::com::sun::star::sdb;
40 	using namespace ::com::sun::star::lang;
41 	using namespace ::com::sun::star::sdbc;
42 	using namespace ::com::sun::star::beans;
43 	using namespace ::com::sun::star::container;
44 
45 	//================================================================
46 	//= ODataAccessStaticTools
47 	//================================================================
48 	//----------------------------------------------------------------
ODataAccessStaticTools()49 	ODataAccessStaticTools::ODataAccessStaticTools()
50 	{
51 	}
52 
53 	//----------------------------------------------------------------
getStandardDate() const54 	Date ODataAccessStaticTools::getStandardDate() const
55 	{
56 		return ::dbtools::DBTypeConversion::getStandardDate();
57 	}
58 
59 	//----------------------------------------------------------------
getValue(const Reference<XColumn> & _rxVariant,const Date & rNullDate) const60 	double ODataAccessStaticTools::getValue(const Reference< XColumn>& _rxVariant, const Date& rNullDate ) const
61 	{
62 		return ::dbtools::DBTypeConversion::getValue( _rxVariant, rNullDate );
63 	}
64 
65 	//----------------------------------------------------------------
getFormattedValue(const Reference<XColumn> & _rxColumn,const Reference<XNumberFormatter> & _rxFormatter,const Date & _rNullDate,sal_Int32 _nKey,sal_Int16 _nKeyType) const66 	::rtl::OUString ODataAccessStaticTools::getFormattedValue(const Reference< XColumn >& _rxColumn, const Reference< XNumberFormatter >& _rxFormatter,
67 		const Date& _rNullDate, sal_Int32 _nKey, sal_Int16 _nKeyType) const
68 	{
69 		return ::dbtools::DBTypeConversion::getFormattedValue(_rxColumn, _rxFormatter, _rNullDate, _nKey, _nKeyType);
70 	}
71 
72 	//----------------------------------------------------------------
getFormattedValue(const Reference<XPropertySet> & _rxColumn,const Reference<XNumberFormatter> & _rxFormatter,const Locale & _rLocale,const Date & _rNullDate) const73 	::rtl::OUString ODataAccessStaticTools::getFormattedValue( const Reference< XPropertySet>& _rxColumn, const Reference< XNumberFormatter>& _rxFormatter,
74 		const Locale& _rLocale, const Date& _rNullDate ) const
75 	{
76 		return ::dbtools::DBTypeConversion::getFormattedValue( _rxColumn, _rxFormatter, _rLocale, _rNullDate );
77 	}
78 
79 	//----------------------------------------------------------------
acquire()80 	oslInterlockedCount SAL_CALL ODataAccessStaticTools::acquire()
81 	{
82 		return ORefBase::acquire();
83 	}
84 
85 	//----------------------------------------------------------------
release()86 	oslInterlockedCount SAL_CALL ODataAccessStaticTools::release()
87 	{
88 		return ORefBase::release();
89 	}
90 
91 	//----------------------------------------------------------------
getConnection_withFeedback(const::rtl::OUString & _rDataSourceName,const::rtl::OUString & _rUser,const::rtl::OUString & _rPwd,const Reference<XMultiServiceFactory> & _rxFactory) const92 	Reference< XConnection> ODataAccessStaticTools::getConnection_withFeedback(const ::rtl::OUString& _rDataSourceName, const ::rtl::OUString& _rUser,
93 		const ::rtl::OUString& _rPwd, const Reference< XMultiServiceFactory>& _rxFactory) const SAL_THROW ( (SQLException) )
94 	{
95 		return ::dbtools::getConnection_withFeedback(_rDataSourceName, _rUser, _rPwd, _rxFactory);
96 	}
97 
98 	//----------------------------------------------------------------
connectRowset(const Reference<XRowSet> & _rxRowSet,const Reference<XMultiServiceFactory> & _rxFactory,sal_Bool _bSetAsActiveConnection) const99 	Reference< XConnection> ODataAccessStaticTools::connectRowset(const Reference< XRowSet>& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory, sal_Bool _bSetAsActiveConnection) const
100 		SAL_THROW ( (SQLException, WrappedTargetException, RuntimeException) )
101 	{
102 		return ::dbtools::connectRowset( _rxRowSet, _rxFactory, _bSetAsActiveConnection);
103 	}
104 
105 	// ------------------------------------------------
getRowSetConnection(const Reference<XRowSet> & _rxRowSet) const106 	Reference< XConnection> ODataAccessStaticTools::getRowSetConnection(
107 				const Reference< XRowSet>& _rxRowSet)
108 				const SAL_THROW ( (RuntimeException) )
109 	{
110 		return ::dbtools::getConnection(_rxRowSet);
111 	}
112 
113 	//----------------------------------------------------------------
getNumberFormats(const Reference<XConnection> & _rxConn,sal_Bool _bAllowDefault) const114 	Reference< XNumberFormatsSupplier> ODataAccessStaticTools::getNumberFormats(const Reference< XConnection>& _rxConn, sal_Bool _bAllowDefault) const
115 	{
116 		return ::dbtools::getNumberFormats(_rxConn, _bAllowDefault);
117 	}
118 
119 	//----------------------------------------------------------------
getDefaultNumberFormat(const Reference<XPropertySet> & _rxColumn,const Reference<XNumberFormatTypes> & _rxTypes,const Locale & _rLocale) const120 	sal_Int32 ODataAccessStaticTools::getDefaultNumberFormat( const Reference< XPropertySet >& _rxColumn, const Reference< XNumberFormatTypes >& _rxTypes,
121 		const Locale& _rLocale ) const
122 	{
123 		return ::dbtools::getDefaultNumberFormat( _rxColumn, _rxTypes, _rLocale );
124 	}
125 
126 	//----------------------------------------------------------------
TransferFormComponentProperties(const Reference<XPropertySet> & _rxOld,const Reference<XPropertySet> & _rxNew,const Locale & _rLocale) const127 	void ODataAccessStaticTools::TransferFormComponentProperties(const Reference< XPropertySet>& _rxOld, const Reference< XPropertySet>& _rxNew, const Locale& _rLocale) const
128 	{
129 		::dbtools::TransferFormComponentProperties(_rxOld, _rxNew, _rLocale);
130 	}
131 
132 	//----------------------------------------------------------------
quoteName(const::rtl::OUString & _rQuote,const::rtl::OUString & _rName) const133 	::rtl::OUString ODataAccessStaticTools::quoteName(const ::rtl::OUString& _rQuote, const ::rtl::OUString& _rName) const
134 	{
135 		return ::dbtools::quoteName(_rQuote, _rName);
136 	}
137 
138 	//----------------------------------------------------------------
composeTableNameForSelect(const Reference<XConnection> & _rxConnection,const::rtl::OUString & _rCatalog,const::rtl::OUString & _rSchema,const::rtl::OUString & _rName) const139 	::rtl::OUString ODataAccessStaticTools::composeTableNameForSelect( const Reference< XConnection >& _rxConnection, const ::rtl::OUString& _rCatalog, const ::rtl::OUString& _rSchema, const ::rtl::OUString& _rName ) const
140     {
141         return ::dbtools::composeTableNameForSelect( _rxConnection, _rCatalog, _rSchema, _rName );
142     }
143 
144 	//----------------------------------------------------------------
composeTableNameForSelect(const Reference<XConnection> & _rxConnection,const Reference<XPropertySet> & _xTable) const145     ::rtl::OUString ODataAccessStaticTools::composeTableNameForSelect( const Reference< XConnection >& _rxConnection, const Reference< XPropertySet>& _xTable ) const
146     {
147         return ::dbtools::composeTableNameForSelect( _rxConnection, _xTable );
148     }
149 
150 	//----------------------------------------------------------------
prependContextInfo(SQLException & _rException,const Reference<XInterface> & _rxContext,const::rtl::OUString & _rContextDescription,const::rtl::OUString & _rContextDetails) const151 	SQLContext ODataAccessStaticTools::prependContextInfo(SQLException& _rException, const Reference< XInterface >& _rxContext,
152 		const ::rtl::OUString& _rContextDescription, const ::rtl::OUString& _rContextDetails) const
153 	{
154 		return ::dbtools::prependContextInfo(_rException, _rxContext, _rContextDescription, _rContextDetails);
155 	}
156 
157 	//----------------------------------------------------------------
getDataSource(const::rtl::OUString & _rsRegisteredName,const Reference<XMultiServiceFactory> & _rxFactory) const158 	Reference< XDataSource > ODataAccessStaticTools::getDataSource( const ::rtl::OUString& _rsRegisteredName, const Reference< XMultiServiceFactory>& _rxFactory ) const
159 	{
160 		return ::dbtools::getDataSource( _rsRegisteredName, _rxFactory );
161 	}
162 
163 	//----------------------------------------------------------------
canInsert(const Reference<XPropertySet> & _rxCursorSet) const164 	sal_Bool ODataAccessStaticTools::canInsert(const Reference< XPropertySet>& _rxCursorSet) const
165 	{
166 		return ::dbtools::canInsert( _rxCursorSet );
167 	}
168 
169 	//----------------------------------------------------------------
canUpdate(const Reference<XPropertySet> & _rxCursorSet) const170 	sal_Bool ODataAccessStaticTools::canUpdate(const Reference< XPropertySet>& _rxCursorSet) const
171 	{
172 		return ::dbtools::canUpdate( _rxCursorSet );
173 	}
174 
175 	//----------------------------------------------------------------
canDelete(const Reference<XPropertySet> & _rxCursorSet) const176 	sal_Bool ODataAccessStaticTools::canDelete(const Reference< XPropertySet>& _rxCursorSet) const
177 	{
178 		return ::dbtools::canDelete( _rxCursorSet );
179 	}
180 
181 	//----------------------------------------------------------------
getFieldsByCommandDescriptor(const Reference<XConnection> & _rxConnection,const sal_Int32 _nCommandType,const::rtl::OUString & _rCommand,Reference<XComponent> & _rxKeepFieldsAlive,::dbtools::SQLExceptionInfo * _pErrorInfo)182 	Reference< XNameAccess > ODataAccessStaticTools::getFieldsByCommandDescriptor( const Reference< XConnection >& _rxConnection,
183 		const sal_Int32 _nCommandType, const ::rtl::OUString& _rCommand,
184 			Reference< XComponent >& _rxKeepFieldsAlive, ::dbtools::SQLExceptionInfo* _pErrorInfo ) SAL_THROW( ( ) )
185 	{
186 		return ::dbtools::getFieldsByCommandDescriptor( _rxConnection, _nCommandType, _rCommand,
187 			_rxKeepFieldsAlive, _pErrorInfo );
188 	}
189 
190 	//----------------------------------------------------------------
getFieldNamesByCommandDescriptor(const Reference<XConnection> & _rxConnection,const sal_Int32 _nCommandType,const::rtl::OUString & _rCommand,::dbtools::SQLExceptionInfo * _pErrorInfo)191 	Sequence< ::rtl::OUString > ODataAccessStaticTools::getFieldNamesByCommandDescriptor(
192 		const Reference< XConnection >& _rxConnection, const sal_Int32 _nCommandType,
193 		const ::rtl::OUString& _rCommand, ::dbtools::SQLExceptionInfo* _pErrorInfo ) SAL_THROW( ( ) )
194 	{
195 		return ::dbtools::getFieldNamesByCommandDescriptor( _rxConnection, _nCommandType,
196 			_rCommand, _pErrorInfo );
197 	}
198 
199 	// ------------------------------------------------
isEmbeddedInDatabase(const Reference<XInterface> & _rxComponent,Reference<XConnection> & _rxActualConnection)200     bool ODataAccessStaticTools::isEmbeddedInDatabase( const Reference< XInterface >& _rxComponent, Reference< XConnection >& _rxActualConnection )
201     {
202 		return ::dbtools::isEmbeddedInDatabase( _rxComponent, _rxActualConnection );
203     }
204 
205 //........................................................................
206 }	// namespace connectivity
207 //........................................................................
208 
209