xref: /AOO41X/main/forms/source/component/Edit.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _FORMS_EDIT_HXX_
29*cdf0e10cSrcweir #define _FORMS_EDIT_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "EditBase.hxx"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir namespace dbtools { class FormattedColumnValue; }
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir //.........................................................................
38*cdf0e10cSrcweir namespace frm
39*cdf0e10cSrcweir {
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir //==================================================================
42*cdf0e10cSrcweir //= OEditModel
43*cdf0e10cSrcweir //==================================================================
44*cdf0e10cSrcweir class OEditModel
45*cdf0e10cSrcweir 				:public OEditBaseModel
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir     ::std::auto_ptr< ::dbtools::FormattedColumnValue >
48*cdf0e10cSrcweir                                 m_pValueFormatter;
49*cdf0e10cSrcweir 	sal_Bool					m_bMaxTextLenModified : 1;	// set to <TRUE/> when we change the MaxTextLen of the aggregate
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir 	sal_Bool					m_bWritingFormattedFake : 1;
52*cdf0e10cSrcweir 		// are we writing something which should be interpreted as formatted upon reading?
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir protected:
55*cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir 	DECLARE_DEFAULT_LEAF_XTOR( OEditModel );
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir 	void enableFormattedWriteFake() { m_bWritingFormattedFake = sal_True; }
60*cdf0e10cSrcweir 	void disableFormattedWriteFake() { m_bWritingFormattedFake = sal_False; }
61*cdf0e10cSrcweir 	sal_Bool lastReadWasFormattedFake() const { return (getLastReadVersion() & PF_FAKE_FORMATTED_FIELD) != 0; }
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 	friend InterfaceRef SAL_CALL OEditModel_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
64*cdf0e10cSrcweir 	friend class OFormattedFieldWrapper;
65*cdf0e10cSrcweir 	friend class OFormattedModel;	// temporary
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir public:
68*cdf0e10cSrcweir 	virtual void SAL_CALL disposing();
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 	// XPropertySet
71*cdf0e10cSrcweir 	virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir     // XPersistObject
74*cdf0e10cSrcweir 	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*cdf0e10cSrcweir 	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*cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException);
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir     // XPropertySet
79*cdf0e10cSrcweir     using OBoundControlModel::getFastPropertyValue;
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir     // XReset
82*cdf0e10cSrcweir     virtual void SAL_CALL reset(  ) throw(::com::sun::star::uno::RuntimeException);
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir     // XServiceInfo
85*cdf0e10cSrcweir 	IMPLEMENTATION_NAME(OEditModel);
86*cdf0e10cSrcweir 	virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     // OControlModel's property handling
89*cdf0e10cSrcweir 	virtual void describeFixedProperties(
90*cdf0e10cSrcweir 		::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
91*cdf0e10cSrcweir     ) const;
92*cdf0e10cSrcweir     virtual void describeAggregateProperties(
93*cdf0e10cSrcweir 		::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps
94*cdf0e10cSrcweir     ) const;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     // XEventListener
97*cdf0e10cSrcweir     using OBoundControlModel::disposing;
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir protected:
100*cdf0e10cSrcweir     // OControlModel overridables
101*cdf0e10cSrcweir     virtual void writeAggregate( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream >& _rxOutStream ) const;
102*cdf0e10cSrcweir     virtual void readAggregate( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream >& _rxInStream );
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     // OBoundControlModel overridables
105*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any
106*cdf0e10cSrcweir                             translateDbColumnToControlValue( );
107*cdf0e10cSrcweir     virtual sal_Bool        commitControlValueToDbColumn( bool _bPostReset );
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any
110*cdf0e10cSrcweir                             getDefaultForReset() const;
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir 	virtual void            onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm );
113*cdf0e10cSrcweir 	virtual void            onDisconnectedDbColumn();
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 	virtual sal_Bool		approveDbColumnType( sal_Int32 _nColumnType );
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	virtual void            resetNoBroadcast();
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir protected:
120*cdf0e10cSrcweir 	virtual sal_uInt16 getPersistenceFlags() const;
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 	DECLARE_XCLONEABLE();
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir private:
125*cdf0e10cSrcweir     bool    implActsAsRichText( ) const;
126*cdf0e10cSrcweir };
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir //==================================================================
129*cdf0e10cSrcweir //= OEditControl
130*cdf0e10cSrcweir //==================================================================
131*cdf0e10cSrcweir typedef ::cppu::ImplHelper3<	::com::sun::star::awt::XFocusListener,
132*cdf0e10cSrcweir 								::com::sun::star::awt::XKeyListener,
133*cdf0e10cSrcweir 								::com::sun::star::form::XChangeBroadcaster > OEditControl_BASE;
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir class OEditControl : public OBoundControl
136*cdf0e10cSrcweir 					  ,public OEditControl_BASE
137*cdf0e10cSrcweir {
138*cdf0e10cSrcweir 	::cppu::OInterfaceContainerHelper
139*cdf0e10cSrcweir 						m_aChangeListeners;
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 	::rtl::OUString			m_aHtmlChangeValue;
142*cdf0e10cSrcweir 	sal_uInt32 				m_nKeyEvent;
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir public:
145*cdf0e10cSrcweir 	OEditControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
146*cdf0e10cSrcweir 	virtual ~OEditControl();
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 	DECLARE_UNO3_AGG_DEFAULTS(OEditControl, OBoundControl);
149*cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException);
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir // OComponentHelper
154*cdf0e10cSrcweir 	virtual void SAL_CALL disposing();
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir // ::com::sun::star::lang::XEventListener
157*cdf0e10cSrcweir 	virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException);
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo
160*cdf0e10cSrcweir 	IMPLEMENTATION_NAME(OEditControl);
161*cdf0e10cSrcweir 	virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir // ::com::sun::star::form::XChangeBroadcaster
164*cdf0e10cSrcweir 	virtual void SAL_CALL addChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XChangeListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException);
165*cdf0e10cSrcweir 	virtual void SAL_CALL removeChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XChangeListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException);
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir // ::com::sun::star::awt::XFocusListener
168*cdf0e10cSrcweir 	virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw ( ::com::sun::star::uno::RuntimeException);
169*cdf0e10cSrcweir 	virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw ( ::com::sun::star::uno::RuntimeException);
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir // ::com::sun::star::awt::XKeyListener
172*cdf0e10cSrcweir 	virtual void SAL_CALL keyPressed(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException);
173*cdf0e10cSrcweir 	virtual void SAL_CALL keyReleased(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException);
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir     // XControl
176*cdf0e10cSrcweir     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*cdf0e10cSrcweir 
178*cdf0e10cSrcweir private:
179*cdf0e10cSrcweir 	DECL_LINK( OnKeyPressed, void* );
180*cdf0e10cSrcweir };
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir //.........................................................................
183*cdf0e10cSrcweir }
184*cdf0e10cSrcweir //.........................................................................
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir #endif // _FORMS_EDIT_HXX_
187*cdf0e10cSrcweir 
188