diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-14 12:39:50 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-14 13:33:20 +0200 |
commit | fcabb9a7263d4128ae934636b5a8eebc2a0217cc (patch) | |
tree | 28badfa7a81d578610f6abfc895d330f8a6437e4 | |
parent | 600b35480da436b2683b720149b576e85c16aa84 (diff) |
loplugin:flatten in forms
Change-Id: I7e264cc1e60280b80a4e2e87b8944de4912c563d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92162
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
24 files changed, 951 insertions, 953 deletions
diff --git a/forms/source/component/Columns.cxx b/forms/source/component/Columns.cxx index ae1b1cb88897..95438dc86cbf 100644 --- a/forms/source/component/Columns.cxx +++ b/forms/source/component/Columns.cxx @@ -197,23 +197,23 @@ OGridColumn::OGridColumn( const Reference<XComponentContext>& _rContext, const O { // Create the UnoControlModel - if ( !m_aModelName.isEmpty() ) // is there a to-be-aggregated model? - { - osl_atomic_increment( &m_refCount ); + if ( m_aModelName.isEmpty() ) // is there a to-be-aggregated model? + return; - { - m_xAggregate.set( _rContext->getServiceManager()->createInstanceWithContext( m_aModelName, _rContext ), UNO_QUERY ); - setAggregation( m_xAggregate ); - } + osl_atomic_increment( &m_refCount ); - if ( m_xAggregate.is() ) - { // don't omit those brackets - they ensure that the following temporary is properly deleted - m_xAggregate->setDelegator( static_cast< ::cppu::OWeakObject* >( this ) ); - } + { + m_xAggregate.set( _rContext->getServiceManager()->createInstanceWithContext( m_aModelName, _rContext ), UNO_QUERY ); + setAggregation( m_xAggregate ); + } - // Set refcount back to zero - osl_atomic_decrement( &m_refCount ); + if ( m_xAggregate.is() ) + { // don't omit those brackets - they ensure that the following temporary is properly deleted + m_xAggregate->setDelegator( static_cast< ::cppu::OWeakObject* >( this ) ); } + + // Set refcount back to zero + osl_atomic_decrement( &m_refCount ); } diff --git a/forms/source/component/Currency.cxx b/forms/source/component/Currency.cxx index e39a5e8c419d..5c682aa6474c 100644 --- a/forms/source/component/Currency.cxx +++ b/forms/source/component/Currency.cxx @@ -61,46 +61,46 @@ css::uno::Sequence<OUString> SAL_CALL OCurrencyControl::getSupportedServiceNames void OCurrencyModel::implConstruct() { - if (m_xAggregateSet.is()) + if (!m_xAggregateSet.is()) + return; + + try { - try - { - // get the system international information - const SvtSysLocale aSysLocale; - const LocaleDataWrapper& aLocaleInfo = aSysLocale.GetLocaleData(); + // get the system international information + const SvtSysLocale aSysLocale; + const LocaleDataWrapper& aLocaleInfo = aSysLocale.GetLocaleData(); - OUString sCurrencySymbol; - bool bPrependCurrencySymbol = false; - switch ( aLocaleInfo.getCurrPositiveFormat() ) - { - case 0: // $1 - sCurrencySymbol = aLocaleInfo.getCurrSymbol(); - bPrependCurrencySymbol = true; - break; - case 1: // 1$ - sCurrencySymbol = aLocaleInfo.getCurrSymbol(); - bPrependCurrencySymbol = false; - break; - case 2: // $ 1 - sCurrencySymbol = aLocaleInfo.getCurrSymbol() + " "; - bPrependCurrencySymbol = true; - break; - case 3: // 1 $ - sCurrencySymbol = " " + aLocaleInfo.getCurrSymbol(); - bPrependCurrencySymbol = false; - break; - } - if (!sCurrencySymbol.isEmpty()) - { - m_xAggregateSet->setPropertyValue(PROPERTY_CURRENCYSYMBOL, makeAny(sCurrencySymbol)); - m_xAggregateSet->setPropertyValue(PROPERTY_CURRSYM_POSITION, makeAny(bPrependCurrencySymbol)); - } + OUString sCurrencySymbol; + bool bPrependCurrencySymbol = false; + switch ( aLocaleInfo.getCurrPositiveFormat() ) + { + case 0: // $1 + sCurrencySymbol = aLocaleInfo.getCurrSymbol(); + bPrependCurrencySymbol = true; + break; + case 1: // 1$ + sCurrencySymbol = aLocaleInfo.getCurrSymbol(); + bPrependCurrencySymbol = false; + break; + case 2: // $ 1 + sCurrencySymbol = aLocaleInfo.getCurrSymbol() + " "; + bPrependCurrencySymbol = true; + break; + case 3: // 1 $ + sCurrencySymbol = " " + aLocaleInfo.getCurrSymbol(); + bPrependCurrencySymbol = false; + break; } - catch(const Exception&) + if (!sCurrencySymbol.isEmpty()) { - OSL_FAIL( "OCurrencyModel::implConstruct: caught an exception while initializing the aggregate!" ); + m_xAggregateSet->setPropertyValue(PROPERTY_CURRENCYSYMBOL, makeAny(sCurrencySymbol)); + m_xAggregateSet->setPropertyValue(PROPERTY_CURRSYM_POSITION, makeAny(bPrependCurrencySymbol)); } } + catch(const Exception&) + { + OSL_FAIL( "OCurrencyModel::implConstruct: caught an exception while initializing the aggregate!" ); + } } diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index b2b8f7e3eade..ca6681c40a23 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -2085,23 +2085,23 @@ static void lcl_dispatch(const Reference< XFrame >& xFrame,const Reference<XURLT FrameSearchFlag::SELF | FrameSearchFlag::PARENT | FrameSearchFlag::CHILDREN | FrameSearchFlag::SIBLINGS | FrameSearchFlag::CREATE | FrameSearchFlag::TASKS); - if (xDisp.is()) - { - Sequence<PropertyValue> aArgs(2); - aArgs.getArray()[0].Name = "Referer"; - aArgs.getArray()[0].Value <<= aReferer; + if (!xDisp.is()) + return; + + Sequence<PropertyValue> aArgs(2); + aArgs.getArray()[0].Name = "Referer"; + aArgs.getArray()[0].Value <<= aReferer; - // build a sequence from the to-be-submitted string - OString a8BitData(OUStringToOString(aData, _eEncoding)); - // always ANSI #58641 - Sequence< sal_Int8 > aPostData(reinterpret_cast<const sal_Int8*>(a8BitData.getStr()), a8BitData.getLength()); - Reference< XInputStream > xPostData = new SequenceInputStream(aPostData); + // build a sequence from the to-be-submitted string + OString a8BitData(OUStringToOString(aData, _eEncoding)); + // always ANSI #58641 + Sequence< sal_Int8 > aPostData(reinterpret_cast<const sal_Int8*>(a8BitData.getStr()), a8BitData.getLength()); + Reference< XInputStream > xPostData = new SequenceInputStream(aPostData); - aArgs.getArray()[1].Name = "PostData"; - aArgs.getArray()[1].Value <<= xPostData; + aArgs.getArray()[1].Name = "PostData"; + aArgs.getArray()[1].Value <<= xPostData; - xDisp->dispatch(aURL, aArgs); - } // if (xDisp.is()) + xDisp->dispatch(aURL, aArgs); } void ODatabaseForm::submit_impl(const Reference<XControl>& Control, const css::awt::MouseEvent& MouseEvt) @@ -2386,26 +2386,26 @@ void SAL_CALL ODatabaseForm::setControlModels(const Sequence<Reference<XControlM sal_Int32 nCount = getCount(); // HiddenControls and forms are not listed - if (rControls.getLength() <= nCount) + if (rControls.getLength() > nCount) + return; + + sal_Int16 nTabIndex = 1; + for (auto const& rControl : rControls) { - sal_Int16 nTabIndex = 1; - for (auto const& rControl : rControls) + Reference<XFormComponent> xComp(rControl, UNO_QUERY); + if (xComp.is()) { - Reference<XFormComponent> xComp(rControl, UNO_QUERY); - if (xComp.is()) + // Find component in the list + for (sal_Int32 j = 0; j < nCount; ++j) { - // Find component in the list - for (sal_Int32 j = 0; j < nCount; ++j) + Reference<XFormComponent> xElement( + getByIndex(j), css::uno::UNO_QUERY); + if (xComp == xElement) { - Reference<XFormComponent> xElement( - getByIndex(j), css::uno::UNO_QUERY); - if (xComp == xElement) - { - Reference<XPropertySet> xSet(xComp, UNO_QUERY); - if (xSet.is() && hasProperty(PROPERTY_TABINDEX, xSet)) - xSet->setPropertyValue( PROPERTY_TABINDEX, makeAny(nTabIndex++) ); - break; - } + Reference<XPropertySet> xSet(xComp, UNO_QUERY); + if (xSet.is() && hasProperty(PROPERTY_TABINDEX, xSet)) + xSet->setPropertyValue( PROPERTY_TABINDEX, makeAny(nTabIndex++) ); + break; } } } @@ -2689,30 +2689,30 @@ void ODatabaseForm::stopSharingConnection( ) { OSL_ENSURE( m_bSharingConnection, "ODatabaseForm::stopSharingConnection: invalid call!" ); - if ( m_bSharingConnection ) - { - // get the connection - Reference< XConnection > xSharedConn; - m_xAggregateSet->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xSharedConn; - OSL_ENSURE( xSharedConn.is(), "ODatabaseForm::stopSharingConnection: there's no conn!" ); + if ( !m_bSharingConnection ) + return; - // remove ourself as event listener - Reference< XComponent > xSharedConnComp( xSharedConn, UNO_QUERY ); - if ( xSharedConnComp.is() ) - xSharedConnComp->removeEventListener( static_cast< XLoadListener* >( this ) ); + // get the connection + Reference< XConnection > xSharedConn; + m_xAggregateSet->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xSharedConn; + OSL_ENSURE( xSharedConn.is(), "ODatabaseForm::stopSharingConnection: there's no conn!" ); - // no need to dispose the conn: we're not the owner, this is our parent - // (in addition, this method may be called if the connection is being disposed while we use it) + // remove ourself as event listener + Reference< XComponent > xSharedConnComp( xSharedConn, UNO_QUERY ); + if ( xSharedConnComp.is() ) + xSharedConnComp->removeEventListener( static_cast< XLoadListener* >( this ) ); - // reset the property - xSharedConn.clear(); - m_bForwardingConnection = true; - m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xSharedConn ) ); - m_bForwardingConnection = false; + // no need to dispose the conn: we're not the owner, this is our parent + // (in addition, this method may be called if the connection is being disposed while we use it) - // reset the flag - m_bSharingConnection = false; - } + // reset the property + xSharedConn.clear(); + m_bForwardingConnection = true; + m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xSharedConn ) ); + m_bForwardingConnection = false; + + // reset the flag + m_bSharingConnection = false; } namespace @@ -3492,35 +3492,35 @@ void SAL_CALL ODatabaseForm::cancelRowUpdates() void SAL_CALL ODatabaseForm::moveToInsertRow() { Reference<XResultSetUpdate> xUpdate; - if (query_aggregation( m_xAggregate, xUpdate)) - { - // _always_ move to the insert row - // - // Formerly, the following line was conditioned with a "not is new", means we did not move the aggregate - // to the insert row if it was already positioned there. - // - // This prevented the RowSet implementation from resetting its column values. We, ourself, formerly - // did this reset of columns in reset_impl, where we set every column to the ControlDefault, or, if this - // was not present, to NULL. However, the problem with setting to NULL was #88888#, the problem with - // _not_ setting to NULL (which was the original fix for #88888#) was #97955#. - // - // So now we - // * move our aggregate to the insert row - // * in reset_impl - // - set the control defaults into the columns if not void - // - do _not_ set the columns to NULL if no control default is set - // - // Still, there is #72756#. During fixing this bug, DG introduced not calling the aggregate here. So - // in theory, we re-introduced #72756#. But the bug described therein does not happen anymore, as the - // preliminaries for it changed (no display of guessed values for new records with autoinc fields) - // - // BTW: the public Issuezilla bug is #i2815# - // - xUpdate->moveToInsertRow(); - - // then set the default values and the parameters given from the parent - reset(); - } + if (!query_aggregation( m_xAggregate, xUpdate)) + return; + + // _always_ move to the insert row + // + // Formerly, the following line was conditioned with a "not is new", means we did not move the aggregate + // to the insert row if it was already positioned there. + // + // This prevented the RowSet implementation from resetting its column values. We, ourself, formerly + // did this reset of columns in reset_impl, where we set every column to the ControlDefault, or, if this + // was not present, to NULL. However, the problem with setting to NULL was #88888#, the problem with + // _not_ setting to NULL (which was the original fix for #88888#) was #97955#. + // + // So now we + // * move our aggregate to the insert row + // * in reset_impl + // - set the control defaults into the columns if not void + // - do _not_ set the columns to NULL if no control default is set + // + // Still, there is #72756#. During fixing this bug, DG introduced not calling the aggregate here. So + // in theory, we re-introduced #72756#. But the bug described therein does not happen anymore, as the + // preliminaries for it changed (no display of guessed values for new records with autoinc fields) + // + // BTW: the public Issuezilla bug is #i2815# + // + xUpdate->moveToInsertRow(); + + // then set the default values and the parameters given from the parent + reset(); } diff --git a/forms/source/component/Date.cxx b/forms/source/component/Date.cxx index 495c95deb8cf..cca3e06821d7 100644 --- a/forms/source/component/Date.cxx +++ b/forms/source/component/Date.cxx @@ -204,18 +204,18 @@ void ODateModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm ) { OBoundControlModel::onConnectedDbColumn( _rxForm ); Reference<XPropertySet> xField = getField(); - if (xField.is()) + if (!xField.is()) + return; + + m_bDateTimeField = false; + try + { + sal_Int32 nFieldType = 0; + xField->getPropertyValue(PROPERTY_FIELDTYPE) >>= nFieldType; + m_bDateTimeField = (nFieldType == DataType::TIMESTAMP); + } + catch(const Exception&) { - m_bDateTimeField = false; - try - { - sal_Int32 nFieldType = 0; - xField->getPropertyValue(PROPERTY_FIELDTYPE) >>= nFieldType; - m_bDateTimeField = (nFieldType == DataType::TIMESTAMP); - } - catch(const Exception&) - { - } } } diff --git a/forms/source/component/Edit.cxx b/forms/source/component/Edit.cxx index 688f846730fb..e1eefb02f396 100644 --- a/forms/source/component/Edit.cxx +++ b/forms/source/component/Edit.cxx @@ -556,31 +556,31 @@ sal_uInt16 OEditModel::getPersistenceFlags() const void OEditModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm ) { Reference< XPropertySet > xField = getField(); - if ( xField.is() ) + if ( !xField.is() ) + return; + + m_pValueFormatter.reset( new ::dbtools::FormattedColumnValue( getContext(), Reference< XRowSet >( _rxForm, UNO_QUERY ), xField ) ); + + if ( m_pValueFormatter->getKeyType() == NumberFormat::SCIENTIFIC ) + return; + + m_bMaxTextLenModified = getINT16(m_xAggregateSet->getPropertyValue(PROPERTY_MAXTEXTLEN)) != 0; + if ( !m_bMaxTextLenModified ) { - m_pValueFormatter.reset( new ::dbtools::FormattedColumnValue( getContext(), Reference< XRowSet >( _rxForm, UNO_QUERY ), xField ) ); + sal_Int32 nFieldLen = 0; + xField->getPropertyValue("Precision") >>= nFieldLen; - if ( m_pValueFormatter->getKeyType() != NumberFormat::SCIENTIFIC ) + if (nFieldLen > 0 && nFieldLen <= SAL_MAX_INT16) { - m_bMaxTextLenModified = getINT16(m_xAggregateSet->getPropertyValue(PROPERTY_MAXTEXTLEN)) != 0; - if ( !m_bMaxTextLenModified ) - { - sal_Int32 nFieldLen = 0; - xField->getPropertyValue("Precision") >>= nFieldLen; + Any aVal; + aVal <<= static_cast<sal_Int16>(nFieldLen); + m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, aVal); - if (nFieldLen > 0 && nFieldLen <= SAL_MAX_INT16) - { - Any aVal; - aVal <<= static_cast<sal_Int16>(nFieldLen); - m_xAggregateSet->setPropertyValue(PROPERTY_MAXTEXTLEN, aVal); - - m_bMaxTextLenModified = true; - } - } - else - m_bMaxTextLenModified = false; // to get sure that the text len won't be set in unloaded + m_bMaxTextLenModified = true; } } + else + m_bMaxTextLenModified = false; // to get sure that the text len won't be set in unloaded } diff --git a/forms/source/component/EventThread.cxx b/forms/source/component/EventThread.cxx index 357888111991..0b38e33f7a4d 100644 --- a/forms/source/component/EventThread.cxx +++ b/forms/source/component/EventThread.cxx @@ -76,25 +76,25 @@ void OComponentEventThread::impl_clearEventQueue() void OComponentEventThread::disposing( const EventObject& evt ) { - if( evt.Source == static_cast<XWeak*>(m_xComp.get()) ) - { - ::osl::MutexGuard aGuard( m_aMutex ); + if( evt.Source != static_cast<XWeak*>(m_xComp.get()) ) + return; + + ::osl::MutexGuard aGuard( m_aMutex ); - // Remove EventListener - Reference<XEventListener> xEvtLstnr = static_cast<XEventListener*>(this); - m_xComp->removeEventListener( xEvtLstnr ); + // Remove EventListener + Reference<XEventListener> xEvtLstnr = static_cast<XEventListener*>(this); + m_xComp->removeEventListener( xEvtLstnr ); - // Clear EventQueue - impl_clearEventQueue(); + // Clear EventQueue + impl_clearEventQueue(); - // Free the Control and set pCompImpl to 0, - // so that the thread knows, that it should terminate. - m_xComp.clear(); + // Free the Control and set pCompImpl to 0, + // so that the thread knows, that it should terminate. + m_xComp.clear(); - // Wake up the thread and terminate - m_aCond.set(); - terminate(); - } + // Wake up the thread and terminate + m_aCond.set(); + terminate(); } void OComponentEventThread::addEvent( std::unique_ptr<EventObject> _pEvt ) diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index 669bf071a06c..450ef822b632 100644 --- a/forms/source/component/FormComponent.cxx +++ b/forms/source/component/FormComponent.cxx @@ -503,32 +503,32 @@ OControlModel::OControlModel( // the native look is ugly... // #i37342# { - if (!_rUnoControlModelTypeName.isEmpty()) // the is a model we have to aggregate + if (_rUnoControlModelTypeName.isEmpty()) // the is a model we have to aggregate + return; + + osl_atomic_increment(&m_refCount); { - osl_atomic_increment(&m_refCount); - { - m_xAggregate.set(m_xContext->getServiceManager()->createInstanceWithContext(_rUnoControlModelTypeName, m_xContext), UNO_QUERY); - setAggregation(m_xAggregate); + m_xAggregate.set(m_xContext->getServiceManager()->createInstanceWithContext(_rUnoControlModelTypeName, m_xContext), UNO_QUERY); + setAggregation(m_xAggregate); - if ( m_xAggregateSet.is() ) + if ( m_xAggregateSet.is() ) + { + try + { + if ( !rDefault.isEmpty() ) + m_xAggregateSet->setPropertyValue( PROPERTY_DEFAULTCONTROL, makeAny( rDefault ) ); + } + catch( const Exception& ) { - try - { - if ( !rDefault.isEmpty() ) - m_xAggregateSet->setPropertyValue( PROPERTY_DEFAULTCONTROL, makeAny( rDefault ) ); - } - catch( const Exception& ) - { - TOOLS_WARN_EXCEPTION("forms.component", "OControlModel::OControlModel"); - } + TOOLS_WARN_EXCEPTION("forms.component", "OControlModel::OControlModel"); } } - if (_bSetDelegator) - doSetDelegator(); - - // Refcount is at NULL again - osl_atomic_decrement(&m_refCount); } + if (_bSetDelegator) + doSetDelegator(); + + // Refcount is at NULL again + osl_atomic_decrement(&m_refCount); } OControlModel::OControlModel( const OControlModel* _pOriginal, const Reference< XComponentContext>& _rxFactory, const bool _bCloneAggregate, const bool _bSetDelegator ) @@ -552,25 +552,25 @@ OControlModel::OControlModel( const OControlModel* _pOriginal, const Reference< m_nControlTypeinMSO = _pOriginal->m_nControlTypeinMSO; m_nObjIDinMSO = _pOriginal->m_nObjIDinMSO; - if ( _bCloneAggregate ) + if ( !_bCloneAggregate ) + return; + + // temporarily increment refcount because of temporary references to ourself in the following + osl_atomic_increment( &m_refCount ); { - // temporarily increment refcount because of temporary references to ourself in the following - osl_atomic_increment( &m_refCount ); - { - // transfer the (only, at the very moment!) ref count - m_xAggregate = createAggregateClone( _pOriginal ); + // transfer the (only, at the very moment!) ref count + m_xAggregate = createAggregateClone( _pOriginal ); - // set aggregation (retrieve other direct interfaces of the aggregate) - setAggregation( m_xAggregate ); - } + // set aggregation (retrieve other direct interfaces of the aggregate) + setAggregation( m_xAggregate ); + } - // set the delegator, if allowed by our derived class - if ( _bSetDelegator ) - doSetDelegator(); + // set the delegator, if allowed by our derived class + if ( _bSetDelegator ) + doSetDelegator(); - // decrement ref count - osl_atomic_decrement( &m_refCount ); - } + // decrement ref count + osl_atomic_decrement( &m_refCount ); } OControlModel::~OControlModel() @@ -1224,18 +1224,17 @@ void OBoundControlModel::clonedFrom( const OControlModel* _pOriginal ) const OBoundControlModel* pBoundOriginal = static_cast< const OBoundControlModel* >( _pOriginal ); // the value binding can be handled as if somebody called setValueBinding here // By definition, bindings can be share between bindables - if ( pBoundOriginal && pBoundOriginal->m_xExternalBinding.is() ) - { - try - { - setValueBinding( pBoundOriginal->m_xExternalBinding ); - } + if ( !(pBoundOriginal && pBoundOriginal->m_xExternalBinding.is()) ) + return; - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("forms.component"); - } + try + { + setValueBinding( pBoundOriginal->m_xExternalBinding ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("forms.component"); } } @@ -1907,94 +1906,93 @@ void OBoundControlModel::connectToField(const Reference<XRowSet>& rForm) { OSL_PRECOND( !hasExternalValueBinding(), "OBoundControlModel::connectToField: invalid call (have an external binding)!" ); // if there's a connection to the database - if (rForm.is() && getConnection(rForm).is()) + if (!(rForm.is() && getConnection(rForm).is())) + return; + + // determine field and PropertyChangeListener + m_xCursor = rForm; + Reference<XPropertySet> xFieldCandidate; + if (m_xCursor.is()) { - // determine field and PropertyChangeListener - m_xCursor = rForm; - Reference<XPropertySet> xFieldCandidate; - if (m_xCursor.is()) + Reference<XColumnsSupplier> xColumnsSupplier(m_xCursor, UNO_QUERY); + DBG_ASSERT(xColumnsSupplier.is(), "OBoundControlModel::connectToField : the row set should support the css::sdb::ResultSet service !"); + if (xColumnsSupplier.is()) { - Reference<XColumnsSupplier> xColumnsSupplier(m_xCursor, UNO_QUERY); - DBG_ASSERT(xColumnsSupplier.is(), "OBoundControlModel::connectToField : the row set should support the css::sdb::ResultSet service !"); - if (xColumnsSupplier.is()) + Reference<XNameAccess> xColumns = xColumnsSupplier->getColumns(); + if (xColumns.is() && xColumns->hasByName(m_aControlSource)) { - Reference<XNameAccess> xColumns = xColumnsSupplier->getColumns(); - if (xColumns.is() && xColumns->hasByName(m_aControlSource)) - { - OSL_VERIFY( xColumns->getByName(m_aControlSource) >>= xFieldCandidate ); - } - + OSL_VERIFY( xColumns->getByName(m_aControlSource) >>= xFieldCandidate ); } } - try + } + + try + { + sal_Int32 nFieldType = DataType::OTHER; + if ( xFieldCandidate.is() ) { - sal_Int32 nFieldType = DataType::OTHER; - if ( xFieldCandidate.is() ) + xFieldCandidate->getPropertyValue( PROPERTY_FIELDTYPE ) >>= nFieldType; + if ( approveDbColumnType( nFieldType ) ) + impl_setField_noNotify( xFieldCandidate ); + } + + else + impl_setField_noNotify( nullptr ); + if ( m_xField.is() ) + { + if ( m_xField->getPropertySetInfo()->hasPropertyByName( PROPERTY_VALUE ) ) { - xFieldCandidate->getPropertyValue( PROPERTY_FIELDTYPE ) >>= nFieldType; - if ( approveDbColumnType( nFieldType ) ) - impl_setField_noNotify( xFieldCandidate ); + m_nFieldType = nFieldType; + // listen to changing values + m_xField->addPropertyChangeListener( PROPERTY_VALUE, this ); + m_xColumnUpdate.set( m_xField, UNO_QUERY ); + m_xColumn.set( m_xField, UNO_QUERY ); + sal_Int32 nNullableFlag = ColumnValue::NO_NULLS; + m_xField->getPropertyValue(PROPERTY_ISNULLABLE) >>= nNullableFlag; + m_bRequired = (ColumnValue::NO_NULLS == nNullableFlag); + // we're optimistic: in case of ColumnValue_NULLABLE_UNKNOWN we assume nullability... } - else - impl_setField_noNotify( nullptr ); - if ( m_xField.is() ) { - if ( m_xField->getPropertySetInfo()->hasPropertyByName( PROPERTY_VALUE ) ) - { - m_nFieldType = nFieldType; - // listen to changing values - m_xField->addPropertyChangeListener( PROPERTY_VALUE, this ); - m_xColumnUpdate.set( m_xField, UNO_QUERY ); - m_xColumn.set( m_xField, UNO_QUERY ); - sal_Int32 nNullableFlag = ColumnValue::NO_NULLS; - m_xField->getPropertyValue(PROPERTY_ISNULLABLE) >>= nNullableFlag; - m_bRequired = (ColumnValue::NO_NULLS == nNullableFlag); - // we're optimistic: in case of ColumnValue_NULLABLE_UNKNOWN we assume nullability... - } - else - { - SAL_WARN("forms.component", "OBoundControlModel::connectToField: property " PROPERTY_VALUE " not supported!"); - impl_setField_noNotify( nullptr ); - } - + SAL_WARN("forms.component", "OBoundControlModel::connectToField: property " PROPERTY_VALUE " not supported!"); + impl_setField_noNotify( nullptr ); } } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("forms.component"); - resetField(); - } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("forms.component"); + resetField(); } } void OBoundControlModel::initFromField( const Reference< XRowSet >& _rxRowSet ) { // but only if the rowset is positioned on a valid record - if ( hasField() && _rxRowSet.is() ) + if ( !(hasField() && _rxRowSet.is()) ) + return; + + bool shouldTransfer(!_rxRowSet->isBeforeFirst() && !_rxRowSet->isAfterLast()); + if (!shouldTransfer) { - bool shouldTransfer(!_rxRowSet->isBeforeFirst() && !_rxRowSet->isAfterLast()); - if (!shouldTransfer) + const Reference< XPropertySet > xPS(_rxRowSet, UNO_QUERY); + if (xPS.is()) { - const Reference< XPropertySet > xPS(_rxRowSet, UNO_QUERY); - if (xPS.is()) - { - assert(!shouldTransfer); - xPS->getPropertyValue("IsNew") >>= shouldTransfer; - } + assert(!shouldTransfer); + xPS->getPropertyValue("IsNew") >>= shouldTransfer; } - if ( shouldTransfer ) - transferDbValueToControl(); - else - // reset the field if the row set is empty - // #i30661# - resetNoBroadcast(); } + if ( shouldTransfer ) + transferDbValueToControl(); + else + // reset the field if the row set is empty + // #i30661# + resetNoBroadcast(); } bool OBoundControlModel::approveDbColumnType(sal_Int32 _nColumnType) @@ -2422,20 +2420,19 @@ void OBoundControlModel::connectExternalValueBinding( transferExternalValueToControl( _rInstanceLock ); // if the binding is also a validator, use it, too. This is a constraint of the // com.sun.star.form.binding.ValidatableBindableFormComponent service - if ( m_bSupportsValidation ) - { - try - { - Reference< XValidator > xAsValidator( _rxBinding, UNO_QUERY ); - if ( xAsValidator.is() ) - setValidator( xAsValidator ); - } + if ( !m_bSupportsValidation ) + return; - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("forms.component"); - } + try + { + Reference< XValidator > xAsValidator( _rxBinding, UNO_QUERY ); + if ( xAsValidator.is() ) + setValidator( xAsValidator ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("forms.component"); } } @@ -2556,26 +2553,26 @@ void OBoundControlModel::transferControlValueToExternal( ControlModelLock& _rIns { OSL_PRECOND( m_bSupportsExternalBinding && hasExternalValueBinding(), "OBoundControlModel::transferControlValueToExternal: precondition not met!" ); - if ( m_xExternalBinding.is() ) - { - Any aExternalValue( translateControlValueToExternalValue() ); - m_bTransferingValue = true; - _rInstanceLock.release(); - // UNSAFE > - try - { - m_xExternalBinding->setValue( aExternalValue ); - } + if ( !m_xExternalBinding.is() ) + return; - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("forms.component"); - } + Any aExternalValue( translateControlValueToExternalValue() ); + m_bTransferingValue = true; + _rInstanceLock.release(); + // UNSAFE > + try + { + m_xExternalBinding->setValue( aExternalValue ); + } - // < UNSAFE - _rInstanceLock.acquire(); - m_bTransferingValue = false; + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("forms.component"); } + + // < UNSAFE + _rInstanceLock.acquire(); + m_bTransferingValue = false; } Sequence< Type > OBoundControlModel::getSupportedBindingTypes() diff --git a/forms/source/component/FormattedField.cxx b/forms/source/component/FormattedField.cxx index 54aa650cb8fc..18cb21882d6a 100644 --- a/forms/source/component/FormattedField.cxx +++ b/forms/source/component/FormattedField.cxx @@ -411,43 +411,43 @@ void OFormattedModel::_propertyChanged( const css::beans::PropertyChangeEvent& e { // TODO: check how this works with external bindings OSL_ENSURE( evt.Source == m_xAggregateSet, "OFormattedModel::_propertyChanged: where did this come from?" ); - if ( evt.Source == m_xAggregateSet ) + if ( evt.Source != m_xAggregateSet ) + return; + + if ( evt.PropertyName == PROPERTY_FORMATKEY ) { - if ( evt.PropertyName == PROPERTY_FORMATKEY ) + if ( evt.NewValue.getValueType().getTypeClass() == TypeClass_LONG ) { - if ( evt.NewValue.getValueType().getTypeClass() == TypeClass_LONG ) + try { - try + ::osl::MutexGuard aGuard( m_aMutex ); + Reference<XNumberFormatsSupplier> xSupplier( calcFormatsSupplier() ); + m_nKeyType = getNumberFormatType(xSupplier->getNumberFormats(), getINT32( evt.NewValue ) ); + // as m_aSaveValue (which is used by commitControlValueToDbColumn) is format dependent we have + // to recalc it, which is done by translateDbColumnToControlValue + if ( m_xColumn.is() && m_xAggregateFastSet.is() && !m_xCursor->isBeforeFirst() && !m_xCursor->isAfterLast()) { - ::osl::MutexGuard aGuard( m_aMutex ); - Reference<XNumberFormatsSupplier> xSupplier( calcFormatsSupplier() ); - m_nKeyType = getNumberFormatType(xSupplier->getNumberFormats(), getINT32( evt.NewValue ) ); - // as m_aSaveValue (which is used by commitControlValueToDbColumn) is format dependent we have - // to recalc it, which is done by translateDbColumnToControlValue - if ( m_xColumn.is() && m_xAggregateFastSet.is() && !m_xCursor->isBeforeFirst() && !m_xCursor->isAfterLast()) - { - setControlValue( translateDbColumnToControlValue(), eOther ); - } - // if we're connected to an external value binding, then re-calculate the type - // used to exchange the value - it depends on the format, too - if ( hasExternalValueBinding() ) - { - calculateExternalValueType(); - } + setControlValue( translateDbColumnToControlValue(), eOther ); } - catch(const Exception&) + // if we're connected to an external value binding, then re-calculate the type + // used to exchange the value - it depends on the format, too + if ( hasExternalValueBinding() ) { + calculateExternalValueType(); } } - return; - } - if ( evt.PropertyName == PROPERTY_FORMATSSUPPLIER ) - { - updateFormatterNullDate(); - return; + catch(const Exception&) + { + } } - OBoundControlModel::_propertyChanged( evt ); + return; + } + if ( evt.PropertyName == PROPERTY_FORMATSSUPPLIER ) + { + updateFormatterNullDate(); + return; } + OBoundControlModel::_propertyChanged( evt ); } void OFormattedModel::updateFormatterNullDate() diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx index af19376db1cc..9080ecedf13a 100644 --- a/forms/source/component/ImageControl.cxx +++ b/forms/source/component/ImageControl.cxx @@ -740,23 +740,23 @@ void SAL_CALL OImageControlControl::disposing( const EventObject& Event ) void OImageControlControl::implClearGraphics( bool _bForce ) { Reference< XPropertySet > xSet( getModel(), UNO_QUERY ); - if ( xSet.is() ) + if ( !xSet.is() ) + return; + + if ( _bForce ) { - if ( _bForce ) - { - OUString sOldImageURL; - xSet->getPropertyValue( PROPERTY_IMAGE_URL ) >>= sOldImageURL; - - if ( sOldImageURL.isEmpty() ) - // the ImageURL is already empty, so simply setting a new empty one would not suffice - // (since it would be ignored) - xSet->setPropertyValue( PROPERTY_IMAGE_URL, makeAny( OUString( "private:emptyImage" ) ) ); - // (the concrete URL we're passing here doesn't matter. It's important that - // the model cannot resolve it to a valid resource describing an image stream - } + OUString sOldImageURL; + xSet->getPropertyValue( PROPERTY_IMAGE_URL ) >>= sOldImageURL; - xSet->setPropertyValue( PROPERTY_IMAGE_URL, makeAny( OUString() ) ); + if ( sOldImageURL.isEmpty() ) + // the ImageURL is already empty, so simply setting a new empty one would not suffice + // (since it would be ignored) + xSet->setPropertyValue( PROPERTY_IMAGE_URL, makeAny( OUString( "private:emptyImage" ) ) ); + // (the concrete URL we're passing here doesn't matter. It's important that + // the model cannot resolve it to a valid resource describing an image stream } + + xSet->setPropertyValue( PROPERTY_IMAGE_URL, makeAny( OUString() ) ); } diff --git a/forms/source/component/RadioButton.cxx b/forms/source/component/RadioButton.cxx index fffd230fbed8..d066e26a6e7e 100644 --- a/forms/source/component/RadioButton.cxx +++ b/forms/source/component/RadioButton.cxx @@ -123,32 +123,32 @@ void ORadioButtonModel::SetSiblingPropsTo(const OUString& rPropName, const Any& // Iterate over my siblings Reference<XIndexAccess> xIndexAccess(getParent(), UNO_QUERY); - if (xIndexAccess.is()) + if (!xIndexAccess.is()) + return; + + Reference<XPropertySet> xMyProps = this; + OUString sCurrentGroup; + sal_Int32 nNumSiblings = xIndexAccess->getCount(); + for (sal_Int32 i=0; i<nNumSiblings; ++i) { - Reference<XPropertySet> xMyProps = this; - OUString sCurrentGroup; - sal_Int32 nNumSiblings = xIndexAccess->getCount(); - for (sal_Int32 i=0; i<nNumSiblings; ++i) - { - Reference<XPropertySet> xSiblingProperties(xIndexAccess->getByIndex(i), UNO_QUERY); - if (!xSiblingProperties.is()) - continue; - if (xMyProps == xSiblingProperties) - continue; // do not set myself - - // Only if it's a RadioButton - if (!hasProperty(PROPERTY_CLASSID, xSiblingProperties)) - continue; - sal_Int16 nType = 0; - xSiblingProperties->getPropertyValue(PROPERTY_CLASSID) >>= nType; - if (nType != FormComponentType::RADIOBUTTON) - continue; - - // The group association is attached to the name - sCurrentGroup = OGroupManager::GetGroupName( xSiblingProperties ); - if (sCurrentGroup == sMyGroup) - xSiblingProperties->setPropertyValue(rPropName, rValue); - } + Reference<XPropertySet> xSiblingProperties(xIndexAccess->getByIndex(i), UNO_QUERY); + if (!xSiblingProperties.is()) + continue; + if (xMyProps == xSiblingProperties) + continue; // do not set myself + + // Only if it's a RadioButton + if (!hasProperty(PROPERTY_CLASSID, xSiblingProperties)) + continue; + sal_Int16 nType = 0; + xSiblingProperties->getPropertyValue(PROPERTY_CLASSID) >>= nType; + if (nType != FormComponentType::RADIOBUTTON) + continue; + + // The group association is attached to the name + sCurrentGroup = OGroupManager::GetGroupName( xSiblingProperties ); + if (sCurrentGroup == sMyGroup) + xSiblingProperties->setPropertyValue(rPropName, rValue); } } @@ -175,62 +175,62 @@ void ORadioButtonModel::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, cons setControlSource(); } - if (nHandle == PROPERTY_ID_DEFAULT_STATE) - { - sal_Int16 nValue; - rValue >>= nValue; - if (1 == nValue) - { // Reset the 'default checked' for all Radios of the same group. - // Because (as the Highlander already knew): "There can be only one" - Any aZero; - nValue = 0; - aZero <<= nValue; - SetSiblingPropsTo(PROPERTY_DEFAULT_STATE, aZero); - } + if (nHandle != PROPERTY_ID_DEFAULT_STATE) + return; + + sal_Int16 nValue; + rValue >>= nValue; + if (1 == nValue) + { // Reset the 'default checked' for all Radios of the same group. + // Because (as the Highlander already knew): "There can be only one" + Any aZero; + nValue = 0; + aZero <<= nValue; + SetSiblingPropsTo(PROPERTY_DEFAULT_STATE, aZero); } } void ORadioButtonModel::setControlSource() { Reference<XIndexAccess> xIndexAccess(getParent(), UNO_QUERY); - if (xIndexAccess.is()) - { - OUString sName, sGroupName; + if (!xIndexAccess.is()) + return; - if (hasProperty(PROPERTY_GROUP_NAME, this)) - getPropertyValue(PROPERTY_GROUP_NAME) >>= sGroupName; - getPropertyValue(PROPERTY_NAME) >>= sName; + OUString sName, sGroupName; - Reference<XPropertySet> xMyProps = this; - for (sal_Int32 i=0; i<xIndexAccess->getCount(); ++i) + if (hasProperty(PROPERTY_GROUP_NAME, this)) + getPropertyValue(PROPERTY_GROUP_NAME) >>= sGroupName; + getPropertyValue(PROPERTY_NAME) >>= sName; + + Reference<XPropertySet> xMyProps = this; + for (sal_Int32 i=0; i<xIndexAccess->getCount(); ++i) + { + Reference<XPropertySet> xSiblingProperties(xIndexAccess->getByIndex(i), UNO_QUERY); + if (!xSiblingProperties.is()) + continue; + + if (xMyProps == xSiblingProperties) + // Only if I didn't find myself + continue; + + sal_Int16 nType = 0; + xSiblingProperties->getPropertyValue(PROPERTY_CLASSID) >>= nType; + if (nType != FormComponentType::RADIOBUTTON) + // Only RadioButtons + continue; + + OUString sSiblingName, sSiblingGroupName; + if (hasProperty(PROPERTY_GROUP_NAME, xSiblingProperties)) + xSiblingProperties->getPropertyValue(PROPERTY_GROUP_NAME) >>= sSiblingGroupName; + xSiblingProperties->getPropertyValue(PROPERTY_NAME) >>= sSiblingName; + + if ((sGroupName.isEmpty() && sSiblingGroupName.isEmpty() && // (no group name + sName == sSiblingName) || // names match) or + (!sGroupName.isEmpty() && !sSiblingGroupName.isEmpty() && // (have group name + sGroupName == sSiblingGroupName)) // they match) { - Reference<XPropertySet> xSiblingProperties(xIndexAccess->getByIndex(i), UNO_QUERY); - if (!xSiblingProperties.is()) - continue; - - if (xMyProps == xSiblingProperties) - // Only if I didn't find myself - continue; - - sal_Int16 nType = 0; - xSiblingProperties->getPropertyValue(PROPERTY_CLASSID) >>= nType; - if (nType != FormComponentType::RADIOBUTTON) - // Only RadioButtons - continue; - - OUString sSiblingName, sSiblingGroupName; - if (hasProperty(PROPERTY_GROUP_NAME, xSiblingProperties)) - xSiblingProperties->getPropertyValue(PROPERTY_GROUP_NAME) >>= sSiblingGroupName; - xSiblingProperties->getPropertyValue(PROPERTY_NAME) >>= sSiblingName; - - if ((sGroupName.isEmpty() && sSiblingGroupName.isEmpty() && // (no group name - sName == sSiblingName) || // names match) or - (!sGroupName.isEmpty() && !sSiblingGroupName.isEmpty() && // (have group name - sGroupName == sSiblingGroupName)) // they match) - { - setPropertyValue(PROPERTY_CONTROLSOURCE, xSiblingProperties->getPropertyValue(PROPERTY_CONTROLSOURCE)); - break; - } + setPropertyValue(PROPERTY_CONTROLSOURCE, xSiblingProperties->getPropertyValue(PROPERTY_CONTROLSOURCE)); + break; } } } diff --git a/forms/source/component/Time.cxx b/forms/source/component/Time.cxx index 3a6dbfca3b32..8ab3e9a10390 100644 --- a/forms/source/component/Time.cxx +++ b/forms/source/component/Time.cxx @@ -196,18 +196,18 @@ void OTimeModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm ) { OBoundControlModel::onConnectedDbColumn( _rxForm ); Reference<XPropertySet> xField = getField(); - if (xField.is()) + if (!xField.is()) + return; + + m_bDateTimeField = false; + try + { + sal_Int32 nFieldType = 0; + xField->getPropertyValue(PROPERTY_FIELDTYPE) >>= nFieldType; + m_bDateTimeField = (nFieldType == DataType::TIMESTAMP); + } + catch(const Exception&) { - m_bDateTimeField = false; - try - { - sal_Int32 nFieldType = 0; - xField->getPropertyValue(PROPERTY_FIELDTYPE) >>= nFieldType; - m_bDateTimeField = (nFieldType == DataType::TIMESTAMP); - } - catch(const Exception&) - { - } } } diff --git a/forms/source/component/entrylisthelper.cxx b/forms/source/component/entrylisthelper.cxx index a9c844e9a1e4..ef27610006d2 100644 --- a/forms/source/component/entrylisthelper.cxx +++ b/forms/source/component/entrylisthelper.cxx @@ -131,35 +131,35 @@ namespace frm OSL_ENSURE( ( _rEvent.Position > 0 ) && ( _rEvent.Count > 0 ) && ( _rEvent.Position + _rEvent.Count <= static_cast<sal_Int32>(m_aStringItems.size()) ), "OEntryListHelper::entryRangeRemoved: invalid count and/or position!" ); - if ( ( _rEvent.Position > 0 ) + if ( !(( _rEvent.Position > 0 ) && ( _rEvent.Count > 0 ) - && ( _rEvent.Position + _rEvent.Count <= static_cast<sal_Int32>(m_aStringItems.size()) ) + && ( _rEvent.Position + _rEvent.Count <= static_cast<sal_Int32>(m_aStringItems.size()) )) ) + return; + + m_aStringItems.erase(m_aStringItems.begin() + _rEvent.Position, + m_aStringItems.begin() + _rEvent.Position + _rEvent.Count ); + if (_rEvent.Position + _rEvent.Count <= m_aTypedItems.getLength()) { - m_aStringItems.erase(m_aStringItems.begin() + _rEvent.Position, - m_aStringItems.begin() + _rEvent.Position + _rEvent.Count ); - if (_rEvent.Position + _rEvent.Count <= m_aTypedItems.getLength()) + Sequence<Any> aTmp( m_aTypedItems.getLength() - _rEvent.Count ); + sal_Int32 nStop = _rEvent.Position; + sal_Int32 i = 0; + for ( ; i < nStop; ++i) { - Sequence<Any> aTmp( m_aTypedItems.getLength() - _rEvent.Count ); - sal_Int32 nStop = _rEvent.Position; - sal_Int32 i = 0; - for ( ; i < nStop; ++i) - { - aTmp[i] = m_aTypedItems[i]; - } - nStop = aTmp.getLength(); - for (sal_Int32 j = _rEvent.Position + _rEvent.Count; i < nStop; ++i, ++j) - { - aTmp[i] = m_aTypedItems[j]; - } - m_aTypedItems = aTmp; + aTmp[i] = m_aTypedItems[i]; } - else if (m_aTypedItems.hasElements()) + nStop = aTmp.getLength(); + for (sal_Int32 j = _rEvent.Position + _rEvent.Count; i < nStop; ++i, ++j) { - m_aTypedItems = Sequence<Any>(); // doesn't match anymore + aTmp[i] = m_aTypedItems[j]; } - stringItemListChanged( aLock ); + m_aTypedItems = aTmp; + } + else if (m_aTypedItems.hasElements()) + { + m_aTypedItems = Sequence<Any>(); // doesn't match anymore } + stringItemListChanged( aLock ); } diff --git a/forms/source/component/imgprod.cxx b/forms/source/component/imgprod.cxx index 930fa60c26df..a7435f2b654e 100644 --- a/forms/source/component/imgprod.cxx +++ b/forms/source/component/imgprod.cxx @@ -62,26 +62,26 @@ ImgProdLockBytes::ImgProdLockBytes( SvStream* pStm, bool bOwner ) : ImgProdLockBytes::ImgProdLockBytes( css::uno::Reference< css::io::XInputStream > const & rStmRef ) : xStmRef( rStmRef ) { - if( xStmRef.is() ) - { - const sal_uInt32 nBytesToRead = 65535; - sal_uInt32 nRead; + if( !xStmRef.is() ) + return; - do - { - css::uno::Sequence< sal_Int8 > aReadSeq; + const sal_uInt32 nBytesToRead = 65535; + sal_uInt32 nRead; - nRead = xStmRef->readSomeBytes( aReadSeq, nBytesToRead ); + do + { + css::uno::Sequence< sal_Int8 > aReadSeq; - if( nRead ) - { - const sal_uInt32 nOldLength = maSeq.getLength(); - maSeq.realloc( nOldLength + nRead ); - memcpy( maSeq.getArray() + nOldLength, aReadSeq.getConstArray(), aReadSeq.getLength() ); - } + nRead = xStmRef->readSomeBytes( aReadSeq, nBytesToRead ); + + if( nRead ) + { + const sal_uInt32 nOldLength = maSeq.getLength(); + maSeq.realloc( nOldLength + nRead ); + memcpy( maSeq.getArray() + nOldLength, aReadSeq.getConstArray(), aReadSeq.getLength() ); } - while( nBytesToRead == nRead ); } + while( nBytesToRead == nRead ); } ErrCode ImgProdLockBytes::ReadAt(sal_uInt64 const nPos, @@ -248,45 +248,45 @@ void ImageProducer::NewDataAvailable() void ImageProducer::startProduction() { - if( !maConsList.empty() || maDoneHdl.IsSet() ) - { - bool bNotifyEmptyGraphics = false; + if( !(!maConsList.empty() || maDoneHdl.IsSet()) ) + return; - // valid stream or filled graphic? => update consumers - if( mpStm || ( mpGraphic->GetType() != GraphicType::NONE ) ) - { - // if we already have a graphic, we don't have to import again; - // graphic is cleared if a new Stream is set - if( ( mpGraphic->GetType() == GraphicType::NONE ) || mpGraphic->GetReaderContext() ) - { - if ( ImplImportGraphic( *mpGraphic ) ) - maDoneHdl.Call( mpGraphic.get() ); - } + bool bNotifyEmptyGraphics = false; - if( mpGraphic->GetType() != GraphicType::NONE ) - ImplUpdateData( *mpGraphic ); - else - bNotifyEmptyGraphics = true; + // valid stream or filled graphic? => update consumers + if( mpStm || ( mpGraphic->GetType() != GraphicType::NONE ) ) + { + // if we already have a graphic, we don't have to import again; + // graphic is cleared if a new Stream is set + if( ( mpGraphic->GetType() == GraphicType::NONE ) || mpGraphic->GetReaderContext() ) + { + if ( ImplImportGraphic( *mpGraphic ) ) + maDoneHdl.Call( mpGraphic.get() ); } + + if( mpGraphic->GetType() != GraphicType::NONE ) + ImplUpdateData( *mpGraphic ); else bNotifyEmptyGraphics = true; + } + else + bNotifyEmptyGraphics = true; - if ( bNotifyEmptyGraphics ) - { - // reset image - // create temporary list to hold interfaces - ConsumerList_t aTmp = maConsList; + if ( !bNotifyEmptyGraphics ) + return; - // iterate through interfaces - for (auto const& elem : aTmp) - { - elem->init( 0, 0 ); - elem->complete( css::awt::ImageStatus::IMAGESTATUS_STATICIMAGEDONE, this ); - } + // reset image + // create temporary list to hold interfaces + ConsumerList_t aTmp = maConsList; - maDoneHdl.Call( nullptr ); - } + // iterate through interfaces + for (auto const& elem : aTmp) + { + elem->init( 0, 0 ); + elem->complete( css::awt::ImageStatus::IMAGESTATUS_STATICIMAGEDONE, this ); } + + maDoneHdl.Call( nullptr ); } @@ -360,99 +360,72 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic ) Bitmap aBmp( aBmpEx.GetBitmap() ); BitmapReadAccess* pBmpAcc = aBmp.AcquireReadAccess(); - if( pBmpAcc ) + if( !pBmpAcc ) + return; + + Bitmap aMask( aBmpEx.GetMask() ); + BitmapReadAccess* pMskAcc = !!aMask ? aMask.AcquireReadAccess() : nullptr; + const long nWidth = pBmpAcc->Width(); + const long nHeight = pBmpAcc->Height(); + const long nStartX = 0; + const long nEndX = nWidth - 1; + const long nStartY = 0; + const long nEndY = nHeight - 1; + const long nPartWidth = nEndX - nStartX + 1; + const long nPartHeight = nEndY - nStartY + 1; + + if( !pMskAcc ) { - Bitmap aMask( aBmpEx.GetMask() ); - BitmapReadAccess* pMskAcc = !!aMask ? aMask.AcquireReadAccess() : nullptr; - const long nWidth = pBmpAcc->Width(); - const long nHeight = pBmpAcc->Height(); - const long nStartX = 0; - const long nEndX = nWidth - 1; - const long nStartY = 0; - const long nEndY = nHeight - 1; - const long nPartWidth = nEndX - nStartX + 1; - const long nPartHeight = nEndY - nStartY + 1; - - if( !pMskAcc ) - { - aMask = Bitmap( aBmp.GetSizePixel(), 1 ); - aMask.Erase( COL_BLACK ); - pMskAcc = aMask.AcquireReadAccess(); - } + aMask = Bitmap( aBmp.GetSizePixel(), 1 ); + aMask.Erase( COL_BLACK ); + pMskAcc = aMask.AcquireReadAccess(); + } - // create temporary list to hold interfaces - ConsumerList_t aTmp = maConsList; + // create temporary list to hold interfaces + ConsumerList_t aTmp = maConsList; + + if( pBmpAcc->HasPalette() ) + { + const BitmapColor aWhite( pMskAcc->GetBestMatchingColor( COL_WHITE ) ); - if( pBmpAcc->HasPalette() ) + if( mnTransIndex < 256 ) { - const BitmapColor aWhite( pMskAcc->GetBestMatchingColor( COL_WHITE ) ); + css::uno::Sequence<sal_Int8> aData( nPartWidth * nPartHeight ); + sal_Int8* pTmp = aData.getArray(); - if( mnTransIndex < 256 ) + for( long nY = nStartY; nY <= nEndY; nY++ ) { - css::uno::Sequence<sal_Int8> aData( nPartWidth * nPartHeight ); - sal_Int8* pTmp = aData.getArray(); - - for( long nY = nStartY; nY <= nEndY; nY++ ) + Scanline pScanlineMask = pMskAcc->GetScanline( nY ); + Scanline pScanline = pBmpAcc->GetScanline( nY ); + for( long nX = nStartX; nX <= nEndX; nX++ ) { - Scanline pScanlineMask = pMskAcc->GetScanline( nY ); - Scanline pScanline = pBmpAcc->GetScanline( nY ); - for( long nX = nStartX; nX <= nEndX; nX++ ) - { - if( pMskAcc->GetPixelFromData( pScanlineMask, nX ) == aWhite ) - *pTmp++ = sal::static_int_cast< sal_Int8 >( - mnTransIndex ); - else - *pTmp++ = pBmpAcc->GetPixelFromData( pScanline, nX ).GetIndex(); - } + if( pMskAcc->GetPixelFromData( pScanlineMask, nX ) == aWhite ) + *pTmp++ = sal::static_int_cast< sal_Int8 >( + mnTransIndex ); + else + *pTmp++ = pBmpAcc->GetPixelFromData( pScanline, nX ).GetIndex(); } - - // iterate through interfaces - for (auto const& elem : aTmp) - elem->setPixelsByBytes( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth ); } - else - { - css::uno::Sequence<sal_Int32> aData( nPartWidth * nPartHeight ); - sal_Int32* pTmp = aData.getArray(); - - for( long nY = nStartY; nY <= nEndY; nY++ ) - { - Scanline pScanlineMask = pMskAcc->GetScanline( nY ); - Scanline pScanline = pBmpAcc->GetScanline( nY ); - for( long nX = nStartX; nX <= nEndX; nX++ ) - { - if( pMskAcc->GetPixelFromData( pScanlineMask, nX ) == aWhite ) - *pTmp++ = mnTransIndex; - else - *pTmp++ = pBmpAcc->GetPixelFromData( pScanline, nX ).GetIndex(); - } - } - // iterate through interfaces - for (auto const& elem : aTmp) - elem->setPixelsByLongs( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth ); - } + // iterate through interfaces + for (auto const& elem : aTmp) + elem->setPixelsByBytes( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth ); } else { css::uno::Sequence<sal_Int32> aData( nPartWidth * nPartHeight ); - const BitmapColor aWhite( pMskAcc->GetBestMatchingColor( COL_WHITE ) ); sal_Int32* pTmp = aData.getArray(); for( long nY = nStartY; nY <= nEndY; nY++ ) { Scanline pScanlineMask = pMskAcc->GetScanline( nY ); Scanline pScanline = pBmpAcc->GetScanline( nY ); - for( long nX = nStartX; nX <= nEndX; nX++, pTmp++ ) + for( long nX = nStartX; nX <= nEndX; nX++ ) { - const BitmapColor aCol( pBmpAcc->GetPixelFromData( pScanline, nX ) ); - - *pTmp = static_cast<sal_Int32>(aCol.GetRed()) << 24; - *pTmp |= static_cast<sal_Int32>(aCol.GetGreen()) << 16; - *pTmp |= static_cast<sal_Int32>(aCol.GetBlue()) << 8; - - if( pMskAcc->GetPixelFromData( pScanlineMask, nX ) != aWhite ) - *pTmp |= 0x000000ffUL; + if( pMskAcc->GetPixelFromData( pScanlineMask, nX ) == aWhite ) + *pTmp++ = mnTransIndex; + else + *pTmp++ = pBmpAcc->GetPixelFromData( pScanline, nX ).GetIndex(); } } @@ -460,10 +433,37 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic ) for (auto const& elem : aTmp) elem->setPixelsByLongs( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth ); } + } + else + { + css::uno::Sequence<sal_Int32> aData( nPartWidth * nPartHeight ); + const BitmapColor aWhite( pMskAcc->GetBestMatchingColor( COL_WHITE ) ); + sal_Int32* pTmp = aData.getArray(); + + for( long nY = nStartY; nY <= nEndY; nY++ ) + { + Scanline pScanlineMask = pMskAcc->GetScanline( nY ); + Scanline pScanline = pBmpAcc->GetScanline( nY ); + for( long nX = nStartX; nX <= nEndX; nX++, pTmp++ ) + { + const BitmapColor aCol( pBmpAcc->GetPixelFromData( pScanline, nX ) ); + + *pTmp = static_cast<sal_Int32>(aCol.GetRed()) << 24; + *pTmp |= static_cast<sal_Int32>(aCol.GetGreen()) << 16; + *pTmp |= static_cast<sal_Int32>(aCol.GetBlue()) << 8; + + if( pMskAcc->GetPixelFromData( pScanlineMask, nX ) != aWhite ) + *pTmp |= 0x000000ffUL; + } + } - Bitmap::ReleaseAccess( pBmpAcc ); - Bitmap::ReleaseAccess( pMskAcc ); + // iterate through interfaces + for (auto const& elem : aTmp) + elem->setPixelsByLongs( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth ); } + + Bitmap::ReleaseAccess( pBmpAcc ); + Bitmap::ReleaseAccess( pMskAcc ); } diff --git a/forms/source/helper/formnavigation.cxx b/forms/source/helper/formnavigation.cxx index 96e2b6b8e935..5182b0544db6 100644 --- a/forms/source/helper/formnavigation.cxx +++ b/forms/source/helper/formnavigation.cxx @@ -119,21 +119,21 @@ namespace frm void SAL_CALL OFormNavigationHelper::disposing( const EventObject& _rSource ) { // was it one of our external dispatchers? - if ( m_nConnectedFeatures ) + if ( !m_nConnectedFeatures ) + return; + + for (auto & feature : m_aSupportedFeatures) { - for (auto & feature : m_aSupportedFeatures) + if ( feature.second.xDispatcher == _rSource.Source ) { - if ( feature.second.xDispatcher == _rSource.Source ) - { - feature.second.xDispatcher->removeStatusListener( static_cast< XStatusListener* >( this ), feature.second.aURL ); - feature.second.xDispatcher = nullptr; - feature.second.bCachedState = false; - feature.second.aCachedAdditionalState.clear(); - --m_nConnectedFeatures; + feature.second.xDispatcher->removeStatusListener( static_cast< XStatusListener* >( this ), feature.second.aURL ); + feature.second.xDispatcher = nullptr; + feature.second.bCachedState = false; + feature.second.aCachedAdditionalState.clear(); + --m_nConnectedFeatures; - featureStateChanged( feature.first, false ); - break; - } + featureStateChanged( feature.first, false ); + break; } } } @@ -234,26 +234,26 @@ namespace frm void OFormNavigationHelper::initializeSupportedFeatures( ) { - if ( m_aSupportedFeatures.empty() ) - { - // ask the derivee which feature ids it wants us to support - ::std::vector< sal_Int16 > aFeatureIds; - getSupportedFeatures( aFeatureIds ); + if ( !m_aSupportedFeatures.empty() ) + return; - OFormNavigationMapper aUrlMapper( m_xORB ); + // ask the derivee which feature ids it wants us to support + ::std::vector< sal_Int16 > aFeatureIds; + getSupportedFeatures( aFeatureIds ); - for (auto const& feature : aFeatureIds) - { - FeatureInfo aFeatureInfo; + OFormNavigationMapper aUrlMapper( m_xORB ); + + for (auto const& feature : aFeatureIds) + { + FeatureInfo aFeatureInfo; - bool bKnownId = - aUrlMapper.getFeatureURL( feature, aFeatureInfo.aURL ); - DBG_ASSERT( bKnownId, "OFormNavigationHelper::initializeSupportedFeatures: unknown feature id!" ); + bool bKnownId = + aUrlMapper.getFeatureURL( feature, aFeatureInfo.aURL ); + DBG_ASSERT( bKnownId, "OFormNavigationHelper::initializeSupportedFeatures: unknown feature id!" ); - if ( bKnownId ) - // add to our map - m_aSupportedFeatures.emplace( feature, aFeatureInfo ); - } + if ( bKnownId ) + // add to our map + m_aSupportedFeatures.emplace( feature, aFeatureInfo ); } } diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx index a30c40859dfc..41dbd7f3c086 100644 --- a/forms/source/misc/InterfaceContainer.cxx +++ b/forms/source/misc/InterfaceContainer.cxx @@ -353,20 +353,21 @@ struct TransformEventTo52Format { void operator()( ScriptEventDescriptor& _rDescriptor ) { - if ( _rDescriptor.ScriptType == "StarBasic" ) - { // it's a starbasic macro - sal_Int32 nPrefixLength = _rDescriptor.ScriptCode.indexOf( ':' ); - if ( 0 <= nPrefixLength ) - { // the macro name does not already contain a : + if ( _rDescriptor.ScriptType != "StarBasic" ) + return; + + // it's a starbasic macro + sal_Int32 nPrefixLength = _rDescriptor.ScriptCode.indexOf( ':' ); + if ( 0 <= nPrefixLength ) + { // the macro name does not already contain a : #ifdef DBG_UTIL - const OUString sPrefix = _rDescriptor.ScriptCode.copy( 0, nPrefixLength ); - DBG_ASSERT( sPrefix == "document" - || sPrefix == "application", - "TransformEventTo52Format: invalid (unknown) prefix!" ); + const OUString sPrefix = _rDescriptor.ScriptCode.copy( 0, nPrefixLength ); + DBG_ASSERT( sPrefix == "document" + || sPrefix == "application", + "TransformEventTo52Format: invalid (unknown) prefix!" ); #endif - // cut the prefix - _rDescriptor.ScriptCode = _rDescriptor.ScriptCode.copy( nPrefixLength + 1 ); - } + // cut the prefix + _rDescriptor.ScriptCode = _rDescriptor.ScriptCode.copy( nPrefixLength + 1 ); } } }; @@ -449,26 +450,26 @@ void SAL_CALL OInterfaceContainer::write( const Reference< XObjectOutputStream > // Write length _rxOutStream->writeLong(nLen); - if (nLen) - { - // 1. Version - _rxOutStream->writeShort(0x0001); + if (!nLen) + return; - // 2. Objects - for (sal_Int32 i = 0; i < nLen; i++) + // 1. Version + _rxOutStream->writeShort(0x0001); + + // 2. Objects + for (sal_Int32 i = 0; i < nLen; i++) + { + Reference<XPersistObject> xObj(m_aItems[i], UNO_QUERY); + if (xObj.is()) + _rxOutStream->writeObject(xObj); + else { - Reference<XPersistObject> xObj(m_aItems[i], UNO_QUERY); - if (xObj.is()) - _rxOutStream->writeObject(xObj); - else - { - // Error - } + // Error } - - // 3. Scripts - writeEvents(_rxOutStream); } + + // 3. Scripts + writeEvents(_rxOutStream); } @@ -619,47 +620,47 @@ void SAL_CALL OInterfaceContainer::disposing(const css::lang::EventObject& _rSou break; } - if ( m_aItems.end() != j ) + if ( m_aItems.end() == j ) + return; + + m_aItems.erase(j); + + // look up in, and erase from, m_aMap, too + OInterfaceMap::iterator i = m_aMap.begin(); + while ( i != m_aMap.end() ) { - m_aItems.erase(j); + DBG_ASSERT( i->second.get() == Reference< XInterface >( i->second, UNO_QUERY ).get(), + "OInterfaceContainer::disposing: map element not normalized!" ); - // look up in, and erase from, m_aMap, too - OInterfaceMap::iterator i = m_aMap.begin(); - while ( i != m_aMap.end() ) + if ( i->second.get() == xSource.get() ) { - DBG_ASSERT( i->second.get() == Reference< XInterface >( i->second, UNO_QUERY ).get(), - "OInterfaceContainer::disposing: map element not normalized!" ); - - if ( i->second.get() == xSource.get() ) - { - // found it - m_aMap.erase(i); - break; - } + // found it + m_aMap.erase(i); + break; + } - ++i; + ++i; - DBG_ASSERT( i != m_aMap.end(), "OInterfaceContainer::disposing: inconsistency: the element was in m_aItems, but not in m_aMap!" ); - } + DBG_ASSERT( i != m_aMap.end(), "OInterfaceContainer::disposing: inconsistency: the element was in m_aItems, but not in m_aMap!" ); } } // XPropertyChangeListener void OInterfaceContainer::propertyChange(const PropertyChangeEvent& evt) { - if (evt.PropertyName == PROPERTY_NAME) - { - ::osl::MutexGuard aGuard( m_rMutex ); - auto range = m_aMap.equal_range(::comphelper::getString(evt.OldValue)); - for (auto it = range.first; it != range.second; ++it) - if (it->second == evt.Source) - { - css::uno::Reference<css::uno::XInterface> xCorrectType(it->second); - m_aMap.erase(it); - m_aMap.insert(::std::pair<const OUString, css::uno::Reference<css::uno::XInterface> >(::comphelper::getString(evt.NewValue),xCorrectType)); - break; - } - } + if (evt.PropertyName != PROPERTY_NAME) + return; + + ::osl::MutexGuard aGuard( m_rMutex ); + auto range = m_aMap.equal_range(::comphelper::getString(evt.OldValue)); + for (auto it = range.first; it != range.second; ++it) + if (it->second == evt.Source) + { + css::uno::Reference<css::uno::XInterface> xCorrectType(it->second); + m_aMap.erase(it); + m_aMap.insert(::std::pair<const OUString, css::uno::Reference<css::uno::XInterface> >(::comphelper::getString(evt.NewValue),xCorrectType)); + break; + } } // XElementAccess diff --git a/forms/source/misc/limitedformats.cxx b/forms/source/misc/limitedformats.cxx index 3ee26ec5f2a7..f49b8617ff2c 100644 --- a/forms/source/misc/limitedformats.cxx +++ b/forms/source/misc/limitedformats.cxx @@ -148,53 +148,53 @@ namespace frm void OLimitedFormats::ensureTableInitialized(const sal_Int16 _nTableId) { FormatEntry* pFormatTable = lcl_getFormatTable(_nTableId); - if (-1 == pFormatTable->nKey) + if (-1 != pFormatTable->nKey) + return; + + ::osl::MutexGuard aGuard(s_aMutex); + if (-1 != pFormatTable->nKey) + return; + + // initialize the keys + Reference<XNumberFormats> xStandardFormats; + if (s_xStandardFormats.is()) + xStandardFormats = s_xStandardFormats->getNumberFormats(); + OSL_ENSURE(xStandardFormats.is(), "OLimitedFormats::ensureTableInitialized: don't have a formats supplier!"); + + if (!xStandardFormats.is()) + return; + + // loop through the table + FormatEntry* pLoopFormats = pFormatTable; + while (pLoopFormats->pDescription) { - ::osl::MutexGuard aGuard(s_aMutex); - if (-1 == pFormatTable->nKey) + // get the key for the description + pLoopFormats->nKey = xStandardFormats->queryKey( + OUString::createFromAscii(pLoopFormats->pDescription), + getLocale(pLoopFormats->eLocale), + false + ); + + if (-1 == pLoopFormats->nKey) { - // initialize the keys - Reference<XNumberFormats> xStandardFormats; - if (s_xStandardFormats.is()) - xStandardFormats = s_xStandardFormats->getNumberFormats(); - OSL_ENSURE(xStandardFormats.is(), "OLimitedFormats::ensureTableInitialized: don't have a formats supplier!"); - - if (xStandardFormats.is()) - { - // loop through the table - FormatEntry* pLoopFormats = pFormatTable; - while (pLoopFormats->pDescription) - { - // get the key for the description - pLoopFormats->nKey = xStandardFormats->queryKey( - OUString::createFromAscii(pLoopFormats->pDescription), - getLocale(pLoopFormats->eLocale), - false - ); - - if (-1 == pLoopFormats->nKey) - { - pLoopFormats->nKey = xStandardFormats->addNew( - OUString::createFromAscii(pLoopFormats->pDescription), - getLocale(pLoopFormats->eLocale) - ); + pLoopFormats->nKey = xStandardFormats->addNew( + OUString::createFromAscii(pLoopFormats->pDescription), + getLocale(pLoopFormats->eLocale) + ); #ifdef DBG_UTIL - try - { - xStandardFormats->getByKey(pLoopFormats->nKey); - } - catch(const Exception&) - { - OSL_FAIL("OLimitedFormats::ensureTableInitialized: adding the key to the formats collection failed!"); - } -#endif - } - - // next - ++pLoopFormats; - } + try + { + xStandardFormats->getByKey(pLoopFormats->nKey); + } + catch(const Exception&) + { + OSL_FAIL("OLimitedFormats::ensureTableInitialized: adding the key to the formats collection failed!"); } +#endif } + + // next + ++pLoopFormats; } } @@ -241,27 +241,27 @@ namespace frm _rValue.clear(); OSL_ENSURE(m_xAggregate.is() && (-1 != m_nFormatEnumPropertyHandle), "OLimitedFormats::getFormatKeyPropertyValue: not initialized!"); - if (m_xAggregate.is()) - { - // get the aggregate's enum property value - Any aEnumPropertyValue = m_xAggregate->getFastPropertyValue(m_nFormatEnumPropertyHandle); - sal_Int32 nValue = -1; - ::cppu::enum2int(nValue, aEnumPropertyValue); - - // get the translation table - const FormatEntry* pFormats = lcl_getFormatTable(m_nTableId); - - // seek to the nValue'th entry - sal_Int32 nLookup = 0; - for ( ; - (nullptr != pFormats->pDescription) && (nLookup < nValue); - ++pFormats, ++nLookup - ) - ; - OSL_ENSURE(nullptr != pFormats->pDescription, "OLimitedFormats::getFormatKeyPropertyValue: did not find the value!"); - if (pFormats->pDescription) - _rValue <<= pFormats->nKey; - } + if (!m_xAggregate.is()) + return; + + // get the aggregate's enum property value + Any aEnumPropertyValue = m_xAggregate->getFastPropertyValue(m_nFormatEnumPropertyHandle); + sal_Int32 nValue = -1; + ::cppu::enum2int(nValue, aEnumPropertyValue); + + // get the translation table + const FormatEntry* pFormats = lcl_getFormatTable(m_nTableId); + + // seek to the nValue'th entry + sal_Int32 nLookup = 0; + for ( ; + (nullptr != pFormats->pDescription) && (nLookup < nValue); + ++pFormats, ++nLookup + ) + ; + OSL_ENSURE(nullptr != pFormats->pDescription, "OLimitedFormats::getFormatKeyPropertyValue: did not find the value!"); + if (pFormats->pDescription) + _rValue <<= pFormats->nKey; // TODO: should use a standard format for the control type we're working for } diff --git a/forms/source/richtext/richtextcontrol.cxx b/forms/source/richtext/richtextcontrol.cxx index 4cf1f3912f89..1c96b9870361 100644 --- a/forms/source/richtext/richtextcontrol.cxx +++ b/forms/source/richtext/richtextcontrol.cxx @@ -168,51 +168,51 @@ namespace frm SolarMutexGuard aGuard; - if (!getPeer().is()) - { - mbCreatingPeer = true; + if (getPeer().is()) + return; - // determine the VLC window for the parent - vcl::Window* pParentWin = nullptr; - if ( _rParentPeer.is() ) - { - VCLXWindow* pParentXWin = comphelper::getUnoTunnelImplementation<VCLXWindow>( _rParentPeer ); - if ( pParentXWin ) - pParentWin = pParentXWin->GetWindow().get(); - DBG_ASSERT( pParentWin, "ORichTextControl::createPeer: could not obtain the VCL-level parent window!" ); - } + mbCreatingPeer = true; - // create the peer - Reference< XControlModel > xModel( getModel() ); - rtl::Reference<ORichTextPeer> pPeer = ORichTextPeer::Create( xModel, pParentWin, getWinBits( xModel ) ); - DBG_ASSERT( pPeer, "ORichTextControl::createPeer: invalid peer returned!" ); - if ( pPeer ) - { - // announce the peer to the base class - setPeer( pPeer.get() ); + // determine the VLC window for the parent + vcl::Window* pParentWin = nullptr; + if ( _rParentPeer.is() ) + { + VCLXWindow* pParentXWin = comphelper::getUnoTunnelImplementation<VCLXWindow>( _rParentPeer ); + if ( pParentXWin ) + pParentWin = pParentXWin->GetWindow().get(); + DBG_ASSERT( pParentWin, "ORichTextControl::createPeer: could not obtain the VCL-level parent window!" ); + } - // initialize ourself (and thus the peer) with the model properties - updateFromModel(); + // create the peer + Reference< XControlModel > xModel( getModel() ); + rtl::Reference<ORichTextPeer> pPeer = ORichTextPeer::Create( xModel, pParentWin, getWinBits( xModel ) ); + DBG_ASSERT( pPeer, "ORichTextControl::createPeer: invalid peer returned!" ); + if ( pPeer ) + { + // announce the peer to the base class + setPeer( pPeer.get() ); - Reference< XView > xPeerView( getPeer(), UNO_QUERY ); - if ( xPeerView.is() ) - { - xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY ); - xPeerView->setGraphics( mxGraphics ); - } + // initialize ourself (and thus the peer) with the model properties + updateFromModel(); - // a lot of initial settings from our component infos - setPosSize( maComponentInfos.nX, maComponentInfos.nY, maComponentInfos.nWidth, maComponentInfos.nHeight, PosSize::POSSIZE ); + Reference< XView > xPeerView( getPeer(), UNO_QUERY ); + if ( xPeerView.is() ) + { + xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY ); + xPeerView->setGraphics( mxGraphics ); + } - pPeer->setVisible ( maComponentInfos.bVisible && !mbDesignMode ); - pPeer->setEnable ( maComponentInfos.bEnable ); - pPeer->setDesignMode( mbDesignMode ); + // a lot of initial settings from our component infos + setPosSize( maComponentInfos.nX, maComponentInfos.nY, maComponentInfos.nWidth, maComponentInfos.nHeight, PosSize::POSSIZE ); - peerCreated(); - } + pPeer->setVisible ( maComponentInfos.bVisible && !mbDesignMode ); + pPeer->setEnable ( maComponentInfos.bEnable ); + pPeer->setDesignMode( mbDesignMode ); - mbCreatingPeer = false; + peerCreated(); } + + mbCreatingPeer = false; } OUString SAL_CALL ORichTextControl::getImplementationName() diff --git a/forms/source/richtext/rtattributehandler.cxx b/forms/source/richtext/rtattributehandler.cxx index 1f17b32c3396..ee7a3fe73b77 100644 --- a/forms/source/richtext/rtattributehandler.cxx +++ b/forms/source/richtext/rtattributehandler.cxx @@ -345,26 +345,26 @@ namespace frm const SvxFontHeightItem* pFontHeightItem = dynamic_cast<const SvxFontHeightItem*>( _pAdditionalArg ); OSL_ENSURE( pFontHeightItem, "FontSizeHandler::executeAttribute: need a FontHeightItem!" ); - if ( pFontHeightItem ) + if ( !pFontHeightItem ) + return; + + sal_uLong nHeight = pFontHeightItem->GetHeight(); + if ( _rNewAttribs.GetPool()->GetMetric( getWhich() ) != MapUnit::MapTwip ) { - sal_uLong nHeight = pFontHeightItem->GetHeight(); - if ( _rNewAttribs.GetPool()->GetMetric( getWhich() ) != MapUnit::MapTwip ) - { - nHeight = OutputDevice::LogicToLogic( - Size( 0, nHeight ), - MapMode( MapUnit::MapTwip ), - MapMode( _rNewAttribs.GetPool()->GetMetric( getWhich() ) ) - ).Height(); - } + nHeight = OutputDevice::LogicToLogic( + Size( 0, nHeight ), + MapMode( MapUnit::MapTwip ), + MapMode( _rNewAttribs.GetPool()->GetMetric( getWhich() ) ) + ).Height(); + } - SvxFontHeightItem aNewItem( nHeight, 100, getWhich() ); - aNewItem.SetProp( pFontHeightItem->GetProp(), pFontHeightItem->GetPropUnit() ); + SvxFontHeightItem aNewItem( nHeight, 100, getWhich() ); + aNewItem.SetProp( pFontHeightItem->GetProp(), pFontHeightItem->GetPropUnit() ); - if ( ( getAttributeId() == SID_ATTR_CHAR_FONTHEIGHT ) && _nForScriptType != SvtScriptType::NONE) - putItemForScript( _rNewAttribs, aNewItem, _nForScriptType ); - else - _rNewAttribs.Put( aNewItem ); - } + if ( ( getAttributeId() == SID_ATTR_CHAR_FONTHEIGHT ) && _nForScriptType != SvtScriptType::NONE) + putItemForScript( _rNewAttribs, aNewItem, _nForScriptType ); + else + _rNewAttribs.Put( aNewItem ); } ParagraphDirectionHandler::ParagraphDirectionHandler( AttributeId _nAttributeId ) diff --git a/forms/source/runtime/formoperations.cxx b/forms/source/runtime/formoperations.cxx index 90208a556463..696616031f23 100644 --- a/forms/source/runtime/formoperations.cxx +++ b/forms/source/runtime/formoperations.cxx @@ -1022,39 +1022,39 @@ namespace frm impl_invalidateAllSupportedFeatures_nothrow( aGuard ); } - if ( m_xParser.is() && ( m_xCursor == _rEvent.Source ) ) + if ( !(m_xParser.is() && ( m_xCursor == _rEvent.Source )) ) + return; + + try { - try + OUString sNewValue; + _rEvent.NewValue >>= sNewValue; + if ( _rEvent.PropertyName == PROPERTY_ACTIVECOMMAND ) { - OUString sNewValue; - _rEvent.NewValue >>= sNewValue; - if ( _rEvent.PropertyName == PROPERTY_ACTIVECOMMAND ) - { - m_xParser->setElementaryQuery( sNewValue ); - } - else if ( _rEvent.PropertyName == PROPERTY_FILTER ) - { - if ( m_xParser->getFilter() != sNewValue ) - m_xParser->setFilter( sNewValue ); - } - else if ( _rEvent.PropertyName == PROPERTY_HAVINGCLAUSE ) - { - if ( m_xParser->getHavingClause() != sNewValue ) - m_xParser->setHavingClause( sNewValue ); - } - else if ( _rEvent.PropertyName == PROPERTY_SORT ) - { - _rEvent.NewValue >>= sNewValue; - if ( m_xParser->getOrder() != sNewValue ) - m_xParser->setOrder( sNewValue ); - } + m_xParser->setElementaryQuery( sNewValue ); } - catch( const Exception& ) + else if ( _rEvent.PropertyName == PROPERTY_FILTER ) { - OSL_FAIL( "FormOperations::propertyChange: caught an exception while updating the parser!" ); + if ( m_xParser->getFilter() != sNewValue ) + m_xParser->setFilter( sNewValue ); } - impl_invalidateAllSupportedFeatures_nothrow( aGuard ); + else if ( _rEvent.PropertyName == PROPERTY_HAVINGCLAUSE ) + { + if ( m_xParser->getHavingClause() != sNewValue ) + m_xParser->setHavingClause( sNewValue ); + } + else if ( _rEvent.PropertyName == PROPERTY_SORT ) + { + _rEvent.NewValue >>= sNewValue; + if ( m_xParser->getOrder() != sNewValue ) + m_xParser->setOrder( sNewValue ); + } + } + catch( const Exception& ) + { + OSL_FAIL( "FormOperations::propertyChange: caught an exception while updating the parser!" ); } + impl_invalidateAllSupportedFeatures_nothrow( aGuard ); } diff --git a/forms/source/solar/component/navbarcontrol.cxx b/forms/source/solar/component/navbarcontrol.cxx index 78acd82b1659..f39464fc8987 100644 --- a/forms/source/solar/component/navbarcontrol.cxx +++ b/forms/source/solar/component/navbarcontrol.cxx @@ -114,48 +114,48 @@ namespace frm { SolarMutexGuard aGuard; - if (!getPeer().is()) - { - mbCreatingPeer = true; + if (getPeer().is()) + return; - // determine the VLC window for the parent - vcl::Window* pParentWin = nullptr; - if ( _rParentPeer.is() ) - { - VCLXWindow* pParentXWin = comphelper::getUnoTunnelImplementation<VCLXWindow>( _rParentPeer ); - if ( pParentXWin ) - pParentWin = pParentXWin->GetWindow().get(); - DBG_ASSERT( pParentWin, "ONavigationBarControl::createPeer: could not obtain the VCL-level parent window!" ); - } + mbCreatingPeer = true; + + // determine the VLC window for the parent + vcl::Window* pParentWin = nullptr; + if ( _rParentPeer.is() ) + { + VCLXWindow* pParentXWin = comphelper::getUnoTunnelImplementation<VCLXWindow>( _rParentPeer ); + if ( pParentXWin ) + pParentWin = pParentXWin->GetWindow().get(); + DBG_ASSERT( pParentWin, "ONavigationBarControl::createPeer: could not obtain the VCL-level parent window!" ); + } - // create the peer - rtl::Reference<ONavigationBarPeer> pPeer = ONavigationBarPeer::Create( m_xContext, pParentWin, getModel() ); - assert(pPeer && "ONavigationBarControl::createPeer: invalid peer returned!"); + // create the peer + rtl::Reference<ONavigationBarPeer> pPeer = ONavigationBarPeer::Create( m_xContext, pParentWin, getModel() ); + assert(pPeer && "ONavigationBarControl::createPeer: invalid peer returned!"); - // announce the peer to the base class - setPeer( pPeer.get() ); + // announce the peer to the base class + setPeer( pPeer.get() ); - // initialize ourself (and thus the peer) with the model properties - updateFromModel(); + // initialize ourself (and thus the peer) with the model properties + updateFromModel(); - Reference< XView > xPeerView( getPeer(), UNO_QUERY ); - if ( xPeerView.is() ) - { - xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY ); - xPeerView->setGraphics( mxGraphics ); - } + Reference< XView > xPeerView( getPeer(), UNO_QUERY ); + if ( xPeerView.is() ) + { + xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY ); + xPeerView->setGraphics( mxGraphics ); + } - // a lot of initial settings from our component infos - setPosSize( maComponentInfos.nX, maComponentInfos.nY, maComponentInfos.nWidth, maComponentInfos.nHeight, PosSize::POSSIZE ); + // a lot of initial settings from our component infos + setPosSize( maComponentInfos.nX, maComponentInfos.nY, maComponentInfos.nWidth, maComponentInfos.nHeight, PosSize::POSSIZE ); - pPeer->setVisible ( maComponentInfos.bVisible && !mbDesignMode ); - pPeer->setEnable ( maComponentInfos.bEnable ); - pPeer->setDesignMode( mbDesignMode ); + pPeer->setVisible ( maComponentInfos.bVisible && !mbDesignMode ); + pPeer->setEnable ( maComponentInfos.bEnable ); + pPeer->setDesignMode( mbDesignMode ); - peerCreated(); + peerCreated(); - mbCreatingPeer = false; - } + mbCreatingPeer = false; } diff --git a/forms/source/xforms/binding.cxx b/forms/source/xforms/binding.cxx index 5c2287edfebc..a3a60864d62a 100644 --- a/forms/source/xforms/binding.cxx +++ b/forms/source/xforms/binding.cxx @@ -461,40 +461,40 @@ static void lcl_addListenerToNode( const Reference<XNode>& xNode, const Reference<XEventListener>& xListener ) { Reference<XEventTarget> xTarget( xNode, UNO_QUERY ); - if( xTarget.is() ) - { - xTarget->addEventListener( "DOMCharacterDataModified", - xListener, false ); - xTarget->addEventListener( "DOMCharacterDataModified", - xListener, true ); - xTarget->addEventListener( "DOMAttrModified", - xListener, false ); - xTarget->addEventListener( "DOMAttrModified", - xListener, true ); - xTarget->addEventListener( "DOMAttrModified", - xListener, true ); - xTarget->addEventListener( "xforms-generic", - xListener, true ); - } + if( !xTarget.is() ) + return; + + xTarget->addEventListener( "DOMCharacterDataModified", + xListener, false ); + xTarget->addEventListener( "DOMCharacterDataModified", + xListener, true ); + xTarget->addEventListener( "DOMAttrModified", + xListener, false ); + xTarget->addEventListener( "DOMAttrModified", + xListener, true ); + xTarget->addEventListener( "DOMAttrModified", + xListener, true ); + xTarget->addEventListener( "xforms-generic", + xListener, true ); } static void lcl_removeListenerFromNode( const Reference<XNode>& xNode, const Reference<XEventListener>& xListener ) { Reference<XEventTarget> xTarget( xNode, UNO_QUERY ); - if( xTarget.is() ) - { - xTarget->removeEventListener( "DOMCharacterDataModified", - xListener, false ); - xTarget->removeEventListener( "DOMCharacterDataModified", - xListener, true ); - xTarget->removeEventListener( "DOMAttrModified", - xListener, false ); - xTarget->removeEventListener( "DOMAttrModified", - xListener, true ); - xTarget->removeEventListener( "xforms-generic", - xListener, true ); - } + if( !xTarget.is() ) + return; + + xTarget->removeEventListener( "DOMCharacterDataModified", + xListener, false ); + xTarget->removeEventListener( "DOMCharacterDataModified", + xListener, true ); + xTarget->removeEventListener( "DOMAttrModified", + xListener, false ); + xTarget->removeEventListener( "DOMAttrModified", + xListener, true ); + xTarget->removeEventListener( "xforms-generic", + xListener, true ); } ::std::vector<EvaluationContext> Binding::_getMIPEvaluationContexts() const @@ -931,24 +931,24 @@ void Binding::_setNamespaces( const css::uno::Reference<css::container::XNameCon void Binding::_checkBindingID() { - if( getModel().is() ) + if( !getModel().is() ) + return; + + Reference<XNameAccess> xBindings( getModel()->getBindings(), UNO_QUERY_THROW ); + if( !msBindingID.isEmpty() ) + return; + + // no binding ID? then make one up! + OUString sIDPrefix = getResource( RID_STR_XFORMS_BINDING_UI_NAME ) + " "; + sal_Int32 nNumber = 0; + OUString sName; + do { - Reference<XNameAccess> xBindings( getModel()->getBindings(), UNO_QUERY_THROW ); - if( msBindingID.isEmpty() ) - { - // no binding ID? then make one up! - OUString sIDPrefix = getResource( RID_STR_XFORMS_BINDING_UI_NAME ) + " "; - sal_Int32 nNumber = 0; - OUString sName; - do - { - nNumber++; - sName = sIDPrefix + OUString::number( nNumber ); - } - while( xBindings->hasByName( sName ) ); - setBindingID( sName ); - } + nNumber++; + sName = sIDPrefix + OUString::number( nNumber ); } + while( xBindings->hasByName( sName ) ); + setBindingID( sName ); } diff --git a/forms/source/xforms/model.cxx b/forms/source/xforms/model.cxx index 433bbb89581b..5075222e1459 100644 --- a/forms/source/xforms/model.cxx +++ b/forms/source/xforms/model.cxx @@ -324,29 +324,29 @@ void Model::loadInstance( sal_Int32 nInstance ) getInstanceData( aSequence, nullptr, nullptr, &sURL, &bOnce ); // if we have a URL, load the document and set it into the instance - if( !sURL.isEmpty() ) + if( sURL.isEmpty() ) + return; + + try { - try + Reference<XInputStream> xInput = + SimpleFileAccess::create( ::comphelper::getProcessComponentContext() )->openFileRead( sURL ); + if( xInput.is() ) { - Reference<XInputStream> xInput = - SimpleFileAccess::create( ::comphelper::getProcessComponentContext() )->openFileRead( sURL ); - if( xInput.is() ) + Reference<XDocument> xInstance = + getDocumentBuilder()->parse( xInput ); + if( xInstance.is() ) { - Reference<XDocument> xInstance = - getDocumentBuilder()->parse( xInput ); - if( xInstance.is() ) - { - OUString sEmpty; - setInstanceData( aSequence, nullptr, &xInstance, - bOnce ? &sEmpty : &sURL, nullptr); - mxInstances->setItem( nInstance, aSequence ); - } + OUString sEmpty; + setInstanceData( aSequence, nullptr, &xInstance, + bOnce ? &sEmpty : &sURL, nullptr); + mxInstances->setItem( nInstance, aSequence ); } } - catch( const Exception& ) - { - // couldn't load the instance -> ignore! - } + } + catch( const Exception& ) + { + // couldn't load the instance -> ignore! } } diff --git a/forms/source/xforms/model_ui.cxx b/forms/source/xforms/model_ui.cxx index a107c6c06bf9..0dca32ac5b91 100644 --- a/forms/source/xforms/model_ui.cxx +++ b/forms/source/xforms/model_ui.cxx @@ -170,32 +170,32 @@ static void lcl_OutInstance( OUStringBuffer& rBuffer, { Reference<XDocument> xDoc = xNode->getOwnerDocument(); - if( xDoc != pModel->getDefaultInstance() ) - { - rBuffer.insert( 0, "')" ); + if( xDoc == pModel->getDefaultInstance() ) + return; - // iterate over instances, and find the right one - OUString sInstanceName; - Reference<XEnumeration> xEnum = - pModel->getInstances()->createEnumeration(); - while( sInstanceName.isEmpty() && xEnum->hasMoreElements() ) - { - Sequence<PropertyValue> aValues; - xEnum->nextElement() >>= aValues; + rBuffer.insert( 0, "')" ); - // get ID and instance - OUString sId; - Reference<XDocument> xInstance; - getInstanceData( aValues, &sId, &xInstance, nullptr, nullptr ); + // iterate over instances, and find the right one + OUString sInstanceName; + Reference<XEnumeration> xEnum = + pModel->getInstances()->createEnumeration(); + while( sInstanceName.isEmpty() && xEnum->hasMoreElements() ) + { + Sequence<PropertyValue> aValues; + xEnum->nextElement() >>= aValues; - // now check whether this was our instance: - if( xInstance == xDoc ) - sInstanceName = sId; - } + // get ID and instance + OUString sId; + Reference<XDocument> xInstance; + getInstanceData( aValues, &sId, &xInstance, nullptr, nullptr ); - rBuffer.insert( 0, sInstanceName ); - rBuffer.insert( 0, "instance('" ); + // now check whether this was our instance: + if( xInstance == xDoc ) + sInstanceName = sId; } + + rBuffer.insert( 0, sInstanceName ); + rBuffer.insert( 0, "instance('" ); } OUString Model::getDefaultBindingExpressionForNode( @@ -443,38 +443,38 @@ void Model::renameInstance( const OUString& sFrom, sal_Bool bURLOnce ) { sal_Int32 nPos = lcl_findInstance( mxInstances.get(), sFrom ); - if( nPos != -1 ) - { - Sequence<PropertyValue> aSeq = mxInstances->getItem( nPos ); - PropertyValue* pSeq = aSeq.getArray(); - sal_Int32 nLength = aSeq.getLength(); + if( nPos == -1 ) + return; - sal_Int32 nProp = lcl_findProp( pSeq, nLength, "ID" ); - if( nProp == -1 ) - { - // add name property - aSeq.realloc( nLength + 1 ); - pSeq = aSeq.getArray(); - pSeq[ nLength ].Name = "ID"; - nProp = nLength; - } + Sequence<PropertyValue> aSeq = mxInstances->getItem( nPos ); + PropertyValue* pSeq = aSeq.getArray(); + sal_Int32 nLength = aSeq.getLength(); + + sal_Int32 nProp = lcl_findProp( pSeq, nLength, "ID" ); + if( nProp == -1 ) + { + // add name property + aSeq.realloc( nLength + 1 ); + pSeq = aSeq.getArray(); + pSeq[ nLength ].Name = "ID"; + nProp = nLength; + } - // change name - pSeq[ nProp ].Value <<= sTo; + // change name + pSeq[ nProp ].Value <<= sTo; - // change url - nProp = lcl_findProp( pSeq, nLength, "URL" ); - if(nProp != -1) - pSeq[ nProp ].Value <<= sURL; + // change url + nProp = lcl_findProp( pSeq, nLength, "URL" ); + if(nProp != -1) + pSeq[ nProp ].Value <<= sURL; - // change urlonce - nProp = lcl_findProp( pSeq, nLength, "URLOnce" ); - if(nProp != -1) - pSeq[ nProp ].Value <<= bURLOnce; + // change urlonce + nProp = lcl_findProp( pSeq, nLength, "URLOnce" ); + if(nProp != -1) + pSeq[ nProp ].Value <<= bURLOnce; - // set instance - mxInstances->setItem( nPos, aSeq ); - } + // set instance + mxInstances->setItem( nPos, aSeq ); } void Model::removeInstance( const OUString& sName ) diff --git a/forms/source/xforms/submission.cxx b/forms/source/xforms/submission.cxx index 2df449991a53..84d8599f8cb1 100644 --- a/forms/source/xforms/submission.cxx +++ b/forms/source/xforms/submission.cxx @@ -510,18 +510,18 @@ static void cloneNodes(Model& aModel, const Reference< XNode >& dstParent, const Reference< XDocument > dstDoc = dstParent->getOwnerDocument(); Reference< XNode > imported; - if (cur.is()) + if (!cur.is()) + return; + + // is this node relevant? + MIP mip = aModel.queryMIP(cur); + if(mip.isRelevant() && !(bRemoveWSNodes && isIgnorable(cur))) { - // is this node relevant? - MIP mip = aModel.queryMIP(cur); - if(mip.isRelevant() && !(bRemoveWSNodes && isIgnorable(cur))) - { - imported = dstDoc->importNode(cur, false); - imported = dstParent->appendChild(imported); - // append source children to new imported parent - for( cur = cur->getFirstChild(); cur.is(); cur = cur->getNextSibling() ) - cloneNodes(aModel, imported, cur, bRemoveWSNodes); - } + imported = dstDoc->importNode(cur, false); + imported = dstParent->appendChild(imported); + // append source children to new imported parent + for( cur = cur->getFirstChild(); cur.is(); cur = cur->getNextSibling() ) + cloneNodes(aModel, imported, cur, bRemoveWSNodes); } } Reference< XDocument > Submission::getInstanceDocument(const Reference< XXPathObject >& aObj) |