Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef _FORMS_EDIT_HXX_
21 : : #define _FORMS_EDIT_HXX_
22 : :
23 : : #include "EditBase.hxx"
24 : :
25 : : #include <tools/link.hxx>
26 : : #include <cppuhelper/implbase3.hxx>
27 : :
28 : : namespace dbtools { class FormattedColumnValue; }
29 : :
30 : : //.........................................................................
31 : : namespace frm
32 : : {
33 : :
34 : : //==================================================================
35 : : //= OEditModel
36 : : //==================================================================
37 : : class OEditModel
38 : : :public OEditBaseModel
39 : : {
40 : : ::std::auto_ptr< ::dbtools::FormattedColumnValue >
41 : : m_pValueFormatter;
42 : : sal_Bool m_bMaxTextLenModified : 1; // set to <TRUE/> when we change the MaxTextLen of the aggregate
43 : :
44 : : sal_Bool m_bWritingFormattedFake : 1;
45 : : // are we writing something which should be interpreted as formatted upon reading?
46 : :
47 : : protected:
48 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
49 : :
50 : : DECLARE_DEFAULT_LEAF_XTOR( OEditModel );
51 : :
52 : 0 : void enableFormattedWriteFake() { m_bWritingFormattedFake = sal_True; }
53 : 0 : void disableFormattedWriteFake() { m_bWritingFormattedFake = sal_False; }
54 : 2 : sal_Bool lastReadWasFormattedFake() const { return (getLastReadVersion() & PF_FAKE_FORMATTED_FIELD) != 0; }
55 : :
56 : : friend InterfaceRef SAL_CALL OEditModel_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
57 : : friend class OFormattedFieldWrapper;
58 : : friend class OFormattedModel; // temporary
59 : :
60 : : public:
61 : : virtual void SAL_CALL disposing();
62 : :
63 : : // XPropertySet
64 : : virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
65 : :
66 : : // XPersistObject
67 : : 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);
68 : : 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);
69 : : virtual ::rtl::OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException);
70 : :
71 : : // XPropertySet
72 : : using OBoundControlModel::getFastPropertyValue;
73 : :
74 : : // XReset
75 : : virtual void SAL_CALL reset( ) throw(::com::sun::star::uno::RuntimeException);
76 : :
77 : : // XServiceInfo
78 [ + - ]: 16 : IMPLEMENTATION_NAME(OEditModel);
79 : : virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
80 : :
81 : : // OControlModel's property handling
82 : : virtual void describeFixedProperties(
83 : : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
84 : : ) const;
85 : : virtual void describeAggregateProperties(
86 : : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps
87 : : ) const;
88 : :
89 : : // XEventListener
90 : : using OBoundControlModel::disposing;
91 : :
92 : : protected:
93 : : // OControlModel overridables
94 : : virtual void writeAggregate( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream >& _rxOutStream ) const;
95 : : virtual void readAggregate( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream >& _rxInStream );
96 : :
97 : : // OBoundControlModel overridables
98 : : virtual ::com::sun::star::uno::Any
99 : : translateDbColumnToControlValue( );
100 : : virtual sal_Bool commitControlValueToDbColumn( bool _bPostReset );
101 : :
102 : : virtual ::com::sun::star::uno::Any
103 : : getDefaultForReset() const;
104 : :
105 : : virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm );
106 : : virtual void onDisconnectedDbColumn();
107 : :
108 : : virtual sal_Bool approveDbColumnType( sal_Int32 _nColumnType );
109 : :
110 : : virtual void resetNoBroadcast();
111 : :
112 : : protected:
113 : : virtual sal_uInt16 getPersistenceFlags() const;
114 : :
115 : : DECLARE_XCLONEABLE();
116 : :
117 : : private:
118 : : bool implActsAsRichText( ) const;
119 : : };
120 : :
121 : : //==================================================================
122 : : //= OEditControl
123 : : //==================================================================
124 : : typedef ::cppu::ImplHelper3< ::com::sun::star::awt::XFocusListener,
125 : : ::com::sun::star::awt::XKeyListener,
126 : : ::com::sun::star::form::XChangeBroadcaster > OEditControl_BASE;
127 : :
128 : : class OEditControl : public OBoundControl
129 : : ,public OEditControl_BASE
130 : : {
131 : : ::cppu::OInterfaceContainerHelper
132 : : m_aChangeListeners;
133 : :
134 : : ::rtl::OUString m_aHtmlChangeValue;
135 : : sal_uInt32 m_nKeyEvent;
136 : :
137 : : public:
138 : : OEditControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
139 : : virtual ~OEditControl();
140 : :
141 : 158171 : DECLARE_UNO3_AGG_DEFAULTS(OEditControl, OBoundControl);
142 : : virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException);
143 : :
144 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
145 : :
146 : : // OComponentHelper
147 : : virtual void SAL_CALL disposing();
148 : :
149 : : // ::com::sun::star::lang::XEventListener
150 : : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource) throw(::com::sun::star::uno::RuntimeException);
151 : :
152 : : // ::com::sun::star::lang::XServiceInfo
153 [ # # ]: 0 : IMPLEMENTATION_NAME(OEditControl);
154 : : virtual StringSequence SAL_CALL getSupportedServiceNames() throw();
155 : :
156 : : // ::com::sun::star::form::XChangeBroadcaster
157 : : virtual void SAL_CALL addChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XChangeListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException);
158 : : virtual void SAL_CALL removeChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XChangeListener>& _rxListener) throw ( ::com::sun::star::uno::RuntimeException);
159 : :
160 : : // ::com::sun::star::awt::XFocusListener
161 : : virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw ( ::com::sun::star::uno::RuntimeException);
162 : : virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw ( ::com::sun::star::uno::RuntimeException);
163 : :
164 : : // ::com::sun::star::awt::XKeyListener
165 : : virtual void SAL_CALL keyPressed(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException);
166 : : virtual void SAL_CALL keyReleased(const ::com::sun::star::awt::KeyEvent& e) throw ( ::com::sun::star::uno::RuntimeException);
167 : :
168 : : // XControl
169 : : 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 );
170 : :
171 : : private:
172 : : DECL_LINK( OnKeyPressed, void* );
173 : : };
174 : :
175 : : //.........................................................................
176 : : }
177 : : //.........................................................................
178 : :
179 : : #endif // _FORMS_EDIT_HXX_
180 : :
181 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|