1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Edit.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _FORMS_EDIT_HXX_
32 #define _FORMS_EDIT_HXX_
34 #include "EditBase.hxx"
36 #include <cppuhelper/implbase3.hxx>
38 namespace dbtools
{ class FormattedColumnValue
; }
40 //.........................................................................
44 //==================================================================
46 //==================================================================
48 :public OEditBaseModel
50 ::com::sun::star::uno::Any m_aLastKnownValue
;
51 ::std::auto_ptr
< ::dbtools::FormattedColumnValue
>
53 sal_Bool m_bMaxTextLenModified
: 1; // set to <TRUE/> when we change the MaxTextLen of the aggregate
55 sal_Bool m_bWritingFormattedFake
: 1;
56 // are we writing something which should be interpreted as formatted upon reading?
59 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> _getTypes();
61 DECLARE_DEFAULT_LEAF_XTOR( OEditModel
);
63 void enableFormattedWriteFake() { m_bWritingFormattedFake
= sal_True
; }
64 void disableFormattedWriteFake() { m_bWritingFormattedFake
= sal_False
; }
65 sal_Bool
lastReadWasFormattedFake() const { return (getLastReadVersion() & PF_FAKE_FORMATTED_FIELD
) != 0; }
67 friend InterfaceRef SAL_CALL
OEditModel_CreateInstance(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxFactory
);
68 friend class OFormattedFieldWrapper
;
69 friend class OFormattedModel
; // temporary
72 virtual void SAL_CALL
disposing();
75 virtual void SAL_CALL
getFastPropertyValue(::com::sun::star::uno::Any
& rValue
, sal_Int32 nHandle
) const;
78 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
);
79 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
);
80 virtual ::rtl::OUString SAL_CALL
getServiceName() throw ( ::com::sun::star::uno::RuntimeException
);
83 using OBoundControlModel::getFastPropertyValue
;
86 virtual void SAL_CALL
reset( ) throw(::com::sun::star::uno::RuntimeException
);
89 IMPLEMENTATION_NAME(OEditModel
);
90 virtual StringSequence SAL_CALL
getSupportedServiceNames() throw();
92 // OControlModel's property handling
93 virtual void describeFixedProperties(
94 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& /* [out] */ _rProps
96 virtual void describeAggregateProperties(
97 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& /* [out] */ _rAggregateProps
101 using OBoundControlModel::disposing
;
104 // OControlModel overridables
105 virtual void writeAggregate( const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XObjectOutputStream
>& _rxOutStream
) const;
106 virtual void readAggregate( const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XObjectInputStream
>& _rxInStream
);
108 // OBoundControlModel overridables
109 virtual ::com::sun::star::uno::Any
110 translateDbColumnToControlValue( );
111 virtual sal_Bool
commitControlValueToDbColumn( bool _bPostReset
);
113 virtual ::com::sun::star::uno::Any
114 getDefaultForReset() const;
116 virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxForm
);
117 virtual void onDisconnectedDbColumn();
119 virtual sal_Bool
approveDbColumnType( sal_Int32 _nColumnType
);
122 virtual sal_uInt16
getPersistenceFlags() const;
124 DECLARE_XCLONEABLE();
127 bool implActsAsRichText( ) const;
130 //==================================================================
132 //==================================================================
133 typedef ::cppu::ImplHelper3
< ::com::sun::star::awt::XFocusListener
,
134 ::com::sun::star::awt::XKeyListener
,
135 ::com::sun::star::form::XChangeBroadcaster
> OEditControl_BASE
;
137 class OEditControl
: public OBoundControl
138 ,public OEditControl_BASE
140 ::cppu::OInterfaceContainerHelper
143 ::rtl::OUString m_aHtmlChangeValue
;
144 sal_uInt32 m_nKeyEvent
;
147 OEditControl(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxFactory
);
148 virtual ~OEditControl();
150 DECLARE_UNO3_AGG_DEFAULTS(OEditControl
, OBoundControl
);
151 virtual ::com::sun::star::uno::Any SAL_CALL
queryAggregation(const ::com::sun::star::uno::Type
& _rType
) throw(::com::sun::star::uno::RuntimeException
);
153 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> _getTypes();
156 virtual void SAL_CALL
disposing();
158 // ::com::sun::star::lang::XEventListener
159 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& _rSource
) throw(::com::sun::star::uno::RuntimeException
);
161 // ::com::sun::star::lang::XServiceInfo
162 IMPLEMENTATION_NAME(OEditControl
);
163 virtual StringSequence SAL_CALL
getSupportedServiceNames() throw();
165 // ::com::sun::star::form::XChangeBroadcaster
166 virtual void SAL_CALL
addChangeListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XChangeListener
>& _rxListener
) throw ( ::com::sun::star::uno::RuntimeException
);
167 virtual void SAL_CALL
removeChangeListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XChangeListener
>& _rxListener
) throw ( ::com::sun::star::uno::RuntimeException
);
169 // ::com::sun::star::awt::XFocusListener
170 virtual void SAL_CALL
focusGained( const ::com::sun::star::awt::FocusEvent
& e
) throw ( ::com::sun::star::uno::RuntimeException
);
171 virtual void SAL_CALL
focusLost( const ::com::sun::star::awt::FocusEvent
& e
) throw ( ::com::sun::star::uno::RuntimeException
);
173 // ::com::sun::star::awt::XKeyListener
174 virtual void SAL_CALL
keyPressed(const ::com::sun::star::awt::KeyEvent
& e
) throw ( ::com::sun::star::uno::RuntimeException
);
175 virtual void SAL_CALL
keyReleased(const ::com::sun::star::awt::KeyEvent
& e
) throw ( ::com::sun::star::uno::RuntimeException
);
178 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
);
181 DECL_LINK( OnKeyPressed
, void* );
184 //.........................................................................
186 //.........................................................................
188 #endif // _FORMS_EDIT_HXX_