[Libreoffice-commits] core.git: forms/source
Eike Rathke
erack at redhat.com
Wed Jun 14 11:34:26 UTC 2017
forms/source/component/ComboBox.cxx | 17 +++++++++++++----
forms/source/component/ListBox.cxx | 26 +++++++++++++++++++++++++-
forms/source/component/entrylisthelper.cxx | 14 ++++++++++++++
forms/source/component/entrylisthelper.hxx | 11 +++++++++++
4 files changed, 63 insertions(+), 5 deletions(-)
New commits:
commit 96ef5d50da2c0c5a1edb279c413f73754d400537
Author: Eike Rathke <erack at redhat.com>
Date: Wed Jun 14 13:33:33 2017 +0200
Handle TypedItemList property in models, tdf#108413 follow-up
Now that the TypedItemList property is somewhat exposed at OListBoxModel and
OComboBoxModel also handle that something could want to set it, even if it was
meant to be used with external sources.
Change-Id: Iae8ce2a50dbbb2166d9a67dbf55900beeb9192d2
diff --git a/forms/source/component/ComboBox.cxx b/forms/source/component/ComboBox.cxx
index 240c4179febd..54da60a79dc3 100644
--- a/forms/source/component/ComboBox.cxx
+++ b/forms/source/component/ComboBox.cxx
@@ -251,10 +251,13 @@ void OComboBoxModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const
}
break;
- // XXX NOTE: PROPERTY_ID_TYPEDITEMLIST not handled here because only
- // set for external sources in which case not even
- // setNewStringItemList() for PROPERTY_ID_STRINGITEMLIST above should
- // had been called ...
+ case PROPERTY_ID_TYPEDITEMLIST:
+ {
+ ControlModelLock aLock( *this );
+ setNewTypedItemList( _rValue, aLock );
+ // Same FIXME as above.
+ }
+ break;
default:
OBoundControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
@@ -287,6 +290,12 @@ sal_Bool OComboBoxModel::convertFastPropertyValue(
bModified = convertNewListSourceProperty( _rConvertedValue, _rOldValue, _rValue );
break;
+ case PROPERTY_ID_TYPEDITEMLIST :
+ if (hasExternalListSource())
+ throw IllegalArgumentException();
+ bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, getTypedItemList());
+ break;
+
default:
bModified = OBoundControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
break;
diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx
index 60de8e2f7468..59e416451b96 100644
--- a/forms/source/component/ListBox.cxx
+++ b/forms/source/component/ListBox.cxx
@@ -387,6 +387,15 @@ namespace frm
resetNoBroadcast();
break;
+ case PROPERTY_ID_TYPEDITEMLIST:
+ {
+ ControlModelLock aLock( *this );
+ setNewTypedItemList( _rValue, aLock );
+ // Same TODO as above.
+ }
+ resetNoBroadcast();
+ break;
+
default:
OBoundControlModel::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
}
@@ -439,6 +448,12 @@ namespace frm
bModified = convertNewListSourceProperty( _rConvertedValue, _rOldValue, _rValue );
break;
+ case PROPERTY_ID_TYPEDITEMLIST :
+ if (hasExternalListSource())
+ throw IllegalArgumentException();
+ bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, getTypedItemList());
+ break;
+
default:
return OBoundControlModel::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
}
@@ -511,7 +526,16 @@ namespace frm
// <----- SYNCHRONIZED
return;
}
- // XXX NOTE: PROPERTY_TYPEDITEMLIST not handled, used only with external list source.
+ else if ( i_rEvent.PropertyName == PROPERTY_TYPEDITEMLIST )
+ {
+ ControlModelLock aLock( *this );
+ // SYNCHRONIZED ----->
+ // our aggregate internally changed its TypedItemList property - reflect this in our "overridden"
+ // version of the property
+ setNewTypedItemList( i_rEvent.NewValue, aLock );
+ // <----- SYNCHRONIZED
+ return;
+ }
OBoundControlModel::_propertyChanged( i_rEvent );
}
diff --git a/forms/source/component/entrylisthelper.cxx b/forms/source/component/entrylisthelper.cxx
index 508ccfd833e9..1e75a98846b1 100644
--- a/forms/source/component/entrylisthelper.cxx
+++ b/forms/source/component/entrylisthelper.cxx
@@ -320,6 +320,20 @@ namespace frm
}
+ void OEntryListHelper::setNewTypedItemList( const css::uno::Any& _rValue, ControlModelLock& _rInstanceLock )
+ {
+ OSL_PRECOND( !hasExternalListSource(), "OEntryListHelper::setNewTypedItemList: this should never have survived convertNewListSourceProperty!" );
+ if (!(_rValue >>= m_aTypedItems ))
+ {
+ OSL_VERIFY(false);
+ if (m_aTypedItems.getLength())
+ m_aTypedItems = Sequence<Any>(); // doesn't match anymore
+ }
+ // Sets both properties, assuming that TypedItemList belongs to StringItemList.
+ stringItemListChanged( _rInstanceLock );
+ }
+
+
} // namespace frm
diff --git a/forms/source/component/entrylisthelper.hxx b/forms/source/component/entrylisthelper.hxx
index b8e3e6504d9e..be2759410e86 100644
--- a/forms/source/component/entrylisthelper.hxx
+++ b/forms/source/component/entrylisthelper.hxx
@@ -112,6 +112,17 @@ namespace frm
*/
void setNewStringItemList( const css::uno::Any& _rValue, ControlModelLock& _rInstanceLock );
+ /** helper for implementing setFastPropertyValueNoBroadcast
+
+ <p>Will internally call stringItemListChanged after the new item list
+ has been set.</p>
+
+ @precond
+ not to be called when we have an external list source
+ @see hasExternalListSource
+ */
+ void setNewTypedItemList( const css::uno::Any& _rValue, ControlModelLock& _rInstanceLock );
+
/** announces that the list of entries has changed.
<p>Derived classes have to override this. Most probably, they'll set the new
More information about the Libreoffice-commits
mailing list