/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
case PROPERTY_ID_LISTSOURCE :
DBG_ASSERT(_rValue.getValueTypeClass() == TypeClass_STRING, "OComboBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
_rValue >>= m_aListSource; // The ListSource has changed -> reload if (ListSourceType_VALUELIST != m_eListSourceType)
{ if ( m_xCursor.is() && !hasField() && !hasExternalListSource() ) // combo box is already connected to a database, and no external list source // data source changed -> refresh
loadData( false );
} break;
case PROPERTY_ID_EMPTY_IS_NULL :
DBG_ASSERT(_rValue.getValueTypeClass() == TypeClass_BOOLEAN, "OComboBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
_rValue >>= m_bEmptyIsNull; break;
case PROPERTY_ID_DEFAULT_TEXT :
DBG_ASSERT(_rValue.getValueTypeClass() == TypeClass_STRING, "OComboBoxModel::setFastPropertyValue_NoBroadcast : invalid type !" );
_rValue >>= m_aDefaultText;
resetNoBroadcast(); break;
case PROPERTY_ID_STRINGITEMLIST:
{
ControlModelLock aLock( *this );
setNewStringItemList( _rValue, aLock ); // FIXME: this is bogus. setNewStringItemList expects a guard which has the *only* // lock to the mutex, but setFastPropertyValue_NoBroadcast is already called with // a lock - so we effectively has two locks here, of which setNewStringItemList can // only control one.
} break;
case PROPERTY_ID_TYPEDITEMLIST:
{
ControlModelLock aLock( *this );
setNewTypedItemList( _rValue, aLock ); // Same FIXME as above.
} break;
// Version // Version 0x0002: EmptyIsNull // Version 0x0003: ListSource->Seq // Version 0x0004: DefaultText // Version 0x0005: HelpText
_rxOutStream->writeShort(0x0006);
// Mask for Any
sal_uInt16 nAnyMask = 0; if (m_aBoundColumn.getValueTypeClass() == TypeClass_SHORT)
nAnyMask |= BOUNDCOLUMN;
_rxOutStream << nAnyMask;
// since we are "overwriting" the StringItemList of our aggregate (means we have // an own place to store the value, instead of relying on our aggregate storing it), // we need to respect what the aggregate just read for the StringItemList property. try
{ if ( m_xAggregateSet.is() )
setNewStringItemList( m_xAggregateSet->getPropertyValue( PROPERTY_STRINGITEMLIST ), aLock );
} catch( const Exception& )
{
TOOLS_WARN_EXCEPTION( "forms.component", "OComboBoxModel::read: caught an exception while examining the aggregate's string item list!" );
}
// Version
sal_uInt16 nVersion = _rxInStream->readShort();
DBG_ASSERT(nVersion > 0, "OComboBoxModel::read : version 0 ? this should never have been written !");
// StringList must be emptied if a ListSource is set. // This can be the case if we save in alive mode. if ( !m_aListSource.isEmpty()
&& !hasExternalListSource()
)
{
setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, Any( css::uno::Sequence<OUString>() ) );
setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, Any( css::uno::Sequence<css::uno::Any>() ) );
}
if (nVersion > 0x0004)
readHelpTextCompatibly(_rxInStream);
if (nVersion > 0x0005)
readCommonProperties(_rxInStream);
// After reading in, display the default values if ( !getControlSource().isEmpty() )
{ // (not if we don't have a control source - the "State" property acts like it is persistent, then
resetNoBroadcast();
}
}
void OComboBoxModel::loadData( bool _bForce )
{
DBG_ASSERT(m_eListSourceType != ListSourceType_VALUELIST, "OComboBoxModel::loadData : do not call for a value list !");
DBG_ASSERT( !hasExternalListSource(), "OComboBoxModel::loadData: cannot load from DB when I have an external list source!" );
if ( hasExternalListSource() ) return;
// Get Connection if (!m_xCursor.is()) return;
Reference<XConnection> xConnection = getConnection(m_xCursor); if (!xConnection.is()) return;
bool bExecuteRowSet( false ); switch (m_eListSourceType)
{ case ListSourceType_TABLEFIELDS: // don't work with a statement here, the fields will be collected below break; case ListSourceType_TABLE:
{ // does the bound field belong to the table ? // if we use an alias for the bound field, we won't find it // in that case we use the first field of the table
if ( bExecuteRowSet )
{ if ( !_bForce && !m_aListRowSet.isDirty() )
{ // if none of the settings of the row set changed, compared to the last // invocation of loadData, then don't re-fill the list. Instead, assume // the list entries are the same. return;
}
xListCursor.reset( m_aListRowSet.execute() );
}
} catch(const SQLException& eSQL)
{
onError(eSQL, ResourceManager::loadString(RID_BASELISTBOX_ERROR_FILLLIST)); return;
} catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("forms.component"); return;
}
switch (m_eListSourceType)
{ case ListSourceType_SQL: case ListSourceType_SQLPASSTHROUGH: case ListSourceType_TABLE: case ListSourceType_QUERY:
{ // The XDatabaseVariant of the first column
Reference<XColumnsSupplier> xSupplyCols(xListCursor, UNO_QUERY);
DBG_ASSERT(xSupplyCols.is(), "OComboBoxModel::loadData : cursor supports the row set service but is no column supplier?!");
Reference<XIndexAccess> xColumns; if (xSupplyCols.is())
{
xColumns.set(xSupplyCols->getColumns(), UNO_QUERY);
DBG_ASSERT(xColumns.is(), "OComboBoxModel::loadData : no columns supplied by the row set !");
}
Reference< XPropertySet > xDataField; if ( xColumns.is() )
xColumns->getByIndex(0) >>= xDataField; if ( !xDataField.is() ) return;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.