1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 FORMS_ENTRYLISTHELPER_HXX
21 #define FORMS_ENTRYLISTHELPER_HXX
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>
28 #include <cppuhelper/implbase3.hxx>
29 #include <cppuhelper/interfacecontainer.hxx>
31 //.........................................................................
34 //.........................................................................
37 class ControlModelLock
;
39 //=====================================================================
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
;
47 class OEntryListHelper
: public OEntryListHelper_BASE
50 OControlModel
& m_rControlModel
;
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
< OUString
>
55 m_aStringItems
; /// "overridden" StringItemList property value
56 ::cppu::OInterfaceContainerHelper
61 OEntryListHelper( OControlModel
& _rControlModel
);
62 OEntryListHelper( const OEntryListHelper
& _rSource
, OControlModel
& _rControlModel
);
63 virtual ~OEntryListHelper( );
65 /// returns the current string item list
66 inline const ::com::sun::star::uno::Sequence
< OUString
>&
67 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
; }
71 /// determines whether we actually have an external list source
72 inline bool hasExternalListSource( ) const { return m_xListSource
.is(); }
74 /** handling the XEventListener::disposing call for the case where
75 our list source is being disposed
77 <TRUE/> if and only if the disposed object was our list source, and so the
80 bool handleDisposing( const ::com::sun::star::lang::EventObject
& _rEvent
);
82 /** to be called by derived classes' instances when they're being disposed
86 // prevent method hiding
87 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
) = 0;
89 /** helper for implementing convertFastPropertyValue( StringItemList )
91 <p>The signature of this method and the return type have the same semantics
92 as convertFastPropertyValue.</p>
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
99 SAL_THROW( ( ::com::sun::star::lang::IllegalArgumentException
) );
101 /** helper for implementing setFastPropertyValueNoBroadcast
103 <p>Will internally call stringItemListChanged after the new item list
107 not to be called when we have an external list source
108 @see hasExternalListSource
110 void setNewStringItemList( const ::com::sun::star::uno::Any
& _rValue
, ControlModelLock
& _rInstanceLock
);
112 /** announces that the list of entries has changed.
114 <p>Derived classes have to override this. Most probably, they'll set the new
115 as model property.</p>
118 @see getStringItemList
120 virtual void stringItemListChanged( ControlModelLock
& _rInstanceLock
) = 0;
122 /** called whenever a connection to a new external list source has been established
124 virtual void connectedExternalListSource( );
126 /** called whenever a connection to a new external list source has been revoked
128 virtual void disconnectedExternalListSource( );
130 /** called when XRefreshable::refresh has been called, and we do *not* have an external
133 virtual void refreshInternalEntryList() = 0;
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
);
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
);
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
);
152 /** disconnects from the active external list source, if present
153 @see connectExternalListSource
155 void disconnectExternalListSource( );
157 /** connects to a new external list source
159 the new list source. Must not be <NULL/>
160 @see disconnectExternalListSource
162 void connectExternalListSource(
163 const ::com::sun::star::uno::Reference
< ::com::sun::star::form::binding::XListEntrySource
>& _rxSource
,
164 ControlModelLock
& _rInstanceLock
167 /** refreshes our list entries
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
173 In case we do not have an external list source, refreshInternalEntryList is called.
175 void impl_lock_refreshList( ControlModelLock
& _rInstanceLock
);
178 OEntryListHelper(); // never implemented
179 OEntryListHelper( const OEntryListHelper
& ); // never implemented
180 OEntryListHelper
& operator=( const OEntryListHelper
& ); // never implemented
183 //.........................................................................
185 //.........................................................................
188 #endif // FORMS_ENTRYLISTHELPER_HXX
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */