summaryrefslogtreecommitdiff
path: root/reportdesign
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 /reportdesign
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 'reportdesign')
-rw-r--r--reportdesign/source/ui/inc/UITools.hxx2
-rw-r--r--reportdesign/source/ui/misc/UITools.cxx6
-rw-r--r--reportdesign/source/ui/report/ReportController.cxx42
3 files changed, 18 insertions, 32 deletions
diff --git a/reportdesign/source/ui/inc/UITools.hxx b/reportdesign/source/ui/inc/UITools.hxx
index c58354960c99..90b60c5ba37b 100644
--- a/reportdesign/source/ui/inc/UITools.hxx
+++ b/reportdesign/source/ui/inc/UITools.hxx
@@ -140,7 +140,7 @@ namespace rptui
*/
SdrObject* isOver(const tools::Rectangle& _rRect,SdrPage const & _rPage,SdrView const & _rView,bool _bAllObjects = false,SdrObject const * _pIgnore = nullptr, sal_Int16 _nIgnoreType=0);
- SdrObject* isOver(const tools::Rectangle& _rRect,SdrPage const & _rPage,SdrView const & _rView,bool _bAllObjects, SdrUnoObj* _pIgnoreList[], int _nIgnoreListLength);
+ SdrObject* isOver(const tools::Rectangle& _rRect,SdrPage const & _rPage,SdrView const & _rView,bool _bAllObjects, std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> _pIgnoreList[], int _nIgnoreListLength);
/** checks whether the given OUnoObject object rectangle overlapps another object in that view.
*
diff --git a/reportdesign/source/ui/misc/UITools.cxx b/reportdesign/source/ui/misc/UITools.cxx
index 00fe7ea80bbb..8bbfd8820fb0 100644
--- a/reportdesign/source/ui/misc/UITools.cxx
+++ b/reportdesign/source/ui/misc/UITools.cxx
@@ -867,11 +867,11 @@ SdrObject* isOver(const tools::Rectangle& _rRect, SdrPage const & _rPage, SdrVie
return pOverlappedObj;
}
-static bool checkArrayForOccurrence(SdrObject const * _pObjToCheck, SdrUnoObj* _pIgnore[], int _nListLength)
+static bool checkArrayForOccurrence(SdrObject const * _pObjToCheck, std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> _pIgnore[], int _nListLength)
{
for(int i=0;i<_nListLength;i++)
{
- SdrObject *pIgnore = _pIgnore[i];
+ SdrObject *pIgnore = _pIgnore[i].get();
if (pIgnore == _pObjToCheck)
{
return true;
@@ -880,7 +880,7 @@ static bool checkArrayForOccurrence(SdrObject const * _pObjToCheck, SdrUnoObj* _
return false;
}
-SdrObject* isOver(const tools::Rectangle& _rRect,SdrPage const & _rPage,SdrView const & _rView,bool _bAllObjects, SdrUnoObj * _pIgnoreList[], int _nIgnoreListLength)
+SdrObject* isOver(const tools::Rectangle& _rRect,SdrPage const & _rPage,SdrView const & _rView,bool _bAllObjects, std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> _pIgnoreList[], int _nIgnoreListLength)
{
SdrObject* pOverlappedObj = nullptr;
SdrObjListIter aIter(&_rPage,SdrIterMode::DeepNoGroups);
diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx
index 411b8eb034b8..92c417dd5c45 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -3134,8 +3134,8 @@ void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,co
}
else
{
- SdrUnoObj* pLabel( nullptr );
- SdrUnoObj* pControl( nullptr );
+ std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pLabel;
+ std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl;
FmFormView::createControlLabelPair(
getDesignView(),
@@ -3146,8 +3146,6 @@ void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,co
_nObjectId,
SdrInventor::ReportDesign,
OBJ_DLG_FIXEDTEXT,
- nullptr,
- pSectionWindow->getReportSection().getPage(),
// tdf#118963 Need a SdrModel for SdrObject creation. Dereferencing
// m_aReportModel seems pretty safe, it's done in other places, initialized
@@ -3157,12 +3155,10 @@ void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,co
pLabel,
pControl);
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(pLabel);
- SdrObject::Free(pTemp);
+ pLabel.reset();
- pNewControl = pControl;
- OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl);
+ pNewControl = pControl.release();
+ OUnoObject* pObj = dynamic_cast<OUnoObject*>(pNewControl);
assert(pObj);
if(pObj)
{
@@ -3440,9 +3436,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
continue;
Reference< XNumberFormats > xNumberFormats(xSupplier->getNumberFormats());
- SdrUnoObj* pControl[2];
- pControl[0] = nullptr;
- pControl[1] = nullptr;
+ std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl[2];
const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN);
const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE).Width - nRightMargin;
OSectionView* pSectionViews[2];
@@ -3459,8 +3453,6 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
nOBJID,
SdrInventor::ReportDesign,
OBJ_DLG_FIXEDTEXT,
- pSectionWindow[1]->getReportSection().getPage(),
- pSectionWindow[0]->getReportSection().getPage(),
// tdf#118963 Need a SdrModel for SdrObject creation. Dereferencing
// m_aReportModel seems pretty safe, it's done in other places, initialized
@@ -3482,7 +3474,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
OUnoObject* pObjs[2];
for(i = 0; i < SAL_N_ELEMENTS(pControl); ++i)
{
- pObjs[i] = dynamic_cast<OUnoObject*>(pControl[i]);
+ pObjs[i] = dynamic_cast<OUnoObject*>(pControl[i].get());
uno::Reference<beans::XPropertySet> xUnoProp(pObjs[i]->GetUnoControlModel(),uno::UNO_QUERY_THROW);
uno::Reference< report::XReportComponent> xShapeProp(pObjs[i]->getUnoShape(),uno::UNO_QUERY_THROW);
xUnoProp->setPropertyValue(PROPERTY_NAME,xShapeProp->getPropertyValue(PROPERTY_NAME));
@@ -3553,21 +3545,21 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
}
xShapePropLabel->setPosition(aPosLabel);
}
- OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl[0]);
+ OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl[0].get());
uno::Reference< report::XFixedText> xShapeProp(pObj->getUnoShape(),uno::UNO_QUERY_THROW);
xShapeProp->setName(xShapeProp->getName() + sDefaultName );
for(i = 0; i < SAL_N_ELEMENTS(pControl); ++i) // insert controls
{
- correctOverlapping(pControl[i],pSectionWindow[1-i]->getReportSection());
+ correctOverlapping(pControl[i].get(), pSectionWindow[1-i]->getReportSection());
}
if (!bLabelAboveTextField )
{
if ( pSectionViews[0] == pSectionViews[1] )
{
- tools::Rectangle aLabel = getRectangleFromControl(pControl[0]);
- tools::Rectangle aTextfield = getRectangleFromControl(pControl[1]);
+ tools::Rectangle aLabel = getRectangleFromControl(pControl[0].get());
+ tools::Rectangle aTextfield = getRectangleFromControl(pControl[1].get());
// create a Union of the given Label and Textfield
tools::Rectangle aLabelAndTextfield( aLabel );
@@ -3603,15 +3595,9 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
}
}
}
- }
- else
- {
- for(SdrUnoObj* i : pControl)
- {
- // always use SdrObject::Free(...) for SdrObjects (!)
- SdrObject* pTemp(i);
- SdrObject::Free(pTemp);
- }
+ // not sure where the ownership of these passes too...
+ pControl[0].release();
+ pControl[1].release();
}
}
}