[Libreoffice-commits] core.git: 2 commits - sw/inc sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Jan 15 05:57:22 UTC 2019
sw/inc/swabstdlg.hxx | 2 +-
sw/source/ui/dialog/swdlgfact.cxx | 2 +-
sw/source/ui/dialog/swdlgfact.hxx | 6 +++---
sw/source/ui/table/instable.cxx | 4 ++--
sw/source/uibase/app/docsh.cxx | 9 ++++-----
sw/source/uibase/app/docsh2.cxx | 5 ++---
sw/source/uibase/app/docstyle.cxx | 12 ++++++------
sw/source/uibase/inc/instable.hxx | 2 +-
sw/source/uibase/lingu/hhcwrp.cxx | 12 ++++++------
sw/source/uibase/shells/basesh.cxx | 7 +++----
10 files changed, 29 insertions(+), 32 deletions(-)
New commits:
commit 6018adfabc30ee68939c2d974aa612757bbca938
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jan 14 10:07:09 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jan 15 06:57:09 2019 +0100
use unique_ptr for SwTableAutoFormat
Change-Id: Ib83be524b5c15e4639a834494726501ac7aa6755
Reviewed-on: https://gerrit.libreoffice.org/66314
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index 2e97df323db9..075d41e873c0 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -120,7 +120,7 @@ protected:
public:
virtual void GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rCol,
SwInsertTableOptions& rInsTableFlags, OUString& rTableAutoFormatName,
- SwTableAutoFormat *& prTAFormat ) = 0;
+ std::unique_ptr<SwTableAutoFormat>& prTAFormat ) = 0;
};
class AbstractJavaEditDialog : public VclAbstractDialog
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index c40f17d9cf4a..d928f116fd90 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -550,7 +550,7 @@ void AbstractInsFootNoteDlg_Impl::SetText( const OUString& rStr )
void AbstractInsTableDlg_Impl::GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rCol,
SwInsertTableOptions& rInsTableFlags, OUString& rTableAutoFormatName,
- SwTableAutoFormat *& prTAFormat )
+ std::unique_ptr<SwTableAutoFormat>& prTAFormat )
{
m_xDlg->GetValues(rName, rRow, rCol, rInsTableFlags, rTableAutoFormatName, prTAFormat);
}
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index 2d9251ce3095..067097fcd3aa 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -444,9 +444,9 @@ public:
{
}
virtual short Execute() override;
- virtual void GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rCol,
- SwInsertTableOptions& rInsTableFlags, OUString& rTableAutoFormatName,
- SwTableAutoFormat *& prTAFormat ) override;
+ virtual void GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rCol,
+ SwInsertTableOptions& rInsTableFlags, OUString& rTableAutoFormatName,
+ std::unique_ptr<SwTableAutoFormat>& prTAFormat ) override;
};
class SwJavaEditDialog;
diff --git a/sw/source/ui/table/instable.cxx b/sw/source/ui/table/instable.cxx
index b960dcb4f168..f2d7f6f3c305 100644
--- a/sw/source/ui/table/instable.cxx
+++ b/sw/source/ui/table/instable.cxx
@@ -29,7 +29,7 @@
void SwInsTableDlg::GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rCol,
SwInsertTableOptions& rInsTableOpts, OUString& rAutoName,
- SwTableAutoFormat *& prTAFormat )
+ std::unique_ptr<SwTableAutoFormat>& prTAFormat )
{
SwInsertTableFlags nInsMode = SwInsertTableFlags::NONE;
rName = m_xNameEdit->get_text();
@@ -46,7 +46,7 @@ void SwInsTableDlg::GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rC
nInsMode |= SwInsertTableFlags::SplitLayout;
if( pTAutoFormat )
{
- prTAFormat = new SwTableAutoFormat( *pTAutoFormat );
+ prTAFormat.reset(new SwTableAutoFormat( *pTAutoFormat ));
rAutoName = prTAFormat->GetName();
}
diff --git a/sw/source/uibase/inc/instable.hxx b/sw/source/uibase/inc/instable.hxx
index c0194403ab98..7c12ce1f3434 100644
--- a/sw/source/uibase/inc/instable.hxx
+++ b/sw/source/uibase/inc/instable.hxx
@@ -82,7 +82,7 @@ public:
void GetValues( OUString& rName, sal_uInt16& rRow, sal_uInt16& rCol,
SwInsertTableOptions& rInsTableOpts, OUString& rTableAutoFormatName,
- SwTableAutoFormat *& prTAFormat );
+ std::unique_ptr<SwTableAutoFormat>& prTAFormat );
};
#endif
diff --git a/sw/source/uibase/lingu/hhcwrp.cxx b/sw/source/uibase/lingu/hhcwrp.cxx
index 4a6c2a61f650..8fce3fae3a3a 100644
--- a/sw/source/uibase/lingu/hhcwrp.cxx
+++ b/sw/source/uibase/lingu/hhcwrp.cxx
@@ -374,7 +374,7 @@ void SwHHCWrapper::ReplaceUnit(
OUString aOrigText( m_rWrtShell.GetSelText() );
OUString aNewText( rReplaceWith );
OSL_ENSURE( aOrigText == rOrigText, "!! text mismatch !!" );
- SwFormatRuby *pRuby = nullptr;
+ std::unique_ptr<SwFormatRuby> pRuby;
bool bRubyBelow = false;
OUString aNewOrigText;
switch (eAction)
@@ -393,24 +393,24 @@ void SwHHCWrapper::ReplaceUnit(
break;
case eReplacementAbove :
{
- pRuby = new SwFormatRuby( rReplaceWith );
+ pRuby.reset(new SwFormatRuby( rReplaceWith ));
}
break;
case eOriginalAbove :
{
- pRuby = new SwFormatRuby( aOrigText );
+ pRuby.reset(new SwFormatRuby( aOrigText ));
aNewOrigText = rReplaceWith;
}
break;
case eReplacementBelow :
{
- pRuby = new SwFormatRuby( rReplaceWith );
+ pRuby.reset(new SwFormatRuby( rReplaceWith ));
bRubyBelow = true;
}
break;
case eOriginalBelow :
{
- pRuby = new SwFormatRuby( aOrigText );
+ pRuby.reset(new SwFormatRuby( aOrigText ));
aNewOrigText = rReplaceWith;
bRubyBelow = true;
}
@@ -445,7 +445,7 @@ void SwHHCWrapper::ReplaceUnit(
pRuby->SetAdjustment( RubyAdjust_CENTER );
m_rWrtShell.SetAttrItem(*pRuby);
- delete pRuby;
+ pRuby.reset();
m_rWrtShell.EndUndo( SwUndoId::SETRUBYATTR );
}
else
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index 48fb9e17c71f..e78e91fa76eb 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -2616,7 +2616,7 @@ void SwBaseShell::InsertTable( SfxRequest& _rRequest )
SwInsertTableOptions aInsTableOpts( SwInsertTableFlags::All, 1 );
OUString aTableName;
OUString aAutoName;
- SwTableAutoFormat* pTAFormat = nullptr;
+ std::unique_ptr<SwTableAutoFormat> pTAFormat;
if( pArgs && pArgs->Count() >= 2 )
{
@@ -2643,7 +2643,7 @@ void SwBaseShell::InsertTable( SfxRequest& _rRequest )
{
if ( aTableTable[n].GetName() == aAutoName )
{
- pTAFormat = new SwTableAutoFormat( aTableTable[n] );
+ pTAFormat.reset(new SwTableAutoFormat( aTableTable[n] ));
break;
}
}
@@ -2689,7 +2689,7 @@ void SwBaseShell::InsertTable( SfxRequest& _rRequest )
if( rSh.HasSelection() )
rSh.DelRight();
- rSh.InsertTable( aInsTableOpts, nRows, nCols, pTAFormat );
+ rSh.InsertTable( aInsTableOpts, nRows, nCols, pTAFormat.get() );
rSh.MoveTable( GotoPrevTable, fnTableStart );
if( !aTableName.isEmpty() && !rSh.GetTableStyle( aTableName ) )
@@ -2701,7 +2701,6 @@ void SwBaseShell::InsertTable( SfxRequest& _rRequest )
rSh.EndAllAction();
rTempView.AutoCaption(TABLE_CAP);
}
- delete pTAFormat;
}
if( bCallEndUndo )
commit e450351a9a1b4b37e34f1c5058a83f284b4979d2
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jan 14 08:48:28 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jan 15 06:57:01 2019 +0100
use unique_ptr in sw
Change-Id: I369ef79e88a40c01f5384e2427c3dec429ea0457
Reviewed-on: https://gerrit.libreoffice.org/66311
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index 0d02885d3d4f..afcb2aea7596 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -872,12 +872,12 @@ void SwDocShell::Draw( OutputDevice* pDev, const JobSetup& rSetup,
// reconnect it after PrtOle2. We don't use an empty JobSetup because
// that would only lead to questionable results after expensive
// reformatting (Preview!)
- JobSetup *pOrig = nullptr;
+ std::unique_ptr<JobSetup> pOrig;
if ( !rSetup.GetPrinterName().isEmpty() && ASPECT_THUMBNAIL != nAspect )
{
- pOrig = const_cast<JobSetup*>(m_xDoc->getIDocumentDeviceAccess().getJobsetup());
- if( pOrig ) // then we copy that
- pOrig = new JobSetup( *pOrig );
+ const JobSetup* pCurrentJobSetup = m_xDoc->getIDocumentDeviceAccess().getJobsetup();
+ if( pCurrentJobSetup ) // then we copy that
+ pOrig.reset(new JobSetup( *pCurrentJobSetup ));
m_xDoc->getIDocumentDeviceAccess().setJobsetup( rSetup );
}
@@ -896,7 +896,6 @@ void SwDocShell::Draw( OutputDevice* pDev, const JobSetup& rSetup,
if( pOrig )
{
m_xDoc->getIDocumentDeviceAccess().setJobsetup( *pOrig );
- delete pOrig;
}
if ( bResetModified )
EnableSetModified();
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index ddcb76e54617..0d30c019c1d0 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -843,7 +843,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
WriterRef xWrt;
// mba: looks as if relative URLs don't make sense here
::GetRTFWriter( OUString('O'), OUString(), xWrt );
- SvMemoryStream *pStrm = new SvMemoryStream();
+ std::unique_ptr<SvMemoryStream> pStrm (new SvMemoryStream());
pStrm->SetBufferSize( 16348 );
SwWriter aWrt( *pStrm, *GetDoc() );
ErrCode eErr = aWrt.Write( xWrt );
@@ -864,7 +864,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
pStrm->Seek( STREAM_SEEK_TO_BEGIN );
// Transfer ownership of stream to a lockbytes object
- SvLockBytes aLockBytes( pStrm, true );
+ SvLockBytes aLockBytes( pStrm.release(), true );
SvLockBytesStat aStat;
if ( aLockBytes.Stat( &aStat ) == ERRCODE_NONE )
{
@@ -887,7 +887,6 @@ void SwDocShell::Execute(SfxRequest& rReq)
pStrm->GetData()), pStrm->GetEndOfData() );
pClipCntnr->CopyToClipboard(
GetView()? &GetView()->GetEditWin() : nullptr );
- delete pStrm;
}
}
else
diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx
index 5979314905c8..e842ec88b3b4 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -1455,7 +1455,7 @@ void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
}
SwFormat* pFormat = nullptr;
- SwPageDesc* pNewDsc = nullptr;
+ std::unique_ptr<SwPageDesc> pNewDsc;
size_t nPgDscPos = 0;
switch(nFamily)
@@ -1611,7 +1611,7 @@ void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
if (rDoc.FindPageDesc(pDesc->GetName(), &nPgDscPos))
{
- pNewDsc = new SwPageDesc( *pDesc );
+ pNewDsc.reset( new SwPageDesc( *pDesc ) );
// #i48949# - no undo actions for the
// copy of the page style
::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
@@ -1696,8 +1696,8 @@ void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
::ItemSetToPageDesc( aSet, *pNewDsc );
rDoc.ChgPageDesc( nPgDscPos, *pNewDsc );
pDesc = &rDoc.GetPageDesc( nPgDscPos );
- rDoc.PreDelPageDesc(pNewDsc); // #i7983#
- delete pNewDsc;
+ rDoc.PreDelPageDesc(pNewDsc.get()); // #i7983#
+ pNewDsc.reset();
}
else
rDoc.ChgFormat(*pFormat, aSet); // put all that is set
@@ -1707,8 +1707,8 @@ void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
aCoreSet.ClearItem();
if( pNewDsc ) // we still need to delete it
{
- rDoc.PreDelPageDesc(pNewDsc); // #i7983#
- delete pNewDsc;
+ rDoc.PreDelPageDesc(pNewDsc.get()); // #i7983#
+ pNewDsc.reset();
}
}
More information about the Libreoffice-commits
mailing list