xref: /AOO41X/main/connectivity/source/simpledbt/staticdbtools_s.cxx (revision 9b5730f6ddef7eb82608ca4d31dc0d7678e652cf)
1*9b5730f6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9b5730f6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9b5730f6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9b5730f6SAndrew Rist  * distributed with this work for additional information
6*9b5730f6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9b5730f6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9b5730f6SAndrew Rist  * "License"); you may not use this file except in compliance
9*9b5730f6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*9b5730f6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*9b5730f6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9b5730f6SAndrew Rist  * software distributed under the License is distributed on an
15*9b5730f6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9b5730f6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9b5730f6SAndrew Rist  * specific language governing permissions and limitations
18*9b5730f6SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*9b5730f6SAndrew Rist  *************************************************************/
21*9b5730f6SAndrew Rist 
22*9b5730f6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
26cdf0e10cSrcweir #include <connectivity/virtualdbtools.hxx>
27cdf0e10cSrcweir #include "staticdbtools_s.hxx"
28cdf0e10cSrcweir #include "connectivity/dbconversion.hxx"
29cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
30cdf0e10cSrcweir #include <com/sun/star/sdb/SQLContext.hpp>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir //........................................................................
33cdf0e10cSrcweir namespace connectivity
34cdf0e10cSrcweir {
35cdf0e10cSrcweir //........................................................................
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 	using namespace ::com::sun::star::util;
38cdf0e10cSrcweir 	using namespace ::com::sun::star::uno;
39cdf0e10cSrcweir 	using namespace ::com::sun::star::sdb;
40cdf0e10cSrcweir 	using namespace ::com::sun::star::lang;
41cdf0e10cSrcweir 	using namespace ::com::sun::star::sdbc;
42cdf0e10cSrcweir 	using namespace ::com::sun::star::beans;
43cdf0e10cSrcweir 	using namespace ::com::sun::star::container;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 	//================================================================
46cdf0e10cSrcweir 	//= ODataAccessStaticTools
47cdf0e10cSrcweir 	//================================================================
48cdf0e10cSrcweir 	//----------------------------------------------------------------
ODataAccessStaticTools()49cdf0e10cSrcweir 	ODataAccessStaticTools::ODataAccessStaticTools()
50cdf0e10cSrcweir 	{
51cdf0e10cSrcweir 	}
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 	//----------------------------------------------------------------
getStandardDate() const54cdf0e10cSrcweir 	Date ODataAccessStaticTools::getStandardDate() const
55cdf0e10cSrcweir 	{
56cdf0e10cSrcweir 		return ::dbtools::DBTypeConversion::getStandardDate();
57cdf0e10cSrcweir 	}
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 	//----------------------------------------------------------------
getValue(const Reference<XColumn> & _rxVariant,const Date & rNullDate) const60cdf0e10cSrcweir 	double ODataAccessStaticTools::getValue(const Reference< XColumn>& _rxVariant, const Date& rNullDate ) const
61cdf0e10cSrcweir 	{
62cdf0e10cSrcweir 		return ::dbtools::DBTypeConversion::getValue( _rxVariant, rNullDate );
63cdf0e10cSrcweir 	}
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	//----------------------------------------------------------------
getFormattedValue(const Reference<XColumn> & _rxColumn,const Reference<XNumberFormatter> & _rxFormatter,const Date & _rNullDate,sal_Int32 _nKey,sal_Int16 _nKeyType) const66cdf0e10cSrcweir 	::rtl::OUString ODataAccessStaticTools::getFormattedValue(const Reference< XColumn >& _rxColumn, const Reference< XNumberFormatter >& _rxFormatter,
67cdf0e10cSrcweir 		const Date& _rNullDate, sal_Int32 _nKey, sal_Int16 _nKeyType) const
68cdf0e10cSrcweir 	{
69cdf0e10cSrcweir 		return ::dbtools::DBTypeConversion::getFormattedValue(_rxColumn, _rxFormatter, _rNullDate, _nKey, _nKeyType);
70cdf0e10cSrcweir 	}
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	//----------------------------------------------------------------
getFormattedValue(const Reference<XPropertySet> & _rxColumn,const Reference<XNumberFormatter> & _rxFormatter,const Locale & _rLocale,const Date & _rNullDate) const73cdf0e10cSrcweir 	::rtl::OUString ODataAccessStaticTools::getFormattedValue( const Reference< XPropertySet>& _rxColumn, const Reference< XNumberFormatter>& _rxFormatter,
74cdf0e10cSrcweir 		const Locale& _rLocale, const Date& _rNullDate ) const
75cdf0e10cSrcweir 	{
76cdf0e10cSrcweir 		return ::dbtools::DBTypeConversion::getFormattedValue( _rxColumn, _rxFormatter, _rLocale, _rNullDate );
77cdf0e10cSrcweir 	}
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	//----------------------------------------------------------------
acquire()80cdf0e10cSrcweir 	oslInterlockedCount SAL_CALL ODataAccessStaticTools::acquire()
81cdf0e10cSrcweir 	{
82cdf0e10cSrcweir 		return ORefBase::acquire();
83cdf0e10cSrcweir 	}
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	//----------------------------------------------------------------
release()86cdf0e10cSrcweir 	oslInterlockedCount SAL_CALL ODataAccessStaticTools::release()
87cdf0e10cSrcweir 	{
88cdf0e10cSrcweir 		return ORefBase::release();
89cdf0e10cSrcweir 	}
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 	//----------------------------------------------------------------
getConnection_withFeedback(const::rtl::OUString & _rDataSourceName,const::rtl::OUString & _rUser,const::rtl::OUString & _rPwd,const Reference<XMultiServiceFactory> & _rxFactory) const92cdf0e10cSrcweir 	Reference< XConnection> ODataAccessStaticTools::getConnection_withFeedback(const ::rtl::OUString& _rDataSourceName, const ::rtl::OUString& _rUser,
93cdf0e10cSrcweir 		const ::rtl::OUString& _rPwd, const Reference< XMultiServiceFactory>& _rxFactory) const SAL_THROW ( (SQLException) )
94cdf0e10cSrcweir 	{
95cdf0e10cSrcweir 		return ::dbtools::getConnection_withFeedback(_rDataSourceName, _rUser, _rPwd, _rxFactory);
96cdf0e10cSrcweir 	}
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	//----------------------------------------------------------------
connectRowset(const Reference<XRowSet> & _rxRowSet,const Reference<XMultiServiceFactory> & _rxFactory,sal_Bool _bSetAsActiveConnection) const99cdf0e10cSrcweir 	Reference< XConnection> ODataAccessStaticTools::connectRowset(const Reference< XRowSet>& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory, sal_Bool _bSetAsActiveConnection) const
100cdf0e10cSrcweir 		SAL_THROW ( (SQLException, WrappedTargetException, RuntimeException) )
101cdf0e10cSrcweir 	{
102cdf0e10cSrcweir 		return ::dbtools::connectRowset( _rxRowSet, _rxFactory, _bSetAsActiveConnection);
103cdf0e10cSrcweir 	}
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 	// ------------------------------------------------
getRowSetConnection(const Reference<XRowSet> & _rxRowSet) const106cdf0e10cSrcweir 	Reference< XConnection> ODataAccessStaticTools::getRowSetConnection(
107cdf0e10cSrcweir 				const Reference< XRowSet>& _rxRowSet)
108cdf0e10cSrcweir 				const SAL_THROW ( (RuntimeException) )
109cdf0e10cSrcweir 	{
110cdf0e10cSrcweir 		return ::dbtools::getConnection(_rxRowSet);
111cdf0e10cSrcweir 	}
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	//----------------------------------------------------------------
getNumberFormats(const Reference<XConnection> & _rxConn,sal_Bool _bAllowDefault) const114cdf0e10cSrcweir 	Reference< XNumberFormatsSupplier> ODataAccessStaticTools::getNumberFormats(const Reference< XConnection>& _rxConn, sal_Bool _bAllowDefault) const
115cdf0e10cSrcweir 	{
116cdf0e10cSrcweir 		return ::dbtools::getNumberFormats(_rxConn, _bAllowDefault);
117cdf0e10cSrcweir 	}
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 	//----------------------------------------------------------------
getDefaultNumberFormat(const Reference<XPropertySet> & _rxColumn,const Reference<XNumberFormatTypes> & _rxTypes,const Locale & _rLocale) const120cdf0e10cSrcweir 	sal_Int32 ODataAccessStaticTools::getDefaultNumberFormat( const Reference< XPropertySet >& _rxColumn, const Reference< XNumberFormatTypes >& _rxTypes,
121cdf0e10cSrcweir 		const Locale& _rLocale ) const
122cdf0e10cSrcweir 	{
123cdf0e10cSrcweir 		return ::dbtools::getDefaultNumberFormat( _rxColumn, _rxTypes, _rLocale );
124cdf0e10cSrcweir 	}
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	//----------------------------------------------------------------
TransferFormComponentProperties(const Reference<XPropertySet> & _rxOld,const Reference<XPropertySet> & _rxNew,const Locale & _rLocale) const127cdf0e10cSrcweir 	void ODataAccessStaticTools::TransferFormComponentProperties(const Reference< XPropertySet>& _rxOld, const Reference< XPropertySet>& _rxNew, const Locale& _rLocale) const
128cdf0e10cSrcweir 	{
129cdf0e10cSrcweir 		::dbtools::TransferFormComponentProperties(_rxOld, _rxNew, _rLocale);
130cdf0e10cSrcweir 	}
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 	//----------------------------------------------------------------
quoteName(const::rtl::OUString & _rQuote,const::rtl::OUString & _rName) const133cdf0e10cSrcweir 	::rtl::OUString ODataAccessStaticTools::quoteName(const ::rtl::OUString& _rQuote, const ::rtl::OUString& _rName) const
134cdf0e10cSrcweir 	{
135cdf0e10cSrcweir 		return ::dbtools::quoteName(_rQuote, _rName);
136cdf0e10cSrcweir 	}
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 	//----------------------------------------------------------------
composeTableNameForSelect(const Reference<XConnection> & _rxConnection,const::rtl::OUString & _rCatalog,const::rtl::OUString & _rSchema,const::rtl::OUString & _rName) const139cdf0e10cSrcweir 	::rtl::OUString ODataAccessStaticTools::composeTableNameForSelect( const Reference< XConnection >& _rxConnection, const ::rtl::OUString& _rCatalog, const ::rtl::OUString& _rSchema, const ::rtl::OUString& _rName ) const
140cdf0e10cSrcweir     {
141cdf0e10cSrcweir         return ::dbtools::composeTableNameForSelect( _rxConnection, _rCatalog, _rSchema, _rName );
142cdf0e10cSrcweir     }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 	//----------------------------------------------------------------
composeTableNameForSelect(const Reference<XConnection> & _rxConnection,const Reference<XPropertySet> & _xTable) const145cdf0e10cSrcweir     ::rtl::OUString ODataAccessStaticTools::composeTableNameForSelect( const Reference< XConnection >& _rxConnection, const Reference< XPropertySet>& _xTable ) const
146cdf0e10cSrcweir     {
147cdf0e10cSrcweir         return ::dbtools::composeTableNameForSelect( _rxConnection, _xTable );
148cdf0e10cSrcweir     }
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	//----------------------------------------------------------------
prependContextInfo(SQLException & _rException,const Reference<XInterface> & _rxContext,const::rtl::OUString & _rContextDescription,const::rtl::OUString & _rContextDetails) const151cdf0e10cSrcweir 	SQLContext ODataAccessStaticTools::prependContextInfo(SQLException& _rException, const Reference< XInterface >& _rxContext,
152cdf0e10cSrcweir 		const ::rtl::OUString& _rContextDescription, const ::rtl::OUString& _rContextDetails) const
153cdf0e10cSrcweir 	{
154cdf0e10cSrcweir 		return ::dbtools::prependContextInfo(_rException, _rxContext, _rContextDescription, _rContextDetails);
155cdf0e10cSrcweir 	}
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 	//----------------------------------------------------------------
getDataSource(const::rtl::OUString & _rsRegisteredName,const Reference<XMultiServiceFactory> & _rxFactory) const158cdf0e10cSrcweir 	Reference< XDataSource > ODataAccessStaticTools::getDataSource( const ::rtl::OUString& _rsRegisteredName, const Reference< XMultiServiceFactory>& _rxFactory ) const
159cdf0e10cSrcweir 	{
160cdf0e10cSrcweir 		return ::dbtools::getDataSource( _rsRegisteredName, _rxFactory );
161cdf0e10cSrcweir 	}
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	//----------------------------------------------------------------
canInsert(const Reference<XPropertySet> & _rxCursorSet) const164cdf0e10cSrcweir 	sal_Bool ODataAccessStaticTools::canInsert(const Reference< XPropertySet>& _rxCursorSet) const
165cdf0e10cSrcweir 	{
166cdf0e10cSrcweir 		return ::dbtools::canInsert( _rxCursorSet );
167cdf0e10cSrcweir 	}
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	//----------------------------------------------------------------
canUpdate(const Reference<XPropertySet> & _rxCursorSet) const170cdf0e10cSrcweir 	sal_Bool ODataAccessStaticTools::canUpdate(const Reference< XPropertySet>& _rxCursorSet) const
171cdf0e10cSrcweir 	{
172cdf0e10cSrcweir 		return ::dbtools::canUpdate( _rxCursorSet );
173cdf0e10cSrcweir 	}
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 	//----------------------------------------------------------------
canDelete(const Reference<XPropertySet> & _rxCursorSet) const176cdf0e10cSrcweir 	sal_Bool ODataAccessStaticTools::canDelete(const Reference< XPropertySet>& _rxCursorSet) const
177cdf0e10cSrcweir 	{
178cdf0e10cSrcweir 		return ::dbtools::canDelete( _rxCursorSet );
179cdf0e10cSrcweir 	}
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 	//----------------------------------------------------------------
getFieldsByCommandDescriptor(const Reference<XConnection> & _rxConnection,const sal_Int32 _nCommandType,const::rtl::OUString & _rCommand,Reference<XComponent> & _rxKeepFieldsAlive,::dbtools::SQLExceptionInfo * _pErrorInfo)182cdf0e10cSrcweir 	Reference< XNameAccess > ODataAccessStaticTools::getFieldsByCommandDescriptor( const Reference< XConnection >& _rxConnection,
183cdf0e10cSrcweir 		const sal_Int32 _nCommandType, const ::rtl::OUString& _rCommand,
184cdf0e10cSrcweir 			Reference< XComponent >& _rxKeepFieldsAlive, ::dbtools::SQLExceptionInfo* _pErrorInfo ) SAL_THROW( ( ) )
185cdf0e10cSrcweir 	{
186cdf0e10cSrcweir 		return ::dbtools::getFieldsByCommandDescriptor( _rxConnection, _nCommandType, _rCommand,
187cdf0e10cSrcweir 			_rxKeepFieldsAlive, _pErrorInfo );
188cdf0e10cSrcweir 	}
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 	//----------------------------------------------------------------
getFieldNamesByCommandDescriptor(const Reference<XConnection> & _rxConnection,const sal_Int32 _nCommandType,const::rtl::OUString & _rCommand,::dbtools::SQLExceptionInfo * _pErrorInfo)191cdf0e10cSrcweir 	Sequence< ::rtl::OUString > ODataAccessStaticTools::getFieldNamesByCommandDescriptor(
192cdf0e10cSrcweir 		const Reference< XConnection >& _rxConnection, const sal_Int32 _nCommandType,
193cdf0e10cSrcweir 		const ::rtl::OUString& _rCommand, ::dbtools::SQLExceptionInfo* _pErrorInfo ) SAL_THROW( ( ) )
194cdf0e10cSrcweir 	{
195cdf0e10cSrcweir 		return ::dbtools::getFieldNamesByCommandDescriptor( _rxConnection, _nCommandType,
196cdf0e10cSrcweir 			_rCommand, _pErrorInfo );
197cdf0e10cSrcweir 	}
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 	// ------------------------------------------------
isEmbeddedInDatabase(const Reference<XInterface> & _rxComponent,Reference<XConnection> & _rxActualConnection)200cdf0e10cSrcweir     bool ODataAccessStaticTools::isEmbeddedInDatabase( const Reference< XInterface >& _rxComponent, Reference< XConnection >& _rxActualConnection )
201cdf0e10cSrcweir     {
202cdf0e10cSrcweir 		return ::dbtools::isEmbeddedInDatabase( _rxComponent, _rxActualConnection );
203cdf0e10cSrcweir     }
204cdf0e10cSrcweir 
205cdf0e10cSrcweir //........................................................................
206cdf0e10cSrcweir }	// namespace connectivity
207cdf0e10cSrcweir //........................................................................
208cdf0e10cSrcweir 
209