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 _FORMS_COMBOBOX_HXX_
21 : #define _FORMS_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 : //==================================================================
45 : // OComboBoxModel
46 : //==================================================================
47 : class OComboBoxModel
48 : :public OBoundControlModel
49 : ,public OEntryListHelper
50 : ,public OErrorBroadcaster
51 : {
52 : CachedRowSet m_aListRowSet; // the row set to fill the list
53 : ::com::sun::star::uno::Any m_aBoundColumn; // obsolet
54 : ::rtl::OUString m_aListSource; //
55 : ::rtl::OUString m_aDefaultText; // DefaultText
56 : ::com::sun::star::uno::Any m_aLastKnownValue;
57 :
58 : StringSequence m_aDesignModeStringItems;
59 : // upon loading, in some cases we reset fill our string item list ourself. We don't want
60 : // to lose the user's items then, so we remember them here.
61 :
62 :
63 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter> m_xFormatter;
64 :
65 : ::com::sun::star::form::ListSourceType m_eListSourceType; // ListSource's type
66 : sal_Bool m_bEmptyIsNull; // Empty string is interpreted as NULL
67 :
68 : ::std::auto_ptr< ::dbtools::FormattedColumnValue >
69 : m_pValueFormatter;
70 :
71 :
72 :
73 : protected:
74 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes();
75 :
76 : public:
77 : DECLARE_DEFAULT_LEAF_XTOR( OComboBoxModel );
78 :
79 : virtual void SAL_CALL disposing();
80 :
81 : // OPropertySetHelper
82 : virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const;
83 : virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
84 : throw (::com::sun::star::uno::Exception);
85 : virtual sal_Bool SAL_CALL convertFastPropertyValue(
86 : ::com::sun::star::uno::Any& _rConvertedValue, ::com::sun::star::uno::Any& _rOldValue, sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue )
87 : throw (::com::sun::star::lang::IllegalArgumentException);
88 :
89 : // XLoadListener
90 : virtual void SAL_CALL reloaded( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException);
91 :
92 : // XServiceInfo
93 0 : IMPLEMENTATION_NAME(OComboBoxModel);
94 : virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
95 :
96 : // UNO
97 0 : DECLARE_UNO3_AGG_DEFAULTS(OComboBoxModel, OBoundControlModel);
98 : virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException);
99 :
100 : // XPersistObject
101 : virtual ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException);
102 : virtual void SAL_CALL
103 : write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
104 : virtual void SAL_CALL
105 : read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
106 :
107 : // OControlModel's property handling
108 : virtual void describeFixedProperties(
109 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
110 : ) const;
111 : virtual void describeAggregateProperties(
112 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps
113 : ) const;
114 :
115 : // XEventListener
116 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException);
117 :
118 : // prevent method hiding
119 : using OBoundControlModel::getFastPropertyValue;
120 :
121 : protected:
122 : // OBoundControlModel overridables
123 : virtual ::com::sun::star::uno::Any
124 : translateDbColumnToControlValue( );
125 : virtual sal_Bool commitControlValueToDbColumn( bool _bPostReset );
126 :
127 : virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm );
128 : virtual void onDisconnectedDbColumn();
129 :
130 : virtual ::com::sun::star::uno::Any
131 : getDefaultForReset() const;
132 :
133 : virtual void resetNoBroadcast();
134 :
135 : // OEntryListHelper overriables
136 : virtual void stringItemListChanged( ControlModelLock& _rInstanceLock );
137 : virtual void connectedExternalListSource( );
138 : virtual void disconnectedExternalListSource( );
139 : virtual void refreshInternalEntryList();
140 :
141 : protected:
142 : void loadData( bool _bForce );
143 :
144 : DECLARE_XCLONEABLE();
145 : };
146 :
147 : //==================================================================
148 : // OComboBoxControl
149 : //==================================================================
150 :
151 0 : class OComboBoxControl : public OBoundControl
152 : {
153 : public:
154 : OComboBoxControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
155 :
156 : // XServiceInfo
157 0 : IMPLEMENTATION_NAME(OComboBoxControl);
158 : virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
159 : };
160 :
161 : //.........................................................................
162 : }
163 : //.........................................................................
164 :
165 : #endif // _FORMS_COMBOBOX_HXX_
166 :
167 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|