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_COMBOBOX_HXX
21 #define INCLUDED_FORMS_SOURCE_COMPONENT_COMBOBOX_HXX
24 #include <FormComponent.hxx>
25 #include "errorbroadcaster.hxx"
26 #include "entrylisthelper.hxx"
27 #include "cachedrowset.hxx"
29 #include <com/sun/star/util/XNumberFormatter.hpp>
30 #include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp>
31 #include <com/sun/star/form/ListSourceType.hpp>
32 #include <com/sun/star/awt/XItemListener.hpp>
33 #include <com/sun/star/awt/XFocusListener.hpp>
35 #include <connectivity/formattedcolumnvalue.hxx>
37 #include <cppuhelper/interfacecontainer.hxx>
39 #include <vcl/timer.hxx>
45 class OComboBoxModel final
46 :public OBoundControlModel
47 ,public OEntryListHelper
48 ,public OErrorBroadcaster
50 CachedRowSet m_aListRowSet
; // the row set to fill the list
51 css::uno::Any m_aBoundColumn
; // obsolete
52 OUString m_aListSource
;
53 OUString m_aDefaultText
; // DefaultText
54 css::uno::Any m_aLastKnownValue
;
56 css::uno::Sequence
<OUString
> m_aDesignModeStringItems
;
58 css::form::ListSourceType m_eListSourceType
; // ListSource's type
59 bool m_bEmptyIsNull
; // Empty string is interpreted as NULL
61 ::std::unique_ptr
< ::dbtools::FormattedColumnValue
> m_pValueFormatter
;
63 virtual css::uno::Sequence
< css::uno::Type
> _getTypes() override
;
66 DECLARE_DEFAULT_LEAF_XTOR( OComboBoxModel
);
68 virtual void SAL_CALL
disposing() override
;
71 virtual void SAL_CALL
getFastPropertyValue(css::uno::Any
& rValue
, sal_Int32 nHandle
) const override
;
72 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const css::uno::Any
& rValue
) override
;
73 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
74 css::uno::Any
& _rConvertedValue
, css::uno::Any
& _rOldValue
, sal_Int32 _nHandle
, const css::uno::Any
& _rValue
) override
;
77 virtual void SAL_CALL
reloaded( const css::lang::EventObject
& aEvent
) override
;
80 OUString SAL_CALL
getImplementationName() override
81 { return "com.sun.star.form.OComboBoxModel"; }
83 virtual css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;
86 DECLARE_UNO3_AGG_DEFAULTS(OComboBoxModel
, OBoundControlModel
)
87 virtual css::uno::Any SAL_CALL
queryAggregation( const css::uno::Type
& _rType
) override
;
90 virtual OUString SAL_CALL
getServiceName() override
;
92 write(const css::uno::Reference
< css::io::XObjectOutputStream
>& _rxOutStream
) override
;
94 read(const css::uno::Reference
< css::io::XObjectInputStream
>& _rxInStream
) override
;
96 // OControlModel's property handling
97 virtual void describeFixedProperties(
98 css::uno::Sequence
< css::beans::Property
>& /* [out] */ _rProps
100 virtual void describeAggregateProperties(
101 css::uno::Sequence
< css::beans::Property
>& /* [out] */ _rAggregateProps
105 virtual void SAL_CALL
disposing(const css::lang::EventObject
& Source
) override
;
107 // prevent method hiding
108 using OBoundControlModel::getFastPropertyValue
;
111 // OBoundControlModel overridables
112 virtual css::uno::Any
translateDbColumnToControlValue( ) override
;
113 virtual bool commitControlValueToDbColumn( bool _bPostReset
) override
;
115 virtual void onConnectedDbColumn( const css::uno::Reference
< css::uno::XInterface
>& _rxForm
) override
;
116 virtual void onDisconnectedDbColumn() override
;
118 virtual css::uno::Any
getDefaultForReset() const override
;
120 virtual void resetNoBroadcast() override
;
122 // OEntryListHelper overridables
123 virtual void stringItemListChanged( ControlModelLock
& _rInstanceLock
) override
;
124 virtual void refreshInternalEntryList() override
;
126 void loadData( bool _bForce
);
128 virtual css::uno::Reference
< css::util::XCloneable
> SAL_CALL
createClone( ) override
;
131 class OComboBoxControl
: public OBoundControl
134 explicit OComboBoxControl(const css::uno::Reference
< css::uno::XComponentContext
>& _rxContext
);
137 OUString SAL_CALL
getImplementationName() override
138 { return "com.sun.star.form.OComboBoxControl"; }
140 virtual css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;
147 #endif // INCLUDED_FORMS_SOURCE_COMPONENT_COMBOBOX_HXX
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */