diff -x .svn -Nur old/comphelper/inc/comphelper/embeddedobjectcontainer.hxx new/comphelper/inc/comphelper/embeddedobjectcontainer.hxx --- old/comphelper/inc/comphelper/embeddedobjectcontainer.hxx 2012-06-11 10:56:09.541327700 +0800 +++ new/comphelper/inc/comphelper/embeddedobjectcontainer.hxx 2012-06-11 10:26:12.214067300 +0800 @@ -129,8 +129,9 @@ sal_Bool MoveEmbeddedObject( EmbeddedObjectContainer& rSrc, const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >&, ::rtl::OUString& ); // remove an embedded object from the container and from the storage; if object can't be closed - sal_Bool RemoveEmbeddedObject( const ::rtl::OUString& rName, sal_Bool bClose = sal_True ); - sal_Bool RemoveEmbeddedObject( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >&, sal_Bool bClose = sal_True ); + // #i119941, bKeepToTempStorage: use to specify whether store the removed object to temporary storage + sal_Bool RemoveEmbeddedObject( const ::rtl::OUString& rName, sal_Bool bClose = sal_True, sal_Bool bKeepToTempStorage = sal_True ); + sal_Bool RemoveEmbeddedObject( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >&, sal_Bool bClose = sal_True, sal_Bool bKeepToTempStorage = sal_True ); // close and remove an embedded object from the container without removing it from the storage sal_Bool CloseEmbeddedObject( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >& ); diff -x .svn -Nur old/comphelper/source/container/embeddedobjectcontainer.cxx new/comphelper/source/container/embeddedobjectcontainer.cxx --- old/comphelper/source/container/embeddedobjectcontainer.cxx 2012-06-11 10:57:25.105762100 +0800 +++ new/comphelper/source/container/embeddedobjectcontainer.cxx 2012-06-11 10:51:18.111992300 +0800 @@ -948,13 +948,14 @@ return bRet; } -sal_Bool EmbeddedObjectContainer::RemoveEmbeddedObject( const ::rtl::OUString& rName, sal_Bool bClose ) +// #i119941, bKeepToTempStorage: use to specify whether store the removed object to temporary storage +sal_Bool EmbeddedObjectContainer::RemoveEmbeddedObject( const ::rtl::OUString& rName, sal_Bool bClose, sal_Bool bKeepToTempStorage ) { RTL_LOGFILE_CONTEXT( aLog, "comphelper (mv76033) comphelper::EmbeddedObjectContainer::RemoveEmbeddedObject( Name )" ); uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObject( rName ); if ( xObj.is() ) - return RemoveEmbeddedObject( xObj, bClose ); + return RemoveEmbeddedObject( xObj, bClose, bKeepToTempStorage ); else return sal_False; } @@ -1012,7 +1013,8 @@ return sal_False; } -sal_Bool EmbeddedObjectContainer::RemoveEmbeddedObject( const uno::Reference < embed::XEmbeddedObject >& xObj, sal_Bool bClose ) +// #i119941, bKeepToTempStorage: use to specify whether store the removed object to temporary storage +sal_Bool EmbeddedObjectContainer::RemoveEmbeddedObject( const uno::Reference < embed::XEmbeddedObject >& xObj, sal_Bool bClose, sal_Bool bKeepToTempStorage ) { RTL_LOGFILE_CONTEXT( aLog, "comphelper (mv76033) comphelper::EmbeddedObjectContainer::RemoveEmbeddedObject( Object )" ); @@ -1049,7 +1051,8 @@ // somebody still needs the object, so we must assign a temporary persistence try { - if ( xPersist.is() ) +// if ( xPersist.is() ) + if ( xPersist.is() && bKeepToTempStorage ) // #i119941 { /* //TODO/LATER: needs storage handling! Why not letting the object do it?! @@ -1128,7 +1131,8 @@ } OSL_ENSURE( bFound, "Object not found for removal!" ); - if ( xPersist.is() ) +// if ( xPersist.is() ) + if ( xPersist.is() && bKeepToTempStorage ) // #i119941 { // remove replacement image (if there is one) RemoveGraphicStream( aName ); diff -x .svn -Nur old/writ/source/core/ole/ndole.cxx new/writ/source/core/ole/ndole.cxx --- old/writ/source/core/ole/ndole.cxx 2012-06-11 10:58:28.201127300 +0800 +++ new/writ/source/core/ole/ndole.cxx 2012-06-11 10:47:18.137099100 +0800 @@ -31,6 +31,7 @@ #include #include #include +#include // #i119941 #include #include @@ -355,7 +356,28 @@ if ( xChild.is() ) xChild->setParent( 0 ); - pCnt->RemoveEmbeddedObject( aOLEObj.aName, sal_False ); + /* #i119941: When cut or move the chart, SwUndoFlyBase::DelFly will call SaveSection to store the comtent to strorage. + In this step, chart filter functions will be called. And chart filter will call chart core functions to create the chart again. + Then chart core function will call the class ExplicitCategoryProvider to create data source. + In this step, when SW data source provider create the data source, it will create a new SwFlyFrm. + But later in SwUndoFlyBase::DelFly, it will clear anchor related attributes of SwFlyFrm. Then finally null pointer occur. + Resolution: + In pCnt->RemoveEmbeddedObject in SaveSection process of table chart, only remove the object from the object container, + without removing it's storage and graphic stream. The chart already removed from formatter.> */ + sal_Bool bChartWithInternalProvider = sal_False; + sal_Bool bKeepObjectToTempStorage = sal_True; + uno::Reference < embed::XEmbeddedObject > xIP = GetOLEObj().GetOleRef(); + if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) ) + { + uno::Reference< chart2::XChartDocument > xChart( xIP->getComponent(), UNO_QUERY ); + if ( xChart.is() && xChart->hasInternalDataProvider() ) + bChartWithInternalProvider = sal_True; + } + + if ( IsChart() && sChartTblName.Len() && !bChartWithInternalProvider ) + bKeepObjectToTempStorage = sal_False; + pCnt->RemoveEmbeddedObject( aOLEObj.aName, sal_False, bKeepObjectToTempStorage ); + // modify end // TODO/LATER: aOLEObj.aName has no meaning here, since the undo container contains the object // by different name, in future it might makes sence that the name is transported here.