[Libreoffice-commits] core.git: 2 commits - sw/source
Takeshi Abe
tabe at fixedpoint.jp
Wed Jan 29 23:55:38 PST 2014
sw/source/core/crsr/findattr.cxx | 9 +++------
sw/source/core/crsr/findfmt.cxx | 5 ++---
sw/source/core/doc/docbasic.cxx | 16 +++++++---------
sw/source/core/text/inftxt.cxx | 1 -
sw/source/ui/dochdl/swdtflvr.cxx | 4 ++--
5 files changed, 14 insertions(+), 21 deletions(-)
New commits:
commit 27aa26a1953524304f75d8a7a58e87f67485d32c
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Thu Jan 30 16:49:24 2014 +0900
Drop unnecessary #include
Change-Id: I2a879712adfad3307d608eca0b27f674d32e6a73
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index de10934..6aa466c 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -61,7 +61,6 @@
#include <pam.hxx>
#include <SwGrammarMarkUp.hxx>
#include "numrule.hxx"
-#include <cstdio>
// #i12836# enhanced pdf export
#include <EnhancedPDFExportHelper.hxx>
#include <docufld.hxx>
commit 9e9a59293a6538f4b41ba6892cf3f84967003000
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Thu Jan 30 16:46:22 2014 +0900
Avoid resource leaks in case of exception
Change-Id: I4461ab619a71fcbe18d4d805a964fd358e857eda
diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx
index 38aac54..9ebd1a2 100644
--- a/sw/source/core/crsr/findattr.cxx
+++ b/sw/source/core/crsr/findattr.cxx
@@ -41,6 +41,7 @@
#include <swundo.hxx>
#include <crsskip.hxx>
#include <boost/optional.hpp>
+#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
@@ -879,7 +880,7 @@ bool SwPaM::Find( const SfxPoolItem& rAttr, bool bValue, SwMoveFn fnMove,
const sal_uInt16 nWhich = rAttr.Which();
bool bCharAttr = isCHRATR(nWhich) || isTXTATR(nWhich);
- SwPaM* pPam = MakeRegion( fnMove, pRegion );
+ boost::scoped_ptr<SwPaM> pPam(MakeRegion( fnMove, pRegion ));
bool bFound = false;
sal_Bool bFirst = sal_True;
@@ -895,7 +896,6 @@ bool SwPaM::Find( const SfxPoolItem& rAttr, bool bValue, SwMoveFn fnMove,
{
if( !(*fnMove->fnNds)( &pPam->GetPoint()->nNode, sal_False ))
{
- delete pPam;
return false;
}
SwCntntNode *pNd = pPam->GetCntntNode();
@@ -950,7 +950,6 @@ bool SwPaM::Find( const SfxPoolItem& rAttr, bool bValue, SwMoveFn fnMove,
if( bFound && !bSrchForward )
Exchange();
- delete pPam;
return bFound;
}
@@ -959,7 +958,7 @@ typedef int (*FnSearchAttr)( const SwTxtNode&, SwAttrCheckArr&, SwPaM& );
bool SwPaM::Find( const SfxItemSet& rSet, bool bNoColls, SwMoveFn fnMove,
const SwPaM *pRegion, bool bInReadOnly, bool bMoveFirst )
{
- SwPaM* pPam = MakeRegion( fnMove, pRegion );
+ boost::scoped_ptr<SwPaM> pPam(MakeRegion( fnMove, pRegion ));
bool bFound = false;
sal_Bool bFirst = sal_True;
@@ -985,7 +984,6 @@ bool SwPaM::Find( const SfxItemSet& rSet, bool bNoColls, SwMoveFn fnMove,
{
if( !(*fnMove->fnNds)( &pPam->GetPoint()->nNode, sal_False ))
{
- delete pPam;
return false;
}
SwCntntNode *pNd = pPam->GetCntntNode();
@@ -1043,7 +1041,6 @@ bool SwPaM::Find( const SfxItemSet& rSet, bool bNoColls, SwMoveFn fnMove,
if( bFound && !bSrchForward )
Exchange();
- delete pPam;
return bFound;
}
diff --git a/sw/source/core/crsr/findfmt.cxx b/sw/source/core/crsr/findfmt.cxx
index e9c30eb..d73f5d9 100644
--- a/sw/source/core/crsr/findfmt.cxx
+++ b/sw/source/core/crsr/findfmt.cxx
@@ -19,13 +19,14 @@
#include <doc.hxx>
#include <pamtyp.hxx>
+#include <boost/scoped_ptr.hpp>
bool SwPaM::Find( const SwFmt& rFmt, SwMoveFn fnMove,
const SwPaM *pRegion, bool bInReadOnly )
{
bool bFound = false;
const bool bSrchForward = (fnMove == fnMoveForward);
- SwPaM* pPam = MakeRegion( fnMove, pRegion );
+ boost::scoped_ptr<SwPaM> pPam(MakeRegion( fnMove, pRegion ));
// if at beginning/end then move it out of the node
if( bSrchForward
@@ -34,7 +35,6 @@ bool SwPaM::Find( const SwFmt& rFmt, SwMoveFn fnMove,
{
if( !(*fnMove->fnNds)( &pPam->GetPoint()->nNode, sal_False ))
{
- delete pPam;
return false;
}
SwCntntNode *pNd = pPam->GetPoint()->nNode.GetNode().GetCntntNode();
@@ -65,7 +65,6 @@ bool SwPaM::Find( const SwFmt& rFmt, SwMoveFn fnMove,
break;
}
}
- delete pPam;
return bFound;
}
diff --git a/sw/source/core/doc/docbasic.cxx b/sw/source/core/doc/docbasic.cxx
index 15fcf5f..4b2fdfe 100644
--- a/sw/source/core/doc/docbasic.cxx
+++ b/sw/source/core/doc/docbasic.cxx
@@ -31,6 +31,7 @@
#include <doc.hxx>
#include <docsh.hxx>
#include <swevent.hxx>
+#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star::uno;
@@ -98,17 +99,17 @@ bool SwDoc::ExecMacro( const SvxMacro& rMacro, OUString* pRet, SbxArray* pArgs )
break;
case EXTENDED_STYPE:
{
- Sequence<Any> *pUnoArgs = 0;
+ boost::scoped_ptr<Sequence<Any> > pUnoArgs;
if( pArgs )
{
// better to rename the local function to lcl_translateBasic2Uno and
// a much shorter routine can be found in sfx2/source/doc/objmisc.cxx
- pUnoArgs = lcl_docbasic_convertArgs( *pArgs );
+ pUnoArgs.reset(lcl_docbasic_convertArgs( *pArgs ));
}
if (!pUnoArgs)
{
- pUnoArgs = new Sequence< Any > (0);
+ pUnoArgs.reset(new Sequence< Any > (0));
}
// TODO - return value is not handled
@@ -122,7 +123,6 @@ bool SwDoc::ExecMacro( const SvxMacro& rMacro, OUString* pRet, SbxArray* pArgs )
eErr = mpDocShell->CallXScript(
rMacro.GetMacName(), *pUnoArgs, aRet, aOutArgsIndex, aOutArgs);
- delete pUnoArgs;
break;
}
}
@@ -210,16 +210,16 @@ sal_uInt16 SwDoc::CallEvent( sal_uInt16 nEvent, const SwCallMouseEvent& rCallEve
}
else if( EXTENDED_STYPE == rMacro.GetScriptType() )
{
- Sequence<Any> *pUnoArgs = 0;
+ boost::scoped_ptr<Sequence<Any> > pUnoArgs;
if( pArgs )
{
- pUnoArgs = lcl_docbasic_convertArgs( *pArgs );
+ pUnoArgs.reset(lcl_docbasic_convertArgs( *pArgs ));
}
if (!pUnoArgs)
{
- pUnoArgs = new Sequence <Any> (0);
+ pUnoArgs.reset(new Sequence <Any> (0));
}
Any aRet;
@@ -231,8 +231,6 @@ sal_uInt16 SwDoc::CallEvent( sal_uInt16 nEvent, const SwCallMouseEvent& rCallEve
nRet += 0 == mpDocShell->CallXScript(
rMacro.GetMacName(), *pUnoArgs,aRet, aOutArgsIndex, aOutArgs) ? 1 : 0;
-
- delete pUnoArgs;
}
// JavaScript calls are ignored
}
diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx
index f4e82f1..5bd3dd7 100644
--- a/sw/source/ui/dochdl/swdtflvr.cxx
+++ b/sw/source/ui/dochdl/swdtflvr.cxx
@@ -670,12 +670,12 @@ sal_Bool SwTransferable::WriteObject( SotStorageStreamRef& xStream,
if ( xTransact.is() )
xTransact->commit();
- SvStream* pSrcStm = ::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), STREAM_READ );
+ boost::scoped_ptr<SvStream> pSrcStm(::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), STREAM_READ ));
if( pSrcStm )
{
xStream->SetBufferSize( 0xff00 );
xStream->WriteStream( *pSrcStm );
- delete pSrcStm;
+ pSrcStm.reset();
}
bRet = sal_True;
More information about the Libreoffice-commits
mailing list