29#include <com/sun/star/beans/PropertyAttribute.hpp>
30#include <com/sun/star/form/FormComponentType.hpp>
31#include <com/sun/star/sdbc/XRowSet.hpp>
32#include <com/sun/star/container/XIndexAccess.hpp>
33#include <com/sun/star/sdbc/XConnection.hpp>
60using namespace ::com::sun::star::form::binding;
65 return ::comphelper::concatSequences(
78 sal_Int32 nOldLen = aSupported.getLength();
79 aSupported.realloc( nOldLen + 9 );
80 OUString* pStoreTo = aSupported.getArray() + nOldLen;
102 if ( !aReturn.hasValue() )
104 if ( !aReturn.hasValue() )
115 ,m_eListSourceType(ListSourceType_TABLE)
116 ,m_bEmptyIsNull(true)
124 :OBoundControlModel( _pOriginal, _rxFactory )
125 ,OEntryListHelper( *_pOriginal, static_cast<OControlModel&>(*this) )
126 ,OErrorBroadcaster( OComponentHelper::rBHelper )
127 ,m_aListSource( _pOriginal->m_aListSource )
128 ,m_aDefaultText( _pOriginal->m_aDefaultText )
129 ,m_eListSourceType( _pOriginal->m_eListSourceType )
130 ,m_bEmptyIsNull( _pOriginal->m_bEmptyIsNull )
137 if (!OComponentHelper::rBHelper.bDisposed)
150 pClone->clonedFrom(
this);
203 "OComboBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
208 DBG_ASSERT(_rValue.getValueType().getTypeClass() == TypeClass_STRING,
209 "OComboBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
222 DBG_ASSERT(_rValue.getValueType().getTypeClass() == TypeClass_BOOLEAN,
223 "OComboBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
228 DBG_ASSERT(_rValue.getValueType().getTypeClass() == TypeClass_STRING,
229 "OComboBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
259 Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle,
const Any& _rValue)
261 bool bModified(
false);
286 throw IllegalArgumentException();
300 sal_Int32 nOldCount = _rProps.getLength();
301 _rProps.realloc( nOldCount + 7);
302 css::beans::Property* pProperties = _rProps.getArray() + nOldCount;
307 css::beans::PropertyAttribute::BOUND);
311 DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(),
"<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?");
340 _rxOutStream->writeShort(0x0006);
343 sal_uInt16 nAnyMask = 0;
344 if (
m_aBoundColumn.getValueType().getTypeClass() == TypeClass_SHORT)
346 _rxOutStream << nAnyMask;
348 css::uno::Sequence<OUString> aListSourceSeq(&
m_aListSource, 1);
349 _rxOutStream << aListSourceSeq;
354 sal_Int16 nBoundColumn = 0;
356 _rxOutStream << nBoundColumn;
378 if ( m_xAggregateSet.is() )
383 TOOLS_WARN_EXCEPTION(
"forms.component",
"OComboBoxModel::read: caught an exception while examining the aggregate's string item list!" );
387 sal_uInt16
nVersion = _rxInStream->readShort();
388 DBG_ASSERT(
nVersion > 0,
"OComboBoxModel::read : version 0 ? this should never have been written !");
392 OSL_FAIL(
"OComboBoxModel::read : invalid (means unknown) version !");
404 _rxInStream >> nAnyMask;
414 css::uno::Sequence<OUString> aListSource;
415 _rxInStream >> aListSource;
416 for (
const OUString& rToken : std::as_const(aListSource))
420 sal_Int16 nListSourceType;
421 _rxInStream >> nListSourceType;
434 _rxInStream >> bNull;
478 if (!xConnection.is())
481 Reference<XServiceInfo> xServiceInfo(xConnection, UNO_QUERY);
484 OSL_FAIL(
"OComboBoxModel::loadData : invalid connection !");
496 bool bExecuteRowSet(
false );
499 case ListSourceType_TABLEFIELDS:
502 case ListSourceType_TABLE:
518 Reference<XPropertySet> xFormProp(
m_xCursor,UNO_QUERY);
519 Reference< XColumnsSupplier > xSupplyFields;
520 xFormProp->getPropertyValue(
"SingleSelectQueryComposer") >>= xSupplyFields;
523 DBG_ASSERT(xSupplyFields.is(),
"OComboBoxModel::loadData : invalid query composer !");
525 Reference< XNameAccess > xFieldNames = xSupplyFields->getColumns();
528 Reference< XPropertySet > xComposerFieldAsSet;
535 if (aFieldName.isEmpty())
538 Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
539 OSL_ENSURE(xMeta.is(),
"No database meta data!");
542 OUString aQuote = xMeta->getIdentifierQuoteString();
547 OUString aStatement =
555 bExecuteRowSet =
true;
558 case ListSourceType_QUERY:
561 bExecuteRowSet =
true;
569 bExecuteRowSet =
true;
573 if ( bExecuteRowSet )
585 catch(
const SQLException& eSQL)
601 "OComboBoxModel::loadData: logic error!" );
607 case ListSourceType_SQL:
608 case ListSourceType_SQLPASSTHROUGH:
609 case ListSourceType_TABLE:
610 case ListSourceType_QUERY:
613 Reference<XColumnsSupplier> xSupplyCols(xListCursor, UNO_QUERY);
614 DBG_ASSERT(xSupplyCols.is(),
"OComboBoxModel::loadData : cursor supports the row set service but is no column supplier?!");
615 Reference<XIndexAccess> xColumns;
616 if (xSupplyCols.is())
618 xColumns.set(xSupplyCols->getColumns(), UNO_QUERY);
619 DBG_ASSERT(xColumns.is(),
"OComboBoxModel::loadData : no columns supplied by the row set !");
621 Reference< XPropertySet > xDataField;
623 xColumns->getByIndex(0) >>= xDataField;
624 if ( !xDataField.is() )
632 while (xListCursor->next() && (
i++<SHRT_MAX))
638 case ListSourceType_TABLEFIELDS:
641 if (xFieldNames.is())
643 const Sequence<OUString>
aFieldNames = xFieldNames->getElementNames();
649 OSL_FAIL(
"OComboBoxModel::loadData: unreachable!" );
653 catch(
const SQLException& eSQL)
673 Reference<XPropertySet> xField =
getField();
675 m_pValueFormatter.reset( new ::dbtools::FormattedColumnValue(
getContext(), Reference< XRowSet >( _rxForm, UNO_QUERY ), xField ) );
718 aNewValue >>= sNewValue;
723 if ( !aNewValue.hasValue()
724 || ( sNewValue.isEmpty()
736 "OComboBoxModel::commitControlValueToDbColumn: no value formatter!");
755 bool bAddToList = bModified && !_bPostReset;
761 css::uno::Sequence<OUString> aStringItemList;
766 for (
const OUString& rStringItem : std::as_const(aStringItemList))
768 if ( (bFound = rStringItem == sNewValue) )
775 sal_Int32 nOldLen = aStringItemList.getLength();
776 aStringItemList.realloc( nOldLen + 1 );
777 aStringItemList.getArray()[ nOldLen ] = sNewValue;
791 "OComboBoxModel::translateDbColumnToControlValue: no value formatter!");
795 if ( sValue.isEmpty()
824 if ( m_xAggregateSet.is() )
864 aSupported.realloc(aSupported.getLength() + 2);
866 OUString* pArray = aSupported.getArray();
874extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
876 css::uno::Sequence<css::uno::Any>
const &)
881extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
883 css::uno::Sequence<css::uno::Any>
const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_form_OComboBoxControl_get_implementation(css::uno::XComponentContext *component, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_form_OComboBoxModel_get_implementation(css::uno::XComponentContext *component, css::uno::Sequence< css::uno::Any > const &)
const char *const aFieldNames[]
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
virtual void SAL_CALL dispose() SAL_OVERRIDE
void setCommand(const OUString &_rCommand)
void setCommandFromQuery(const OUString &_rQueryName)
sets the command of a query as command to be executed
css::uno::Reference< css::sdbc::XResultSet > execute()
executes the statement
void dispose()
disposes the instance and frees all associated resources
bool isDirty() const
determines whether the row set properties are dirty, i.e. have changed since the last call to execute
void setConnection(const css::uno::Reference< css::sdbc::XConnection > &_rxConnection)
void setEscapeProcessing(const bool _bEscapeProcessing)
class whose instances lock an OControlModel
void writeCommonProperties(const css::uno::Reference< css::io::XObjectOutputStream > &_rxOutStream)
We can't write (new) common properties in this base class, as the file format doesn't allow this (unf...
sal_Int32 getValuePropertyAggHandle() const
void defaultCommonProperties()
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &_rType) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
virtual void SAL_CALL disposing() override
void initValueProperty(const OUString &_rValuePropertyName, sal_Int32 _nValuePropertyExternalHandle)
initializes the part of the class which is related to the control value.
virtual void describeFixedProperties(css::uno::Sequence< css::beans::Property > &_rProps) const override
describes the properties provided by this class, or its respective derived class
virtual void resetNoBroadcast()
called to reset the control to some kind of default.
const OUString & getControlSource() const
virtual css::uno::Sequence< css::uno::Type > _getTypes() override
virtual void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream > &OutStream) override
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &_rConvertedValue, css::uno::Any &_rOldValue, sal_Int32 _nHandle, const css::uno::Any &_rValue) override
virtual void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream > &InStream) override
void readCommonProperties(const css::uno::Reference< css::io::XObjectInputStream > &_rxInStream)
css::uno::Reference< css::sdbc::XRowSet > m_xCursor
const css::uno::Reference< css::beans::XPropertySet > & getField() const
css::uno::Reference< css::sdb::XColumnUpdate > m_xColumnUpdate
virtual void SAL_CALL reloaded(const css::lang::EventObject &aEvent) override
OComboBoxControl(const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Any m_aBoundColumn
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &_rConvertedValue, css::uno::Any &_rOldValue, sal_Int32 _nHandle, const css::uno::Any &_rValue) override
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &_rType) override
virtual css::uno::Any getDefaultForReset() const override
returns the default which should be used when resetting the control
virtual void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream > &_rxOutStream) override
virtual void describeAggregateProperties(css::uno::Sequence< css::beans::Property > &_rAggregateProps) const override
describes the properties of our aggregate
virtual void onDisconnectedDbColumn() override
called whenever a connection to a database column has been suspended
virtual void resetNoBroadcast() override
called to reset the control to some kind of default.
css::form::ListSourceType m_eListSourceType
virtual void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream > &_rxInStream) override
virtual void onConnectedDbColumn(const css::uno::Reference< css::uno::XInterface > &_rxForm) override
called whenever a connection to a database column has been established
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
virtual void stringItemListChanged(ControlModelLock &_rInstanceLock) override
announces that the list of entries has changed.
virtual void refreshInternalEntryList() override
called when XRefreshable::refresh has been called, and we do not have an external list source
void loadData(bool _bForce)
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual void SAL_CALL disposing() override
virtual css::uno::Sequence< css::uno::Type > _getTypes() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
OComboBoxModel(const css::uno::Reference< css::uno::XComponentContext > &_rxFactory)
virtual void describeFixedProperties(css::uno::Sequence< css::beans::Property > &_rProps) const override
describes the properties provided by this class, or its respective derived class
virtual void SAL_CALL reloaded(const css::lang::EventObject &aEvent) override
virtual ~OComboBoxModel() override
CachedRowSet m_aListRowSet
virtual bool commitControlValueToDbColumn(bool _bPostReset) override
commits the current control value to the database column we're bound to @precond we're properly bound...
virtual OUString SAL_CALL getServiceName() override
::std::unique_ptr< ::dbtools::FormattedColumnValue > m_pValueFormatter
virtual css::uno::Any translateDbColumnToControlValue() override
translates a db column value into a control value.
css::uno::Any m_aLastKnownValue
css::uno::Sequence< OUString > m_aDesignModeStringItems
const css::uno::Reference< css::uno::XComponentContext > & getContext() const
virtual void describeAggregateProperties(css::uno::Sequence< css::beans::Property > &_rAggregateProps) const
describes the properties of our aggregate
void writeHelpTextCompatibly(const css::uno::Reference< css::io::XObjectOutputStream > &_rxOutStream)
void readHelpTextCompatibly(const css::uno::Reference< css::io::XObjectInputStream > &_rxInStream)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
bool convertNewListSourceProperty(css::uno::Any &_rConvertedValue, css::uno::Any &_rOldValue, const css::uno::Any &_rValue)
helper for implementing convertFastPropertyValue( StringItemList )
void setNewStringItemList(const css::uno::Any &_rValue, ControlModelLock &_rInstanceLock)
helper for implementing setFastPropertyValueNoBroadcast
void disposing()
to be called by derived classes' instances when they're being disposed
void setNewTypedItemList(const css::uno::Any &_rValue, ControlModelLock &_rInstanceLock)
helper for implementing setFastPropertyValueNoBroadcast
const css::uno::Sequence< css::uno::Any > & getTypedItemList() const
returns the current typed item list
bool handleDisposing(const css::lang::EventObject &_rEvent)
handling the XEventListener::disposing call for the case where our list source is being disposed
bool hasExternalListSource() const
determines whether we actually have an external list source
const std::vector< OUString > & getStringItemList() const
returns the current string item list
void onError(const css::sdbc::SQLException &_rException, const OUString &_rContextDescription)
void reset(const css::uno::Reference< INTERFACE > &_rxComponent, AssignmentMode _eMode=TakeOwnership)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
constexpr OUStringLiteral PROPERTY_TABINDEX
constexpr OUStringLiteral PROPERTY_DEFAULT_TEXT
constexpr OUStringLiteral PROPERTY_TEXT
constexpr OUStringLiteral PROPERTY_EMPTY_IS_NULL
constexpr OUStringLiteral PROPERTY_LISTSOURCETYPE
constexpr OUStringLiteral PROPERTY_TYPEDITEMLIST
constexpr OUStringLiteral PROPERTY_STRINGITEMLIST
constexpr OUStringLiteral PROPERTY_LISTSOURCE
constexpr OUStringLiteral PROPERTY_FIELDSOURCE
bool hasProperty(const OUString &_rName, const Reference< XPropertySet > &_rxSet)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
bool tryPropertyValue(Any &_rConvertedValue, Any &_rOldValue, const Any &_rValueToSet, const Any &_rCurrentValue, const Type &_rExpectedType)
std::enable_if< std::is_enum< ENUMTYPE >::value, bool >::type tryPropertyValueEnum(css::uno::Any &_rConvertedValue, css::uno::Any &_rOldValue, const css::uno::Any &_rValueToSet, const ENUMTYPE &_rCurrentValue)
void RemoveProperty(Sequence< Property > &_rProps, const OUString &_rPropName)
OUString loadString(TranslateId aResId)
loads the string with the specified resource id from the FormLayer mo file
ListBox is a bit confusing / different from other form components, so here are a few notes:
const sal_uInt16 BOUNDCOLUMN
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
#define PROPERTY_ID_TYPEDITEMLIST
#define PROPERTY_ID_STRINGITEMLIST
#define PROPERTY_ID_LISTSOURCETYPE
#define PROPERTY_ID_EMPTY_IS_NULL
#define PROPERTY_ID_DEFAULT_TEXT
#define PROPERTY_ID_LISTSOURCE
#define PROPERTY_ID_TABINDEX
constexpr OUStringLiteral FRM_SUN_CONTROL_COMBOBOX
constexpr OUStringLiteral BINDABLE_DATABASE_COMBO_BOX
constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_COMBOBOX
constexpr OUStringLiteral FRM_SUN_COMPONENT_COMBOBOX
constexpr OUStringLiteral FRM_COMPONENT_COMBOBOX
constexpr OUStringLiteral VALIDATABLE_BINDABLE_CONTROL_MODEL
constexpr OUStringLiteral FRM_SUN_COMPONENT_DATABASE_COMBOBOX
constexpr OUStringLiteral VCL_CONTROL_COMBOBOX
constexpr OUStringLiteral BINDABLE_DATA_AWARE_CONTROL_MODEL
constexpr OUStringLiteral VCL_CONTROLMODEL_COMBOBOX
constexpr OUStringLiteral DATA_AWARE_CONTROL_MODEL
constexpr OUStringLiteral SRV_SDB_CONNECTION
constexpr OUStringLiteral VALIDATABLE_CONTROL_MODEL
constexpr OUStringLiteral BINDABLE_CONTROL_MODEL
const std::u16string_view aStringList[]