LibreOffice Module forms (master) 1
FormattedField.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 "EditBase.hxx"
23#include <tools/link.hxx>
25#include "errorbroadcaster.hxx"
26
27#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
28
29struct ImplSVEvent;
30
31namespace frm
32{
33class OFormattedModel final
34 :public OEditBaseModel
35 ,public OErrorBroadcaster
36 {
37 // the original, in case I faked the format properties of my aggregated model,
38 // i.e. I just passed on the attributes of the field to which I am bound
39 // (only valid if loaded)
40
41 css::uno::Reference< css::util::XNumberFormatsSupplier> m_xOriginalFormatter;
42 css::util::Date m_aNullDate;
43 css::uno::Any m_aSaveValue;
44
45 sal_Int16 m_nKeyType;
47 m_bNumeric : 1; // analogous for the TreatAsNumeric-property
48
49 css::uno::Reference< css::util::XNumberFormatsSupplier> calcDefaultFormatsSupplier() const;
50 css::uno::Reference< css::util::XNumberFormatsSupplier> calcFormFormatsSupplier() const;
51 css::uno::Reference< css::util::XNumberFormatsSupplier> calcFormatsSupplier() const;
52
54 const css::uno::Reference< css::uno::XComponentContext>& _rxFactory
55 );
57 const OFormattedModel* _pOriginal,
58 const css::uno::Reference< css::uno::XComponentContext>& _rxFactory
59 );
60 virtual ~OFormattedModel() override;
61
63
64 public:
65 // XInterface
67
68 // XTypeProvider
69 virtual css::uno::Sequence< css::uno::Type> _getTypes() override;
70
71 // XAggregation
72 virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type& _rType) override;
73
74 // OComponentHelper
75 virtual void SAL_CALL disposing() override;
76
77 // XServiceInfo
78 OUString SAL_CALL getImplementationName() override
79 { return "com.sun.star.form.OFormattedModel"; }
80
81 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
82
83 // XPersistObject
84 virtual void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream>& _rxOutStream) override;
85 virtual void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream>& _rxInStream) override;
86 virtual OUString SAL_CALL getServiceName() override;
87
88 // XLoadListener
89 virtual void SAL_CALL loaded(const css::lang::EventObject& rEvent) override;
90
91 // XPropertyState
92 void setPropertyToDefaultByHandle(sal_Int32 nHandle) override;
93 css::uno::Any getPropertyDefaultByHandle(sal_Int32 nHandle) const override;
94
95 void SAL_CALL setPropertyToDefault(const OUString& aPropertyName) override;
96 css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
97
98 // OControlModel's property handling
99 virtual void describeFixedProperties(
100 css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps
101 ) const override;
102 virtual void describeAggregateProperties(
103 css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps
104 ) const override;
105
106 // XPropertyChangeListener
107 virtual void _propertyChanged(const css::beans::PropertyChangeEvent& evt) override;
108
109 // prevent method hiding
112
113 virtual sal_uInt16 getPersistenceFlags() const override;
114 // as we have an own version handling for persistence
115
116 // OBoundControlModel overridables
117 virtual css::uno::Any
119 virtual bool commitControlValueToDbColumn( bool _bPostReset ) override;
120
121 virtual css::uno::Sequence< css::uno::Type >
122 getSupportedBindingTypes() override;
123 virtual css::uno::Any
124 translateExternalValueToControlValue( const css::uno::Any& _rExternalValue ) const override;
125 virtual css::uno::Any
126 translateControlValueToExternalValue( ) const override;
127 virtual void onConnectedExternalValue( ) override;
128
129 virtual css::uno::Any
130 getDefaultForReset() const override;
131 virtual void resetNoBroadcast() override;
132
133 virtual void onConnectedDbColumn( const css::uno::Reference< css::uno::XInterface >& _rxForm ) override;
134 virtual void onDisconnectedDbColumn() override;
135
136 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) override;
137
138 void implConstruct();
139
141 };
142
143 typedef ::cppu::ImplHelper1< css::awt::XKeyListener> OFormattedControl_BASE;
146 {
148
149 public:
150 explicit OFormattedControl(const css::uno::Reference< css::uno::XComponentContext>& _rxContext);
151 virtual ~OFormattedControl() override;
152
154 virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type& _rType) override;
155
156 virtual css::uno::Sequence< css::uno::Type> _getTypes() override;
157
158 // css::lang::XServiceInfo
159 OUString SAL_CALL getImplementationName() override
160 { return "com.sun.star.form.OFormattedControl"; }
161
162 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
163
164 // css::lang::XEventListener
165 virtual void SAL_CALL disposing(const css::lang::EventObject& _rSource) override;
166
167 // css::awt::XKeyListener
168 virtual void SAL_CALL keyPressed(const css::awt::KeyEvent& e) override;
169 virtual void SAL_CALL keyReleased(const css::awt::KeyEvent& e) override;
170
171 // css::awt::XControl
173
174 // disambiguation
176
177 private:
178 DECL_LINK( OnKeyPressed, void*, void );
179 };
180}
181
182/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL disposing() override
virtual void SAL_CALL disposing() override
virtual void SAL_CALL setDesignMode(sal_Bool bOn) override
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
Definition: EditBase.cxx:268
DECL_LINK(OnKeyPressed, void *, void)
OFormattedControl(const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
virtual void SAL_CALL keyReleased(const css::awt::KeyEvent &e) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Sequence< css::uno::Type > _getTypes() override
virtual void SAL_CALL disposing() override
virtual ~OFormattedControl() override
virtual void SAL_CALL keyPressed(const css::awt::KeyEvent &e) override
OUString SAL_CALL getImplementationName() override
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &_rType) override
virtual void onConnectedDbColumn(const css::uno::Reference< css::uno::XInterface > &_rxForm) override
called whenever a connection to a database column has been established
virtual void resetNoBroadcast() override
called to reset the control to some kind of default.
css::uno::Reference< css::util::XNumberFormatsSupplier > calcDefaultFormatsSupplier() const
virtual css::uno::Any getDefaultForReset() const override
returns the default which should be used when resetting the control
css::util::Date m_aNullDate
css::uno::Reference< css::util::XNumberFormatsSupplier > m_xOriginalFormatter
OFormattedModel(const css::uno::Reference< css::uno::XComponentContext > &_rxFactory)
OUString SAL_CALL getImplementationName() override
css::uno::Any SAL_CALL getPropertyDefault(const OUString &aPropertyName) override
OFormattedModel(const OFormattedModel *_pOriginal, const css::uno::Reference< css::uno::XComponentContext > &_rxFactory)
virtual void SAL_CALL loaded(const css::lang::EventObject &rEvent) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Any translateDbColumnToControlValue() override
translates a db column value into a control value.
css::uno::Reference< css::util::XNumberFormatsSupplier > calcFormFormatsSupplier() const
virtual void describeFixedProperties(css::uno::Sequence< css::beans::Property > &_rProps) const override
describes the properties provided by this class, or its respective derived class
virtual OUString SAL_CALL getServiceName() override
void setPropertyToDefaultByHandle(sal_Int32 nHandle) override
virtual css::uno::Sequence< css::uno::Type > getSupportedBindingTypes() override
returns the data types which the control could use to exchange data with an external value binding
void SAL_CALL setPropertyToDefault(const OUString &aPropertyName) override
css::uno::Reference< css::util::XNumberFormatsSupplier > calcFormatsSupplier() const
virtual void onConnectedExternalValue() override
called whenever a connection to an external supplier of values (XValueBinding) has been established
virtual void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream > &_rxInStream) override
virtual css::uno::Sequence< css::uno::Type > _getTypes() override
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
virtual bool commitControlValueToDbColumn(bool _bPostReset) override
commits the current control value to the database column we're bound to @precond we're properly bound...
virtual sal_uInt16 getPersistenceFlags() const override
virtual ~OFormattedModel() override
css::uno::Any m_aSaveValue
virtual void onDisconnectedDbColumn() override
called whenever a connection to a database column has been suspended
virtual void SAL_CALL disposing() override
virtual css::uno::Any translateControlValueToExternalValue() const override
commits the current control value to our external value binding
virtual css::uno::Any translateExternalValueToControlValue(const css::uno::Any &_rExternalValue) const override
translates the given value, which was obtained from the current external value binding,...
virtual void describeAggregateProperties(css::uno::Sequence< css::beans::Property > &_rAggregateProps) const override
describes the properties of our aggregate
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &_rType) override
virtual void _propertyChanged(const css::beans::PropertyChangeEvent &evt) override
virtual void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream > &_rxOutStream) override
css::uno::Any getPropertyDefaultByHandle(sal_Int32 nHandle) const override
ListBox is a bit confusing / different from other form components, so here are a few notes:
Definition: BaseListBox.hxx:25
::cppu::ImplHelper1< css::awt::XKeyListener > OFormattedControl_BASE
#define DECLARE_UNO3_AGG_DEFAULTS(classname, baseclass)