LibreOffice Module forms (master) 1
Edit.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <memory>
23#include "EditBase.hxx"
24
25#include <tools/link.hxx>
28
29#include <com/sun/star/form/XChangeBroadcaster.hpp>
30
31namespace dbtools { class FormattedColumnValue; }
32struct ImplSVEvent;
33
34namespace frm
35{
36
37class OEditModel final : public OEditBaseModel
38{
39 ::std::unique_ptr< ::dbtools::FormattedColumnValue >
41 bool m_bMaxTextLenModified : 1; // set to <TRUE/> when we change the MaxTextLen of the aggregate
42
43 bool m_bWritingFormattedFake : 1; // are we writing something which should be interpreted as formatted upon reading?
44
45public:
47 const css::uno::Reference< css::uno::XComponentContext>& _rxFactory
48 );
50 const OEditModel* _pOriginal,
51 const css::uno::Reference< css::uno::XComponentContext>& _rxFactory
52 );
53 virtual ~OEditModel() override;
54
55private:
59
61 friend class OFormattedModel; // temporary
62
63public:
64 virtual void SAL_CALL disposing() override;
65
66 // XPropertySet
67 virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue, sal_Int32 nHandle ) const override;
68
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;
73
74 // XPropertySet
76
77 // XReset
78 virtual void SAL_CALL reset( ) override;
79
80 // XServiceInfo
81 OUString SAL_CALL getImplementationName() override
82 { return "com.sun.star.form.OEditModel"; }
83
84 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
85
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;
93
94 // XEventListener
96
97private:
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;
101
102 // OBoundControlModel overridables
103 virtual css::uno::Any translateDbColumnToControlValue( ) override;
104 virtual bool commitControlValueToDbColumn( bool _bPostReset ) override;
105
106 virtual css::uno::Any getDefaultForReset() const override;
107
108 virtual void onConnectedDbColumn( const css::uno::Reference< css::uno::XInterface >& _rxForm ) override;
109 virtual void onDisconnectedDbColumn() override;
110
111 virtual bool approveDbColumnType( sal_Int32 _nColumnType ) override;
112
113 virtual sal_uInt16 getPersistenceFlags() const override;
114
115 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) override;
116
117 bool implActsAsRichText( ) const;
118};
119
120
121//= OEditControl
122
123typedef ::cppu::ImplHelper3< css::awt::XFocusListener,
124 css::awt::XKeyListener,
125 css::form::XChangeBroadcaster > OEditControl_BASE;
126
128 ,public OEditControl_BASE
129{
132
135
136public:
137 explicit OEditControl(const css::uno::Reference< css::uno::XComponentContext>& _rxContext);
138 virtual ~OEditControl() override;
139
141 virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type& _rType) override;
142
143 virtual css::uno::Sequence< css::uno::Type> _getTypes() override;
144
145// OComponentHelper
146 virtual void SAL_CALL disposing() override;
147
148// css::lang::XEventListener
149 virtual void SAL_CALL disposing(const css::lang::EventObject& _rSource) override;
150
151// css::lang::XServiceInfo
152 OUString SAL_CALL getImplementationName() override
153 { return "com.sun.star.form.OEditControl"; }
154
155 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
156
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;
160
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;
164
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;
168
169 // XControl
171
172private:
173 DECL_LINK( OnKeyPressed, void*, void );
174};
175
176}
177
178/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define PF_FAKE_FORMATTED_FIELD
Definition: EditBase.hxx:29
virtual void SAL_CALL disposing() override
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual void SAL_CALL createPeer(const css::uno::Reference< css::awt::XToolkit > &Toolkit, const css::uno::Reference< css::awt::XWindowPeer > &Parent) override
sal_Int16 getLastReadVersion() const
Definition: EditBase.hxx:50
virtual void SAL_CALL focusGained(const css::awt::FocusEvent &e) override
Definition: Edit.cxx:157
::comphelper::OInterfaceContainerHelper3< css::form::XChangeListener > m_aChangeListeners
Definition: Edit.hxx:131
virtual void SAL_CALL addChangeListener(const css::uno::Reference< css::form::XChangeListener > &_rxListener) override
Definition: Edit.cxx:113
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &_rType) override
Definition: Edit.cxx:69
OUString m_aHtmlChangeValue
Definition: Edit.hxx:133
virtual void SAL_CALL keyReleased(const css::awt::KeyEvent &e) override
Definition: Edit.cxx:239
virtual ~OEditControl() override
Definition: Edit.cxx:98
OEditControl(const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
virtual void SAL_CALL removeChangeListener(const css::uno::Reference< css::form::XChangeListener > &_rxListener) override
Definition: Edit.cxx:119
virtual void SAL_CALL disposing() override
Definition: Edit.cxx:126
virtual void SAL_CALL disposing(const css::lang::EventObject &_rSource) override
virtual css::uno::Sequence< css::uno::Type > _getTypes() override
Definition: Edit.cxx:61
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: Edit.cxx:136
DECL_LINK(OnKeyPressed, void *, void)
virtual void SAL_CALL focusLost(const css::awt::FocusEvent &e) override
Definition: Edit.cxx:165
ImplSVEvent * m_nKeyEvent
Definition: Edit.hxx:134
virtual void SAL_CALL keyPressed(const css::awt::KeyEvent &e) override
Definition: Edit.cxx:182
OUString SAL_CALL getImplementationName() override
Definition: Edit.hxx:152
virtual OUString SAL_CALL getServiceName() override
Definition: Edit.cxx:309
virtual void SAL_CALL reset() override
Definition: Edit.cxx:401
virtual void onDisconnectedDbColumn() override
called whenever a connection to a database column has been suspended
Definition: Edit.cxx:600
bool lastReadWasFormattedFake() const
Definition: Edit.hxx:58
OUString SAL_CALL getImplementationName() override
Definition: Edit.hxx:81
virtual void SAL_CALL disposing() override
Definition: Edit.cxx:301
virtual sal_uInt16 getPersistenceFlags() const override
Definition: Edit.cxx:558
::std::unique_ptr< ::dbtools::FormattedColumnValue > m_pValueFormatter
Definition: Edit.hxx:40
virtual void writeAggregate(const css::uno::Reference< css::io::XObjectOutputStream > &_rxOutStream) const override
Definition: Edit.cxx:465
void disableFormattedWriteFake()
Definition: Edit.hxx:57
virtual css::uno::Any translateDbColumnToControlValue() override
translates a db column value into a control value.
Definition: Edit.cxx:665
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: Edit.cxx:316
bool m_bMaxTextLenModified
Definition: Edit.hxx:41
bool m_bWritingFormattedFake
Definition: Edit.hxx:43
OEditModel(const css::uno::Reference< css::uno::XComponentContext > &_rxFactory)
virtual ~OEditModel() override
Definition: Edit.cxx:282
virtual bool approveDbColumnType(sal_Int32 _nColumnType) override
nFieldType is the type of the field, on which the model will be linked.
Definition: Edit.cxx:616
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
Definition: Edit.cxx:341
virtual css::uno::Any getDefaultForReset() const override
returns the default which should be used when resetting the control
Definition: Edit.cxx:697
virtual void onConnectedDbColumn(const css::uno::Reference< css::uno::XInterface > &_rxForm) override
called whenever a connection to a database column has been established
Definition: Edit.cxx:569
virtual void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream > &_rxInStream) override
Definition: Edit.cxx:536
virtual void describeAggregateProperties(css::uno::Sequence< css::beans::Property > &_rAggregateProps) const override
describes the properties of our aggregate
Definition: Edit.cxx:374
OEditModel(const OEditModel *_pOriginal, const css::uno::Reference< css::uno::XComponentContext > &_rxFactory)
virtual void describeFixedProperties(css::uno::Sequence< css::beans::Property > &_rProps) const override
describes the properties provided by this class, or its respective derived class
Definition: Edit.cxx:357
virtual void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream > &_rxOutStream) override
Definition: Edit.cxx:506
virtual void readAggregate(const css::uno::Reference< css::io::XObjectInputStream > &_rxInStream) override
Definition: Edit.cxx:487
void enableFormattedWriteFake()
Definition: Edit.hxx:56
virtual bool commitControlValueToDbColumn(bool _bPostReset) override
commits the current control value to the database column we're bound to @precond we're properly bound...
Definition: Edit.cxx:626
bool implActsAsRichText() const
Definition: Edit.cxx:390
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
Definition: Edit.cxx:293
ListBox is a bit confusing / different from other form components, so here are a few notes:
Definition: BaseListBox.hxx:25
::cppu::ImplHelper3< css::awt::XFocusListener, css::awt::XKeyListener, css::form::XChangeBroadcaster > OEditControl_BASE
Definition: Edit.hxx:125
#define DECLARE_UNO3_AGG_DEFAULTS(classname, baseclass)