summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-12-21 15:22:06 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-12-21 17:14:14 +0100
commit489bce598626390d9c0aa5e5b8514e26070add61 (patch)
tree170ec95dcb393dbe4f7178bc08e6d96b6b76954b /forms
parentf19599c929ac6ae2708b19b9eff62ff70b44ee75 (diff)
loplugin:flatten in filter..framework
Change-Id: I15a577b3c6da03001bbbf2c2b43b29b41c4007c1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127234 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'forms')
-rw-r--r--forms/source/component/CheckBox.cxx58
-rw-r--r--forms/source/component/ComboBox.cxx40
-rw-r--r--forms/source/component/DatabaseForm.cxx96
-rw-r--r--forms/source/component/Date.cxx52
-rw-r--r--forms/source/component/Filter.cxx43
-rw-r--r--forms/source/component/FormattedField.cxx48
-rw-r--r--forms/source/component/Pattern.cxx44
-rw-r--r--forms/source/component/Time.cxx58
-rw-r--r--forms/source/misc/limitedformats.cxx106
-rw-r--r--forms/source/runtime/formoperations.cxx37
10 files changed, 288 insertions, 294 deletions
diff --git a/forms/source/component/CheckBox.cxx b/forms/source/component/CheckBox.cxx
index 7718b7d74504..f82a49f7042c 100644
--- a/forms/source/component/CheckBox.cxx
+++ b/forms/source/component/CheckBox.cxx
@@ -236,39 +236,39 @@ Any OCheckBoxModel::translateDbColumnToControlValue()
bool OCheckBoxModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
{
OSL_PRECOND( m_xColumnUpdate.is(), "OCheckBoxModel::commitControlValueToDbColumn: not bound!" );
- if ( m_xColumnUpdate.is() )
+ if ( !m_xColumnUpdate )
+ return true;
+
+ Any aControlValue( m_xAggregateSet->getPropertyValue( PROPERTY_STATE ) );
+ try
{
- Any aControlValue( m_xAggregateSet->getPropertyValue( PROPERTY_STATE ) );
- try
- {
- sal_Int16 nValue = TRISTATE_INDET;
- aControlValue >>= nValue;
- switch (nValue)
- {
- case TRISTATE_INDET:
- m_xColumnUpdate->updateNull();
- break;
- case TRISTATE_TRUE:
- if (DbUseBool())
- m_xColumnUpdate->updateBoolean( true );
- else
- m_xColumnUpdate->updateString( getReferenceValue() );
- break;
- case TRISTATE_FALSE:
- if (DbUseBool())
- m_xColumnUpdate->updateBoolean( false );
- else
- m_xColumnUpdate->updateString( getNoCheckReferenceValue() );
- break;
- default:
- OSL_FAIL("OCheckBoxModel::commitControlValueToDbColumn: invalid value !");
- }
- }
- catch(const Exception&)
+ sal_Int16 nValue = TRISTATE_INDET;
+ aControlValue >>= nValue;
+ switch (nValue)
{
- OSL_FAIL("OCheckBoxModel::commitControlValueToDbColumn: could not commit !");
+ case TRISTATE_INDET:
+ m_xColumnUpdate->updateNull();
+ break;
+ case TRISTATE_TRUE:
+ if (DbUseBool())
+ m_xColumnUpdate->updateBoolean( true );
+ else
+ m_xColumnUpdate->updateString( getReferenceValue() );
+ break;
+ case TRISTATE_FALSE:
+ if (DbUseBool())
+ m_xColumnUpdate->updateBoolean( false );
+ else
+ m_xColumnUpdate->updateString( getNoCheckReferenceValue() );
+ break;
+ default:
+ OSL_FAIL("OCheckBoxModel::commitControlValueToDbColumn: invalid value !");
}
}
+ catch(const Exception&)
+ {
+ OSL_FAIL("OCheckBoxModel::commitControlValueToDbColumn: could not commit !");
+ }
return true;
}
diff --git a/forms/source/component/ComboBox.cxx b/forms/source/component/ComboBox.cxx
index d43903bfea35..c26b90f04778 100644
--- a/forms/source/component/ComboBox.cxx
+++ b/forms/source/component/ComboBox.cxx
@@ -755,29 +755,29 @@ bool OComboBoxModel::commitControlValueToDbColumn( bool _bPostReset )
bool bAddToList = bModified && !_bPostReset;
// (only if this is not the "commit" triggered by a "reset")
- if ( bAddToList )
+ if ( !bAddToList )
+ return true;
+
+ css::uno::Sequence<OUString> aStringItemList;
+ if ( !(getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aStringItemList) )
+ return true;
+
+ bool bFound = false;
+ for (const OUString& rStringItem : std::as_const(aStringItemList))
{
- css::uno::Sequence<OUString> aStringItemList;
- if ( getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aStringItemList )
- {
- bool bFound = false;
- for (const OUString& rStringItem : std::as_const(aStringItemList))
- {
- if ( (bFound = rStringItem == sNewValue) )
- break;
- }
+ if ( (bFound = rStringItem == sNewValue) )
+ break;
+ }
- // not found -> add
- if (!bFound)
- {
- sal_Int32 nOldLen = aStringItemList.getLength();
- aStringItemList.realloc( nOldLen + 1 );
- aStringItemList.getArray()[ nOldLen ] = sNewValue;
+ // not found -> add
+ if (!bFound)
+ {
+ sal_Int32 nOldLen = aStringItemList.getLength();
+ aStringItemList.realloc( nOldLen + 1 );
+ aStringItemList.getArray()[ nOldLen ] = sNewValue;
- setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( aStringItemList ) );
- setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, makeAny( css::uno::Sequence<css::uno::Any>() ) );
- }
- }
+ setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( aStringItemList ) );
+ setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, makeAny( css::uno::Sequence<css::uno::Any>() ) );
}
return true;
diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx
index 45ffd5e595f1..74fbaf77e6be 100644
--- a/forms/source/component/DatabaseForm.cxx
+++ b/forms/source/component/DatabaseForm.cxx
@@ -1033,32 +1033,31 @@ void ODatabaseForm::updateParameterInfo()
bool ODatabaseForm::hasValidParent() const
{
// do we have to fill the parameters again?
- if (m_bSubForm)
+ if (!m_bSubForm)
+ return true;
+ Reference<XResultSet> xResultSet(m_xParent, UNO_QUERY);
+ if (!xResultSet.is())
{
- Reference<XResultSet> xResultSet(m_xParent, UNO_QUERY);
- if (!xResultSet.is())
- {
- OSL_FAIL("ODatabaseForm::hasValidParent() : no parent resultset !");
- return false;
- }
- try
- {
- Reference< XPropertySet > xSet( m_xParent, UNO_QUERY );
- Reference< XLoadable > xLoad( m_xParent, UNO_QUERY );
- if ( xLoad->isLoaded()
- && ( xResultSet->isBeforeFirst()
- || xResultSet->isAfterLast()
- || getBOOL( xSet->getPropertyValue( PROPERTY_ISNEW ) )
- )
+ OSL_FAIL("ODatabaseForm::hasValidParent() : no parent resultset !");
+ return false;
+ }
+ try
+ {
+ Reference< XPropertySet > xSet( m_xParent, UNO_QUERY );
+ Reference< XLoadable > xLoad( m_xParent, UNO_QUERY );
+ if ( xLoad->isLoaded()
+ && ( xResultSet->isBeforeFirst()
+ || xResultSet->isAfterLast()
+ || getBOOL( xSet->getPropertyValue( PROPERTY_ISNEW ) )
)
- // the parent form is loaded and on a "virtual" row -> not valid
- return false;
- }
- catch(const Exception&)
- {
- // parent could be forwardonly?
+ )
+ // the parent form is loaded and on a "virtual" row -> not valid
return false;
- }
+ }
+ catch(const Exception&)
+ {
+ // parent could be forwardonly?
+ return false;
}
return true;
}
@@ -3110,35 +3109,34 @@ sal_Bool SAL_CALL ODatabaseForm::approveCursorMove(const EventObject& event)
sal_Bool SAL_CALL ODatabaseForm::approveRowChange(const RowChangeEvent& event)
{
// is our aggregate calling?
- if (event.Source == css::uno::Reference<css::uno::XInterface>(static_cast<XWeak*>(this)))
+ if (event.Source != css::uno::Reference<css::uno::XInterface>(static_cast<XWeak*>(this)))
+ return true;
+
+ // Our aggregate doesn't have any ApproveRowSetListeners (expect ourself), as we re-routed the queryInterface
+ // for XRowSetApproveBroadcaster-interface.
+ // So we have to multiplex this approve request.
+ ::comphelper::OInterfaceIteratorHelper3 aIter( m_aRowSetApproveListeners );
+ while ( aIter.hasMoreElements() )
{
- // Our aggregate doesn't have any ApproveRowSetListeners (expect ourself), as we re-routed the queryInterface
- // for XRowSetApproveBroadcaster-interface.
- // So we have to multiplex this approve request.
- ::comphelper::OInterfaceIteratorHelper3 aIter( m_aRowSetApproveListeners );
- while ( aIter.hasMoreElements() )
+ Reference< XRowSetApproveListener > xListener( aIter.next() );
+ try
{
- Reference< XRowSetApproveListener > xListener( aIter.next() );
- try
- {
- if ( !xListener->approveRowChange( event ) )
- return false;
- }
- catch (const DisposedException& e)
- {
- if ( e.Context == xListener )
- aIter.remove();
- }
- catch (const RuntimeException&)
- {
- throw;
- }
- catch (const Exception&)
- {
- DBG_UNHANDLED_EXCEPTION("forms.component");
- }
+ if ( !xListener->approveRowChange( event ) )
+ return false;
+ }
+ catch (const DisposedException& e)
+ {
+ if ( e.Context == xListener )
+ aIter.remove();
+ }
+ catch (const RuntimeException&)
+ {
+ throw;
+ }
+ catch (const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("forms.component");
}
- return true;
}
return true;
}
diff --git a/forms/source/component/Date.cxx b/forms/source/component/Date.cxx
index cf3de99e1b24..35b2f3f7424b 100644
--- a/forms/source/component/Date.cxx
+++ b/forms/source/component/Date.cxx
@@ -219,40 +219,40 @@ void ODateModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm )
bool ODateModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
{
Any aControlValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) );
- if ( aControlValue != m_aSaveValue )
+ if ( aControlValue == m_aSaveValue )
+ return true;
+
+ if ( !aControlValue.hasValue() )
+ m_xColumnUpdate->updateNull();
+ else
{
- if ( !aControlValue.hasValue() )
- m_xColumnUpdate->updateNull();
- else
+ try
{
- try
+ util::Date aDate;
+ if ( !( aControlValue >>= aDate ) )
{
- util::Date aDate;
- if ( !( aControlValue >>= aDate ) )
- {
- sal_Int32 nAsInt(0);
- aControlValue >>= nAsInt;
- aDate = DBTypeConversion::toDate(nAsInt);
- }
-
- if ( !m_bDateTimeField )
- m_xColumnUpdate->updateDate( aDate );
- else
- {
- util::DateTime aDateTime = m_xColumn->getTimestamp();
- aDateTime.Day = aDate.Day;
- aDateTime.Month = aDate.Month;
- aDateTime.Year = aDate.Year;
- m_xColumnUpdate->updateTimestamp( aDateTime );
- }
+ sal_Int32 nAsInt(0);
+ aControlValue >>= nAsInt;
+ aDate = DBTypeConversion::toDate(nAsInt);
}
- catch(const Exception&)
+
+ if ( !m_bDateTimeField )
+ m_xColumnUpdate->updateDate( aDate );
+ else
{
- return false;
+ util::DateTime aDateTime = m_xColumn->getTimestamp();
+ aDateTime.Day = aDate.Day;
+ aDateTime.Month = aDate.Month;
+ aDateTime.Year = aDate.Year;
+ m_xColumnUpdate->updateTimestamp( aDateTime );
}
}
- m_aSaveValue = aControlValue;
+ catch(const Exception&)
+ {
+ return false;
+ }
}
+ m_aSaveValue = aControlValue;
return true;
}
diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx
index 38ed0b7ada01..9c6459a0dd04 100644
--- a/forms/source/component/Filter.cxx
+++ b/forms/source/component/Filter.cxx
@@ -510,32 +510,31 @@ namespace frm
default:
return true;
}
- if ( m_aText != aText )
+ if ( m_aText == aText )
+ return true;
+ // check the text with the SQL-Parser
+ OUString aNewText = aText.trim();
+ if ( !aNewText.isEmpty() )
{
- // check the text with the SQL-Parser
- OUString aNewText = aText.trim();
- if ( !aNewText.isEmpty() )
+ ::dbtools::OPredicateInputController aPredicateInput( m_xContext, m_xConnection, getParseContext() );
+ OUString sErrorMessage;
+ if ( !aPredicateInput.normalizePredicateString( aNewText, m_xField, &sErrorMessage ) )
{
- ::dbtools::OPredicateInputController aPredicateInput( m_xContext, m_xConnection, getParseContext() );
- OUString sErrorMessage;
- if ( !aPredicateInput.normalizePredicateString( aNewText, m_xField, &sErrorMessage ) )
- {
- // display the error and outta here
- SQLContext aError;
- aError.Message = ResourceManager::loadString(RID_STR_SYNTAXERROR);
- aError.Details = sErrorMessage;
- displayException( aError );
- return false;
- }
+ // display the error and outta here
+ SQLContext aError;
+ aError.Message = ResourceManager::loadString(RID_STR_SYNTAXERROR);
+ aError.Details = sErrorMessage;
+ displayException( aError );
+ return false;
}
-
- setText(aNewText);
- TextEvent aEvt;
- aEvt.Source = *this;
- ::comphelper::OInterfaceIteratorHelper3 aIt(m_aTextListeners);
- while( aIt.hasMoreElements() )
- aIt.next()->textChanged(aEvt);
}
+
+ setText(aNewText);
+ TextEvent aEvt;
+ aEvt.Source = *this;
+ ::comphelper::OInterfaceIteratorHelper3 aIt(m_aTextListeners);
+ while( aIt.hasMoreElements() )
+ aIt.next()->textChanged(aEvt);
#endif
return true;
}
diff --git a/forms/source/component/FormattedField.cxx b/forms/source/component/FormattedField.cxx
index 340ee79a8a0f..432456802c4c 100644
--- a/forms/source/component/FormattedField.cxx
+++ b/forms/source/component/FormattedField.cxx
@@ -809,38 +809,38 @@ sal_uInt16 OFormattedModel::getPersistenceFlags() const
bool OFormattedModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
{
Any aControlValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) );
- if ( aControlValue != m_aSaveValue )
- {
- // empty string + EmptyIsNull = void
- if ( !aControlValue.hasValue()
- || ( ( aControlValue.getValueType().getTypeClass() == TypeClass_STRING )
- && getString( aControlValue ).isEmpty()
- && m_bEmptyIsNull
- )
+ if ( aControlValue == m_aSaveValue )
+ return true;
+
+ // empty string + EmptyIsNull = void
+ if ( !aControlValue.hasValue()
+ || ( ( aControlValue.getValueType().getTypeClass() == TypeClass_STRING )
+ && getString( aControlValue ).isEmpty()
+ && m_bEmptyIsNull
)
- m_xColumnUpdate->updateNull();
- else
+ )
+ m_xColumnUpdate->updateNull();
+ else
+ {
+ try
{
- try
+ double f = 0.0;
+ if ( aControlValue.getValueType().getTypeClass() == TypeClass_DOUBLE || (aControlValue >>= f)) // #i110323
{
- double f = 0.0;
- if ( aControlValue.getValueType().getTypeClass() == TypeClass_DOUBLE || (aControlValue >>= f)) // #i110323
- {
- DBTypeConversion::setValue( m_xColumnUpdate, m_aNullDate, getDouble( aControlValue ), m_nKeyType );
- }
- else
- {
- DBG_ASSERT( aControlValue.getValueType().getTypeClass() == TypeClass_STRING, "OFormattedModel::commitControlValueToDbColumn: invalid value type!" );
- m_xColumnUpdate->updateString( getString( aControlValue ) );
- }
+ DBTypeConversion::setValue( m_xColumnUpdate, m_aNullDate, getDouble( aControlValue ), m_nKeyType );
}
- catch(const Exception&)
+ else
{
- return false;
+ DBG_ASSERT( aControlValue.getValueType().getTypeClass() == TypeClass_STRING, "OFormattedModel::commitControlValueToDbColumn: invalid value type!" );
+ m_xColumnUpdate->updateString( getString( aControlValue ) );
}
}
- m_aSaveValue = aControlValue;
+ catch(const Exception&)
+ {
+ return false;
+ }
}
+ m_aSaveValue = aControlValue;
return true;
}
diff --git a/forms/source/component/Pattern.cxx b/forms/source/component/Pattern.cxx
index 434bf27f7cfc..24e9ac10585d 100644
--- a/forms/source/component/Pattern.cxx
+++ b/forms/source/component/Pattern.cxx
@@ -126,33 +126,33 @@ bool OPatternModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
{
Any aNewValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) );
- if ( aNewValue != m_aLastKnownValue )
- {
- OUString sNewValue;
- aNewValue >>= sNewValue;
+ if ( aNewValue == m_aLastKnownValue )
+ return true;
- if ( !aNewValue.hasValue()
- || ( sNewValue.isEmpty() // an empty string
- && m_bEmptyIsNull // which should be interpreted as NULL
- )
- )
- {
- m_xColumnUpdate->updateNull();
- }
- else
- {
- OSL_ENSURE(m_pFormattedValue,
- "OPatternModel::commitControlValueToDbColumn: no value helper!");
- if (!m_pFormattedValue)
- return false;
+ OUString sNewValue;
+ aNewValue >>= sNewValue;
- if ( !m_pFormattedValue->setFormattedValue( sNewValue ) )
- return false;
- }
+ if ( !aNewValue.hasValue()
+ || ( sNewValue.isEmpty() // an empty string
+ && m_bEmptyIsNull // which should be interpreted as NULL
+ )
+ )
+ {
+ m_xColumnUpdate->updateNull();
+ }
+ else
+ {
+ OSL_ENSURE(m_pFormattedValue,
+ "OPatternModel::commitControlValueToDbColumn: no value helper!");
+ if (!m_pFormattedValue)
+ return false;
- m_aLastKnownValue = aNewValue;
+ if ( !m_pFormattedValue->setFormattedValue( sNewValue ) )
+ return false;
}
+ m_aLastKnownValue = aNewValue;
+
return true;
}
diff --git a/forms/source/component/Time.cxx b/forms/source/component/Time.cxx
index 24d4a0369a90..fffcbd5466ed 100644
--- a/forms/source/component/Time.cxx
+++ b/forms/source/component/Time.cxx
@@ -224,43 +224,43 @@ void OTimeModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm )
bool OTimeModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
{
Any aControlValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) );
- if ( aControlValue != m_aSaveValue )
+ if ( aControlValue == m_aSaveValue )
+ return true;
+
+ if ( !aControlValue.hasValue() )
+ m_xColumnUpdate->updateNull();
+ else
{
- if ( !aControlValue.hasValue() )
- m_xColumnUpdate->updateNull();
- else
+ try
{
- try
+ util::Time aTime;
+ if ( !( aControlValue >>= aTime ) )
{
- util::Time aTime;
- if ( !( aControlValue >>= aTime ) )
- {
- sal_Int64 nAsInt(0);
- aControlValue >>= nAsInt;
- aTime = DBTypeConversion::toTime(nAsInt);
- }
-
- if (!m_bDateTimeField)
- m_xColumnUpdate->updateTime(aTime);
- else
- {
- util::DateTime aDateTime = m_xColumn->getTimestamp();
- if (aDateTime.Year == 0 && aDateTime.Month == 0 && aDateTime.Day == 0)
- aDateTime = ::com::sun::star::util::DateTime(0,0,0,0,30,12,1899, false);
- aDateTime.NanoSeconds = aTime.NanoSeconds;
- aDateTime.Seconds = aTime.Seconds;
- aDateTime.Minutes = aTime.Minutes;
- aDateTime.Hours = aTime.Hours;
- m_xColumnUpdate->updateTimestamp(aDateTime);
- }
+ sal_Int64 nAsInt(0);
+ aControlValue >>= nAsInt;
+ aTime = DBTypeConversion::toTime(nAsInt);
}
- catch(const Exception&)
+
+ if (!m_bDateTimeField)
+ m_xColumnUpdate->updateTime(aTime);
+ else
{
- return false;
+ util::DateTime aDateTime = m_xColumn->getTimestamp();
+ if (aDateTime.Year == 0 && aDateTime.Month == 0 && aDateTime.Day == 0)
+ aDateTime = ::com::sun::star::util::DateTime(0,0,0,0,30,12,1899, false);
+ aDateTime.NanoSeconds = aTime.NanoSeconds;
+ aDateTime.Seconds = aTime.Seconds;
+ aDateTime.Minutes = aTime.Minutes;
+ aDateTime.Hours = aTime.Hours;
+ m_xColumnUpdate->updateTimestamp(aDateTime);
}
}
- m_aSaveValue = aControlValue;
+ catch(const Exception&)
+ {
+ return false;
+ }
}
+ m_aSaveValue = aControlValue;
return true;
}
diff --git a/forms/source/misc/limitedformats.cxx b/forms/source/misc/limitedformats.cxx
index f49b8617ff2c..b7a0d5abcbd6 100644
--- a/forms/source/misc/limitedformats.cxx
+++ b/forms/source/misc/limitedformats.cxx
@@ -271,70 +271,68 @@ namespace frm
{
OSL_ENSURE(m_xAggregate.is() && (-1 != m_nFormatEnumPropertyHandle), "OLimitedFormats::convertFormatKeyPropertyValue: not initialized!");
- if (m_xAggregate.is())
+ if (!m_xAggregate)
+ return false;
+
+ // the new format key to set
+ sal_Int32 nNewFormat = 0;
+ if (!(_rNewValue >>= nNewFormat))
+ throw IllegalArgumentException();
+
+ // get the old (enum) value from the aggregate
+ Any aEnumPropertyValue = m_xAggregate->getFastPropertyValue(m_nFormatEnumPropertyHandle);
+ sal_Int32 nOldEnumValue = -1;
+ ::cppu::enum2int(nOldEnumValue, aEnumPropertyValue);
+
+ // get the translation table
+ const FormatEntry* pFormats = lcl_getFormatTable(m_nTableId);
+
+ _rOldValue.clear();
+ _rConvertedValue.clear();
+
+ // look for the entry with the given format key
+ sal_Int32 nTablePosition = 0;
+ for ( ;
+ (nullptr != pFormats->pDescription) && (nNewFormat != pFormats->nKey);
+ ++pFormats, ++nTablePosition
+ )
{
- // the new format key to set
- sal_Int32 nNewFormat = 0;
- if (!(_rNewValue >>= nNewFormat))
- throw IllegalArgumentException();
-
- // get the old (enum) value from the aggregate
- Any aEnumPropertyValue = m_xAggregate->getFastPropertyValue(m_nFormatEnumPropertyHandle);
- sal_Int32 nOldEnumValue = -1;
- ::cppu::enum2int(nOldEnumValue, aEnumPropertyValue);
-
- // get the translation table
- const FormatEntry* pFormats = lcl_getFormatTable(m_nTableId);
-
- _rOldValue.clear();
- _rConvertedValue.clear();
-
- // look for the entry with the given format key
- sal_Int32 nTablePosition = 0;
- for ( ;
- (nullptr != pFormats->pDescription) && (nNewFormat != pFormats->nKey);
- ++pFormats, ++nTablePosition
- )
- {
- if (nTablePosition == nOldEnumValue)
- _rOldValue <<= pFormats->nKey;
- }
+ if (nTablePosition == nOldEnumValue)
+ _rOldValue <<= pFormats->nKey;
+ }
- bool bFoundIt = (nullptr != pFormats->pDescription);
- bool bModified = false;
- if (bFoundIt)
- {
- _rConvertedValue <<= static_cast<sal_Int16>(nTablePosition);
- bModified = nTablePosition != nOldEnumValue;
- }
+ bool bFoundIt = (nullptr != pFormats->pDescription);
+ bool bModified = false;
+ if (bFoundIt)
+ {
+ _rConvertedValue <<= static_cast<sal_Int16>(nTablePosition);
+ bModified = nTablePosition != nOldEnumValue;
+ }
- if (!_rOldValue.hasValue())
- { // did not reach the end of the table (means we found nNewFormat)
- // -> go to the end to ensure that _rOldValue is set
- while (pFormats->pDescription)
+ if (!_rOldValue.hasValue())
+ { // did not reach the end of the table (means we found nNewFormat)
+ // -> go to the end to ensure that _rOldValue is set
+ while (pFormats->pDescription)
+ {
+ if (nTablePosition == nOldEnumValue)
{
- if (nTablePosition == nOldEnumValue)
- {
- _rOldValue <<= pFormats->nKey;
- break;
- }
-
- ++pFormats;
- ++nTablePosition;
+ _rOldValue <<= pFormats->nKey;
+ break;
}
- }
- OSL_ENSURE(_rOldValue.hasValue(), "OLimitedFormats::convertFormatKeyPropertyValue: did not find the old enum value in the table!");
-
- if (!bFoundIt)
- { // somebody gave us a format which we can't translate
- throw IllegalArgumentException("This control supports only a very limited number of formats.", nullptr, 2);
+ ++pFormats;
+ ++nTablePosition;
}
+ }
+
+ OSL_ENSURE(_rOldValue.hasValue(), "OLimitedFormats::convertFormatKeyPropertyValue: did not find the old enum value in the table!");
- return bModified;
+ if (!bFoundIt)
+ { // somebody gave us a format which we can't translate
+ throw IllegalArgumentException("This control supports only a very limited number of formats.", nullptr, 2);
}
- return false;
+ return bModified;
}
diff --git a/forms/source/runtime/formoperations.cxx b/forms/source/runtime/formoperations.cxx
index e7c7d135f61a..ae40c527b4d6 100644
--- a/forms/source/runtime/formoperations.cxx
+++ b/forms/source/runtime/formoperations.cxx
@@ -430,26 +430,25 @@ namespace frm
// returns false if parent should *abort* (user pressed cancel)
bool checkConfirmation(bool &needConfirmation, bool &shouldCommit)
{
- if(needConfirmation)
+ if(!needConfirmation)
+ return true;
+ // TODO: shouldn't this be done with an interaction handler?
+ std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr,
+ VclMessageType::Question, VclButtonsType::YesNo,
+ ResourceManager::loadString(RID_STR_QUERY_SAVE_MODIFIED_ROW)));
+ xQueryBox->add_button(GetStandardText(StandardButtonType::Cancel), RET_CANCEL);
+ xQueryBox->set_default_response(RET_YES);
+
+ switch (xQueryBox->run())
{
- // TODO: shouldn't this be done with an interaction handler?
- std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr,
- VclMessageType::Question, VclButtonsType::YesNo,
- ResourceManager::loadString(RID_STR_QUERY_SAVE_MODIFIED_ROW)));
- xQueryBox->add_button(GetStandardText(StandardButtonType::Cancel), RET_CANCEL);
- xQueryBox->set_default_response(RET_YES);
-
- switch (xQueryBox->run())
- {
- case RET_NO:
- shouldCommit = false;
- [[fallthrough]]; // don't ask again!
- case RET_YES:
- needConfirmation = false;
- return true;
- case RET_CANCEL:
- return false;
- }
+ case RET_NO:
+ shouldCommit = false;
+ [[fallthrough]]; // don't ask again!
+ case RET_YES:
+ needConfirmation = false;
+ return true;
+ case RET_CANCEL:
+ return false;
}
return true;
}