xref: /AOO41X/main/forms/source/component/EditBase.hxx (revision 2d785d7ea953737df3731803a26e291d82066c5a)
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 _FORMS_EDITBASE_HXX_
25 #define _FORMS_EDITBASE_HXX_
26 
27 #include "FormComponent.hxx"
28 #include <tools/date.hxx>
29 #include <tools/link.hxx>
30 #include <com/sun/star/util/XNumberFormatter.hpp>
31 #include <com/sun/star/awt/XFocusListener.hpp>
32 #include <com/sun/star/awt/XKeyListener.hpp>
33 #include <com/sun/star/form/XChangeBroadcaster.hpp>
34 #include <com/sun/star/lang/XEventListener.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/lang/XComponent.hpp>
37 
38 // persistence flags for use with the version id
39 #define PF_HANDLE_COMMON_PROPS  0x8000
40     // Derived classes which use their own persistence methods (read/write) and have an own
41     // version handling therein may want to clear this flag in getPersistenceFlags.
42     // If done so, this class will write an version without a call to writeCommonEditProperties.
43 #define PF_FAKE_FORMATTED_FIELD 0x4000
44     // .... hmmm .... a fake, as the name suggests. see OFormattedFieldWrapper
45 #define PF_RESERVED_2           0x2000
46 #define PF_RESERVED_3           0x1000
47 #define PF_RESERVED_4           0x0800
48 #define PF_RESERVED_5           0x0400
49 #define PF_RESERVED_6           0x0200
50 #define PF_RESERVED_7           0x0100
51 
52 #define PF_SPECIAL_FLAGS        0xFF00
53 
54 //.........................................................................
55 namespace frm
56 {
57 
58 //==================================================================
59 //= OEditBaseModel
60 //==================================================================
61 class OEditBaseModel :  public OBoundControlModel
62 {
63     sal_Int16                   m_nLastReadVersion;
64 
65 protected:
66 // [properties]         fuer all Editierfelder
67     ::com::sun::star::uno::Any  m_aDefault;
68     ::rtl::OUString             m_aDefaultText;             // default value
69     sal_Bool                    m_bEmptyIsNull : 1;         // empty string will be interepreted as NULL when committing
70     sal_Bool                    m_bFilterProposal : 1;      // use a list of possible value in filtermode
71 // [properties]
72 
getLastReadVersion() const73     sal_Int16   getLastReadVersion() const { return m_nLastReadVersion; }
74 
75 public:
76     DECLARE_DEFAULT_BOUND_XTOR( OEditBaseModel );
77 
78     // XPersistObject
79     virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
80     virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
81 
82     // XPropertySet
83     virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
84     virtual sal_Bool SAL_CALL convertFastPropertyValue(::com::sun::star::uno::Any& rConvertedValue, ::com::sun::star::uno::Any& rOldValue,
85                                           sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
86                                         throw(::com::sun::star::lang::IllegalArgumentException);
87     virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw ( ::com::sun::star::uno::Exception);
88     using ::cppu::OPropertySetHelper::getFastPropertyValue;
89 
90     // XPropertyState
91     virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle( sal_Int32 nHandle ) const;
92 
93 protected:
94     // new properties common to all edit models should be handled with the following two methods
95     void SAL_CALL readCommonEditProperties(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream);
96     void SAL_CALL writeCommonEditProperties(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream);
97     void defaultCommonEditProperties();
98 
99     virtual sal_uInt16 getPersistenceFlags() const;
100         // derived classes may use this if they want this base class to write additinal version flags
101         // (one of the PF_.... constants). After ::read they may ask for that flags with getLastReadVersion
102 };
103 
104 //.........................................................................
105 }
106 //.........................................................................
107 
108 #endif // _FORMS_EDITBASE_HXX_
109 
110