tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / forms / source / component / entrylisthelper.hxx
blobcb0e0789a4aa17ef2e182176181c6d64dc708e24
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <com/sun/star/form/binding/XListEntrySink.hpp>
23 #include <com/sun/star/util/XRefreshable.hpp>
24 #include <com/sun/star/form/binding/XListEntryListener.hpp>
26 #include <cppuhelper/implbase3.hxx>
27 #include <comphelper/interfacecontainer3.hxx>
30 namespace frm
34 class OControlModel;
35 class ControlModelLock;
38 //= OEntryListHelper
40 typedef ::cppu::ImplHelper3 < css::form::binding::XListEntrySink
41 , css::form::binding::XListEntryListener
42 , css::util::XRefreshable
43 > OEntryListHelper_BASE;
45 class OEntryListHelper : public OEntryListHelper_BASE
47 private:
48 OControlModel& m_rControlModel;
50 css::uno::Reference< css::form::binding::XListEntrySource >
51 m_xListSource; /// our external list source
52 std::vector< OUString >
53 m_aStringItems; /// "overridden" StringItemList property value
54 css::uno::Sequence< css::uno::Any >
55 m_aTypedItems; /// "overridden" TypedItemList property value
56 ::comphelper::OInterfaceContainerHelper3<css::util::XRefreshListener>
57 m_aRefreshListeners;
60 protected:
61 explicit OEntryListHelper( OControlModel& _rControlModel );
62 OEntryListHelper( const OEntryListHelper& _rSource, OControlModel& _rControlModel );
63 virtual ~OEntryListHelper( );
65 /// returns the current string item list
66 const std::vector< OUString >&
67 getStringItemList() const { return m_aStringItems; }
69 /// returns the current typed item list
70 const css::uno::Sequence< css::uno::Any >&
71 getTypedItemList() const { return m_aTypedItems; }
73 /// determines whether we actually have an external list source
74 bool hasExternalListSource( ) const { return m_xListSource.is(); }
76 /** handling the XEventListener::disposing call for the case where
77 our list source is being disposed
78 @return
79 <TRUE/> if and only if the disposed object was our list source, and so the
80 event was handled
82 bool handleDisposing( const css::lang::EventObject& _rEvent );
84 /** to be called by derived classes' instances when they're being disposed
86 void disposing( );
88 // prevent method hiding
89 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override = 0;
91 /** helper for implementing convertFastPropertyValue( StringItemList )
93 <p>The signature of this method and the return type have the same semantics
94 as convertFastPropertyValue.</p>
96 bool convertNewListSourceProperty(
97 css::uno::Any& _rConvertedValue,
98 css::uno::Any& _rOldValue,
99 const css::uno::Any& _rValue
102 /** helper for implementing setFastPropertyValueNoBroadcast
104 <p>Will internally call stringItemListChanged after the new item list
105 has been set.</p>
107 @precond
108 not to be called when we have an external list source
109 @see hasExternalListSource
111 void setNewStringItemList( const css::uno::Any& _rValue, ControlModelLock& _rInstanceLock );
113 /** helper for implementing setFastPropertyValueNoBroadcast
115 <p>Will internally call stringItemListChanged after the new item list
116 has been set.</p>
118 @precond
119 not to be called when we have an external list source
120 @see hasExternalListSource
122 void setNewTypedItemList( const css::uno::Any& _rValue, ControlModelLock& _rInstanceLock );
124 /** announces that the list of entries has changed.
126 <p>Derived classes have to override this. Most probably, they'll set the new
127 as model property.</p>
129 @pure
130 @see getStringItemList
132 virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ) = 0;
134 /** called when XRefreshable::refresh has been called, and we do *not* have an external
135 list source
137 virtual void refreshInternalEntryList() = 0;
139 private:
140 // XListEntrySink
141 virtual void SAL_CALL setListEntrySource( const css::uno::Reference< css::form::binding::XListEntrySource >& _rxSource ) override;
142 virtual css::uno::Reference< css::form::binding::XListEntrySource > SAL_CALL getListEntrySource( ) override;
144 // XListEntryListener
145 virtual void SAL_CALL entryChanged( const css::form::binding::ListEntryEvent& _rSource ) override;
146 virtual void SAL_CALL entryRangeInserted( const css::form::binding::ListEntryEvent& _rSource ) override;
147 virtual void SAL_CALL entryRangeRemoved( const css::form::binding::ListEntryEvent& _rSource ) override;
148 virtual void SAL_CALL allEntriesChanged( const css::lang::EventObject& _rSource ) override;
150 // XRefreshable
151 virtual void SAL_CALL refresh() override;
152 virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener>& _rxListener) override;
153 virtual void SAL_CALL removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener>& _rxListener) override;
155 private:
156 /** disconnects from the active external list source, if present
157 @see connectExternalListSource
159 void disconnectExternalListSource( );
161 /** connects to a new external list source
162 @param _rxSource
163 the new list source. Must not be <NULL/>
164 @see disconnectExternalListSource
166 void connectExternalListSource(
167 const css::uno::Reference< css::form::binding::XListEntrySource >& _rxSource,
168 ControlModelLock& _rInstanceLock
171 /** obtains list entries and possibly data values from list source
173 @precond
174 m_xListSource has to hold an external list source
176 void obtainListSourceEntries( ControlModelLock& _rInstanceLock );
178 /** refreshes our list entries
180 In case we have an external list source, it's used to obtain the new entries, and then
181 stringItemListChanged is called to give the derived class the possibility to
182 react on this.
184 In case we do not have an external list source, refreshInternalEntryList is called.
186 void impl_lock_refreshList( ControlModelLock& _rInstanceLock );
188 private:
189 OEntryListHelper( const OEntryListHelper& ) = delete;
190 OEntryListHelper& operator=( const OEntryListHelper& ) = delete;
194 } // namespace frm
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */