Line data Source code
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 : #ifndef INCLUDED_FORMS_SOURCE_COMPONENT_COMBOBOX_HXX
21 : #define INCLUDED_FORMS_SOURCE_COMPONENT_COMBOBOX_HXX
22 :
23 : #include "FormComponent.hxx"
24 : #include "errorbroadcaster.hxx"
25 : #include "entrylisthelper.hxx"
26 : #include "cachedrowset.hxx"
27 :
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>
33 :
34 : #include <connectivity/formattedcolumnvalue.hxx>
35 :
36 : #include <cppuhelper/interfacecontainer.hxx>
37 :
38 : #include <vcl/timer.hxx>
39 :
40 :
41 : namespace frm
42 : {
43 :
44 : class OComboBoxModel
45 : :public OBoundControlModel
46 : ,public OEntryListHelper
47 : ,public OErrorBroadcaster
48 : {
49 : CachedRowSet m_aListRowSet; // the row set to fill the list
50 : ::com::sun::star::uno::Any m_aBoundColumn; // obsolete
51 : OUString m_aListSource;
52 : OUString m_aDefaultText; // DefaultText
53 : ::com::sun::star::uno::Any m_aLastKnownValue;
54 :
55 : StringSequence 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 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter> m_xFormatter;
59 :
60 : ::com::sun::star::form::ListSourceType m_eListSourceType; // ListSource's type
61 : bool m_bEmptyIsNull; // Empty string is interpreted as NULL
62 :
63 : ::std::unique_ptr< ::dbtools::FormattedColumnValue > m_pValueFormatter;
64 :
65 :
66 :
67 : protected:
68 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes() SAL_OVERRIDE;
69 :
70 : public:
71 : DECLARE_DEFAULT_LEAF_XTOR( OComboBoxModel );
72 :
73 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
74 :
75 : // OPropertySetHelper
76 : virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const SAL_OVERRIDE;
77 : virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
78 : throw (::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
79 : virtual sal_Bool SAL_CALL convertFastPropertyValue(
80 : ::com::sun::star::uno::Any& _rConvertedValue, ::com::sun::star::uno::Any& _rOldValue, sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue )
81 : throw (::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
82 :
83 : // XLoadListener
84 : virtual void SAL_CALL reloaded( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
85 :
86 : // XServiceInfo
87 8 : OUString SAL_CALL getImplementationName()
88 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
89 8 : { return OUString("com.sun.star.form.OComboBoxModel"); }
90 :
91 : virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
92 :
93 : // UNO
94 139620 : DECLARE_UNO3_AGG_DEFAULTS(OComboBoxModel, OBoundControlModel)
95 : virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
96 :
97 : // XPersistObject
98 : virtual OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 : virtual void SAL_CALL
100 : write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
101 : virtual void SAL_CALL
102 : read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
103 :
104 : // OControlModel's property handling
105 : virtual void describeFixedProperties(
106 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
107 : ) const SAL_OVERRIDE;
108 : virtual void describeAggregateProperties(
109 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps
110 : ) const SAL_OVERRIDE;
111 :
112 : // XEventListener
113 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 :
115 : // prevent method hiding
116 : using OBoundControlModel::getFastPropertyValue;
117 :
118 : protected:
119 : // OBoundControlModel overridables
120 : virtual ::com::sun::star::uno::Any
121 : translateDbColumnToControlValue( ) SAL_OVERRIDE;
122 : virtual bool commitControlValueToDbColumn( bool _bPostReset ) SAL_OVERRIDE;
123 :
124 : virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm ) SAL_OVERRIDE;
125 : virtual void onDisconnectedDbColumn() SAL_OVERRIDE;
126 :
127 : virtual ::com::sun::star::uno::Any
128 : getDefaultForReset() const SAL_OVERRIDE;
129 :
130 : virtual void resetNoBroadcast() SAL_OVERRIDE;
131 :
132 : // OEntryListHelper overridables
133 : virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ) SAL_OVERRIDE;
134 : virtual void connectedExternalListSource( ) SAL_OVERRIDE;
135 : virtual void disconnectedExternalListSource( ) SAL_OVERRIDE;
136 : virtual void refreshInternalEntryList() SAL_OVERRIDE;
137 :
138 : protected:
139 : void loadData( bool _bForce );
140 :
141 : virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
142 : };
143 :
144 42 : class OComboBoxControl : public OBoundControl
145 : {
146 : public:
147 : OComboBoxControl(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext);
148 :
149 : // XServiceInfo
150 1 : OUString SAL_CALL getImplementationName()
151 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
152 1 : { return OUString("com.sun.star.form.OComboBoxControl"); }
153 :
154 : virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
155 : };
156 :
157 :
158 : }
159 :
160 :
161 : #endif // INCLUDED_FORMS_SOURCE_COMPONENT_COMBOBOX_HXX
162 :
163 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|