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 INCLUDED_FORMS_SOURCE_COMPONENT_ENTRYLISTHELPER_HXX
21 #define INCLUDED_FORMS_SOURCE_COMPONENT_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>
37 class ControlModelLock
;
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
, std::exception
) SAL_OVERRIDE
= 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 bool convertNewListSourceProperty(
95 ::com::sun::star::uno::Any
& _rConvertedValue
,
96 ::com::sun::star::uno::Any
& _rOldValue
,
97 const ::com::sun::star::uno::Any
& _rValue
100 /** helper for implementing setFastPropertyValueNoBroadcast
102 <p>Will internally call stringItemListChanged after the new item list
106 not to be called when we have an external list source
107 @see hasExternalListSource
109 void setNewStringItemList( const ::com::sun::star::uno::Any
& _rValue
, ControlModelLock
& _rInstanceLock
);
111 /** announces that the list of entries has changed.
113 <p>Derived classes have to override this. Most probably, they'll set the new
114 as model property.</p>
117 @see getStringItemList
119 virtual void stringItemListChanged( ControlModelLock
& _rInstanceLock
) = 0;
121 /** called whenever a connection to a new external list source has been established
123 virtual void connectedExternalListSource( );
125 /** called whenever a connection to a new external list source has been revoked
127 virtual void disconnectedExternalListSource( );
129 /** called when XRefreshable::refresh has been called, and we do *not* have an external
132 virtual void refreshInternalEntryList() = 0;
136 virtual void SAL_CALL
setListEntrySource( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::binding::XListEntrySource
>& _rxSource
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
137 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::form::binding::XListEntrySource
> SAL_CALL
getListEntrySource( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
139 // XListEntryListener
140 virtual void SAL_CALL
entryChanged( const ::com::sun::star::form::binding::ListEntryEvent
& _rSource
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
141 virtual void SAL_CALL
entryRangeInserted( const ::com::sun::star::form::binding::ListEntryEvent
& _rSource
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
142 virtual void SAL_CALL
entryRangeRemoved( const ::com::sun::star::form::binding::ListEntryEvent
& _rSource
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
143 virtual void SAL_CALL
allEntriesChanged( const ::com::sun::star::lang::EventObject
& _rSource
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
146 virtual void SAL_CALL
refresh() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
147 virtual void SAL_CALL
addRefreshListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XRefreshListener
>& _rxListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
148 virtual void SAL_CALL
removeRefreshListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XRefreshListener
>& _rxListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
151 /** disconnects from the active external list source, if present
152 @see connectExternalListSource
154 void disconnectExternalListSource( );
156 /** connects to a new external list source
158 the new list source. Must not be <NULL/>
159 @see disconnectExternalListSource
161 void connectExternalListSource(
162 const ::com::sun::star::uno::Reference
< ::com::sun::star::form::binding::XListEntrySource
>& _rxSource
,
163 ControlModelLock
& _rInstanceLock
166 /** refreshes our list entries
168 In case we have an external list source, its used to obtain the new entries, and then
169 stringItemListChanged is called to give the derived class the possibility to
172 In case we do not have an external list source, refreshInternalEntryList is called.
174 void impl_lock_refreshList( ControlModelLock
& _rInstanceLock
);
177 OEntryListHelper( const OEntryListHelper
& ) SAL_DELETED_FUNCTION
;
178 OEntryListHelper
& operator=( const OEntryListHelper
& ) SAL_DELETED_FUNCTION
;
186 #endif // INCLUDED_FORMS_SOURCE_COMPONENT_ENTRYLISTHELPER_HXX
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */