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 SVX_TYPECONVERSION_CLIENT_HXX
25 #define SVX_TYPECONVERSION_CLIENT_HXX
26 
27 #include "svx/dbtoolsclient.hxx"
28 
29 //........................................................................
30 namespace svxform
31 {
32 //........................................................................
33 
34 	//====================================================================
35 	//= OTypeConversionClient
36 	//====================================================================
37 	class OTypeConversionClient : public ODbtoolsClient
38 	{
39 	protected:
40 		mutable ::rtl::Reference< ::connectivity::simple::IDataAccessTypeConversion >
41 				m_xTypeConversion;
42         virtual bool ensureLoaded() const;
43 
44 	public:
45 		OTypeConversionClient();
46 
47 		// --------------------------------------------------------
getStandardDate() const48 		inline ::com::sun::star::util::Date getStandardDate() const
49 		{
50 			::com::sun::star::util::Date aReturn;
51             if ( ensureLoaded() )
52 				aReturn = m_xTypeConversion->getStandardDate();
53 			return aReturn;
54 		}
55 
56 		// --------------------------------------------------------
getValue(const::com::sun::star::uno::Reference<::com::sun::star::sdb::XColumn> & _rxVariant,const::com::sun::star::util::Date & _rNullDate) const57 		inline double getValue(
58 			const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& _rxVariant,
59 			const ::com::sun::star::util::Date& _rNullDate ) const
60 		{
61 			double nReturn(0);
62             if ( ensureLoaded() )
63 				nReturn = m_xTypeConversion->getValue( _rxVariant, _rNullDate );
64 			return nReturn;
65 		}
66 
67 		// --------------------------------------------------------
getFormattedValue(const::com::sun::star::uno::Reference<::com::sun::star::sdb::XColumn> & _rxColumn,const::com::sun::star::uno::Reference<::com::sun::star::util::XNumberFormatter> & _rxFormatter,const::com::sun::star::util::Date & _rNullDate,sal_Int32 _nKey,sal_Int16 _nKeyType) const68 		inline ::rtl::OUString getFormattedValue(
69 			const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxColumn,
70 			const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
71 			const ::com::sun::star::util::Date& _rNullDate,
72 			sal_Int32 _nKey,
73 			sal_Int16 _nKeyType) const
74 		{
75 			::rtl::OUString sReturn;
76             if ( ensureLoaded() )
77 				sReturn = m_xTypeConversion->getFormattedValue(_rxColumn, _rxFormatter, _rNullDate, _nKey, _nKeyType);
78 			return sReturn;
79 		}
80 	};
81 
82 //........................................................................
83 }	// namespace svxform
84 //........................................................................
85 
86 #endif // SVX_TYPECONVERSION_CLIENT_HXX
87 
88 
89