diff options
author | Philipp Lohmann [pl] <Philipp.Lohmann@Oracle.COM> | 2010-11-24 18:50:17 +0100 |
---|---|---|
committer | Philipp Lohmann [pl] <Philipp.Lohmann@Oracle.COM> | 2010-11-24 18:50:17 +0100 |
commit | 4592bb216c141007fb21395b91190790d140b456 (patch) | |
tree | 7462b8339e02d2227c62e1da934f9024866fac98 /forms/source | |
parent | bd6ee967cdf357ae485dea1611ed5b29d630ca96 (diff) | |
parent | 84025fa376598f1c42023ffddd2d851db914e984 (diff) |
merge with DEV300_m94
Diffstat (limited to 'forms/source')
-rw-r--r-- | forms/source/component/Filter.cxx | 48 | ||||
-rw-r--r-- | forms/source/component/Filter.hxx | 5 | ||||
-rw-r--r-- | forms/source/component/FormComponent.cxx | 54 | ||||
-rw-r--r-- | forms/source/component/ListBox.cxx | 24 | ||||
-rw-r--r-- | forms/source/helper/windowstateguard.cxx | 28 |
5 files changed, 103 insertions, 56 deletions
diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx index 9cba722789e8..f9f17524756f 100644 --- a/forms/source/component/Filter.cxx +++ b/forms/source/component/Filter.cxx @@ -57,6 +57,7 @@ #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> #include <com/sun/star/sdbcx/XTablesSupplier.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <com/sun/star/awt/XItemList.hpp> /** === end UNO includes === **/ #include <comphelper/numbers.hxx> @@ -342,11 +343,28 @@ 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 ); + ::rtl::OUString sItemText( xItemList->getItemText( rEvent.Selected ) ); + + const MapString2String::const_iterator itemPos = m_aDisplayItemToValueItem.find( sItemText ); + if ( itemPos != m_aDisplayItemToValueItem.end() ) + { + sItemText = itemPos->second; + if ( sItemText.getLength() ) + { + ::dbtools::OPredicateInputController aPredicateInput( m_aContext.getLegacyServiceFactory(), m_xConnection, getParseContext() ); + ::rtl::OUString sErrorMessage; + OSL_VERIFY( aPredicateInput.normalizePredicateString( sItemText, m_xField, &sErrorMessage ) ); + } + } + aText.append( sItemText ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } break; @@ -614,6 +632,16 @@ namespace frm { m_aText = aText; xListBox->selectItem(m_aText, sal_True); + if ( xListBox->getSelectedItemPos() >= 0 ) + { + const bool isQuoted = ( aText.getLength() > 0 ) + && ( aText[0] == '\'' ) + && ( aText[aText.getLength() - 1] == '\'' ); + if ( isQuoted ) + { + xListBox->selectItem( aText.copy( 1, aText.getLength() - 2 ), sal_True ); + } + } } } break; default: @@ -804,6 +832,16 @@ namespace frm case FormComponentType::LISTBOX: case FormComponentType::COMBOBOX: m_nControlClass = nClassId; + if ( FormComponentType::LISTBOX == nClassId ) + { + Sequence< ::rtl::OUString > aDisplayItems; + OSL_VERIFY( xControlModel->getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aDisplayItems ); + Sequence< ::rtl::OUString > aValueItems; + OSL_VERIFY( xControlModel->getPropertyValue( PROPERTY_VALUE_SEQ ) >>= aValueItems ); + OSL_ENSURE( aDisplayItems.getLength() == aValueItems.getLength(), "OFilterControl::initialize: inconsistent item lists!" ); + for ( sal_Int32 i=0; i < ::std::min( aDisplayItems.getLength(), aValueItems.getLength() ); ++i ) + m_aDisplayItemToValueItem[ aDisplayItems[i] ] = aValueItems[i]; + } break; default: m_bMultiLine = ::comphelper::hasProperty( PROPERTY_MULTILINE, xControlModel ) && ::comphelper::getBOOL( xControlModel->getPropertyValue( PROPERTY_MULTILINE ) ); diff --git a/forms/source/component/Filter.hxx b/forms/source/component/Filter.hxx index 8e2933e93158..99c621d6cdf6 100644 --- a/forms/source/component/Filter.hxx +++ b/forms/source/component/Filter.hxx @@ -45,7 +45,7 @@ #include <connectivity/sqlparse.hxx> #include <svx/ParseContext.hxx> -class Window; +#include <hash_map> //......................................................................... namespace frm @@ -75,6 +75,9 @@ namespace frm ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xMessageParent; + typedef ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash > MapString2String; + MapString2String m_aDisplayItemToValueItem; + ::rtl::OUString m_aText; ::connectivity::OSQLParser m_aParser; sal_Int16 m_nControlClass; // which kind of control do we use? 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<com::sun::star::lang::XEventListener> 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<com::sun::star::lang::XComponent> xComp(m_xLabelControl, UNO_QUERY); - if (xComp.is()) - xComp->removeEventListener(static_cast<com::sun::star::lang::XEventListener*>(static_cast<XPropertyChangeListener*>(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<XControlModel> xAsModel(xNewValue, UNO_QUERY); - Reference<com::sun::star::lang::XServiceInfo> xAsServiceInfo(xNewValue, UNO_QUERY); - Reference<XPropertySet> xAsPropSet(xNewValue, UNO_QUERY); - Reference<XChild> 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<XChild> xCont; query_interface(static_cast<XWeak*>(this), xCont); - InterfaceRef xMyTopLevel = xCont->getParent(); + Reference< XInterface > xMyTopLevel = xCont->getParent(); while (xMyTopLevel.is()) { Reference<XForm> xAsForm(xMyTopLevel, UNO_QUERY); @@ -1907,9 +1901,9 @@ void OBoundControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, co break; Reference<XChild> 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<XForm> xAsForm(xNewTopLevel, UNO_QUERY); @@ -1917,7 +1911,7 @@ void OBoundControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, co break; Reference<XChild> xLoopAsChild(xNewTopLevel, UNO_QUERY); - xNewTopLevel = xLoopAsChild.is() ? xLoopAsChild->getParent() : InterfaceRef(); + xNewTopLevel = xLoopAsChild.is() ? xLoopAsChild->getParent() : Reference< XInterface >(); } if (xNewTopLevel != xMyTopLevel) { diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index da335308933e..909cc1f23659 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -64,6 +64,8 @@ #include <unotools/sharedunocomponent.hxx> #include <vcl/svapp.hxx> +#include <boost/optional.hpp> + #include <algorithm> #include <functional> @@ -677,9 +679,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 @@ -703,14 +709,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<XPropertySet> xFieldAsSet(xFieldsByIndex->getByIndex(nBoundColumn),UNO_QUERY); + Reference<XPropertySet> 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; @@ -840,11 +846,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& ) @@ -868,7 +874,7 @@ namespace frm if ( impl_hasBoundComponent() ) { - aBoundValue.fill( nBoundColumn + 1, m_nBoundColumnType, xCursorRow ); + aBoundValue.fill( *aBoundColumn + 1, m_nBoundColumnType, xCursorRow ); aValueList.push_back( aBoundValue ); } diff --git a/forms/source/helper/windowstateguard.cxx b/forms/source/helper/windowstateguard.cxx index c4bb6154a4d5..1bbc8e4242f6 100644 --- a/forms/source/helper/windowstateguard.cxx +++ b/forms/source/helper/windowstateguard.cxx @@ -98,7 +98,7 @@ namespace frm @precond our mutex is locked */ - void impl_ensureEnabledState_nothrow() const; + void impl_ensureEnabledState_nothrow_nolck(); }; //-------------------------------------------------------------------- @@ -129,16 +129,24 @@ namespace frm } //-------------------------------------------------------------------- - void WindowStateGuard_Impl::impl_ensureEnabledState_nothrow() const + void WindowStateGuard_Impl::impl_ensureEnabledState_nothrow_nolck() { try { - sal_Bool bEnabled = m_xWindow->isEnabled(); + Reference< XWindow2 > xWindow; + sal_Bool bEnabled = sal_False; sal_Bool bShouldBeEnabled = sal_False; - OSL_VERIFY( m_xModelProps->getPropertyValue( PROPERTY_ENABLED ) >>= bShouldBeEnabled ); - - if ( !bShouldBeEnabled && bEnabled ) - m_xWindow->setEnable( sal_False ); + { + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !m_xWindow.is() || !m_xModelProps.is() ) + return; + xWindow = m_xWindow; + bEnabled = xWindow->isEnabled(); + OSL_VERIFY( m_xModelProps->getPropertyValue( PROPERTY_ENABLED ) >>= bShouldBeEnabled ); + } + + if ( !bShouldBeEnabled && bEnabled && xWindow.is() ) + xWindow->setEnable( sal_False ); } catch( const Exception& ) { @@ -149,15 +157,13 @@ namespace frm //-------------------------------------------------------------------- void SAL_CALL WindowStateGuard_Impl::windowEnabled( const EventObject& /*e*/ ) throw (RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - impl_ensureEnabledState_nothrow(); + impl_ensureEnabledState_nothrow_nolck(); } //-------------------------------------------------------------------- void SAL_CALL WindowStateGuard_Impl::windowDisabled( const EventObject& /*e*/ ) throw (RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - impl_ensureEnabledState_nothrow(); + impl_ensureEnabledState_nothrow_nolck(); } //-------------------------------------------------------------------- |