From dfc599fdc4e7d8f6b78d5fef69f7766e2c2c515d Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 13 Sep 2010 18:59:52 +0200 Subject: dba34a: during #i114403#: allow list boxes to have a bound column of '0' --- forms/source/component/ListBox.cxx | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'forms/source/component') diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index d2de4882dead..7bf1885af992 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -64,6 +64,8 @@ #include #include +#include + #include #include @@ -675,9 +677,13 @@ namespace frm return; } - sal_Int16 nBoundColumn = 0; - if (m_aBoundColumn.getValueType().getTypeClass() == TypeClass_SHORT) + ::boost::optional< sal_Int16 > aBoundColumn; + if ( m_aBoundColumn.getValueType().getTypeClass() == TypeClass_SHORT ) + { + sal_Int16 nBoundColumn( 0 ); m_aBoundColumn >>= nBoundColumn; + aBoundColumn.reset( nBoundColumn ); + } ::utl::SharedUNOComponent< XResultSet > xListCursor; try @@ -701,14 +707,14 @@ namespace frm ::rtl::OUString aFieldName; ::rtl::OUString aBoundFieldName; - if ((nBoundColumn > 0) && xFieldsByIndex.is()) + if ( !!aBoundColumn && ( *aBoundColumn >= 0 ) && xFieldsByIndex.is() ) { - if (xFieldsByIndex->getCount() <= nBoundColumn) + if ( *aBoundColumn >= xFieldsByIndex->getCount() ) break; - Reference xFieldAsSet(xFieldsByIndex->getByIndex(nBoundColumn),UNO_QUERY); + Reference xFieldAsSet(xFieldsByIndex->getByIndex( *aBoundColumn ),UNO_QUERY); xFieldAsSet->getPropertyValue(PROPERTY_NAME) >>= aBoundFieldName; - nBoundColumn = 1; + aBoundColumn.reset( 1 ); xFieldAsSet.set(xFieldsByIndex->getByIndex(0),UNO_QUERY); xFieldAsSet->getPropertyValue(PROPERTY_NAME) >>= aFieldName; @@ -836,11 +842,11 @@ namespace frm // Feld der BoundColumn des ResultSets holen m_nBoundColumnType = DataType::SQLNULL; - if ( ( nBoundColumn > 0 ) && m_xColumn.is() ) + if ( !!aBoundColumn && ( *aBoundColumn >= 0 ) && m_xColumn.is() ) { // don't look for a bound column if we're not connected to a field try { - Reference< XPropertySet > xBoundField( xColumns->getByIndex( nBoundColumn ), UNO_QUERY_THROW ); + Reference< XPropertySet > xBoundField( xColumns->getByIndex( *aBoundColumn ), UNO_QUERY_THROW ); OSL_VERIFY( xBoundField->getPropertyValue( ::rtl::OUString::createFromAscii( "Type" ) ) >>= m_nBoundColumnType ); } catch( const Exception& ) @@ -864,7 +870,7 @@ namespace frm if ( impl_hasBoundComponent() ) { - aBoundValue.fill( nBoundColumn + 1, m_nBoundColumnType, xCursorRow ); + aBoundValue.fill( *aBoundColumn + 1, m_nBoundColumnType, xCursorRow ); aValueList.push_back( aBoundValue ); } -- cgit v1.2.3 From 0096dc80abf5c1456389848c2fcc33edcc29cca0 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 17 Sep 2010 08:38:54 +0200 Subject: dba34a: #i114403# fixed the form-based filter for list boxes --- forms/source/component/Filter.cxx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'forms/source/component') diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx index 9cbc5237cf95..f4aa133a44f4 100644 --- a/forms/source/component/Filter.cxx +++ b/forms/source/component/Filter.cxx @@ -57,6 +57,7 @@ #include #include #include +#include /** === end UNO includes === **/ #include @@ -342,11 +343,16 @@ namespace frm case FormComponentType::LISTBOX: { - Sequence< ::rtl::OUString> aValueSelection; - Reference< XPropertySet > aPropertyPointer(getModel(), UNO_QUERY); - aPropertyPointer->getPropertyValue(PROPERTY_VALUE_SEQ) >>= aValueSelection; - if (rEvent.Selected <= aValueSelection.getLength()) - aText.append( aValueSelection[ rEvent.Selected ] ); + try + { + const Reference< XItemList > xItemList( getModel(), UNO_QUERY_THROW ); + const ::rtl::OUString sItemText( xItemList->getItemText( rEvent.Selected ) ); + aText.append( sItemText ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } break; -- cgit v1.2.3 From f41c780b2771695421d8d2a1e8dc9d2229d786f5 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 28 Sep 2010 09:42:32 +0200 Subject: dba34a: #i114752# allow setting an empty reference, not only an empty Any, as ControlLabel --- forms/source/component/FormComponent.cxx | 54 ++++++++++++++------------------ 1 file changed, 24 insertions(+), 30 deletions(-) (limited to 'forms/source/component') diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index f9d3ffab9709..de2dda9ca388 100644 --- a/forms/source/component/FormComponent.cxx +++ b/forms/source/component/FormComponent.cxx @@ -296,11 +296,11 @@ Sequence< ::rtl::OUString > SAL_CALL OControl::getSupportedServiceNames_Static() //------------------------------------------------------------------------------ void SAL_CALL OControl::disposing(const com::sun::star::lang::EventObject& _rEvent) throw (RuntimeException) { - InterfaceRef xAggAsIface; + Reference< XInterface > xAggAsIface; query_aggregation(m_xAggregate, xAggAsIface); // does the disposing come from the aggregate ? - if (xAggAsIface != InterfaceRef(_rEvent.Source, UNO_QUERY)) + if (xAggAsIface != Reference< XInterface >(_rEvent.Source, UNO_QUERY)) { // no -> forward it Reference xListener; if (query_aggregation(m_xAggregate, xListener)) @@ -310,16 +310,16 @@ void SAL_CALL OControl::disposing(const com::sun::star::lang::EventObject& _rEve // XControl //------------------------------------------------------------------------------ -void SAL_CALL OControl::setContext(const InterfaceRef& Context) throw (RuntimeException) +void SAL_CALL OControl::setContext(const Reference< XInterface >& Context) throw (RuntimeException) { if (m_xControl.is()) m_xControl->setContext(Context); } //------------------------------------------------------------------------------ -InterfaceRef SAL_CALL OControl::getContext() throw (RuntimeException) +Reference< XInterface > SAL_CALL OControl::getContext() throw (RuntimeException) { - return m_xControl.is() ? m_xControl->getContext() : InterfaceRef(); + return m_xControl.is() ? m_xControl->getContext() : Reference< XInterface >(); } //------------------------------------------------------------------------------ @@ -711,13 +711,13 @@ void OControlModel::doSetDelegator() // XChild //------------------------------------------------------------------------------ -InterfaceRef SAL_CALL OControlModel::getParent() throw(RuntimeException) +Reference< XInterface > SAL_CALL OControlModel::getParent() throw(RuntimeException) { return m_xParent; } //------------------------------------------------------------------------------ -void SAL_CALL OControlModel::setParent(const InterfaceRef& _rxParent) throw(com::sun::star::lang::NoSupportException, RuntimeException) +void SAL_CALL OControlModel::setParent(const Reference< XInterface >& _rxParent) throw(com::sun::star::lang::NoSupportException, RuntimeException) { osl::MutexGuard aGuard(m_aMutex); @@ -1867,30 +1867,24 @@ void OBoundControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, co throw com::sun::star::lang::IllegalArgumentException(); case PROPERTY_ID_CONTROLLABEL: { - DBG_ASSERT(!rValue.hasValue() || (rValue.getValueType().getTypeClass() == TypeClass_INTERFACE), - "OBoundControlModel::setFastPropertyValue_NoBroadcast : invalid argument !"); - if (!rValue.hasValue()) + if ( rValue.hasValue() && ( rValue.getValueTypeClass() != TypeClass_INTERFACE ) ) + throw com::sun::star::lang::IllegalArgumentException(); + + Reference< XInterface > xNewValue( rValue, UNO_QUERY ); + if ( !xNewValue.is() ) { // set property to "void" - Reference xComp(m_xLabelControl, UNO_QUERY); - if (xComp.is()) - xComp->removeEventListener(static_cast(static_cast(this))); + Reference< XComponent > xComp( m_xLabelControl, UNO_QUERY ); + if ( xComp.is() ) + xComp->removeEventListener( static_cast< XPropertyChangeListener* >( this ) ); m_xLabelControl = NULL; break; } - InterfaceRef xNewValue; - rValue >>= xNewValue; - - Reference xAsModel(xNewValue, UNO_QUERY); - Reference xAsServiceInfo(xNewValue, UNO_QUERY); - Reference xAsPropSet(xNewValue, UNO_QUERY); - Reference xAsChild(xNewValue, UNO_QUERY); - if (!xAsModel.is() || !xAsServiceInfo.is() || !xAsPropSet.is() || !xAsChild.is()) - { - throw com::sun::star::lang::IllegalArgumentException(); - } - - if (!xAsServiceInfo->supportsService(m_aLabelServiceName)) + Reference< XControlModel > xAsModel ( xNewValue, UNO_QUERY ); + Reference< XServiceInfo > xAsServiceInfo ( xAsModel, UNO_QUERY ); + Reference< XPropertySet > xAsPropSet ( xAsServiceInfo, UNO_QUERY ); + Reference< XChild > xAsChild ( xAsPropSet, UNO_QUERY ); + if ( !xAsChild.is() || !xAsServiceInfo->supportsService( m_aLabelServiceName ) ) { throw com::sun::star::lang::IllegalArgumentException(); } @@ -1898,7 +1892,7 @@ void OBoundControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, co // check if weself and the given model have a common anchestor (up to the forms collection) Reference xCont; query_interface(static_cast(this), xCont); - InterfaceRef xMyTopLevel = xCont->getParent(); + Reference< XInterface > xMyTopLevel = xCont->getParent(); while (xMyTopLevel.is()) { Reference xAsForm(xMyTopLevel, UNO_QUERY); @@ -1907,9 +1901,9 @@ void OBoundControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, co break; Reference xLoopAsChild(xMyTopLevel, UNO_QUERY); - xMyTopLevel = xLoopAsChild.is() ? xLoopAsChild->getParent() : InterfaceRef(); + xMyTopLevel = xLoopAsChild.is() ? xLoopAsChild->getParent() : Reference< XInterface >(); } - InterfaceRef xNewTopLevel = xAsChild->getParent(); + Reference< XInterface > xNewTopLevel = xAsChild->getParent(); while (xNewTopLevel.is()) { Reference xAsForm(xNewTopLevel, UNO_QUERY); @@ -1917,7 +1911,7 @@ void OBoundControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, co break; Reference xLoopAsChild(xNewTopLevel, UNO_QUERY); - xNewTopLevel = xLoopAsChild.is() ? xLoopAsChild->getParent() : InterfaceRef(); + xNewTopLevel = xLoopAsChild.is() ? xLoopAsChild->getParent() : Reference< XInterface >(); } if (xNewTopLevel != xMyTopLevel) { -- cgit v1.2.3 From f7c9efe9c6253d809ccbe157c2ef66ff6821522f Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 28 Sep 2010 11:45:50 +0200 Subject: dba34a: #i114792# restore m_nNULLPos/m_nBoundColumnType when old list data is still cached --- forms/source/component/ListBox.cxx | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'forms/source/component') diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index 7bf1885af992..909cc1f23659 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -649,6 +649,8 @@ namespace frm DBG_ASSERT( m_eListSourceType != ListSourceType_VALUELIST, "OListBoxModel::loadData: cannot load value list from DB!" ); DBG_ASSERT( !hasExternalListSource(), "OListBoxModel::loadData: cannot load from DB when I have an external list source!" ); + const sal_Int16 nNULLPosBackup( m_nNULLPos ); + const sal_Int32 nBoundColumnTypeBackup( m_nBoundColumnType ); m_nNULLPos = -1; m_nBoundColumnType = DataType::SQLNULL; @@ -788,6 +790,8 @@ namespace frm // 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. + m_nNULLPos = nNULLPosBackup; + m_nBoundColumnType = nBoundColumnTypeBackup; return; } xListCursor.reset( m_aListRowSet.execute() ); -- cgit v1.2.3