tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / forms / source / component / Edit.hxx
blob6f3c568bcbb6d0e8cfb36e380e9a969e64849a8f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <memory>
23 #include "EditBase.hxx"
25 #include <tools/link.hxx>
26 #include <comphelper/interfacecontainer3.hxx>
27 #include <cppuhelper/implbase3.hxx>
29 #include <com/sun/star/form/XChangeBroadcaster.hpp>
31 namespace dbtools { class FormattedColumnValue; }
32 struct ImplSVEvent;
34 namespace frm
37 class OEditModel final : public OEditBaseModel
39 ::std::unique_ptr< ::dbtools::FormattedColumnValue >
40 m_pValueFormatter;
41 bool m_bMaxTextLenModified : 1; // set to <TRUE/> when we change the MaxTextLen of the aggregate
43 bool m_bWritingFormattedFake : 1; // are we writing something which should be interpreted as formatted upon reading?
45 public:
46 OEditModel(
47 const css::uno::Reference< css::uno::XComponentContext>& _rxFactory
49 OEditModel(
50 const OEditModel* _pOriginal,
51 const css::uno::Reference< css::uno::XComponentContext>& _rxFactory
53 virtual ~OEditModel() override;
55 private:
56 void enableFormattedWriteFake() { m_bWritingFormattedFake = true; }
57 void disableFormattedWriteFake() { m_bWritingFormattedFake = false; }
58 bool lastReadWasFormattedFake() const { return (getLastReadVersion() & PF_FAKE_FORMATTED_FIELD) != 0; }
60 friend class OFormattedFieldWrapper;
61 friend class OFormattedModel; // temporary
63 public:
64 virtual void SAL_CALL disposing() override;
66 // XPropertySet
67 virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue, sal_Int32 nHandle ) const override;
69 // XPersistObject
70 virtual void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream>& _rxOutStream) override;
71 virtual void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream>& _rxInStream) override;
72 virtual OUString SAL_CALL getServiceName() override;
74 // XPropertySet
75 using OBoundControlModel::getFastPropertyValue;
77 // XReset
78 virtual void SAL_CALL reset( ) override;
80 // XServiceInfo
81 OUString SAL_CALL getImplementationName() override
82 { return u"com.sun.star.form.OEditModel"_ustr; }
84 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
86 // OControlModel's property handling
87 virtual void describeFixedProperties(
88 css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps
89 ) const override;
90 virtual void describeAggregateProperties(
91 css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps
92 ) const override;
94 // XEventListener
95 using OBoundControlModel::disposing;
97 private:
98 // OControlModel overridables
99 virtual void writeAggregate( const css::uno::Reference< css::io::XObjectOutputStream >& _rxOutStream ) const override;
100 virtual void readAggregate( const css::uno::Reference< css::io::XObjectInputStream >& _rxInStream ) override;
102 // OBoundControlModel overridables
103 virtual css::uno::Any translateDbColumnToControlValue( ) override;
104 virtual bool commitControlValueToDbColumn( bool _bPostReset ) override;
106 virtual css::uno::Any getDefaultForReset() const override;
108 virtual void onConnectedDbColumn( const css::uno::Reference< css::uno::XInterface >& _rxForm ) override;
109 virtual void onDisconnectedDbColumn() override;
111 virtual bool approveDbColumnType( sal_Int32 _nColumnType ) override;
113 virtual sal_uInt16 getPersistenceFlags() const override;
115 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) override;
117 bool implActsAsRichText( ) const;
121 //= OEditControl
123 typedef ::cppu::ImplHelper3< css::awt::XFocusListener,
124 css::awt::XKeyListener,
125 css::form::XChangeBroadcaster > OEditControl_BASE;
127 class OEditControl : public OBoundControl
128 ,public OEditControl_BASE
130 ::comphelper::OInterfaceContainerHelper3<css::form::XChangeListener>
131 m_aChangeListeners;
133 OUString m_aHtmlChangeValue;
134 ImplSVEvent * m_nKeyEvent;
136 public:
137 explicit OEditControl(const css::uno::Reference< css::uno::XComponentContext>& _rxContext);
138 virtual ~OEditControl() override;
140 DECLARE_UNO3_AGG_DEFAULTS(OEditControl, OBoundControl)
141 virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type& _rType) override;
143 virtual css::uno::Sequence< css::uno::Type> _getTypes() override;
145 // OComponentHelper
146 virtual void SAL_CALL disposing() override;
148 // css::lang::XEventListener
149 virtual void SAL_CALL disposing(const css::lang::EventObject& _rSource) override;
151 // css::lang::XServiceInfo
152 OUString SAL_CALL getImplementationName() override
153 { return u"com.sun.star.form.OEditControl"_ustr; }
155 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
157 // css::form::XChangeBroadcaster
158 virtual void SAL_CALL addChangeListener(const css::uno::Reference< css::form::XChangeListener>& _rxListener) override;
159 virtual void SAL_CALL removeChangeListener(const css::uno::Reference< css::form::XChangeListener>& _rxListener) override;
161 // css::awt::XFocusListener
162 virtual void SAL_CALL focusGained( const css::awt::FocusEvent& e ) override;
163 virtual void SAL_CALL focusLost( const css::awt::FocusEvent& e ) override;
165 // css::awt::XKeyListener
166 virtual void SAL_CALL keyPressed(const css::awt::KeyEvent& e) override;
167 virtual void SAL_CALL keyReleased(const css::awt::KeyEvent& e) override;
169 // XControl
170 using OBoundControl::createPeer;
172 private:
173 DECL_LINK( OnKeyPressed, void*, void );
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */