summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-08-23 16:56:51 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-24 13:18:41 +0200
commit38d82e5724080a7799de430dc9ddaeb3c647bc05 (patch)
tree9ff4fd0a8f69ba7abbf034b366a23df5ad25b315
parent8e74d55a89b00e3d1a8e6d356c21009cda02eb5c (diff)
loplugin:useuniqueptr in ScTransferObj
Change-Id: I43f813b11fc0ed27cab9c97a7e25124aaae1d398 Reviewed-on: https://gerrit.libreoffice.org/59540 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/source/ui/app/seltrans.cxx8
-rw-r--r--sc/source/ui/app/transobj.cxx4
-rw-r--r--sc/source/ui/inc/transobj.hxx5
-rw-r--r--sc/source/ui/navipi/content.cxx6
-rw-r--r--sc/source/ui/view/select.cxx8
-rw-r--r--sc/source/ui/view/tabcont.cxx6
-rw-r--r--sc/source/ui/view/viewfun3.cxx10
7 files changed, 22 insertions, 25 deletions
diff --git a/sc/source/ui/app/seltrans.cxx b/sc/source/ui/app/seltrans.cxx
index 65b12506d3a7..e2e6004c6154 100644
--- a/sc/source/ui/app/seltrans.cxx
+++ b/sc/source/ui/app/seltrans.cxx
@@ -273,11 +273,11 @@ void ScSelectionTransferObj::CreateCellData()
}
ScDrawLayer::SetGlobalDrawPersist( aDragShellRef.get() );
- ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+ ScDocumentUniquePtr pClipDoc(new ScDocument( SCDOCMODE_CLIP ));
// bApi = sal_True -> no error messages
// #i18364# bStopEdit = sal_False -> don't end edit mode
// (this may be called from pasting into the edit line)
- bool bCopied = rViewData.GetView()->CopyToClip( pClipDoc, false, true, true, false );
+ bool bCopied = rViewData.GetView()->CopyToClip( pClipDoc.get(), false, true, true, false );
ScDrawLayer::SetGlobalDrawPersist(nullptr);
@@ -288,7 +288,7 @@ void ScSelectionTransferObj::CreateCellData()
aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
// maSize is set in ScTransferObj ctor
- rtl::Reference<ScTransferObj> pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ rtl::Reference<ScTransferObj> pTransferObj = new ScTransferObj( std::move(pClipDoc), aObjDesc );
// SetDragHandlePos is not used - there is no mouse position
//? pTransferObj->SetVisibleTab( nTab );
@@ -300,8 +300,6 @@ void ScSelectionTransferObj::CreateCellData()
mxCellData = pTransferObj;
}
- else
- delete pClipDoc;
}
}
OSL_ENSURE( mxCellData.is(), "can't create CellData" );
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 4cfc9fffeedd..047ca19f92a8 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -117,8 +117,8 @@ void ScTransferObj::PaintToDev( OutputDevice* pDev, ScDocument* pDoc, double nPr
ScPrintFunc::DrawToDev( pDoc, pDev, nPrintFactor, aBound, &aViewData, false/*bMetaFile*/ );
}
-ScTransferObj::ScTransferObj( ScDocument* pClipDoc, const TransferableObjectDescriptor& rDesc ) :
- m_pDoc( pClipDoc ),
+ScTransferObj::ScTransferObj( ScDocumentUniquePtr pClipDoc, const TransferableObjectDescriptor& rDesc ) :
+ m_pDoc( std::move(pClipDoc ) ),
m_nNonFiltered(0),
m_aObjDesc( rDesc ),
m_nDragHandleX( 0 ),
diff --git a/sc/source/ui/inc/transobj.hxx b/sc/source/ui/inc/transobj.hxx
index ad15541fc3f3..e22ee5be52f3 100644
--- a/sc/source/ui/inc/transobj.hxx
+++ b/sc/source/ui/inc/transobj.hxx
@@ -23,6 +23,7 @@
#include <svtools/transfer.hxx>
#include <global.hxx>
#include <address.hxx>
+#include <document.hxx>
#include <sfx2/objsh.hxx>
@@ -40,7 +41,7 @@ namespace com { namespace sun { namespace star {
class ScTransferObj : public TransferableHelper
{
private:
- std::unique_ptr<ScDocument> m_pDoc;
+ ScDocumentUniquePtr m_pDoc;
ScRange m_aBlock;
SCROW m_nNonFiltered; // non-filtered rows
TransferableObjectDescriptor m_aObjDesc;
@@ -69,7 +70,7 @@ private:
static void GetAreaSize( const ScDocument* pDoc, SCTAB nTab1, SCTAB nTab2, SCROW& nRow, SCCOL& nCol );
public:
- ScTransferObj( ScDocument* pClipDoc, const TransferableObjectDescriptor& rDesc );
+ ScTransferObj( ScDocumentUniquePtr pClipDoc, const TransferableObjectDescriptor& rDesc );
virtual ~ScTransferObj() override;
virtual void AddSupportedFormats() override;
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index f06dc527471b..71405a56d22d 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -1283,9 +1283,9 @@ static void lcl_DoDragCells( ScDocShell* pSrcShell, const ScRange& rRange, ScDra
rRange.aEnd.Col(), rRange.aEnd.Row(),
aMark ) )
{
- ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+ ScDocumentUniquePtr pClipDoc(new ScDocument( SCDOCMODE_CLIP ));
ScClipParam aClipParam(rRange, false);
- rSrcDoc.CopyToClip(aClipParam, pClipDoc, &aMark, false, false);
+ rSrcDoc.CopyToClip(aClipParam, pClipDoc.get(), &aMark, false, false);
// pClipDoc->ExtendMerge( rRange, sal_True );
TransferableObjectDescriptor aObjDesc;
@@ -1293,7 +1293,7 @@ static void lcl_DoDragCells( ScDocShell* pSrcShell, const ScRange& rRange, ScDra
aObjDesc.maDisplayName = pSrcShell->GetMedium()->GetURLObject().GetURLNoPass();
// maSize is set in ScTransferObj ctor
- rtl::Reference<ScTransferObj> pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ rtl::Reference<ScTransferObj> pTransferObj = new ScTransferObj( std::move(pClipDoc), aObjDesc );
pTransferObj->SetDragSource( pSrcShell, aMark );
pTransferObj->SetDragSourceFlags( nFlags );
diff --git a/sc/source/ui/view/select.cxx b/sc/source/ui/view/select.cxx
index d15db4c3e5b0..0c4e171cd097 100644
--- a/sc/source/ui/view/select.cxx
+++ b/sc/source/ui/view/select.cxx
@@ -169,9 +169,9 @@ void ScViewFunctionSet::BeginDrag()
rMark.MarkToSimple();
if ( rMark.IsMarked() && !rMark.IsMultiMarked() )
{
- ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+ ScDocumentUniquePtr pClipDoc(new ScDocument( SCDOCMODE_CLIP ));
// bApi = TRUE -> no error messages
- bool bCopied = pViewData->GetView()->CopyToClip( pClipDoc, false, true );
+ bool bCopied = pViewData->GetView()->CopyToClip( pClipDoc.get(), false, true );
if ( bCopied )
{
sal_Int8 nDragActions = pViewData->GetView()->SelectionEditable() ?
@@ -184,7 +184,7 @@ void ScViewFunctionSet::BeginDrag()
aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
// maSize is set in ScTransferObj ctor
- rtl::Reference<ScTransferObj> pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ rtl::Reference<ScTransferObj> pTransferObj = new ScTransferObj( std::move(pClipDoc), aObjDesc );
// set position of dragged cell within range
ScRange aMarkRange = pTransferObj->GetRange();
@@ -207,8 +207,6 @@ void ScViewFunctionSet::BeginDrag()
return; // dragging started
}
- else
- delete pClipDoc;
}
}
diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx
index 62d270613978..5e0d005d513f 100644
--- a/sc/source/ui/view/tabcont.cxx
+++ b/sc/source/ui/view/tabcont.cxx
@@ -483,16 +483,16 @@ void ScTabControl::DoDrag()
aTabMark.ResetMark(); // doesn't change marked table information
aTabMark.SetMarkArea( aTabRange );
- ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+ ScDocumentUniquePtr pClipDoc(new ScDocument( SCDOCMODE_CLIP ));
ScClipParam aClipParam(aTabRange, false);
- rDoc.CopyToClip(aClipParam, pClipDoc, &aTabMark, false, false);
+ rDoc.CopyToClip(aClipParam, pClipDoc.get(), &aTabMark, false, false);
TransferableObjectDescriptor aObjDesc;
pDocSh->FillTransferableObjectDescriptor( aObjDesc );
aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
// maSize is set in ScTransferObj ctor
- rtl::Reference<ScTransferObj> pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ rtl::Reference<ScTransferObj> pTransferObj = new ScTransferObj( std::move(pClipDoc), aObjDesc );
pTransferObj->SetDragSourceFlags(ScDragSrc::Table);
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 570cf5f3f06e..d052717e7a57 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -279,7 +279,7 @@ bool ScViewFunc::CopyToClipSingleRange( ScDocument* pClipDoc, const ScRangeList&
aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
// maSize is set in ScTransferObj ctor
- ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ ScTransferObj* pTransferObj = new ScTransferObj( ScDocumentUniquePtr(pClipDoc), aObjDesc );
uno::Reference<css::datatransfer::XTransferable2> xTransferObj = pTransferObj;
if ( ScGlobal::xDrawClipDocShellRef.is() )
{
@@ -396,7 +396,7 @@ bool ScViewFunc::CopyToClipMultiRange( ScDocument* pInputClipDoc, const ScRangeL
aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
// maSize is set in ScTransferObj ctor
- ScTransferObj* pTransferObj = new ScTransferObj( pDocClip.release(), aObjDesc );
+ ScTransferObj* pTransferObj = new ScTransferObj( std::move(pDocClip), aObjDesc );
uno::Reference<css::datatransfer::XTransferable2> xTransferObj = pTransferObj;
if ( ScGlobal::xDrawClipDocShellRef.is() )
{
@@ -429,13 +429,13 @@ ScTransferObj* ScViewFunc::CopyToTransferable()
aRange.aEnd.Col(), aRange.aEnd.Row(),
rMark ) )
{
- ScDocument *pClipDoc = new ScDocument( SCDOCMODE_CLIP ); // create one (deleted by ScTransferObj)
+ ScDocumentUniquePtr pClipDoc(new ScDocument( SCDOCMODE_CLIP )); // create one (deleted by ScTransferObj)
bool bAnyOle = pDoc->HasOLEObjectsInArea( aRange, &rMark );
ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle ) );
ScClipParam aClipParam(aRange, false);
- pDoc->CopyToClip(aClipParam, pClipDoc, &rMark, false, true);
+ pDoc->CopyToClip(aClipParam, pClipDoc.get(), &rMark, false, true);
ScDrawLayer::SetGlobalDrawPersist(nullptr);
pClipDoc->ExtendMerge( aRange, true );
@@ -444,7 +444,7 @@ ScTransferObj* ScViewFunc::CopyToTransferable()
TransferableObjectDescriptor aObjDesc;
pDocSh->FillTransferableObjectDescriptor( aObjDesc );
aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
- ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ ScTransferObj* pTransferObj = new ScTransferObj( std::move(pClipDoc), aObjDesc );
return pTransferObj;
}
}