[Libreoffice-commits] core.git: 2 commits - sc/source
Takeshi Abe
tabe at fixedpoint.jp
Fri May 9 02:26:27 PDT 2014
sc/source/ui/view/viewfun4.cxx | 20 ++++++++++----------
sc/source/ui/view/viewfun5.cxx | 21 ++++++++++-----------
sc/source/ui/view/viewfunc.cxx | 13 ++++++-------
sc/source/ui/view/viewutil.cxx | 6 +++---
4 files changed, 29 insertions(+), 31 deletions(-)
New commits:
commit 63297cd4202593754d05841b02434b18d0e2bb8f
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Fri May 9 18:24:02 2014 +0900
Avoid possible memory leaks in case of exceptions
Change-Id: I6542885b0de6dad0244726f1ee8bf9cdc851e746
diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
index 13bdec0..2e05759 100644
--- a/sc/source/ui/view/viewfun4.cxx
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -92,7 +92,7 @@ void ScViewFunc::PasteRTF( SCCOL nStartCol, SCROW nStartRow,
const bool bRecord (pDoc->IsUndoEnabled());
const ScPatternAttr* pPattern = pDoc->GetPattern( nStartCol, nStartRow, nTab );
- ScTabEditEngine* pEngine = new ScTabEditEngine( *pPattern, pDoc->GetEnginePool() );
+ boost::scoped_ptr<ScTabEditEngine> pEngine(new ScTabEditEngine( *pPattern, pDoc->GetEnginePool() ));
pEngine->EnableUndo( false );
Window* pActWin = GetActiveWin();
@@ -100,7 +100,7 @@ void ScViewFunc::PasteRTF( SCCOL nStartCol, SCROW nStartRow,
{
pEngine->SetPaperSize(Size(100000,100000));
Window aWin( pActWin );
- EditView aEditView( pEngine, &aWin );
+ EditView aEditView( pEngine.get(), &aWin );
aEditView.SetOutputArea(Rectangle(0,0,100000,100000));
// same method now for clipboard or drag&drop
@@ -152,7 +152,7 @@ void ScViewFunc::PasteRTF( SCCOL nStartCol, SCROW nStartRow,
}
}
- delete pEngine;
+ pEngine.reset();
ShowAllCursors();
}
@@ -495,23 +495,23 @@ void ScViewFunc::DoSheetConversion( const ScConversionParam& rConvParam, bool bR
// *** create and init the edit engine *** --------------------------------
- ScConversionEngineBase* pEngine = NULL;
+ boost::scoped_ptr<ScConversionEngineBase> pEngine;
switch( rConvParam.GetType() )
{
case SC_CONVERSION_SPELLCHECK:
- pEngine = new ScSpellingEngine(
- pDoc->GetEnginePool(), rViewData, pUndoDoc, pRedoDoc, LinguMgr::GetSpellChecker() );
+ pEngine.reset(new ScSpellingEngine(
+ pDoc->GetEnginePool(), rViewData, pUndoDoc, pRedoDoc, LinguMgr::GetSpellChecker() ));
break;
case SC_CONVERSION_HANGULHANJA:
case SC_CONVERSION_CHINESE_TRANSL:
- pEngine = new ScTextConversionEngine(
- pDoc->GetEnginePool(), rViewData, rConvParam, pUndoDoc, pRedoDoc );
+ pEngine.reset(new ScTextConversionEngine(
+ pDoc->GetEnginePool(), rViewData, rConvParam, pUndoDoc, pRedoDoc ));
break;
default:
OSL_FAIL( "ScViewFunc::DoSheetConversion - unknown conversion type" );
}
- MakeEditView( pEngine, nCol, nRow );
+ MakeEditView( pEngine.get(), nCol, nRow );
pEngine->SetRefDevice( rViewData.GetActiveWin() );
// dummy Zelle simulieren:
pEditView = rViewData.GetEditView( rViewData.GetActivePart() );
@@ -558,7 +558,7 @@ void ScViewFunc::DoSheetConversion( const ScConversionParam& rConvParam, bool bR
rViewData.SetSpellingView( NULL );
KillEditView(true);
- delete pEngine;
+ pEngine.reset();
pDocSh->PostPaintGridAll();
rViewData.GetViewShell()->UpdateInputHandler();
pDoc->EnableIdle(bOldEnabled);
diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
index 311db74..dc708e0 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -67,6 +67,7 @@
#include <vcl/msgbox.hxx>
#include <sfx2/viewfrm.hxx>
#include <svx/dbaexchange.hxx>
+#include <boost/scoped_ptr.hpp>
using namespace com::sun::star;
@@ -139,7 +140,7 @@ bool ScViewFunc::PasteDataFormat( sal_uLong nFormatId,
ScMarkData aSrcMark;
aSrcMark.SelectOneTable( nSrcTab ); // for CopyToClip
- ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+ boost::scoped_ptr<ScDocument> pClipDoc(new ScDocument( SCDOCMODE_CLIP ));
SCCOL nFirstCol, nLastCol;
SCROW nFirstRow, nLastRow;
@@ -151,15 +152,14 @@ bool ScViewFunc::PasteDataFormat( sal_uLong nFormatId,
nFirstRow = nLastRow = 0;
}
ScClipParam aClipParam(ScRange(nFirstCol, nFirstRow, nSrcTab, nLastCol, nLastRow, nSrcTab), false);
- pSrcDoc->CopyToClip(aClipParam, pClipDoc, &aSrcMark);
+ pSrcDoc->CopyToClip(aClipParam, pClipDoc.get(), &aSrcMark);
ScGlobal::SetClipDocName( xDocShRef->GetTitle( SFX_TITLE_FULLNAME ) );
SetCursor( nPosX, nPosY );
Unmark();
- PasteFromClip( IDF_ALL, pClipDoc,
+ PasteFromClip( IDF_ALL, pClipDoc.get(),
PASTE_NOFUNC, false, false, false, INS_NONE, IDF_NONE,
bAllowDialogs );
- delete pClipDoc;
bRet = true;
}
@@ -333,9 +333,9 @@ bool ScViewFunc::PasteDataFormat( sal_uLong nFormatId,
ScImportStringStream aStrm( aStr);
ScAbstractDialogFactory* pFact =
ScAbstractDialogFactory::Create();
- AbstractScImportAsciiDlg *pDlg =
+ boost::scoped_ptr<AbstractScImportAsciiDlg> pDlg(
pFact->CreateScImportAsciiDlg( NULL, OUString(), &aStrm,
- SC_PASTETEXT);
+ SC_PASTETEXT));
if (pDlg->Execute() == RET_OK)
{
@@ -356,7 +356,6 @@ bool ScViewFunc::PasteDataFormat( sal_uLong nFormatId,
bRet = true;
// Yes, no failure, don't raise a "couldn't paste"
// dialog if user cancelled.
- delete pDlg;
}
else
bRet = aObj.ImportString( aStr, nFormatId );
@@ -491,13 +490,13 @@ bool ScViewFunc::PasteDataFormat( sal_uLong nFormatId,
ScDocShellRef aDragShellRef( new ScDocShell );
aDragShellRef->DoInitNew(NULL);
- FmFormModel* pModel = new FmFormModel( aPath, NULL, aDragShellRef );
+ boost::scoped_ptr<FmFormModel> pModel(new FmFormModel( aPath, NULL, aDragShellRef ));
pModel->GetItemPool().FreezeIdRanges();
xStm->Seek(0);
com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xInputStream( new utl::OInputStreamWrapper( *xStm ) );
- SvxDrawingLayerImport( pModel, xInputStream );
+ SvxDrawingLayerImport( pModel.get(), xInputStream );
// set everything to right layer:
sal_uLong nObjCount = 0;
@@ -519,8 +518,8 @@ bool ScViewFunc::PasteDataFormat( sal_uLong nFormatId,
nObjCount += pPage->GetObjCount(); // count group object only once
}
- PasteDraw( aPos, pModel, (nObjCount > 1) ); // grouped if more than 1 object
- delete pModel;
+ PasteDraw( aPos, pModel.get(), (nObjCount > 1) ); // grouped if more than 1 object
+ pModel.reset();
aDragShellRef->DoClose();
bRet = true;
}
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 7c66d9c..9ce469a 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -76,6 +76,7 @@
#include "cellsuno.hxx"
#include "tokenarray.hxx"
#include <rowheightcontext.hxx>
+#include <boost/scoped_ptr.hpp>
static void lcl_PostRepaintCondFormat( const ScConditionalFormat *pCondFmt, ScDocShell *pDocSh )
{
@@ -625,7 +626,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
bool bSimple = false;
bool bCommon = false;
- ScPatternAttr* pCellAttrs = NULL;
+ boost::scoped_ptr<ScPatternAttr> pCellAttrs;
OUString aString;
const ScPatternAttr* pOldPattern = pDoc->GetPattern( nCol, nRow, nTab );
@@ -650,7 +651,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
if (bCommon) // attribute for tab
{
- pCellAttrs = new ScPatternAttr( *pOldPattern );
+ pCellAttrs.reset(new ScPatternAttr( *pOldPattern ));
pCellAttrs->GetFromEditItemSet( &aAttrTester.GetAttribs() );
//! remove common attributes from EditEngine?
}
@@ -726,8 +727,6 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
aModificator.SetDocumentModified();
}
lcl_PostRepaintCondFormat( pDoc->GetCondFormat( nCol, nRow, nTab ), pDocSh );
-
- delete pCellAttrs;
}
else
{
@@ -1207,7 +1206,7 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr,
}
aChangeRanges.Append(aPos);
- ScPatternAttr* pOldPat = new ScPatternAttr(*pDoc->GetPattern( nCol, nRow, nTab ));
+ boost::scoped_ptr<ScPatternAttr> pOldPat(new ScPatternAttr(*pDoc->GetPattern( nCol, nRow, nTab )));
pDoc->ApplyPattern( nCol, nRow, nTab, rAttr );
@@ -1216,11 +1215,11 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr,
if (bRecord)
{
ScUndoCursorAttr* pUndo = new ScUndoCursorAttr(
- pDocSh, nCol, nRow, nTab, pOldPat, pNewPat, &rAttr, false );
+ pDocSh, nCol, nRow, nTab, pOldPat.get(), pNewPat, &rAttr, false );
pUndo->SetEditData(pOldEditData, pNewEditData);
pDocSh->GetUndoManager()->AddUndoAction(pUndo);
}
- delete pOldPat; // is copied in undo (Pool)
+ pOldPat.reset(); // is copied in undo (Pool)
pDocSh->PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PAINT_GRID, nExtFlags | SC_PF_TESTMERGE );
pDocSh->UpdateOle(GetViewData());
diff --git a/sc/source/ui/view/viewutil.cxx b/sc/source/ui/view/viewutil.cxx
index a1704be..c7535a1 100644
--- a/sc/source/ui/view/viewutil.cxx
+++ b/sc/source/ui/view/viewutil.cxx
@@ -49,7 +49,7 @@
#include <svx/svxdlg.hxx>
#include <svx/dialogs.hrc>
-
+#include <boost/scoped_ptr.hpp>
void ScViewUtil::PutItemScript( SfxItemSet& rShellSet, const SfxItemSet& rCoreSet,
sal_uInt16 nWhichId, sal_uInt16 nScript )
@@ -352,7 +352,7 @@ bool ScViewUtil::ExecuteCharMap( const SvxFontItem& rOldFont,
SfxAllItemSet aSet( rFrame.GetObjectShell()->GetPool() );
aSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
aSet.Put( SvxFontItem( rOldFont.GetFamily(), rOldFont.GetFamilyName(), rOldFont.GetStyleName(), rOldFont.GetPitch(), rOldFont.GetCharSet(), aSet.GetPool()->GetWhich( SID_ATTR_CHAR_FONT ) ) );
- SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( &rFrame.GetWindow(), aSet, rFrame.GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
+ boost::scoped_ptr<SfxAbstractDialog> pDlg(pFact->CreateSfxDialog( &rFrame.GetWindow(), aSet, rFrame.GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP ));
if ( pDlg->Execute() == RET_OK )
{
SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pItem, SfxStringItem, SID_CHARMAP, false );
@@ -363,7 +363,6 @@ bool ScViewUtil::ExecuteCharMap( const SvxFontItem& rOldFont,
rNewFont = SvxFontItem( pFontItem->GetFamily(), pFontItem->GetFamilyName(), pFontItem->GetStyleName(), pFontItem->GetPitch(), pFontItem->GetCharSet(), rNewFont.Which() );
bRet = true;
}
- delete pDlg;
}
return bRet;
}
commit 0b92cacb1537f266c4805e15ee1814741912d523
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Fri May 9 16:22:38 2014 +0900
Start with the mode line
Change-Id: I0156daaa12cfe147df26be061bc037d291d4f0c6
diff --git a/sc/source/ui/view/viewutil.cxx b/sc/source/ui/view/viewutil.cxx
index 342c6e5..a1704be 100644
--- a/sc/source/ui/view/viewutil.cxx
+++ b/sc/source/ui/view/viewutil.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
More information about the Libreoffice-commits
mailing list