Kaydet (Commit) 803b94a2 authored tarafından Armin Le Grand's avatar Armin Le Grand

#120105# Avoid MemoryLeak in ScTableSheetObj::PrintAreaUndo_Impl by handling…

#120105# Avoid MemoryLeak in ScTableSheetObj::PrintAreaUndo_Impl by handling created ScPrintRageSaver objects more careful.

Found by: Chao Huang
Patch by: Chao Huang, alg
Review by: alg
üst e755623a
......@@ -7365,31 +7365,43 @@ void SAL_CALL ScTableSheetObj::copyRange( const table::CellAddress& aDestination
void ScTableSheetObj::PrintAreaUndo_Impl( ScPrintRangeSaver* pOldRanges )
{
// Umbrueche und Undo
ScDocShell* pDocSh = GetDocShell();
if ( pDocSh )
ScDocument* pDoc = pDocSh ? pDocSh->GetDocument() : 0;
if(pDocSh && pDoc)
{
ScDocument* pDoc = pDocSh->GetDocument();
sal_Bool bUndo(pDoc->IsUndoEnabled());
SCTAB nTab = GetTab_Impl();
const bool bUndo(pDoc->IsUndoEnabled());
const SCTAB nTab(GetTab_Impl());
ScPrintRangeSaver* pNewRanges = pDoc->CreatePrintRangeSaver();
if (bUndo)
if(bUndo)
{
pDocSh->GetUndoManager()->AddUndoAction(
new ScUndoPrintRange( pDocSh, nTab, pOldRanges, pNewRanges ) );
}
new ScUndoPrintRange(
pDocSh,
nTab,
pOldRanges,
pDoc->CreatePrintRangeSaver())); // create new ranges
ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ).UpdatePages();
// #120105# ownership of old ranges has changed, mark as consumed
pOldRanges = 0;
}
ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nTab).UpdatePages();
SfxBindings* pBindings = pDocSh->GetViewBindings();
if (pBindings)
pBindings->Invalidate( SID_DELETE_PRINTAREA );
if(pBindings)
{
pBindings->Invalidate(SID_DELETE_PRINTAREA);
}
pDocSh->SetDocumentModified();
}
else
if(pOldRanges)
{
// #120105# pOldRanges not used, need to cleanup
delete pOldRanges;
}
}
uno::Sequence<table::CellRangeAddress> SAL_CALL ScTableSheetObj::getPrintAreas()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment