LibreOffice Module forms (master) 1
ComboBox.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 <FormComponent.hxx>
24#include "errorbroadcaster.hxx"
25#include "entrylisthelper.hxx"
26#include "cachedrowset.hxx"
27
28#include <com/sun/star/form/ListSourceType.hpp>
29
31
32
33namespace frm
34{
35
36class OComboBoxModel final
37 :public OBoundControlModel
38 ,public OEntryListHelper
39 ,public OErrorBroadcaster
40{
41 CachedRowSet m_aListRowSet; // the row set to fill the list
42 css::uno::Any m_aBoundColumn; // obsolete
43 OUString m_aListSource;
44 OUString m_aDefaultText; // DefaultText
45 css::uno::Any m_aLastKnownValue;
46
47 css::uno::Sequence<OUString> m_aDesignModeStringItems;
48
49 css::form::ListSourceType m_eListSourceType; // ListSource's type
50 bool m_bEmptyIsNull; // Empty string is interpreted as NULL
51
52 ::std::unique_ptr< ::dbtools::FormattedColumnValue > m_pValueFormatter;
53
54 virtual css::uno::Sequence< css::uno::Type> _getTypes() override;
55
56public:
58 const css::uno::Reference< css::uno::XComponentContext>& _rxFactory
59 );
61 const OComboBoxModel* _pOriginal,
62 const css::uno::Reference< css::uno::XComponentContext>& _rxFactory
63 );
64 virtual ~OComboBoxModel() override;
65
66 virtual void SAL_CALL disposing() override;
67
68 // OPropertySetHelper
69 virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue, sal_Int32 nHandle) const override;
70 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override;
71 virtual sal_Bool SAL_CALL convertFastPropertyValue(
72 css::uno::Any& _rConvertedValue, css::uno::Any& _rOldValue, sal_Int32 _nHandle, const css::uno::Any& _rValue ) override;
73
74 // XLoadListener
75 virtual void SAL_CALL reloaded( const css::lang::EventObject& aEvent ) override;
76
77 // XServiceInfo
78 OUString SAL_CALL getImplementationName() override
79 { return "com.sun.star.form.OComboBoxModel"; }
80
81 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
82
83 // UNO
85 virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override;
86
87 // XPersistObject
88 virtual OUString SAL_CALL getServiceName() override;
89 virtual void SAL_CALL
90 write(const css::uno::Reference< css::io::XObjectOutputStream>& _rxOutStream) override;
91 virtual void SAL_CALL
92 read(const css::uno::Reference< css::io::XObjectInputStream>& _rxInStream) override;
93
94 // OControlModel's property handling
95 virtual void describeFixedProperties(
96 css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps
97 ) const override;
98 virtual void describeAggregateProperties(
99 css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps
100 ) const override;
101
102 // XEventListener
103 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
104
105 // prevent method hiding
107
108private:
109 // OBoundControlModel overridables
110 virtual css::uno::Any translateDbColumnToControlValue( ) override;
111 virtual bool commitControlValueToDbColumn( bool _bPostReset ) override;
112
113 virtual void onConnectedDbColumn( const css::uno::Reference< css::uno::XInterface >& _rxForm ) override;
114 virtual void onDisconnectedDbColumn() override;
115
116 virtual css::uno::Any getDefaultForReset() const override;
117
118 virtual void resetNoBroadcast() override;
119
120 // OEntryListHelper overridables
121 virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ) override;
122 virtual void refreshInternalEntryList() override;
123
124 void loadData( bool _bForce );
125
126 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) override;
127};
128
130{
131public:
132 explicit OComboBoxControl(const css::uno::Reference< css::uno::XComponentContext>& _rxContext);
133
134 // XServiceInfo
135 OUString SAL_CALL getImplementationName() override
136 { return "com.sun.star.form.OComboBoxControl"; }
137
138 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
139};
140
141
142}
143
144
145/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
caches a result set obtained from a SQL statement
class whose instances lock an OControlModel
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
OComboBoxControl(const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
Definition: ComboBox.cxx:855
OUString SAL_CALL getImplementationName() override
Definition: ComboBox.hxx:135
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: ComboBox.cxx:861
css::uno::Any m_aBoundColumn
Definition: ComboBox.hxx:42
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
Definition: ComboBox.cxx:147
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &_rConvertedValue, css::uno::Any &_rOldValue, sal_Int32 _nHandle, const css::uno::Any &_rValue) override
Definition: ComboBox.cxx:258
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &_rType) override
Definition: ComboBox.cxx:99
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual css::uno::Any getDefaultForReset() const override
returns the default which should be used when resetting the control
Definition: ComboBox.cxx:816
OUString m_aDefaultText
Definition: ComboBox.hxx:44
virtual void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream > &_rxOutStream) override
Definition: ComboBox.cxx:331
virtual void describeAggregateProperties(css::uno::Sequence< css::beans::Property > &_rAggregateProps) const override
describes the properties of our aggregate
Definition: ComboBox.cxx:315
virtual void onDisconnectedDbColumn() override
called whenever a connection to a database column has been suspended
Definition: ComboBox.cxx:684
virtual void resetNoBroadcast() override
called to reset the control to some kind of default.
Definition: ComboBox.cxx:706
OComboBoxModel(const OComboBoxModel *_pOriginal, const css::uno::Reference< css::uno::XComponentContext > &_rxFactory)
css::form::ListSourceType m_eListSourceType
Definition: ComboBox.hxx:49
virtual void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream > &_rxInStream) override
Definition: ComboBox.cxx:368
virtual void onConnectedDbColumn(const css::uno::Reference< css::uno::XInterface > &_rxForm) override
called whenever a connection to a database column has been established
Definition: ComboBox.cxx:671
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
Definition: ComboBox.cxx:197
virtual void stringItemListChanged(ControlModelLock &_rInstanceLock) override
announces that the list of entries has changed.
Definition: ComboBox.cxx:822
virtual void refreshInternalEntryList() override
called when XRefreshable::refresh has been called, and we do not have an external list source
Definition: ComboBox.cxx:832
void loadData(bool _bForce)
Definition: ComboBox.cxx:466
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
Definition: ComboBox.cxx:163
virtual void SAL_CALL disposing() override
Definition: ComboBox.cxx:155
OUString SAL_CALL getImplementationName() override
Definition: ComboBox.hxx:78
virtual css::uno::Sequence< css::uno::Type > _getTypes() override
Definition: ComboBox.cxx:63
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: ComboBox.cxx:74
OComboBoxModel(const css::uno::Reference< css::uno::XComponentContext > &_rxFactory)
OUString m_aListSource
Definition: ComboBox.hxx:43
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: ComboBox.cxx:297
virtual void SAL_CALL reloaded(const css::lang::EventObject &aEvent) override
Definition: ComboBox.cxx:696
virtual ~OComboBoxModel() override
Definition: ComboBox.cxx:135
CachedRowSet m_aListRowSet
Definition: ComboBox.hxx:41
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: ComboBox.cxx:713
virtual OUString SAL_CALL getServiceName() override
Definition: ComboBox.cxx:325
::std::unique_ptr< ::dbtools::FormattedColumnValue > m_pValueFormatter
Definition: ComboBox.hxx:52
virtual css::uno::Any translateDbColumnToControlValue() override
translates a db column value into a control value.
Definition: ComboBox.cxx:788
css::uno::Any m_aLastKnownValue
Definition: ComboBox.hxx:45
css::uno::Sequence< OUString > m_aDesignModeStringItems
Definition: ComboBox.hxx:47
ListBox is a bit confusing / different from other form components, so here are a few notes:
Definition: BaseListBox.hxx:25
unsigned char sal_Bool
#define DECLARE_UNO3_AGG_DEFAULTS(classname, baseclass)