summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-10-04 15:11:13 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-10-05 12:06:26 +0200
commit42b629bc7f700d6f1d1b922e5c6aab119b8edf27 (patch)
treeb860545d390a89d989554c89a148eef4c20990d8 /svx/source
parent1fefdd6f3b4165491af433a815e6c82aa5ac8204 (diff)
use more std::unique_ptr in FmFormView::createControlLabelPair
Change-Id: I36f364739e5a37f9adc0fbad8a49a71947b7318b Reviewed-on: https://gerrit.libreoffice.org/61399 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/form/fmview.cxx6
-rw-r--r--svx/source/form/fmvwimp.cxx37
-rw-r--r--svx/source/inc/fmvwimp.hxx11
-rw-r--r--svx/source/svdraw/svdmodel.cxx11
4 files changed, 32 insertions, 33 deletions
diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx
index 15df6aa0adfb..e4670a1fb714 100644
--- a/svx/source/form/fmview.cxx
+++ b/svx/source/form/fmview.cxx
@@ -566,13 +566,15 @@ FmFormObj* FmFormView::getMarkedGrid() const
void FmFormView::createControlLabelPair( OutputDevice const * _pOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM,
const Reference< XPropertySet >& _rxField, const Reference< XNumberFormats >& _rxNumberFormats,
sal_uInt16 _nControlObjectID, SdrInventor _nInventor, sal_uInt16 _nLabelObjectID,
- SdrPage* _pLabelPage, SdrPage* _pControlPage, SdrModel& _rModel, SdrUnoObj*& _rpLabel, SdrUnoObj*& _rpControl )
+ SdrModel& _rModel,
+ std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
+ std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl )
{
FmXFormView::createControlLabelPair(
*_pOutDev, _nXOffsetMM, _nYOffsetMM,
_rxField, _rxNumberFormats,
_nControlObjectID, "", _nInventor, _nLabelObjectID,
- _pLabelPage, _pControlPage, _rModel,
+ _rModel,
_rpLabel, _rpControl
);
}
diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx
index 491a9c548ad2..ec0df8ee71a7 100644
--- a/svx/source/form/fmvwimp.cxx
+++ b/svx/source/form/fmvwimp.cxx
@@ -1333,8 +1333,8 @@ SdrObject* FmXFormView::implCreateFieldControl( const svx::ODataAccessDescriptor
if (!nOBJID)
return nullptr;
- SdrUnoObj* pLabel( nullptr );
- SdrUnoObj* pControl( nullptr );
+ std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pLabel;
+ std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl;
if ( !createControlLabelPair( *pOutDev, 0, 0, xField, xNumberFormats, nOBJID, sLabelPostfix,
pLabel, pControl, xDataSource, sDataSource, sCommand, nCommandType )
)
@@ -1347,23 +1347,22 @@ SdrObject* FmXFormView::implCreateFieldControl( const svx::ODataAccessDescriptor
bool bCheckbox = ( OBJ_FM_CHECKBOX == nOBJID );
OSL_ENSURE( !bCheckbox || !pLabel, "FmXFormView::implCreateFieldControl: why was there a label created for a check box?" );
if ( bCheckbox )
- return pControl;
+ return pControl.release();
SdrObjGroup* pGroup = new SdrObjGroup(getView()->getSdrModelFromSdrView());
SdrObjList* pObjList = pGroup->GetSubList();
- pObjList->InsertObject( pLabel );
- pObjList->InsertObject( pControl );
+ pObjList->InsertObject( pLabel.release() );
+ pObjList->InsertObject( pControl.release() );
if ( bDateNTimeField )
{ // so far we created a date field only, but we also need a time field
- pLabel = pControl = nullptr;
if ( createControlLabelPair( *pOutDev, 0, 1000, xField, xNumberFormats, OBJ_FM_TIMEFIELD,
SvxResId(RID_STR_POSTFIX_TIME), pLabel, pControl,
xDataSource, sDataSource, sCommand, nCommandType )
)
{
- pObjList->InsertObject( pLabel );
- pObjList->InsertObject( pControl );
+ pObjList->InsertObject( pLabel.release() );
+ pObjList->InsertObject( pControl.release() );
}
}
@@ -1436,8 +1435,8 @@ SdrObject* FmXFormView::implCreateXFormsControl( const svx::OXFormsDescriptor &_
// xform control or submission button?
if ( !xSubmission.is() )
{
- SdrUnoObj* pLabel( nullptr );
- SdrUnoObj* pControl( nullptr );
+ std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pLabel;
+ std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl;
if ( !createControlLabelPair( *pOutDev, 0, 0, nullptr, xNumberFormats, nOBJID, sLabelPostfix,
pLabel, pControl, nullptr, "", "", -1 )
)
@@ -1457,14 +1456,14 @@ SdrObject* FmXFormView::implCreateXFormsControl( const svx::OXFormsDescriptor &_
bool bCheckbox = ( OBJ_FM_CHECKBOX == nOBJID );
OSL_ENSURE( !bCheckbox || !pLabel, "FmXFormView::implCreateXFormsControl: why was there a label created for a check box?" );
if ( bCheckbox )
- return pControl;
+ return pControl.release();
// group objects
SdrObjGroup* pGroup = new SdrObjGroup(getView()->getSdrModelFromSdrView());
SdrObjList* pObjList = pGroup->GetSubList();
- pObjList->InsertObject(pLabel);
- pObjList->InsertObject(pControl);
+ pObjList->InsertObject(pLabel.release());
+ pObjList->InsertObject(pControl.release());
return pGroup;
}
@@ -1512,7 +1511,8 @@ SdrObject* FmXFormView::implCreateXFormsControl( const svx::OXFormsDescriptor &_
bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM,
const Reference< XPropertySet >& _rxField, const Reference< XNumberFormats >& _rxNumberFormats,
sal_uInt16 _nControlObjectID, const OUString& _rFieldPostfix,
- SdrUnoObj*& _rpLabel, SdrUnoObj*& _rpControl,
+ std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
+ std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl,
const Reference< XDataSource >& _rxDataSource, const OUString& _rDataSourceName,
const OUString& _rCommand, const sal_Int32 _nCommandType )
{
@@ -1526,8 +1526,6 @@ bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int
_rFieldPostfix,
SdrInventor::FmForm,
OBJ_FM_FIXEDTEXT,
- nullptr,
- nullptr,
// tdf#118963 Hand over a SdrModel to SdrObject-creation. It uses the local m_pView
// and already returning false when nullptr == getView() could be done, but m_pView
@@ -1559,7 +1557,8 @@ bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int
const Reference< XPropertySet >& _rxField,
const Reference< XNumberFormats >& _rxNumberFormats, sal_uInt16 _nControlObjectID,
const OUString& _rFieldPostfix, SdrInventor _nInventor, sal_uInt16 _nLabelObjectID,
- SdrPage* /*_pLabelPage*/, SdrPage* /*_pControlPage*/, SdrModel& _rModel, SdrUnoObj*& _rpLabel, SdrUnoObj*& _rpControl)
+ SdrModel& _rModel,
+ std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel, std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl)
{
sal_Int32 nDataType = 0;
OUString sFieldName;
@@ -1714,8 +1713,8 @@ bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int
FormControlFactory::initializeFieldDependentProperties( _rxField, xControlSet, _rxNumberFormats );
}
- _rpLabel = pLabel.release();
- _rpControl = pControl.release();
+ _rpLabel = std::move(pLabel);
+ _rpControl = std::move(pControl);
return true;
}
diff --git a/svx/source/inc/fmvwimp.hxx b/svx/source/inc/fmvwimp.hxx
index 5fb1403bec42..f56a70e5db25 100644
--- a/svx/source/inc/fmvwimp.hxx
+++ b/svx/source/inc/fmvwimp.hxx
@@ -25,6 +25,7 @@
#include <memory>
#include <svx/svdmark.hxx>
+#include <svx/svdobj.hxx>
#include "fmdocumentclassification.hxx"
#include <com/sun/star/form/XForm.hpp>
@@ -259,15 +260,13 @@ private:
const OUString& _rFieldPostfix,
SdrInventor _nInventor,
sal_uInt16 _nLabelObjectID,
- SdrPage* _pLabelPage,
- SdrPage* _pControlPage,
// tdf#118963 Need a SdrModel for SdrObject creation. To make the
// demand clear, hand over a SdrMldel&
SdrModel& _rModel,
- SdrUnoObj*& _rpLabel,
- SdrUnoObj*& _rpControl
+ std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
+ std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl
);
bool createControlLabelPair(
@@ -278,8 +277,8 @@ private:
const css::uno::Reference< css::util::XNumberFormats >& _rxNumberFormats,
sal_uInt16 _nControlObjectID,
const OUString& _rFieldPostfix,
- SdrUnoObj*& _rpLabel,
- SdrUnoObj*& _rpControl,
+ std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpLabel,
+ std::unique_ptr<SdrUnoObj, SdrObjectFreeOp>& _rpControl,
const css::uno::Reference< css::sdbc::XDataSource >& _rxDataSource,
const OUString& _rDataSourceName,
const OUString& _rCommand,
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 405ef170ab23..2c1576d4988a 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -348,9 +348,9 @@ void SdrModel::Undo()
pDo->Undo();
if(!pRedoStack)
pRedoStack.reset(new std::deque<std::unique_ptr<SfxUndoAction>>);
- SfxUndoAction* p = pUndoStack->front().release();
+ std::unique_ptr<SfxUndoAction> p = std::move(pUndoStack->front());
pUndoStack->pop_front();
- pRedoStack->emplace_front(p);
+ pRedoStack->emplace_front(std::move(p));
mbUndoEnabled = bWasUndoEnabled;
}
}
@@ -372,9 +372,9 @@ void SdrModel::Redo()
pDo->Redo();
if(!pUndoStack)
pUndoStack.reset(new std::deque<std::unique_ptr<SfxUndoAction>>);
- SfxUndoAction* p = pRedoStack->front().release();
+ std::unique_ptr<SfxUndoAction> p = std::move(pRedoStack->front());
pRedoStack->pop_front();
- pUndoStack->emplace_front(p);
+ pUndoStack->emplace_front(std::move(p));
mbUndoEnabled = bWasUndoEnabled;
}
}
@@ -514,8 +514,7 @@ void SdrModel::EndUndo()
{
if(pCurrentUndoGroup->GetActionCount()!=0)
{
- SdrUndoAction* pUndo=pCurrentUndoGroup.release();
- ImpPostUndoAction(std::unique_ptr<SdrUndoAction>(pUndo));
+ ImpPostUndoAction(std::move(pCurrentUndoGroup));
}
else
{