summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-07-21 12:12:24 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-07-21 13:52:54 -0400
commit38272ba9157c35d882642634c4bf9da7007802cd (patch)
treef0d3aec7e338e203ca0ba75554766defba2a187d /chart2
parent059ce597b544f9eccd7f12a4218ab3631025d95d (diff)
Scope reduction by throwing early.
Change-Id: Ic0b7b69b8c4e57064b31ef62ddceaf6094ca9991
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/model/main/DataSeries.cxx49
1 files changed, 23 insertions, 26 deletions
diff --git a/chart2/source/model/main/DataSeries.cxx b/chart2/source/model/main/DataSeries.cxx
index f97f31035568..3189100fb80a 100644
--- a/chart2/source/model/main/DataSeries.cxx
+++ b/chart2/source/model/main/DataSeries.cxx
@@ -335,41 +335,38 @@ Reference< beans::XPropertySet >
::std::vector< Reference< chart2::data::XLabeledDataSequence > > aValuesSeries(
DataSeriesHelper::getAllDataSequencesByRole( aSequences , "values", true ) );
- if( !aValuesSeries.empty() )
+
+ if (aValuesSeries.empty())
+ throw lang::IndexOutOfBoundsException();
+
+ Reference< chart2::data::XDataSequence > xSeq( aValuesSeries.front()->getValues() );
+ if( 0 <= nIndex && nIndex < xSeq->getData().getLength() )
{
- Reference< chart2::data::XDataSequence > xSeq( aValuesSeries.front()->getValues() );
- if( 0 <= nIndex && nIndex < xSeq->getData().getLength() )
{
+ MutexGuard aGuard( GetMutex() );
+ tDataPointAttributeContainer::iterator aIt( m_aAttributedDataPoints.find( nIndex ) );
+ if( aIt != m_aAttributedDataPoints.end() )
+ xResult = (*aIt).second;
+ }
+ if( !xResult.is() )
+ {
+ Reference< beans::XPropertySet > xParentProperties;
+ Reference< util::XModifyListener > xModifyEventForwarder;
{
MutexGuard aGuard( GetMutex() );
- tDataPointAttributeContainer::iterator aIt( m_aAttributedDataPoints.find( nIndex ) );
- if( aIt != m_aAttributedDataPoints.end() )
- xResult = (*aIt).second;
+ xParentProperties = this;
+ xModifyEventForwarder = m_xModifyEventForwarder;
}
- if( !xResult.is() )
- {
- Reference< beans::XPropertySet > xParentProperties;
- Reference< util::XModifyListener > xModifyEventForwarder;
- {
- MutexGuard aGuard( GetMutex() );
- xParentProperties = this;
- xModifyEventForwarder = m_xModifyEventForwarder;
- }
- // create a new XPropertySet for this data point
- xResult.set( new DataPoint( xParentProperties ) );
- {
- MutexGuard aGuard( GetMutex() );
- m_aAttributedDataPoints[ nIndex ] = xResult;
- }
- ModifyListenerHelper::addListener( xResult, xModifyEventForwarder );
+ // create a new XPropertySet for this data point
+ xResult.set( new DataPoint( xParentProperties ) );
+ {
+ MutexGuard aGuard( GetMutex() );
+ m_aAttributedDataPoints[ nIndex ] = xResult;
}
+ ModifyListenerHelper::addListener( xResult, xModifyEventForwarder );
}
}
- else
- {
- throw lang::IndexOutOfBoundsException();
- }
return xResult;
}