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