summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorIngrid Halama <iha@openoffice.org>2010-05-28 16:13:48 +0200
committerIngrid Halama <iha@openoffice.org>2010-05-28 16:13:48 +0200
commit5347bfcf72ac68be94b565f760210463308a0cb4 (patch)
tree3644855d35f18c8634e8254dc2a4fa84ac6cfac5 /chart2
parentd6616fb95ac01bd8767935ac7a5adcb489666936 (diff)
chart47: #i79087# prevent deadlock + prevent null pointer access
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/main/UndoGuard.cxx42
-rw-r--r--chart2/source/model/main/DataSeries.cxx173
-rw-r--r--chart2/source/model/main/Diagram.cxx171
-rw-r--r--chart2/source/model/main/Title.cxx16
4 files changed, 238 insertions, 164 deletions
diff --git a/chart2/source/controller/main/UndoGuard.cxx b/chart2/source/controller/main/UndoGuard.cxx
index 61bed4029db5..8513b6ba9093 100644
--- a/chart2/source/controller/main/UndoGuard.cxx
+++ b/chart2/source/controller/main/UndoGuard.cxx
@@ -55,7 +55,7 @@ UndoGuard_Base::~UndoGuard_Base()
void UndoGuard_Base::commitAction()
{
- if( !m_bActionPosted )
+ if( !m_bActionPosted && m_xUndoManager.is() )
m_xUndoManager->postAction( m_aUndoString );
m_bActionPosted = true;
}
@@ -67,12 +67,13 @@ UndoGuard::UndoGuard( const OUString& rUndoString
, const uno::Reference< frame::XModel > & xModel )
: UndoGuard_Base( rUndoString, xUndoManager, xModel )
{
- m_xUndoManager->preAction( m_xModel );
+ if( m_xUndoManager.is() )
+ m_xUndoManager->preAction( m_xModel );
}
UndoGuard::~UndoGuard()
{
- if( !m_bActionPosted )
+ if( !m_bActionPosted && m_xUndoManager.is() )
m_xUndoManager->cancelAction();
}
@@ -83,12 +84,13 @@ UndoLiveUpdateGuard::UndoLiveUpdateGuard( const OUString& rUndoString
, const uno::Reference< frame::XModel > & xModel )
: UndoGuard_Base( rUndoString, xUndoManager, xModel )
{
- m_xUndoManager->preAction( m_xModel );
+ if( m_xUndoManager.is() )
+ m_xUndoManager->preAction( m_xModel );
}
UndoLiveUpdateGuard::~UndoLiveUpdateGuard()
{
- if( !m_bActionPosted )
+ if( !m_bActionPosted && m_xUndoManager.is() )
m_xUndoManager->cancelActionWithUndo( m_xModel );
}
@@ -99,16 +101,19 @@ UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData( const OUString& rUndoS
, const uno::Reference< frame::XModel > & xModel )
: UndoGuard_Base( rUndoString, xUndoManager, xModel )
{
- Sequence< beans::PropertyValue > aArgs(1);
- aArgs[0] = beans::PropertyValue(
- OUString( RTL_CONSTASCII_USTRINGPARAM("WithData")), -1, uno::Any(),
- beans::PropertyState_DIRECT_VALUE );
- m_xUndoManager->preActionWithArguments( m_xModel, aArgs );
+ if( m_xUndoManager.is() )
+ {
+ Sequence< beans::PropertyValue > aArgs(1);
+ aArgs[0] = beans::PropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("WithData")), -1, uno::Any(),
+ beans::PropertyState_DIRECT_VALUE );
+ m_xUndoManager->preActionWithArguments( m_xModel, aArgs );
+ }
}
UndoLiveUpdateGuardWithData::~UndoLiveUpdateGuardWithData()
{
- if( !m_bActionPosted )
+ if( !m_bActionPosted && m_xUndoManager.is() )
m_xUndoManager->cancelActionWithUndo( m_xModel );
}
@@ -119,16 +124,19 @@ UndoGuardWithSelection::UndoGuardWithSelection( const rtl::OUString& rUndoString
, const uno::Reference< frame::XModel > & xModel )
: UndoGuard_Base( rUndoString, xUndoManager, xModel )
{
- Sequence< beans::PropertyValue > aArgs(1);
- aArgs[0] = beans::PropertyValue(
- OUString( RTL_CONSTASCII_USTRINGPARAM("WithSelection")), -1, uno::Any(),
- beans::PropertyState_DIRECT_VALUE );
- m_xUndoManager->preActionWithArguments( m_xModel, aArgs );
+ if( m_xUndoManager.is() )
+ {
+ Sequence< beans::PropertyValue > aArgs(1);
+ aArgs[0] = beans::PropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("WithSelection")), -1, uno::Any(),
+ beans::PropertyState_DIRECT_VALUE );
+ m_xUndoManager->preActionWithArguments( m_xModel, aArgs );
+ }
}
UndoGuardWithSelection::~UndoGuardWithSelection()
{
- if( !m_bActionPosted )
+ if( !m_bActionPosted && m_xUndoManager.is() )
m_xUndoManager->cancelAction();
}
diff --git a/chart2/source/model/main/DataSeries.cxx b/chart2/source/model/main/DataSeries.cxx
index 4faca33e936c..e14f244862b7 100644
--- a/chart2/source/model/main/DataSeries.cxx
+++ b/chart2/source/model/main/DataSeries.cxx
@@ -370,64 +370,76 @@ Reference< beans::XPropertySet >
throw (lang::IndexOutOfBoundsException,
uno::RuntimeException)
{
- Reference< beans::XPropertySet > aResult;
+ Reference< beans::XPropertySet > xResult;
- // /--
- MutexGuard aGuard( GetMutex() );
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences;
+ {
+ MutexGuard aGuard( GetMutex() );
+ aSequences = ContainerHelper::ContainerToSequence( m_aDataSequences );
+ }
- if( ! m_aDataSequences.empty() )
+ ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aValuesSeries(
+ DataSeriesHelper::getAllDataSequencesByRole( aSequences , C2U("values"), true ) );
+ if( !aValuesSeries.empty() )
{
- ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aValuesSeries(
- DataSeriesHelper::getAllDataSequencesByRole(
- ContainerHelper::ContainerToSequence( m_aDataSequences ),
- C2U("values"), true ));
- if( ! aValuesSeries.empty())
+ 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())
{
- tDataPointAttributeContainer::iterator aIt(
- m_aAttributedDataPoints.find( nIndex ));
-
- if( aIt == m_aAttributedDataPoints.end())
+ 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;
{
- // create a new XPropertySet for this data point
- aResult.set( new DataPoint( this ));
- ModifyListenerHelper::addListener( aResult, m_xModifyEventForwarder );
- m_aAttributedDataPoints[ nIndex ] = aResult;
+ MutexGuard aGuard( GetMutex() );
+ xParentProperties = this;
+ xModifyEventForwarder = m_xModifyEventForwarder;
}
- else
+
+ // create a new XPropertySet for this data point
+ xResult.set( new DataPoint( xParentProperties ) );
{
- aResult = (*aIt).second;
+ MutexGuard aGuard( GetMutex() );
+ m_aAttributedDataPoints[ nIndex ] = xResult;
}
+ ModifyListenerHelper::addListener( xResult, xModifyEventForwarder );
}
}
- else
- {
- throw lang::IndexOutOfBoundsException();
- }
}
else
{
throw lang::IndexOutOfBoundsException();
}
- return aResult;
- // \--
+ return xResult;
}
void SAL_CALL DataSeries::resetDataPoint( sal_Int32 nIndex )
throw (uno::RuntimeException)
{
- MutexGuard aGuard( GetMutex() );
- tDataPointAttributeContainer::iterator aIt( m_aAttributedDataPoints.find( nIndex ));
- if( aIt != m_aAttributedDataPoints.end())
+ Reference< beans::XPropertySet > xDataPointProp;
+ Reference< util::XModifyListener > xModifyEventForwarder;
+ {
+ MutexGuard aGuard( GetMutex() );
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ tDataPointAttributeContainer::iterator aIt( m_aAttributedDataPoints.find( nIndex ));
+ if( aIt != m_aAttributedDataPoints.end())
+ {
+ xDataPointProp = (*aIt).second;
+ m_aAttributedDataPoints.erase(aIt);
+ }
+
+ }
+ if( xDataPointProp.is() )
{
- Reference< beans::XPropertySet > xDataPointProp( (*aIt).second );
Reference< util::XModifyBroadcaster > xBroadcaster( xDataPointProp, uno::UNO_QUERY );
- if( xBroadcaster.is() && m_xModifyEventForwarder.is())
- xBroadcaster->removeModifyListener( m_xModifyEventForwarder );
- m_aAttributedDataPoints.erase(aIt);
+ if( xBroadcaster.is() && xModifyEventForwarder.is())
+ xBroadcaster->removeModifyListener( xModifyEventForwarder );
fireModifyEvent();
}
}
@@ -435,9 +447,15 @@ void SAL_CALL DataSeries::resetDataPoint( sal_Int32 nIndex )
void SAL_CALL DataSeries::resetAllDataPoints()
throw (uno::RuntimeException)
{
- MutexGuard aGuard( GetMutex() );
- ModifyListenerHelper::removeListenerFromAllMapElements( m_aAttributedDataPoints, m_xModifyEventForwarder );
- m_aAttributedDataPoints.clear();
+ tDataPointAttributeContainer aOldAttributedDataPoints;
+ Reference< util::XModifyListener > xModifyEventForwarder;
+ {
+ MutexGuard aGuard( GetMutex() );
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ std::swap( aOldAttributedDataPoints, m_aAttributedDataPoints );
+ }
+ ModifyListenerHelper::removeListenerFromAllMapElements( aOldAttributedDataPoints, xModifyEventForwarder );
+ aOldAttributedDataPoints.clear();
fireModifyEvent();
}
@@ -445,25 +463,31 @@ void SAL_CALL DataSeries::resetAllDataPoints()
void SAL_CALL DataSeries::setData( const uno::Sequence< Reference< chart2::data::XLabeledDataSequence > >& aData )
throw (uno::RuntimeException)
{
- // /--
- MutexGuard aGuard( GetMutex() );
- ModifyListenerHelper::removeListenerFromAllElements( m_aDataSequences, m_xModifyEventForwarder );
- EventListenerHelper::removeListenerFromAllElements( m_aDataSequences, this );
- m_aDataSequences = ContainerHelper::SequenceToVector( aData );
- EventListenerHelper::addListenerToAllElements( m_aDataSequences, this );
- ModifyListenerHelper::addListenerToAllElements( m_aDataSequences, m_xModifyEventForwarder );
+ tDataSequenceContainer aOldDataSequences;
+ tDataSequenceContainer aNewDataSequences;
+ Reference< util::XModifyListener > xModifyEventForwarder;
+ Reference< lang::XEventListener > xListener;
+ {
+ MutexGuard aGuard( GetMutex() );
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ xListener = this;
+ std::swap( aOldDataSequences, m_aDataSequences );
+ aNewDataSequences = ContainerHelper::SequenceToVector( aData );
+ m_aDataSequences = aNewDataSequences;
+ }
+ ModifyListenerHelper::removeListenerFromAllElements( aOldDataSequences, xModifyEventForwarder );
+ EventListenerHelper::removeListenerFromAllElements( aOldDataSequences, xListener );
+ EventListenerHelper::addListenerToAllElements( aNewDataSequences, xListener );
+ ModifyListenerHelper::addListenerToAllElements( aNewDataSequences, xModifyEventForwarder );
fireModifyEvent();
- // \--
}
// ____ XDataSource ____
Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL DataSeries::getDataSequences()
throw (uno::RuntimeException)
{
- // /--
MutexGuard aGuard( GetMutex() );
return ContainerHelper::ContainerToSequence( m_aDataSequences );
- // \--
}
@@ -473,12 +497,16 @@ void SAL_CALL DataSeries::addRegressionCurve(
throw (lang::IllegalArgumentException,
uno::RuntimeException)
{
- if( ::std::find( m_aRegressionCurves.begin(), m_aRegressionCurves.end(), xRegressionCurve )
- != m_aRegressionCurves.end())
- throw lang::IllegalArgumentException();
-
- m_aRegressionCurves.push_back( xRegressionCurve );
- ModifyListenerHelper::addListener( xRegressionCurve, m_xModifyEventForwarder );
+ Reference< util::XModifyListener > xModifyEventForwarder;
+ {
+ MutexGuard aGuard( GetMutex() );
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ if( ::std::find( m_aRegressionCurves.begin(), m_aRegressionCurves.end(), xRegressionCurve )
+ != m_aRegressionCurves.end())
+ throw lang::IllegalArgumentException();
+ m_aRegressionCurves.push_back( xRegressionCurve );
+ }
+ ModifyListenerHelper::addListener( xRegressionCurve, xModifyEventForwarder );
fireModifyEvent();
}
@@ -487,25 +515,30 @@ void SAL_CALL DataSeries::removeRegressionCurve(
throw (container::NoSuchElementException,
uno::RuntimeException)
{
- if( ! xRegressionCurve.is())
+ if( !xRegressionCurve.is() )
throw container::NoSuchElementException();
- tRegressionCurveContainerType::iterator aIt(
+ Reference< util::XModifyListener > xModifyEventForwarder;
+ {
+ MutexGuard aGuard( GetMutex() );
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ tRegressionCurveContainerType::iterator aIt(
::std::find( m_aRegressionCurves.begin(), m_aRegressionCurves.end(), xRegressionCurve ) );
+ if( aIt == m_aRegressionCurves.end())
+ throw container::NoSuchElementException(
+ C2U( "The given regression curve is no element of this series" ),
+ static_cast< uno::XWeak * >( this ));
+ m_aRegressionCurves.erase( aIt );
+ }
- if( aIt == m_aRegressionCurves.end())
- throw container::NoSuchElementException(
- C2U( "The given regression curve is no element of this series" ),
- static_cast< uno::XWeak * >( this ));
-
- ModifyListenerHelper::removeListener( xRegressionCurve, m_xModifyEventForwarder );
- m_aRegressionCurves.erase( aIt );
+ ModifyListenerHelper::removeListener( xRegressionCurve, xModifyEventForwarder );
fireModifyEvent();
}
uno::Sequence< uno::Reference< chart2::XRegressionCurve > > SAL_CALL DataSeries::getRegressionCurves()
throw (uno::RuntimeException)
{
+ MutexGuard aGuard( GetMutex() );
return ContainerHelper::ContainerToSequence( m_aRegressionCurves );
}
@@ -513,10 +546,18 @@ void SAL_CALL DataSeries::setRegressionCurves(
const Sequence< Reference< chart2::XRegressionCurve > >& aRegressionCurves )
throw (uno::RuntimeException)
{
- ModifyListenerHelper::removeListenerFromAllElements( m_aRegressionCurves, m_xModifyEventForwarder );
- m_aRegressionCurves.clear();
- for( sal_Int32 i=0; i<aRegressionCurves.getLength(); ++i )
- addRegressionCurve( aRegressionCurves[i] );
+ tRegressionCurveContainerType aOldCurves;
+ tRegressionCurveContainerType aNewCurves( ContainerHelper::SequenceToVector( aRegressionCurves ) );
+ Reference< util::XModifyListener > xModifyEventForwarder;
+ {
+ MutexGuard aGuard( GetMutex() );
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ std::swap( aOldCurves, m_aRegressionCurves );
+ m_aRegressionCurves = aNewCurves;
+ }
+ ModifyListenerHelper::removeListenerFromAllElements( aOldCurves, xModifyEventForwarder );
+ ModifyListenerHelper::addListenerToAllElements( aNewCurves, xModifyEventForwarder );
+ fireModifyEvent();
}
// ____ XModifyBroadcaster ____
diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx
index f74764c398ef..467e0feba5b4 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -300,72 +300,91 @@ Diagram::~Diagram()
uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getWall()
throw (uno::RuntimeException)
{
- // /--
- MutexGuard aGuard( GetMutex() );
- if( ! m_xWall.is())
+ uno::Reference< beans::XPropertySet > xRet;
+ bool bAddListener = false;
{
- m_xWall.set( new Wall());
- ModifyListenerHelper::addListener( m_xWall, m_xModifyEventForwarder );
+ MutexGuard aGuard( GetMutex() );
+ if( !m_xWall.is() )
+ {
+ m_xWall.set( new Wall() );
+ bAddListener = true;
+ }
+ xRet = m_xWall;
}
- return m_xWall;
- // \--
+ if(bAddListener)
+ ModifyListenerHelper::addListener( xRet, m_xModifyEventForwarder );
+ return xRet;
}
uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getFloor()
throw (uno::RuntimeException)
{
- // /--
- MutexGuard aGuard( GetMutex() );
- if( ! m_xFloor.is())
+ uno::Reference< beans::XPropertySet > xRet;
+ bool bAddListener = false;
{
- m_xFloor.set( new Wall());
- ModifyListenerHelper::addListener( m_xFloor, m_xModifyEventForwarder );
+ MutexGuard aGuard( GetMutex() );
+ if( !m_xFloor.is() )
+ {
+ m_xFloor.set( new Wall() );
+ bAddListener = true;
+ }
+ xRet = m_xFloor;
}
- return m_xFloor;
- // \--
+ if(bAddListener)
+ ModifyListenerHelper::addListener( xRet, m_xModifyEventForwarder );
+ return xRet;
}
uno::Reference< chart2::XLegend > SAL_CALL Diagram::getLegend()
throw (uno::RuntimeException)
{
- // /--
MutexGuard aGuard( GetMutex() );
return m_xLegend;
- // \--
}
-void SAL_CALL Diagram::setLegend( const uno::Reference< chart2::XLegend >& xLegend )
+void SAL_CALL Diagram::setLegend( const uno::Reference< chart2::XLegend >& xNewLegend )
throw (uno::RuntimeException)
{
- // /--
- ::osl::ClearableMutexGuard aGuard( GetMutex() );
- if( xLegend != m_xLegend )
+ Reference< chart2::XLegend > xOldLegend;
{
- if( m_xLegend.is())
- ModifyListenerHelper::removeListener( m_xLegend, m_xModifyEventForwarder );
- m_xLegend = xLegend;
- if( m_xLegend.is())
- ModifyListenerHelper::addListener( m_xLegend, m_xModifyEventForwarder );
- aGuard.clear();
- // \--
- fireModifyEvent();
+ MutexGuard aGuard( GetMutex() );
+ if( m_xLegend == xNewLegend )
+ return;
+ xOldLegend = m_xLegend;
+ m_xLegend = xNewLegend;
}
+ if( xOldLegend.is())
+ ModifyListenerHelper::removeListener( xOldLegend, m_xModifyEventForwarder );
+ if( xNewLegend.is())
+ ModifyListenerHelper::addListener( xNewLegend, m_xModifyEventForwarder );
+ fireModifyEvent();
}
Reference< chart2::XColorScheme > SAL_CALL Diagram::getDefaultColorScheme()
throw (uno::RuntimeException)
{
- if( ! m_xColorScheme.is())
+ Reference< chart2::XColorScheme > xRet;
+ {
+ MutexGuard aGuard( GetMutex() );
+ xRet = m_xColorScheme;
+ }
+
+ if( !xRet.is())
{
- m_xColorScheme.set( createConfigColorScheme( m_xContext ));
+ xRet.set( createConfigColorScheme( m_xContext ));
+ MutexGuard aGuard( GetMutex() );
+ m_xColorScheme = xRet;
}
- return m_xColorScheme;
+ return xRet;
}
void SAL_CALL Diagram::setDefaultColorScheme( const Reference< chart2::XColorScheme >& xColorScheme )
throw (uno::RuntimeException)
{
- m_xColorScheme.set( xColorScheme );
+ {
+ MutexGuard aGuard( GetMutex() );
+ m_xColorScheme.set( xColorScheme );
+ }
fireModifyEvent();
}
@@ -373,27 +392,26 @@ void SAL_CALL Diagram::setDefaultColorScheme( const Reference< chart2::XColorSch
uno::Reference< chart2::XTitle > SAL_CALL Diagram::getTitleObject()
throw (uno::RuntimeException)
{
- // /--
MutexGuard aGuard( GetMutex() );
return m_xTitle;
- // \--
}
-void SAL_CALL Diagram::setTitleObject( const uno::Reference< chart2::XTitle >& Title )
+void SAL_CALL Diagram::setTitleObject( const uno::Reference< chart2::XTitle >& xNewTitle )
throw (uno::RuntimeException)
{
- // /--
- ::osl::ClearableMutexGuard aGuard( GetMutex() );
-
- if( m_xTitle != Title )
+ Reference< chart2::XTitle > xOldTitle;
{
- ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
- m_xTitle = Title;
- ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder );
- // \--
- aGuard.clear();
- fireModifyEvent();
+ MutexGuard aGuard( GetMutex() );
+ if( m_xTitle == xNewTitle )
+ return;
+ xOldTitle = m_xTitle;
+ m_xTitle = xNewTitle;
}
+ if( xOldTitle.is())
+ ModifyListenerHelper::removeListener( xOldTitle, m_xModifyEventForwarder );
+ if( xNewTitle.is())
+ ModifyListenerHelper::addListener( xNewTitle, m_xModifyEventForwarder );
+ fireModifyEvent();
}
// ____ X3DDefaultSetter ____
@@ -421,18 +439,19 @@ void SAL_CALL Diagram::addCoordinateSystem(
throw (lang::IllegalArgumentException,
uno::RuntimeException)
{
- if( ::std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys )
- != m_aCoordSystems.end())
- throw lang::IllegalArgumentException();
-
- if( m_aCoordSystems.size()>=1 )
{
- OSL_ENSURE( false, "more than one coordinatesystem is not supported yet by the fileformat" );
- return;
- }
-
- m_aCoordSystems.push_back( aCoordSys );
+ MutexGuard aGuard( GetMutex() );
+ if( ::std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys )
+ != m_aCoordSystems.end())
+ throw lang::IllegalArgumentException();
+ if( m_aCoordSystems.size()>=1 )
+ {
+ OSL_ENSURE( false, "more than one coordinatesystem is not supported yet by the fileformat" );
+ return;
+ }
+ m_aCoordSystems.push_back( aCoordSys );
+ }
ModifyListenerHelper::addListener( aCoordSys, m_xModifyEventForwarder );
fireModifyEvent();
}
@@ -442,15 +461,16 @@ void SAL_CALL Diagram::removeCoordinateSystem(
throw (container::NoSuchElementException,
uno::RuntimeException)
{
- ::std::vector< uno::Reference< chart2::XCoordinateSystem > >::iterator
- aIt( ::std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys ));
- if( aIt == m_aCoordSystems.end())
- throw container::NoSuchElementException(
- C2U( "The given coordinate-system is no element of the container" ),
- static_cast< uno::XWeak * >( this ));
-
- m_aCoordSystems.erase( aIt );
-
+ {
+ MutexGuard aGuard( GetMutex() );
+ ::std::vector< uno::Reference< chart2::XCoordinateSystem > >::iterator
+ aIt( ::std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys ));
+ if( aIt == m_aCoordSystems.end())
+ throw container::NoSuchElementException(
+ C2U( "The given coordinate-system is no element of the container" ),
+ static_cast< uno::XWeak * >( this ));
+ m_aCoordSystems.erase( aIt );
+ }
ModifyListenerHelper::removeListener( aCoordSys, m_xModifyEventForwarder );
fireModifyEvent();
}
@@ -458,6 +478,7 @@ void SAL_CALL Diagram::removeCoordinateSystem(
uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > SAL_CALL Diagram::getCoordinateSystems()
throw (uno::RuntimeException)
{
+ MutexGuard aGuard( GetMutex() );
return ContainerHelper::ContainerToSequence( m_aCoordSystems );
}
@@ -466,17 +487,20 @@ void SAL_CALL Diagram::setCoordinateSystems(
throw (lang::IllegalArgumentException,
uno::RuntimeException)
{
- Sequence< Reference< chart2::XCoordinateSystem > > aNew(aCoordinateSystems);
-
- if( aNew.getLength()>1 )
+ tCoordinateSystemContainerType aNew;
+ tCoordinateSystemContainerType aOld;
+ if( aCoordinateSystems.getLength()>0 )
{
- OSL_ENSURE( false, "more than one coordinatesystem is not supported yet by the fileformat" );
- aNew.realloc(1);
+ OSL_ENSURE( aCoordinateSystems.getLength()<=1, "more than one coordinatesystem is not supported yet by the fileformat" );
+ aNew.push_back( aCoordinateSystems[0] );
}
-
- ModifyListenerHelper::removeListenerFromAllElements( m_aCoordSystems, m_xModifyEventForwarder );
- m_aCoordSystems = ContainerHelper::SequenceToVector( aNew );
- ModifyListenerHelper::addListenerToAllElements( m_aCoordSystems, m_xModifyEventForwarder );
+ {
+ MutexGuard aGuard( GetMutex() );
+ std::swap( aOld, m_aCoordSystems );
+ m_aCoordSystems = aNew;
+ }
+ ModifyListenerHelper::removeListenerFromAllElements( aOld, m_xModifyEventForwarder );
+ ModifyListenerHelper::addListenerToAllElements( aNew, m_xModifyEventForwarder );
fireModifyEvent();
}
@@ -484,6 +508,7 @@ void SAL_CALL Diagram::setCoordinateSystems(
Reference< util::XCloneable > SAL_CALL Diagram::createClone()
throw (uno::RuntimeException)
{
+ MutexGuard aGuard( GetMutex() );
return Reference< util::XCloneable >( new Diagram( *this ));
}
diff --git a/chart2/source/model/main/Title.cxx b/chart2/source/model/main/Title.cxx
index 8b3235636964..d7c5691d160d 100644
--- a/chart2/source/model/main/Title.cxx
+++ b/chart2/source/model/main/Title.cxx
@@ -256,24 +256,24 @@ uno::Reference< util::XCloneable > SAL_CALL Title::createClone()
uno::Sequence< uno::Reference< chart2::XFormattedString > > SAL_CALL Title::getText()
throw (uno::RuntimeException)
{
- // /--
MutexGuard aGuard( GetMutex() );
return m_aStrings;
- // \--
}
-void SAL_CALL Title::setText( const uno::Sequence< uno::Reference< chart2::XFormattedString > >& Strings )
+void SAL_CALL Title::setText( const uno::Sequence< uno::Reference< chart2::XFormattedString > >& rNewStrings )
throw (uno::RuntimeException)
{
+ uno::Sequence< uno::Reference< chart2::XFormattedString > > aOldStrings;
{
MutexGuard aGuard( GetMutex() );
- ModifyListenerHelper::removeListenerFromAllElements(
- ContainerHelper::SequenceToVector( m_aStrings ), m_xModifyEventForwarder );
- m_aStrings = Strings;
- ModifyListenerHelper::addListenerToAllElements(
- ContainerHelper::SequenceToVector( m_aStrings ), m_xModifyEventForwarder );
+ std::swap( m_aStrings, aOldStrings );
+ m_aStrings = rNewStrings;
}
//don't keep the mutex locked while calling out
+ ModifyListenerHelper::removeListenerFromAllElements(
+ ContainerHelper::SequenceToVector( aOldStrings ), m_xModifyEventForwarder );
+ ModifyListenerHelper::addListenerToAllElements(
+ ContainerHelper::SequenceToVector( rNewStrings ), m_xModifyEventForwarder );
fireModifyEvent();
}