1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_FORMS_SOURCE_COMPONENT_EDIT_HXX
21 #define INCLUDED_FORMS_SOURCE_COMPONENT_EDIT_HXX
23 #include "EditBase.hxx"
25 #include <tools/link.hxx>
26 #include <cppuhelper/implbase3.hxx>
28 namespace dbtools
{ class FormattedColumnValue
; }
34 class OEditModel
: public OEditBaseModel
36 ::std::unique_ptr
< ::dbtools::FormattedColumnValue
>
38 bool m_bMaxTextLenModified
: 1; // set to <TRUE/> when we change the MaxTextLen of the aggregate
40 bool m_bWritingFormattedFake
: 1; // are we writing something which should be interpreted as formatted upon reading?
43 DECLARE_DEFAULT_LEAF_XTOR( OEditModel
);
46 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> _getTypes() SAL_OVERRIDE
;
48 void enableFormattedWriteFake() { m_bWritingFormattedFake
= true; }
49 void disableFormattedWriteFake() { m_bWritingFormattedFake
= false; }
50 bool lastReadWasFormattedFake() const { return (getLastReadVersion() & PF_FAKE_FORMATTED_FIELD
) != 0; }
52 friend class OFormattedFieldWrapper
;
53 friend class OFormattedModel
; // temporary
56 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
59 virtual void SAL_CALL
getFastPropertyValue(::com::sun::star::uno::Any
& rValue
, sal_Int32 nHandle
) const SAL_OVERRIDE
;
62 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
;
63 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
;
64 virtual OUString SAL_CALL
getServiceName() throw ( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
67 using OBoundControlModel::getFastPropertyValue
;
70 virtual void SAL_CALL
reset( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
73 OUString SAL_CALL
getImplementationName()
74 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
75 { return OUString("com.sun.star.form.OEditModel"); }
77 virtual StringSequence SAL_CALL
getSupportedServiceNames() throw(std::exception
) SAL_OVERRIDE
;
79 // OControlModel's property handling
80 virtual void describeFixedProperties(
81 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& /* [out] */ _rProps
83 virtual void describeAggregateProperties(
84 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
>& /* [out] */ _rAggregateProps
88 using OBoundControlModel::disposing
;
91 // OControlModel overridables
92 virtual void writeAggregate( const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XObjectOutputStream
>& _rxOutStream
) const SAL_OVERRIDE
;
93 virtual void readAggregate( const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XObjectInputStream
>& _rxInStream
) SAL_OVERRIDE
;
95 // OBoundControlModel overridables
96 virtual ::com::sun::star::uno::Any
97 translateDbColumnToControlValue( ) SAL_OVERRIDE
;
98 virtual bool commitControlValueToDbColumn( bool _bPostReset
) SAL_OVERRIDE
;
100 virtual ::com::sun::star::uno::Any
101 getDefaultForReset() const SAL_OVERRIDE
;
103 virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxForm
) SAL_OVERRIDE
;
104 virtual void onDisconnectedDbColumn() SAL_OVERRIDE
;
106 virtual bool approveDbColumnType( sal_Int32 _nColumnType
) SAL_OVERRIDE
;
108 virtual void resetNoBroadcast() SAL_OVERRIDE
;
111 virtual sal_uInt16
getPersistenceFlags() const SAL_OVERRIDE
;
113 virtual css::uno::Reference
< css::util::XCloneable
> SAL_CALL
createClone( ) throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
116 bool implActsAsRichText( ) const;
122 typedef ::cppu::ImplHelper3
< ::com::sun::star::awt::XFocusListener
,
123 ::com::sun::star::awt::XKeyListener
,
124 ::com::sun::star::form::XChangeBroadcaster
> OEditControl_BASE
;
126 class OEditControl
: public OBoundControl
127 ,public OEditControl_BASE
129 ::cppu::OInterfaceContainerHelper
132 OUString m_aHtmlChangeValue
;
133 ImplSVEvent
* m_nKeyEvent
;
136 OEditControl(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
);
137 virtual ~OEditControl();
139 DECLARE_UNO3_AGG_DEFAULTS(OEditControl
, OBoundControl
)
140 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
;
142 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> _getTypes() SAL_OVERRIDE
;
145 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
147 // ::com::sun::star::lang::XEventListener
148 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& _rSource
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
150 // ::com::sun::star::lang::XServiceInfo
151 OUString SAL_CALL
getImplementationName()
152 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
153 { return OUString("com.sun.star.form.OEditControl"); }
155 virtual StringSequence SAL_CALL
getSupportedServiceNames() throw(std::exception
) SAL_OVERRIDE
;
157 // ::com::sun::star::form::XChangeBroadcaster
158 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
;
159 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
;
161 // ::com::sun::star::awt::XFocusListener
162 virtual void SAL_CALL
focusGained( const ::com::sun::star::awt::FocusEvent
& e
) throw ( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
163 virtual void SAL_CALL
focusLost( const ::com::sun::star::awt::FocusEvent
& e
) throw ( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
165 // ::com::sun::star::awt::XKeyListener
166 virtual void SAL_CALL
keyPressed(const ::com::sun::star::awt::KeyEvent
& e
) throw ( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
167 virtual void SAL_CALL
keyReleased(const ::com::sun::star::awt::KeyEvent
& e
) throw ( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
170 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
;
173 DECL_LINK( OnKeyPressed
, void* );
178 #endif // INCLUDED_FORMS_SOURCE_COMPONENT_EDIT_HXX
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */