xref: /aoo41x/main/forms/source/component/Date.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _FORMS_DATE_HXX_
29 #define _FORMS_DATE_HXX_
30 
31 #include "EditBase.hxx"
32 #include "limitedformats.hxx"
33 
34 //.........................................................................
35 namespace frm
36 {
37 //.........................................................................
38 
39 //==================================================================
40 //= ODateModel
41 //==================================================================
42 class ODateModel
43 				:public OEditBaseModel
44 				,public OLimitedFormats
45 {
46 	::com::sun::star::uno::Any		m_aSaveValue;
47 	sal_Bool			            m_bDateTimeField;
48 
49 protected:
50 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
51 
52 public:
53 	DECLARE_DEFAULT_LEAF_XTOR( ODateModel );
54 
55     // XPersistObject
56 	virtual ::rtl::OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException );
57 
58 	// ::com::sun::star::beans::XPropertySet
59 	virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
60 	virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue,
61 										  sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
62 										throw(::com::sun::star::lang::IllegalArgumentException);
63 	virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw ( ::com::sun::star::uno::Exception);
64 
65     // XServiceInfo
66 	IMPLEMENTATION_NAME(ODateModel);
67 	virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
68 
69     // XPropertySet
70     using OEditBaseModel::getFastPropertyValue;
71 
72     // OControlModel's property handling
73 	virtual void describeFixedProperties(
74 		::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
75     ) const;
76 
77 protected:
78     // OBoundControlModel overridables
79     virtual ::com::sun::star::uno::Any
80                             translateDbColumnToControlValue( );
81     virtual sal_Bool        commitControlValueToDbColumn( bool _bPostReset );
82 
83     virtual ::com::sun::star::uno::Any
84                             translateControlValueToExternalValue( ) const;
85     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >
86                             getSupportedBindingTypes();
87     virtual ::com::sun::star::uno::Any
88                             translateExternalValueToControlValue( const ::com::sun::star::uno::Any& _rExternalValue ) const;
89 
90     virtual ::com::sun::star::uno::Any
91                             translateControlValueToValidatableValue( ) const;
92 
93     virtual ::com::sun::star::uno::Any
94                             getDefaultForReset() const;
95 
96 	virtual void            resetNoBroadcast();
97 
98     virtual void		    onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm );
99 
100 protected:
101 	DECLARE_XCLONEABLE();
102 
103 private:
104     /** translates the control value (the VCL-internal integer representation of a date) into
105         a UNO-Date.
106     */
107     void                    impl_translateControlValueToUNODate(
108                                 ::com::sun::star::uno::Any& _rUNOValue ) const;
109 };
110 
111 //==================================================================
112 //= ODateControl
113 //==================================================================
114 class ODateControl: public OBoundControl
115 {
116 protected:
117 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
118 
119 public:
120 	ODateControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
121 	DECLARE_UNO3_AGG_DEFAULTS(ODateControl, OBoundControl);
122 
123 // ::com::sun::star::lang::XServiceInfo
124 	IMPLEMENTATION_NAME(ODateControl);
125 	virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
126 };
127 
128 //.........................................................................
129 }	// namespace frm
130 //.........................................................................
131 
132 #endif // _FORMS_DATE_HXX_
133 
134