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 .
23 #include <FormComponent.hxx>
24 #include "errorbroadcaster.hxx"
25 #include "entrylisthelper.hxx"
26 #include "cachedrowset.hxx"
28 #include <com/sun/star/form/ListSourceType.hpp>
30 #include <connectivity/formattedcolumnvalue.hxx>
36 class OComboBoxModel final
37 :public OBoundControlModel
38 ,public OEntryListHelper
39 ,public OErrorBroadcaster
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
;
47 css::uno::Sequence
<OUString
> m_aDesignModeStringItems
;
49 css::form::ListSourceType m_eListSourceType
; // ListSource's type
50 bool m_bEmptyIsNull
; // Empty string is interpreted as NULL
52 ::std::unique_ptr
< ::dbtools::FormattedColumnValue
> m_pValueFormatter
;
54 virtual css::uno::Sequence
< css::uno::Type
> _getTypes() override
;
58 const css::uno::Reference
< css::uno::XComponentContext
>& _rxFactory
61 const OComboBoxModel
* _pOriginal
,
62 const css::uno::Reference
< css::uno::XComponentContext
>& _rxFactory
64 virtual ~OComboBoxModel() override
;
66 virtual void SAL_CALL
disposing() override
;
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
;
75 virtual void SAL_CALL
reloaded( const css::lang::EventObject
& aEvent
) override
;
78 OUString SAL_CALL
getImplementationName() override
79 { return u
"com.sun.star.form.OComboBoxModel"_ustr
; }
81 virtual css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;
84 DECLARE_UNO3_AGG_DEFAULTS(OComboBoxModel
, OBoundControlModel
)
85 virtual css::uno::Any SAL_CALL
queryAggregation( const css::uno::Type
& _rType
) override
;
88 virtual OUString SAL_CALL
getServiceName() override
;
90 write(const css::uno::Reference
< css::io::XObjectOutputStream
>& _rxOutStream
) override
;
92 read(const css::uno::Reference
< css::io::XObjectInputStream
>& _rxInStream
) override
;
94 // OControlModel's property handling
95 virtual void describeFixedProperties(
96 css::uno::Sequence
< css::beans::Property
>& /* [out] */ _rProps
98 virtual void describeAggregateProperties(
99 css::uno::Sequence
< css::beans::Property
>& /* [out] */ _rAggregateProps
103 virtual void SAL_CALL
disposing(const css::lang::EventObject
& Source
) override
;
105 // prevent method hiding
106 using OBoundControlModel::getFastPropertyValue
;
109 // OBoundControlModel overridables
110 virtual css::uno::Any
translateDbColumnToControlValue( ) override
;
111 virtual bool commitControlValueToDbColumn( bool _bPostReset
) override
;
113 virtual void onConnectedDbColumn( const css::uno::Reference
< css::uno::XInterface
>& _rxForm
) override
;
114 virtual void onDisconnectedDbColumn() override
;
116 virtual css::uno::Any
getDefaultForReset() const override
;
118 virtual void resetNoBroadcast() override
;
120 // OEntryListHelper overridables
121 virtual void stringItemListChanged( ControlModelLock
& _rInstanceLock
) override
;
122 virtual void refreshInternalEntryList() override
;
124 void loadData( bool _bForce
);
126 virtual css::uno::Reference
< css::util::XCloneable
> SAL_CALL
createClone( ) override
;
129 class OComboBoxControl
: public OBoundControl
132 explicit OComboBoxControl(const css::uno::Reference
< css::uno::XComponentContext
>& _rxContext
);
135 OUString SAL_CALL
getImplementationName() override
136 { return u
"com.sun.star.form.OComboBoxControl"_ustr
; }
138 virtual css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */