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 14 : IMPLEMENTATION_NAME(OComboBoxModel);
88 : virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
89 :
90 : // UNO
91 230074 : DECLARE_UNO3_AGG_DEFAULTS(OComboBoxModel, OBoundControlModel)
92 : 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;
93 :
94 : // XPersistObject
95 : virtual OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
96 : virtual void SAL_CALL
97 : 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;
98 : virtual void SAL_CALL
99 : 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;
100 :
101 : // OControlModel's property handling
102 : virtual void describeFixedProperties(
103 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
104 : ) const SAL_OVERRIDE;
105 : virtual void describeAggregateProperties(
106 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps
107 : ) const SAL_OVERRIDE;
108 :
109 : // XEventListener
110 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
111 :
112 : // prevent method hiding
113 : using OBoundControlModel::getFastPropertyValue;
114 :
115 : protected:
116 : // OBoundControlModel overridables
117 : virtual ::com::sun::star::uno::Any
118 : translateDbColumnToControlValue( ) SAL_OVERRIDE;
119 : virtual bool commitControlValueToDbColumn( bool _bPostReset ) SAL_OVERRIDE;
120 :
121 : virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm ) SAL_OVERRIDE;
122 : virtual void onDisconnectedDbColumn() SAL_OVERRIDE;
123 :
124 : virtual ::com::sun::star::uno::Any
125 : getDefaultForReset() const SAL_OVERRIDE;
126 :
127 : virtual void resetNoBroadcast() SAL_OVERRIDE;
128 :
129 : // OEntryListHelper overridables
130 : virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ) SAL_OVERRIDE;
131 : virtual void connectedExternalListSource( ) SAL_OVERRIDE;
132 : virtual void disconnectedExternalListSource( ) SAL_OVERRIDE;
133 : virtual void refreshInternalEntryList() SAL_OVERRIDE;
134 :
135 : protected:
136 : void loadData( bool _bForce );
137 :
138 : virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
139 : };
140 :
141 60 : class OComboBoxControl : public OBoundControl
142 : {
143 : public:
144 : OComboBoxControl(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext);
145 :
146 : // XServiceInfo
147 0 : IMPLEMENTATION_NAME(OComboBoxControl);
148 : virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
149 : };
150 :
151 :
152 : }
153 :
154 :
155 : #endif // INCLUDED_FORMS_SOURCE_COMPONENT_COMBOBOX_HXX
156 :
157 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|