sc/source/ui/drawfunc/fuins2.cxx | 546 +++++++++++++++++++-------------------- sfx2/source/doc/objmisc.cxx | 29 +- 2 files changed, 291 insertions(+), 284 deletions(-)
New commits: commit ee5cae3da45dec3c17bbff849cbbfd5363984bd0 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Mon May 12 17:19:17 2014 -0400 Let's not forget to free the SdrOle2Obj instance here. When the chart creation wizard is cancelled. Change-Id: I5eb2b2719ce3ec1eaa180a8c7193df23794dc03d diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx index ddc961b..9c7b192 100644 --- a/sc/source/ui/drawfunc/fuins2.cxx +++ b/sc/source/ui/drawfunc/fuins2.cxx @@ -746,7 +746,12 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* OSL_ASSERT( pPage ); OSL_ASSERT( pObj ); if( pPage ) - pPage->RemoveObject( pObj->GetOrdNum()); + { + // Remove the OLE2 object from the sdr page. + SdrObject* pRemoved = pPage->RemoveObject(pObj->GetOrdNum()); + OSL_ASSERT(pRemoved == pObj); + SdrObject::Free(pRemoved); // Don't forget to free it. + } bAddUndo = false; // don't create the undo action for inserting commit 13c9628c2641a44267e6681995b3261e4ac6d809 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Mon May 12 17:16:30 2014 -0400 Bail out early if it's not a chart module. Change-Id: I2e487b79671153786f02f12b4aac2b32476585e4 diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx index 1505b28..ddc961b 100644 --- a/sc/source/ui/drawfunc/fuins2.cxx +++ b/sc/source/ui/drawfunc/fuins2.cxx @@ -439,346 +439,345 @@ FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* if( ! rReq.IsAPI() ) rReq.Done(); - if( SvtModuleOptions().IsChart() ) - { + if (!SvtModuleOptions().IsChart()) + return; - // BM/IHA -- + // BM/IHA -- - // get range - OUString aRangeString; - ScRange aPositionRange; // cell range for chart positioning - ScMarkData aMark = pViewSh->GetViewData()->GetMarkData(); - if( pReqArgs ) - { - const SfxPoolItem* pItem; - if( pReqArgs->HasItem( FN_PARAM_5, &pItem ) ) - aRangeString = OUString( ((const SfxStringItem*)pItem)->GetValue()); + // get range + OUString aRangeString; + ScRange aPositionRange; // cell range for chart positioning + ScMarkData aMark = pViewSh->GetViewData()->GetMarkData(); + if( pReqArgs ) + { + const SfxPoolItem* pItem; + if( pReqArgs->HasItem( FN_PARAM_5, &pItem ) ) + aRangeString = OUString( ((const SfxStringItem*)pItem)->GetValue()); - aPositionRange = pViewSh->GetViewData()->GetCurPos(); + aPositionRange = pViewSh->GetViewData()->GetCurPos(); + } + else + { + bool bAutomaticMark = false; + if ( !aMark.IsMarked() && !aMark.IsMultiMarked() ) + { + pViewSh->GetViewData()->GetView()->MarkDataArea( true ); + bAutomaticMark = true; } - else + + ScMarkData aMultiMark( aMark ); + aMultiMark.MarkToMulti(); + + ScRangeList aRanges; + aMultiMark.FillRangeListWithMarks( &aRanges, false ); + OUString aStr; + ScDocument* pDocument = pViewSh->GetViewData()->GetDocument(); + aRanges.Format( aStr, SCR_ABS_3D, pDocument, pDocument->GetAddressConvention() ); + aRangeString = aStr; + + // get "total" range for positioning + if ( !aRanges.empty() ) { - bool bAutomaticMark = false; - if ( !aMark.IsMarked() && !aMark.IsMultiMarked() ) + aPositionRange = *aRanges[ 0 ]; + for ( size_t i = 1, nCount = aRanges.size(); i < nCount; ++i ) { - pViewSh->GetViewData()->GetView()->MarkDataArea( true ); - bAutomaticMark = true; + aPositionRange.ExtendTo( *aRanges[ i ] ); } + } - ScMarkData aMultiMark( aMark ); - aMultiMark.MarkToMulti(); + if(bAutomaticMark) + pViewSh->GetViewData()->GetView()->Unmark(); + } - ScRangeList aRanges; - aMultiMark.FillRangeListWithMarks( &aRanges, false ); - OUString aStr; - ScDocument* pDocument = pViewSh->GetViewData()->GetDocument(); - aRanges.Format( aStr, SCR_ABS_3D, pDocument, pDocument->GetAddressConvention() ); - aRangeString = aStr; - // get "total" range for positioning - if ( !aRanges.empty() ) - { - aPositionRange = *aRanges[ 0 ]; - for ( size_t i = 1, nCount = aRanges.size(); i < nCount; ++i ) - { - aPositionRange.ExtendTo( *aRanges[ i ] ); - } - } + // adapted old code + pView->UnmarkAll(); - if(bAutomaticMark) - pViewSh->GetViewData()->GetView()->Unmark(); - } + OUString aName; + const sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; + uno::Reference < embed::XEmbeddedObject > xObj = + pViewShell->GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID_60 ).GetByteSequence(), aName ); - // adapted old code - pView->UnmarkAll(); + uno::Reference< ::com::sun::star::chart2::data::XDataReceiver > xReceiver; + uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY ); + if( xCompSupp.is()) + xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY ); - OUString aName; - const sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; + // lock the model to suppress any internal updates + uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY ); + if( xChartModel.is() ) + xChartModel->lockControllers(); - uno::Reference < embed::XEmbeddedObject > xObj = - pViewShell->GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID_60 ).GetByteSequence(), aName ); + ScRangeListRef aDummy; + Rectangle aMarkDest; + SCTAB nMarkTab; + bool bDrawRect = pViewShell->GetChartArea( aDummy, aMarkDest, nMarkTab ); - uno::Reference< ::com::sun::star::chart2::data::XDataReceiver > xReceiver; - uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY ); - if( xCompSupp.is()) - xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY ); + // Objekt-Groesse + awt::Size aSz = xObj->getVisualAreaSize( nAspect ); + Size aSize( aSz.Width, aSz.Height ); - // lock the model to suppress any internal updates - uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY ); - if( xChartModel.is() ) - xChartModel->lockControllers(); + MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) ); - ScRangeListRef aDummy; - Rectangle aMarkDest; - SCTAB nMarkTab; - bool bDrawRect = pViewShell->GetChartArea( aDummy, aMarkDest, nMarkTab ); + bool bSizeCh = false; + if (bDrawRect && !aMarkDest.IsEmpty()) + { + aSize = aMarkDest.GetSize(); + bSizeCh = true; + } + if (aSize.Height() <= 0 || aSize.Width() <= 0) + { + aSize.Width() = 5000; + aSize.Height() = 5000; + bSizeCh = true; + } + if (bSizeCh) + { + aSize = Window::LogicToLogic( aSize, MapMode( MAP_100TH_MM ), MapMode( aMapUnit ) ); + aSz.Width = aSize.Width(); + aSz.Height = aSize.Height(); + xObj->setVisualAreaSize( nAspect, aSz ); + } - // Objekt-Groesse - awt::Size aSz = xObj->getVisualAreaSize( nAspect ); - Size aSize( aSz.Width, aSz.Height ); + ScViewData* pData = pViewSh->GetViewData(); + ScDocShell* pScDocSh = pData->GetDocShell(); + ScDocument* pScDoc = pScDocSh->GetDocument(); + bool bUndo (pScDoc->IsUndoEnabled()); + + Window* pParentWindow = pData->GetActiveWin(); + OpenGLWindow* pChildWindow = new OpenGLWindow(pParentWindow); + Size aWindowSize = pChildWindow->LogicToPixel( aSize, MapMode( MAP_100TH_MM ) ); + pChildWindow->SetSizePixel(aWindowSize); + pChildWindow->Show(); + uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider( xChartModel, uno::UNO_QUERY_THROW ); + sal_uInt64 nWindowPtr = reinterpret_cast<sal_uInt64>(pChildWindow); + x3DWindowProvider->setWindow(nWindowPtr); + ScGridWindow* pGridWindow = dynamic_cast<ScGridWindow*>(pParentWindow); + if(pGridWindow) + { + pGridWindow->AddChildWindow(pChildWindow); + } + else + SAL_WARN("sc", "not a grid window. You are in serious trouble"); - MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) ); + if( pReqArgs ) + { + const SfxPoolItem* pItem; + sal_uInt16 nToTable = 0; - bool bSizeCh = false; - if (bDrawRect && !aMarkDest.IsEmpty()) - { - aSize = aMarkDest.GetSize(); - bSizeCh = true; - } - if (aSize.Height() <= 0 || aSize.Width() <= 0) + if( pReqArgs->HasItem( FN_PARAM_4, &pItem ) ) { - aSize.Width() = 5000; - aSize.Height() = 5000; - bSizeCh = true; - } - if (bSizeCh) - { - aSize = Window::LogicToLogic( aSize, MapMode( MAP_100TH_MM ), MapMode( aMapUnit ) ); - aSz.Width = aSize.Width(); - aSz.Height = aSize.Height(); - xObj->setVisualAreaSize( nAspect, aSz ); - } + if ( pItem->ISA( SfxUInt16Item ) ) + nToTable = ((const SfxUInt16Item*)pItem)->GetValue(); + else if ( pItem->ISA( SfxBoolItem ) ) + { + // in der idl fuer Basic steht FN_PARAM_4 als SfxBoolItem + // -> wenn gesetzt, neue Tabelle, sonst aktuelle Tabelle - ScViewData* pData = pViewSh->GetViewData(); - ScDocShell* pScDocSh = pData->GetDocShell(); - ScDocument* pScDoc = pScDocSh->GetDocument(); - bool bUndo (pScDoc->IsUndoEnabled()); - - Window* pParentWindow = pData->GetActiveWin(); - OpenGLWindow* pChildWindow = new OpenGLWindow(pParentWindow); - Size aWindowSize = pChildWindow->LogicToPixel( aSize, MapMode( MAP_100TH_MM ) ); - pChildWindow->SetSizePixel(aWindowSize); - pChildWindow->Show(); - uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider( xChartModel, uno::UNO_QUERY_THROW ); - sal_uInt64 nWindowPtr = reinterpret_cast<sal_uInt64>(pChildWindow); - x3DWindowProvider->setWindow(nWindowPtr); - ScGridWindow* pGridWindow = dynamic_cast<ScGridWindow*>(pParentWindow); - if(pGridWindow) - { - pGridWindow->AddChildWindow(pChildWindow); + if ( ((const SfxBoolItem*)pItem)->GetValue() ) + nToTable = static_cast<sal_uInt16>(pScDoc->GetTableCount()); + else + nToTable = static_cast<sal_uInt16>(pData->GetTabNo()); + } } else - SAL_WARN("sc", "not a grid window. You are in serious trouble"); - - if( pReqArgs ) { - const SfxPoolItem* pItem; - sal_uInt16 nToTable = 0; + if (bDrawRect) + nToTable = static_cast<sal_uInt16>(nMarkTab); + rReq.AppendItem( SfxUInt16Item( FN_PARAM_4, nToTable ) ); + } - if( pReqArgs->HasItem( FN_PARAM_4, &pItem ) ) - { - if ( pItem->ISA( SfxUInt16Item ) ) - nToTable = ((const SfxUInt16Item*)pItem)->GetValue(); - else if ( pItem->ISA( SfxBoolItem ) ) - { - // in der idl fuer Basic steht FN_PARAM_4 als SfxBoolItem - // -> wenn gesetzt, neue Tabelle, sonst aktuelle Tabelle + // auf neue Tabelle ausgeben? + if ( nToTable == pScDoc->GetTableCount() ) + { + // dann los... + OUString aTabName; + SCTAB nNewTab = pScDoc->GetTableCount(); - if ( ((const SfxBoolItem*)pItem)->GetValue() ) - nToTable = static_cast<sal_uInt16>(pScDoc->GetTableCount()); - else - nToTable = static_cast<sal_uInt16>(pData->GetTabNo()); - } - } - else - { - if (bDrawRect) - nToTable = static_cast<sal_uInt16>(nMarkTab); - rReq.AppendItem( SfxUInt16Item( FN_PARAM_4, nToTable ) ); - } + pScDoc->CreateValidTabName( aTabName ); - // auf neue Tabelle ausgeben? - if ( nToTable == pScDoc->GetTableCount() ) + if ( pScDoc->InsertTab( nNewTab, aTabName ) ) { - // dann los... - OUString aTabName; - SCTAB nNewTab = pScDoc->GetTableCount(); + bool bAppend = true; - pScDoc->CreateValidTabName( aTabName ); - - if ( pScDoc->InsertTab( nNewTab, aTabName ) ) - { - bool bAppend = true; - - if (bUndo) - { - pScDocSh->GetUndoManager()->AddUndoAction( - new ScUndoInsertTab( pScDocSh, nNewTab, - bAppend, aTabName ) ); - } - - pScDocSh->Broadcast( ScTablesHint( SC_TAB_INSERTED, nNewTab ) ); - pViewSh->SetTabNo( nNewTab, true ); - pScDocSh->PostPaintExtras(); //! erst hinterher ??? - } - else + if (bUndo) { - OSL_FAIL( "Could not create new table :-/" ); + pScDocSh->GetUndoManager()->AddUndoAction( + new ScUndoInsertTab( pScDocSh, nNewTab, + bAppend, aTabName ) ); } + + pScDocSh->Broadcast( ScTablesHint( SC_TAB_INSERTED, nNewTab ) ); + pViewSh->SetTabNo( nNewTab, true ); + pScDocSh->PostPaintExtras(); //! erst hinterher ??? } - else if ( nToTable != pData->GetTabNo() ) + else { - pViewSh->SetTabNo( nToTable, true ); + OSL_FAIL( "Could not create new table :-/" ); } } + else if ( nToTable != pData->GetTabNo() ) + { + pViewSh->SetTabNo( nToTable, true ); + } + } - lcl_ChartInit( xObj, pData, aRangeString ); // set source range, auto-detect column/row headers + lcl_ChartInit( xObj, pData, aRangeString ); // set source range, auto-detect column/row headers - // Objekt-Position + // Objekt-Position - Point aStart; - if ( bDrawRect ) - aStart = aMarkDest.TopLeft(); // marked by hand - else - { - // get chart position (from window size and data range) - aStart = pViewSh->GetChartInsertPos( aSize, aPositionRange ); - } - pChildWindow->SetPosPixel(pChildWindow->LogicToPixel(aStart, MapMode(MAP_100TH_MM))); + Point aStart; + if ( bDrawRect ) + aStart = aMarkDest.TopLeft(); // marked by hand + else + { + // get chart position (from window size and data range) + aStart = pViewSh->GetChartInsertPos( aSize, aPositionRange ); + } + pChildWindow->SetPosPixel(pChildWindow->LogicToPixel(aStart, MapMode(MAP_100TH_MM))); - Rectangle aRect (aStart, aSize); - SdrOle2Obj* pObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aName, aRect); - SdrPageView* pPV = pView->GetSdrPageView(); + Rectangle aRect (aStart, aSize); + SdrOle2Obj* pObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aName, aRect); + SdrPageView* pPV = pView->GetSdrPageView(); - // #i121334# This call will change the chart's default background fill from white to transparent. - // Add here again if this is wanted (see task description for details) - // ChartHelper::AdaptDefaultsForChart( xObj ); + // #i121334# This call will change the chart's default background fill from white to transparent. + // Add here again if this is wanted (see task description for details) + // ChartHelper::AdaptDefaultsForChart( xObj ); // pView->InsertObjectAtView(pObj, *pPV);//this call leads to an immidiate redraw and asks the chart for a visual representation - // use the page instead of the view to insert, so no undo action is created yet - SdrPage* pInsPage = pPV->GetPage(); - pInsPage->InsertObject( pObj ); - pView->UnmarkAllObj(); - pView->MarkObj( pObj, pPV ); - bool bAddUndo = true; // add undo action later, unless the dialog is canceled + // use the page instead of the view to insert, so no undo action is created yet + SdrPage* pInsPage = pPV->GetPage(); + pInsPage->InsertObject( pObj ); + pView->UnmarkAllObj(); + pView->MarkObj( pObj, pPV ); + bool bAddUndo = true; // add undo action later, unless the dialog is canceled - if (rReq.IsAPI()) - { - if( xChartModel.is() ) - xChartModel->unlockControllers(); - } - else - { - //the controller will be unlocked by the dialog when the dialog is told to do so + if (rReq.IsAPI()) + { + if( xChartModel.is() ) + xChartModel->unlockControllers(); + } + else + { + //the controller will be unlocked by the dialog when the dialog is told to do so - // only activate object if not called via API (e.g. macro) - pViewShell->ActivateObject( (SdrOle2Obj*) pObj, SVVERB_SHOW ); + // only activate object if not called via API (e.g. macro) + pViewShell->ActivateObject( (SdrOle2Obj*) pObj, SVVERB_SHOW ); - //open wizard - //@todo get context from calc if that has one - uno::Reference< uno::XComponentContext > xContext( - ::cppu::defaultBootstrap_InitialComponentContext() ); - if(xContext.is()) + //open wizard + //@todo get context from calc if that has one + uno::Reference< uno::XComponentContext > xContext( + ::cppu::defaultBootstrap_InitialComponentContext() ); + if(xContext.is()) + { + uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); + if(xMCF.is()) { - uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); - if(xMCF.is()) + uno::Reference< ui::dialogs::XExecutableDialog > xDialog( + xMCF->createInstanceWithContext( + OUString("com.sun.star.comp.chart2.WizardDialog") + , xContext), uno::UNO_QUERY); + uno::Reference< lang::XInitialization > xInit( xDialog, uno::UNO_QUERY ); + if( xChartModel.is() && xInit.is() ) { - uno::Reference< ui::dialogs::XExecutableDialog > xDialog( - xMCF->createInstanceWithContext( - OUString("com.sun.star.comp.chart2.WizardDialog") - , xContext), uno::UNO_QUERY); - uno::Reference< lang::XInitialization > xInit( xDialog, uno::UNO_QUERY ); - if( xChartModel.is() && xInit.is() ) + uno::Reference< awt::XWindow > xDialogParentWindow(0); + // initialize dialog + uno::Sequence<uno::Any> aSeq(2); + uno::Any* pArray = aSeq.getArray(); + beans::PropertyValue aParam1; + aParam1.Name = "ParentWindow"; + aParam1.Value <<= uno::makeAny(xDialogParentWindow); + beans::PropertyValue aParam2; + aParam2.Name = "ChartModel"; + aParam2.Value <<= uno::makeAny(xChartModel); + pArray[0] <<= uno::makeAny(aParam1); + pArray[1] <<= uno::makeAny(aParam2); + xInit->initialize( aSeq ); + + // try to set the dialog's position so it doesn't hide the chart + uno::Reference < beans::XPropertySet > xDialogProps( xDialog, uno::UNO_QUERY ); + if ( xDialogProps.is() ) { - uno::Reference< awt::XWindow > xDialogParentWindow(0); - // initialize dialog - uno::Sequence<uno::Any> aSeq(2); - uno::Any* pArray = aSeq.getArray(); - beans::PropertyValue aParam1; - aParam1.Name = "ParentWindow"; - aParam1.Value <<= uno::makeAny(xDialogParentWindow); - beans::PropertyValue aParam2; - aParam2.Name = "ChartModel"; - aParam2.Value <<= uno::makeAny(xChartModel); - pArray[0] <<= uno::makeAny(aParam1); - pArray[1] <<= uno::makeAny(aParam2); - xInit->initialize( aSeq ); - - // try to set the dialog's position so it doesn't hide the chart - uno::Reference < beans::XPropertySet > xDialogProps( xDialog, uno::UNO_QUERY ); - if ( xDialogProps.is() ) + try { - try + //get dialog size: + awt::Size aDialogAWTSize; + if( xDialogProps->getPropertyValue("Size") + >>= aDialogAWTSize ) { - //get dialog size: - awt::Size aDialogAWTSize; - if( xDialogProps->getPropertyValue("Size") - >>= aDialogAWTSize ) + Size aDialogSize( aDialogAWTSize.Width, aDialogAWTSize.Height ); + if ( aDialogSize.Width() > 0 && aDialogSize.Height() > 0 ) { - Size aDialogSize( aDialogAWTSize.Width, aDialogAWTSize.Height ); - if ( aDialogSize.Width() > 0 && aDialogSize.Height() > 0 ) - { - //calculate and set new position - Point aDialogPos = pViewShell->GetChartDialogPos( aDialogSize, aRect ); - xDialogProps->setPropertyValue("Position", - uno::makeAny( awt::Point(aDialogPos.getX(),aDialogPos.getY()) ) ); - } + //calculate and set new position + Point aDialogPos = pViewShell->GetChartDialogPos( aDialogSize, aRect ); + xDialogProps->setPropertyValue("Position", + uno::makeAny( awt::Point(aDialogPos.getX(),aDialogPos.getY()) ) ); } - //tell the dialog to unlock controller - xDialogProps->setPropertyValue("UnlockControllersOnExecute", - uno::makeAny( sal_True ) ); - - } - catch( uno::Exception& ) - { - OSL_FAIL( "Chart wizard couldn't be positioned automatically\n" ); } - } + //tell the dialog to unlock controller + xDialogProps->setPropertyValue("UnlockControllersOnExecute", + uno::makeAny( sal_True ) ); - sal_Int16 nDialogRet = xDialog->execute(); - if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL ) + } + catch( uno::Exception& ) { - pGridWindow->DeleteChildWindow(pChildWindow); - // leave OLE inplace mode and unmark - OSL_ASSERT( pViewShell ); - OSL_ASSERT( pView ); - pViewShell->DeactivateOle(); - pView->UnmarkAll(); + OSL_FAIL( "Chart wizard couldn't be positioned automatically\n" ); + } + } - // old page view pointer is invalid after switching sheets - pPV = pView->GetSdrPageView(); + sal_Int16 nDialogRet = xDialog->execute(); + if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL ) + { + pGridWindow->DeleteChildWindow(pChildWindow); + // leave OLE inplace mode and unmark + OSL_ASSERT( pViewShell ); + OSL_ASSERT( pView ); + pViewShell->DeactivateOle(); + pView->UnmarkAll(); - // remove the chart - OSL_ASSERT( pPV ); - SdrPage * pPage( pPV->GetPage()); - OSL_ASSERT( pPage ); - OSL_ASSERT( pObj ); - if( pPage ) - pPage->RemoveObject( pObj->GetOrdNum()); + // old page view pointer is invalid after switching sheets + pPV = pView->GetSdrPageView(); - bAddUndo = false; // don't create the undo action for inserting + // remove the chart + OSL_ASSERT( pPV ); + SdrPage * pPage( pPV->GetPage()); + OSL_ASSERT( pPage ); + OSL_ASSERT( pObj ); + if( pPage ) + pPage->RemoveObject( pObj->GetOrdNum()); - // leave the draw shell - pViewShell->SetDrawShell( false ); + bAddUndo = false; // don't create the undo action for inserting - // reset marked cell area + // leave the draw shell + pViewShell->SetDrawShell( false ); - pViewSh->GetViewData()->GetViewShell()->SetMarkData(aMark); - } - else - { - OSL_ASSERT( nDialogRet == ui::dialogs::ExecutableDialogResults::OK ); - //@todo maybe move chart to different table - } + // reset marked cell area + + pViewSh->GetViewData()->GetViewShell()->SetMarkData(aMark); + } + else + { + OSL_ASSERT( nDialogRet == ui::dialogs::ExecutableDialogResults::OK ); + //@todo maybe move chart to different table } - uno::Reference< lang::XComponent > xComponent( xDialog, uno::UNO_QUERY ); - if( xComponent.is()) - xComponent->dispose(); } + uno::Reference< lang::XComponent > xComponent( xDialog, uno::UNO_QUERY ); + if( xComponent.is()) + xComponent->dispose(); } } + } - if ( bAddUndo ) - { - // add undo action the same way as in SdrEditView::InsertObjectAtView - // (using UndoActionHdl etc.) - pView->AddUndo(pDoc->GetSdrUndoFactory().CreateUndoNewObject(*pObj)); - } - - // BM/IHA -- + if ( bAddUndo ) + { + // add undo action the same way as in SdrEditView::InsertObjectAtView + // (using UndoActionHdl etc.) + pView->AddUndo(pDoc->GetSdrUndoFactory().CreateUndoNewObject(*pObj)); } + + // BM/IHA -- } void FuInsertChart::Activate() commit 34100ec12962e2799d1ab454dcfc3513968aa22d Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Mon May 12 16:13:38 2014 -0400 It makes no sense to create object container when no objects are embedded. Change-Id: Id13a0955a2b26dcc06766ad85f6ff9c598b4f0f2 diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 163e326..070703e 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -302,25 +302,28 @@ bool SfxObjectShell::IsModified() return false; } - uno::Sequence < OUString > aNames = GetEmbeddedObjectContainer().GetObjectNames(); - for ( sal_Int32 n=0; n<aNames.getLength(); n++ ) + if (pImp->mpObjectContainer) { - uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObjectContainer().GetEmbeddedObject( aNames[n] ); - OSL_ENSURE( xObj.is(), "An empty entry in the embedded objects list!\n" ); - if ( xObj.is() ) + uno::Sequence < OUString > aNames = GetEmbeddedObjectContainer().GetObjectNames(); + for ( sal_Int32 n=0; n<aNames.getLength(); n++ ) { - try + uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObjectContainer().GetEmbeddedObject( aNames[n] ); + OSL_ENSURE( xObj.is(), "An empty entry in the embedded objects list!\n" ); + if ( xObj.is() ) { - sal_Int32 nState = xObj->getCurrentState(); - if ( nState != embed::EmbedStates::LOADED ) + try { - uno::Reference< util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY ); - if ( xModifiable.is() && xModifiable->isModified() ) - return true; + sal_Int32 nState = xObj->getCurrentState(); + if ( nState != embed::EmbedStates::LOADED ) + { + uno::Reference< util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY ); + if ( xModifiable.is() && xModifiable->isModified() ) + return true; + } } + catch( uno::Exception& ) + {} } - catch( uno::Exception& ) - {} } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits