xref: /trunk/main/forms/source/component/Edit.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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_EDIT_HXX_
29 #define _FORMS_EDIT_HXX_
30 
31 #include "EditBase.hxx"
32 
33 #include <cppuhelper/implbase3.hxx>
34 
35 namespace dbtools { class FormattedColumnValue; }
36 
37 //.........................................................................
38 namespace frm
39 {
40 
41 //==================================================================
42 //= OEditModel
43 //==================================================================
44 class OEditModel
45                 :public OEditBaseModel
46 {
47     ::std::auto_ptr< ::dbtools::FormattedColumnValue >
48                                 m_pValueFormatter;
49     sal_Bool                    m_bMaxTextLenModified : 1;  // set to <TRUE/> when we change the MaxTextLen of the aggregate
50 
51     sal_Bool                    m_bWritingFormattedFake : 1;
52         // are we writing something which should be interpreted as formatted upon reading?
53 
54 protected:
55     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
56 
57     DECLARE_DEFAULT_LEAF_XTOR( OEditModel );
58 
59     void enableFormattedWriteFake() { m_bWritingFormattedFake = sal_True; }
60     void disableFormattedWriteFake() { m_bWritingFormattedFake = sal_False; }
61     sal_Bool lastReadWasFormattedFake() const { return (getLastReadVersion() & PF_FAKE_FORMATTED_FIELD) != 0; }
62 
63     friend InterfaceRef SAL_CALL OEditModel_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
64     friend class OFormattedFieldWrapper;
65     friend class OFormattedModel;   // temporary
66 
67 public:
68     virtual void SAL_CALL disposing();
69 
70     // XPropertySet
71     virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
72 
73     // XPersistObject
74     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);
75     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);
76     virtual ::rtl::OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException);
77 
78     // XPropertySet
79     using OBoundControlModel::getFastPropertyValue;
80 
81     // XReset
82     virtual void SAL_CALL reset(  ) throw(::com::sun::star::uno::RuntimeException);
83 
84     // XServiceInfo
85     IMPLEMENTATION_NAME(OEditModel);
86     virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
87 
88     // OControlModel's property handling
89     virtual void describeFixedProperties(
90         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
91     ) const;
92     virtual void describeAggregateProperties(
93         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps
94     ) const;
95 
96     // XEventListener
97     using OBoundControlModel::disposing;
98 
99 protected:
100     // OControlModel overridables
101     virtual void writeAggregate( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream >& _rxOutStream ) const;
102     virtual void readAggregate( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream >& _rxInStream );
103 
104     // OBoundControlModel overridables
105     virtual ::com::sun::star::uno::Any
106                             translateDbColumnToControlValue( );
107     virtual sal_Bool        commitControlValueToDbColumn( bool _bPostReset );
108 
109     virtual ::com::sun::star::uno::Any
110                             getDefaultForReset() const;
111 
112     virtual void            onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm );
113     virtual void            onDisconnectedDbColumn();
114 
115     virtual sal_Bool        approveDbColumnType( sal_Int32 _nColumnType );
116 
117     virtual void            resetNoBroadcast();
118 
119 protected:
120     virtual sal_uInt16 getPersistenceFlags() const;
121 
122     DECLARE_XCLONEABLE();
123 
124 private:
125     bool    implActsAsRichText( ) const;
126 };
127 
128 //==================================================================
129 //= OEditControl
130 //==================================================================
131 typedef ::cppu::ImplHelper3<    ::com::sun::star::awt::XFocusListener,
132                                 ::com::sun::star::awt::XKeyListener,
133                                 ::com::sun::star::form::XChangeBroadcaster > OEditControl_BASE;
134 
135 class OEditControl : public OBoundControl
136                       ,public OEditControl_BASE
137 {
138     ::cppu::OInterfaceContainerHelper
139                         m_aChangeListeners;
140 
141     ::rtl::OUString         m_aHtmlChangeValue;
142     sal_uInt32              m_nKeyEvent;
143 
144 public:
145     OEditControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
146     virtual ~OEditControl();
147 
148     DECLARE_UNO3_AGG_DEFAULTS(OEditControl, OBoundControl);
149     virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException);
150 
151     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
152 
153 // OComponentHelper
154     virtual void SAL_CALL disposing();
155 
156 // ::com::sun::star::lang::XEventListener
157     virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException);
158 
159 // ::com::sun::star::lang::XServiceInfo
160     IMPLEMENTATION_NAME(OEditControl);
161     virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
162 
163 // ::com::sun::star::form::XChangeBroadcaster
164     virtual void SAL_CALL addChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XChangeListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException);
165     virtual void SAL_CALL removeChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XChangeListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException);
166 
167 // ::com::sun::star::awt::XFocusListener
168     virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw ( ::com::sun::star::uno::RuntimeException);
169     virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw ( ::com::sun::star::uno::RuntimeException);
170 
171 // ::com::sun::star::awt::XKeyListener
172     virtual void SAL_CALL keyPressed(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException);
173     virtual void SAL_CALL keyReleased(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException);
174 
175     // XControl
176     virtual void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& _rxToolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& _rxParent ) throw ( ::com::sun::star::uno::RuntimeException );
177 
178 private:
179     DECL_LINK( OnKeyPressed, void* );
180 };
181 
182 //.........................................................................
183 }
184 //.........................................................................
185 
186 #endif // _FORMS_EDIT_HXX_
187 
188