Branch data 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_ENTRYLISTHELPER_HXX
21 : : #define FORMS_ENTRYLISTHELPER_HXX
22 : :
23 : : #include <com/sun/star/form/binding/XListEntrySink.hpp>
24 : : #include <com/sun/star/util/XRefreshable.hpp>
25 : : #include <com/sun/star/form/binding/XListEntryListener.hpp>
26 : : #include <com/sun/star/lang/IllegalArgumentException.hpp>
27 : :
28 : : #include <cppuhelper/implbase3.hxx>
29 : : #include <cppuhelper/interfacecontainer.hxx>
30 : :
31 : : //.........................................................................
32 : : namespace frm
33 : : {
34 : : //.........................................................................
35 : :
36 : : class OControlModel;
37 : : class ControlModelLock;
38 : :
39 : : //=====================================================================
40 : : //= OEntryListHelper
41 : : //=====================================================================
42 : : typedef ::cppu::ImplHelper3 < ::com::sun::star::form::binding::XListEntrySink
43 : : , ::com::sun::star::form::binding::XListEntryListener
44 : : , ::com::sun::star::util::XRefreshable
45 : : > OEntryListHelper_BASE;
46 : :
47 : : class OEntryListHelper : public OEntryListHelper_BASE
48 : : {
49 : : private:
50 : : OControlModel& m_rControlModel;
51 : :
52 : : ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >
53 : : m_xListSource; /// our external list source
54 : : ::com::sun::star::uno::Sequence< ::rtl::OUString >
55 : : m_aStringItems; /// "overridden" StringItemList property value
56 : : ::cppu::OInterfaceContainerHelper
57 : : m_aRefreshListeners;
58 : :
59 : :
60 : : protected:
61 : : OEntryListHelper( OControlModel& _rControlModel );
62 : : OEntryListHelper( const OEntryListHelper& _rSource, OControlModel& _rControlModel );
63 : : virtual ~OEntryListHelper( );
64 : :
65 : : /// returns the current string item list
66 : : inline const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
67 : 506 : getStringItemList() const { return m_aStringItems; }
68 : : inline const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >&
69 : : getExternalListEntrySource() const { return m_xListSource; }
70 : :
71 : : /// determines whether we actually have an external list source
72 : 280 : inline bool hasExternalListSource( ) const { return m_xListSource.is(); }
73 : :
74 : : /** handling the XEventListener::disposing call for the case where
75 : : our list source is being disposed
76 : : @return
77 : : <TRUE/> if and only if the disposed object was our list source, and so the
78 : : event was handled
79 : : */
80 : : bool handleDisposing( const ::com::sun::star::lang::EventObject& _rEvent );
81 : :
82 : : /** to be called by derived classes' instances when they're being disposed
83 : : */
84 : : void disposing( );
85 : :
86 : : // prevent method hiding
87 : : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException) = 0;
88 : :
89 : : /** helper for implementing convertFastPropertyValue( StringItemList )
90 : :
91 : : <p>The signature of this method and the return type have the same semantics
92 : : as convertFastPropertyValue.</p>
93 : : */
94 : : sal_Bool convertNewListSourceProperty(
95 : : ::com::sun::star::uno::Any& _rConvertedValue,
96 : : ::com::sun::star::uno::Any& _rOldValue,
97 : : const ::com::sun::star::uno::Any& _rValue
98 : : )
99 : : SAL_THROW( ( ::com::sun::star::lang::IllegalArgumentException ) );
100 : :
101 : : /** helper for implementing setFastPropertyValueNoBroadcast
102 : :
103 : : <p>Will internally call stringItemListChanged after the new item list
104 : : has been set.</p>
105 : :
106 : : @precond
107 : : not to be called when we have an external list source
108 : : @see hasExternalListSource
109 : : */
110 : : void setNewStringItemList( const ::com::sun::star::uno::Any& _rValue, ControlModelLock& _rInstanceLock );
111 : :
112 : : /** announces that the list of entries has changed.
113 : :
114 : : <p>Derived classes have to override this. Most probably, they'll set the new
115 : : as model property.</p>
116 : :
117 : : @pure
118 : : @see getStringItemList
119 : : */
120 : : virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ) = 0;
121 : :
122 : : /** called whenever a connection to a new external list source has been established
123 : : */
124 : : virtual void connectedExternalListSource( );
125 : :
126 : : /** called whenever a connection to a new external list source has been revoked
127 : : */
128 : : virtual void disconnectedExternalListSource( );
129 : :
130 : : /** called when XRefreshable::refresh has been called, and we do *not* have an external
131 : : list source
132 : : */
133 : : virtual void refreshInternalEntryList() = 0;
134 : :
135 : : private:
136 : : // XListEntrySink
137 : : virtual void SAL_CALL setListEntrySource( const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource ) throw (::com::sun::star::uno::RuntimeException);
138 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource > SAL_CALL getListEntrySource( ) throw (::com::sun::star::uno::RuntimeException);
139 : :
140 : : // XListEntryListener
141 : : virtual void SAL_CALL entryChanged( const ::com::sun::star::form::binding::ListEntryEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException);
142 : : virtual void SAL_CALL entryRangeInserted( const ::com::sun::star::form::binding::ListEntryEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException);
143 : : virtual void SAL_CALL entryRangeRemoved( const ::com::sun::star::form::binding::ListEntryEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException);
144 : : virtual void SAL_CALL allEntriesChanged( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException);
145 : :
146 : : // XRefreshable
147 : : virtual void SAL_CALL refresh() throw(::com::sun::star::uno::RuntimeException);
148 : : virtual void SAL_CALL addRefreshListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException);
149 : : virtual void SAL_CALL removeRefreshListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException);
150 : :
151 : : private:
152 : : /** disconnects from the active external list source, if present
153 : : @see connectExternalListSource
154 : : */
155 : : void disconnectExternalListSource( );
156 : :
157 : : /** connects to a new external list source
158 : : @param _rxSource
159 : : the new list source. Must not be <NULL/>
160 : : @see disconnectExternalListSource
161 : : */
162 : : void connectExternalListSource(
163 : : const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource,
164 : : ControlModelLock& _rInstanceLock
165 : : );
166 : :
167 : : /** refreshes our list entries
168 : :
169 : : In case we have an external list source, its used to obtain the new entries, and then
170 : : stringItemListChanged is called to give the derived class the possibility to
171 : : react on this.
172 : :
173 : : In case we do not have an external list source, refreshInternalEntryList is called.
174 : : */
175 : : void impl_lock_refreshList( ControlModelLock& _rInstanceLock );
176 : :
177 : : private:
178 : : OEntryListHelper(); // never implemented
179 : : OEntryListHelper( const OEntryListHelper& ); // never implemented
180 : : OEntryListHelper& operator=( const OEntryListHelper& ); // never implemented
181 : : };
182 : :
183 : : //.........................................................................
184 : : } // namespace frm
185 : : //.........................................................................
186 : :
187 : :
188 : : #endif // FORMS_ENTRYLISTHELPER_HXX
189 : :
190 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|