Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / forms / source / component / ComboBox.hxx
blob57f05f3f3503af90e8d06b400e9cd6a253a3b449
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
23 #include "FormComponent.hxx"
24 #include "errorbroadcaster.hxx"
25 #include "entrylisthelper.hxx"
26 #include "cachedrowset.hxx"
28 #include <com/sun/star/util/XNumberFormatter.hpp>
29 #include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp>
30 #include <com/sun/star/form/ListSourceType.hpp>
31 #include <com/sun/star/awt/XItemListener.hpp>
32 #include <com/sun/star/awt/XFocusListener.hpp>
34 #include <connectivity/formattedcolumnvalue.hxx>
36 #include <cppuhelper/interfacecontainer.hxx>
38 #include <vcl/timer.hxx>
41 namespace frm
44 class OComboBoxModel
45 :public OBoundControlModel
46 ,public OEntryListHelper
47 ,public OErrorBroadcaster
49 CachedRowSet m_aListRowSet; // the row set to fill the list
50 css::uno::Any m_aBoundColumn; // obsolete
51 OUString m_aListSource;
52 OUString m_aDefaultText; // DefaultText
53 css::uno::Any m_aLastKnownValue;
55 css::uno::Sequence<OUString> m_aDesignModeStringItems;
56 // upon loading, in some cases we reset fill our string item list ourself. We don't want
57 // to lose the user's items then, so we remember them here.
58 css::uno::Reference< css::util::XNumberFormatter> m_xFormatter;
60 css::form::ListSourceType m_eListSourceType; // ListSource's type
61 bool m_bEmptyIsNull; // Empty string is interpreted as NULL
63 ::std::unique_ptr< ::dbtools::FormattedColumnValue > m_pValueFormatter;
66 protected:
67 virtual css::uno::Sequence< css::uno::Type> _getTypes() override;
69 public:
70 DECLARE_DEFAULT_LEAF_XTOR( OComboBoxModel );
72 virtual void SAL_CALL disposing() override;
74 // OPropertySetHelper
75 virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue, sal_Int32 nHandle) const override;
76 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue )
77 throw (css::uno::Exception, std::exception) override;
78 virtual sal_Bool SAL_CALL convertFastPropertyValue(
79 css::uno::Any& _rConvertedValue, css::uno::Any& _rOldValue, sal_Int32 _nHandle, const css::uno::Any& _rValue )
80 throw (css::lang::IllegalArgumentException) override;
82 // XLoadListener
83 virtual void SAL_CALL reloaded( const css::lang::EventObject& aEvent ) throw(css::uno::RuntimeException, std::exception) override;
85 // XServiceInfo
86 OUString SAL_CALL getImplementationName()
87 throw (css::uno::RuntimeException, std::exception) override
88 { return OUString("com.sun.star.form.OComboBoxModel"); }
90 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() throw(css::uno::RuntimeException, std::exception) override;
92 // UNO
93 DECLARE_UNO3_AGG_DEFAULTS(OComboBoxModel, OBoundControlModel)
94 virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) throw (css::uno::RuntimeException, std::exception) override;
96 // XPersistObject
97 virtual OUString SAL_CALL getServiceName() throw(css::uno::RuntimeException, std::exception) override;
98 virtual void SAL_CALL
99 write(const css::uno::Reference< css::io::XObjectOutputStream>& _rxOutStream) throw(css::io::IOException, css::uno::RuntimeException, std::exception) override;
100 virtual void SAL_CALL
101 read(const css::uno::Reference< css::io::XObjectInputStream>& _rxInStream) throw(css::io::IOException, css::uno::RuntimeException, std::exception) override;
103 // OControlModel's property handling
104 virtual void describeFixedProperties(
105 css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps
106 ) const override;
107 virtual void describeAggregateProperties(
108 css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps
109 ) const override;
111 // XEventListener
112 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) throw (css::uno::RuntimeException, std::exception) override;
114 // prevent method hiding
115 using OBoundControlModel::getFastPropertyValue;
117 protected:
118 // OBoundControlModel overridables
119 virtual css::uno::Any translateDbColumnToControlValue( ) override;
120 virtual bool commitControlValueToDbColumn( bool _bPostReset ) override;
122 virtual void onConnectedDbColumn( const css::uno::Reference< css::uno::XInterface >& _rxForm ) override;
123 virtual void onDisconnectedDbColumn() override;
125 virtual css::uno::Any getDefaultForReset() const override;
127 virtual void resetNoBroadcast() override;
129 // OEntryListHelper overridables
130 virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ) override;
131 virtual void connectedExternalListSource( ) override;
132 virtual void disconnectedExternalListSource( ) override;
133 virtual void refreshInternalEntryList() override;
135 protected:
136 void loadData( bool _bForce );
138 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) throw (css::uno::RuntimeException, std::exception) override;
141 class OComboBoxControl : public OBoundControl
143 public:
144 explicit OComboBoxControl(const css::uno::Reference< css::uno::XComponentContext>& _rxContext);
146 // XServiceInfo
147 OUString SAL_CALL getImplementationName()
148 throw (css::uno::RuntimeException, std::exception) override
149 { return OUString("com.sun.star.form.OComboBoxControl"); }
151 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() throw(css::uno::RuntimeException, std::exception) override;
158 #endif // INCLUDED_FORMS_SOURCE_COMPONENT_COMBOBOX_HXX
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */