[Libreoffice-commits] core.git: 2 commits - svx/source xmlscript/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Aug 21 10:10:29 UTC 2018
svx/source/fmcomp/gridcell.cxx | 75 ++++++++++++++---------------
svx/source/inc/gridcell.hxx | 18 +++---
xmlscript/source/xml_helper/xml_impctx.cxx | 23 ++++----
3 files changed, 59 insertions(+), 57 deletions(-)
New commits:
commit 7469e078dc3a7a891bd7f5c44a693e4421d3bcdd
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Aug 20 11:21:55 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Aug 21 12:10:16 2018 +0200
loplugin:useuniqueptr in FmXGridCell
Change-Id: I4783b59f5fe83354fb47d081a60a81c9cebfac71
Reviewed-on: https://gerrit.libreoffice.org/59354
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index edd41b7c6568..59a559a33aff 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -179,26 +179,26 @@ void DbGridColumn::CreateControl(sal_Int32 _nFieldPos, const Reference< css::bea
}
}
- DbCellControl* pCellControl = nullptr;
+ std::unique_ptr<DbCellControl> pCellControl;
if (m_rParent.IsFilterMode())
{
- pCellControl = new DbFilterField(m_rParent.getContext(),*this);
+ pCellControl.reset(new DbFilterField(m_rParent.getContext(),*this));
}
else
{
switch (nTypeId)
{
- case TYPE_CHECKBOX: pCellControl = new DbCheckBox(*this); break;
- case TYPE_COMBOBOX: pCellControl = new DbComboBox(*this); break;
- case TYPE_CURRENCYFIELD: pCellControl = new DbCurrencyField(*this); break;
- case TYPE_DATEFIELD: pCellControl = new DbDateField(*this); break;
- case TYPE_LISTBOX: pCellControl = new DbListBox(*this); break;
- case TYPE_NUMERICFIELD: pCellControl = new DbNumericField(*this); break;
- case TYPE_PATTERNFIELD: pCellControl = new DbPatternField( *this, m_rParent.getContext() ); break;
- case TYPE_TEXTFIELD: pCellControl = new DbTextField(*this); break;
- case TYPE_TIMEFIELD: pCellControl = new DbTimeField(*this); break;
- case TYPE_FORMATTEDFIELD: pCellControl = new DbFormattedField(*this); break;
+ case TYPE_CHECKBOX: pCellControl.reset(new DbCheckBox(*this)); break;
+ case TYPE_COMBOBOX: pCellControl.reset(new DbComboBox(*this)); break;
+ case TYPE_CURRENCYFIELD: pCellControl.reset(new DbCurrencyField(*this)); break;
+ case TYPE_DATEFIELD: pCellControl.reset(new DbDateField(*this)); break;
+ case TYPE_LISTBOX: pCellControl.reset(new DbListBox(*this)); break;
+ case TYPE_NUMERICFIELD: pCellControl.reset(new DbNumericField(*this)); break;
+ case TYPE_PATTERNFIELD: pCellControl.reset(new DbPatternField( *this, m_rParent.getContext() )); break;
+ case TYPE_TEXTFIELD: pCellControl.reset(new DbTextField(*this)); break;
+ case TYPE_TIMEFIELD: pCellControl.reset(new DbTimeField(*this)); break;
+ case TYPE_FORMATTEDFIELD: pCellControl.reset(new DbFormattedField(*this)); break;
default:
OSL_FAIL("DbGridColumn::CreateControl: Unknown Column");
return;
@@ -213,17 +213,18 @@ void DbGridColumn::CreateControl(sal_Int32 _nFieldPos, const Reference< css::bea
pCellControl->Init( m_rParent.GetDataWindow(), xCur );
// now create the control wrapper
+ auto pTempCellControl = pCellControl.get();
if (m_rParent.IsFilterMode())
- m_pCell = new FmXFilterCell(this, static_cast<DbFilterField*>(pCellControl));
+ m_pCell = new FmXFilterCell(this, std::unique_ptr<DbFilterField>(static_cast<DbFilterField*>(pCellControl.release())));
else
{
switch (nTypeId)
{
- case TYPE_CHECKBOX: m_pCell = new FmXCheckBoxCell( this, *pCellControl ); break;
- case TYPE_LISTBOX: m_pCell = new FmXListBoxCell( this, *pCellControl ); break;
- case TYPE_COMBOBOX: m_pCell = new FmXComboBoxCell( this, *pCellControl ); break;
+ case TYPE_CHECKBOX: m_pCell = new FmXCheckBoxCell( this, std::move(pCellControl) ); break;
+ case TYPE_LISTBOX: m_pCell = new FmXListBoxCell( this, std::move(pCellControl) ); break;
+ case TYPE_COMBOBOX: m_pCell = new FmXComboBoxCell( this, std::move(pCellControl) ); break;
default:
- m_pCell = new FmXEditCell( this, *pCellControl );
+ m_pCell = new FmXEditCell( this, std::move(pCellControl) );
}
}
m_pCell->init();
@@ -233,7 +234,7 @@ void DbGridColumn::CreateControl(sal_Int32 _nFieldPos, const Reference< css::bea
// only if we use have a bound field, we use a controller for displaying the
// window in the grid
if (m_xField.is())
- m_xController = pCellControl->CreateController();
+ m_xController = pTempCellControl->CreateController();
}
@@ -3122,10 +3123,10 @@ IMPL_LINK_NOARG(DbFilterField, OnClick, VclPtr<CheckBox>, void)
}
-FmXGridCell::FmXGridCell( DbGridColumn* pColumn, DbCellControl* _pControl )
+FmXGridCell::FmXGridCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> _pControl )
:OComponentHelper(m_aMutex)
,m_pColumn(pColumn)
- ,m_pCellControl( _pControl )
+ ,m_pCellControl( std::move(_pControl) )
,m_aWindowListeners( m_aMutex )
,m_aFocusListeners( m_aMutex )
,m_aKeyListeners( m_aMutex )
@@ -3503,8 +3504,8 @@ void FmXDataCell::UpdateFromColumn()
}
-FmXTextCell::FmXTextCell( DbGridColumn* pColumn, DbCellControl& _rControl )
- :FmXDataCell( pColumn, _rControl )
+FmXTextCell::FmXTextCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl )
+ :FmXDataCell( pColumn, std::move(pControl) )
,m_bFastPaint( true )
{
}
@@ -3557,15 +3558,15 @@ void FmXTextCell::PaintFieldToCell(OutputDevice& rDev,
}
}
-FmXEditCell::FmXEditCell( DbGridColumn* pColumn, DbCellControl& _rControl )
- :FmXTextCell( pColumn, _rControl )
+FmXEditCell::FmXEditCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl )
+ :FmXTextCell( pColumn, std::move(pControl) )
,m_aTextListeners(m_aMutex)
,m_aChangeListeners( m_aMutex )
,m_pEditImplementation( nullptr )
,m_bOwnEditImplementation( false )
{
- DbTextField* pTextField = dynamic_cast<DbTextField*>( &_rControl );
+ DbTextField* pTextField = dynamic_cast<DbTextField*>( m_pCellControl.get() );
if ( pTextField )
{
@@ -3575,7 +3576,7 @@ FmXEditCell::FmXEditCell( DbGridColumn* pColumn, DbCellControl& _rControl )
}
else
{
- m_pEditImplementation = new EditImplementation( static_cast< Edit& >( _rControl.GetWindow() ) );
+ m_pEditImplementation = new EditImplementation( static_cast< Edit& >( m_pCellControl->GetWindow() ) );
m_bOwnEditImplementation = true;
}
}
@@ -3820,11 +3821,11 @@ void FmXEditCell::onWindowEvent( const VclEventId _nEventId, const vcl::Window&
FmXTextCell::onWindowEvent( _nEventId, _rWindow, _pEventData );
}
-FmXCheckBoxCell::FmXCheckBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl )
- :FmXDataCell( pColumn, _rControl )
+FmXCheckBoxCell::FmXCheckBoxCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl )
+ :FmXDataCell( pColumn, std::move(pControl) )
,m_aItemListeners(m_aMutex)
,m_aActionListeners( m_aMutex )
- ,m_pBox( & static_cast< CheckBoxControl& >( _rControl.GetWindow() ).GetBox() )
+ ,m_pBox( & static_cast< CheckBoxControl& >( m_pCellControl->GetWindow() ).GetBox() )
{
}
@@ -3994,11 +3995,11 @@ void FmXCheckBoxCell::onWindowEvent( const VclEventId _nEventId, const vcl::Wind
}
}
-FmXListBoxCell::FmXListBoxCell(DbGridColumn* pColumn, DbCellControl& _rControl)
- :FmXTextCell( pColumn, _rControl )
+FmXListBoxCell::FmXListBoxCell(DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl)
+ :FmXTextCell( pColumn, std::move(pControl) )
,m_aItemListeners(m_aMutex)
,m_aActionListeners(m_aMutex)
- ,m_pBox( &static_cast< ListBox& >( _rControl.GetWindow() ) )
+ ,m_pBox( &static_cast< ListBox& >( m_pCellControl->GetWindow() ) )
{
m_pBox->SetDoubleClickHdl( LINK( this, FmXListBoxCell, OnDoubleClick ) );
@@ -4329,11 +4330,11 @@ IMPL_LINK_NOARG(FmXListBoxCell, OnDoubleClick, ListBox&, void)
}
}
-FmXComboBoxCell::FmXComboBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl )
- :FmXTextCell( pColumn, _rControl )
+FmXComboBoxCell::FmXComboBoxCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl )
+ :FmXTextCell( pColumn, std::move(pControl) )
,m_aItemListeners( m_aMutex )
,m_aActionListeners( m_aMutex )
- ,m_pComboBox( &static_cast< ComboBox& >( _rControl.GetWindow() ) )
+ ,m_pComboBox( &static_cast< ComboBox& >( m_pCellControl->GetWindow() ) )
{
}
@@ -4517,8 +4518,8 @@ void FmXComboBoxCell::onWindowEvent( const VclEventId _nEventId, const vcl::Wind
}
-FmXFilterCell::FmXFilterCell(DbGridColumn* pColumn, DbFilterField* pControl )
- :FmXGridCell( pColumn, pControl )
+FmXFilterCell::FmXFilterCell(DbGridColumn* pColumn, std::unique_ptr<DbFilterField> pControl )
+ :FmXGridCell( pColumn, std::move(pControl) )
,m_aTextListeners(m_aMutex)
{
pControl->SetCommitHdl( LINK( this, FmXFilterCell, OnCommit ) );
diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx
index f67196fd23b3..42cc075d98c4 100644
--- a/svx/source/inc/gridcell.hxx
+++ b/svx/source/inc/gridcell.hxx
@@ -717,7 +717,7 @@ protected:
virtual ~FmXGridCell() override;
public:
- FmXGridCell( DbGridColumn* pColumn, DbCellControl* pControl );
+ FmXGridCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl );
void init();
DECLARE_UNO3_AGG_DEFAULTS(FmXGridCell, OComponentHelper)
@@ -798,8 +798,8 @@ private:
class FmXDataCell : public FmXGridCell
{
public:
- FmXDataCell( DbGridColumn* pColumn, DbCellControl& _rControl )
- :FmXGridCell( pColumn, &_rControl )
+ FmXDataCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl )
+ :FmXGridCell( pColumn, std::move(pControl) )
{
}
@@ -836,7 +836,7 @@ protected:
bool m_bFastPaint;
public:
- FmXTextCell( DbGridColumn* pColumn, DbCellControl& _rControl );
+ FmXTextCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl );
virtual void PaintFieldToCell(OutputDevice& rDev,
const tools::Rectangle& rRect,
@@ -857,7 +857,7 @@ class FmXEditCell final : public FmXTextCell,
public FmXEditCell_Base
{
public:
- FmXEditCell( DbGridColumn* pColumn, DbCellControl& _rControl );
+ FmXEditCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl );
DECLARE_UNO3_AGG_DEFAULTS(FmXEditCell, FmXTextCell)
virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override;
@@ -920,7 +920,7 @@ protected:
virtual ~FmXCheckBoxCell() override;
public:
- FmXCheckBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl );
+ FmXCheckBoxCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl );
// UNO
DECLARE_UNO3_AGG_DEFAULTS(FmXCheckBoxCell, FmXDataCell)
@@ -957,7 +957,7 @@ class FmXListBoxCell final :public FmXTextCell
,public FmXListBoxCell_Base
{
public:
- FmXListBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl );
+ FmXListBoxCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl );
DECLARE_UNO3_AGG_DEFAULTS(FmXListBoxCell, FmXTextCell)
virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override;
@@ -1017,7 +1017,7 @@ protected:
virtual ~FmXComboBoxCell() override;
public:
- FmXComboBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl );
+ FmXComboBoxCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl );
DECLARE_UNO3_AGG_DEFAULTS(FmXListBoxCell, FmXTextCell)
virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override;
@@ -1053,7 +1053,7 @@ class FmXFilterCell final : public FmXGridCell
,public FmXFilterCell_Base
{
public:
- FmXFilterCell(DbGridColumn* pColumn, DbFilterField* pControl);
+ FmXFilterCell(DbGridColumn* pColumn, std::unique_ptr<DbFilterField> pControl);
DECLARE_UNO3_AGG_DEFAULTS(FmXFilterCell, FmXGridCell)
commit 9ca80b550216daac3cfb3d373c344c0154fa7df2
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Aug 20 09:54:12 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Aug 21 12:10:07 2018 +0200
loplugin:useuniqueptr in ExtendedAttributes
Change-Id: I86af2614ac9e3282ecd2aba5d23f6a075712968f
Reviewed-on: https://gerrit.libreoffice.org/59351
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/xmlscript/source/xml_helper/xml_impctx.cxx b/xmlscript/source/xml_helper/xml_impctx.cxx
index 3ebc809d1cfe..47d8a544b4e6 100644
--- a/xmlscript/source/xml_helper/xml_impctx.cxx
+++ b/xmlscript/source/xml_helper/xml_impctx.cxx
@@ -310,8 +310,9 @@ class ExtendedAttributes :
public:
inline ExtendedAttributes(
sal_Int32 nAttributes,
- sal_Int32 * pUids,
- OUString * pLocalNames, OUString * pQNames,
+ std::unique_ptr<sal_Int32[]> pUids,
+ std::unique_ptr<OUString[]> pLocalNames,
+ std::unique_ptr<OUString[]> pQNames,
Reference< xml::sax::XAttributeList > const & xAttributeList );
// XAttributes
@@ -336,13 +337,13 @@ public:
inline ExtendedAttributes::ExtendedAttributes(
sal_Int32 nAttributes,
- sal_Int32 * pUids,
- OUString * pLocalNames, OUString * pQNames,
+ std::unique_ptr<sal_Int32[]> pUids,
+ std::unique_ptr<OUString[]> pLocalNames, std::unique_ptr<OUString[]> pQNames,
Reference< xml::sax::XAttributeList > const & xAttributeList )
: m_nAttributes( nAttributes )
- , m_pUids( pUids )
- , m_pLocalNames( pLocalNames )
- , m_pQNames( pQNames )
+ , m_pUids( std::move(pUids) )
+ , m_pLocalNames( std::move(pLocalNames) )
+ , m_pQNames( std::move(pQNames) )
, m_pValues( new OUString[ nAttributes ] )
{
for ( sal_Int32 nPos = 0; nPos < nAttributes; ++nPos )
@@ -441,10 +442,10 @@ void DocumentHandlerImpl::startElement(
sal_Int16 nAttribs = xAttribs->getLength();
// save all namespace ids
- sal_Int32 * pUids = new sal_Int32[ nAttribs ];
+ std::unique_ptr<sal_Int32[]> pUids(new sal_Int32[ nAttribs ]);
OUString * pPrefixes = new OUString[ nAttribs ];
- OUString * pLocalNames = new OUString[ nAttribs ];
- OUString * pQNames = new OUString[ nAttribs ];
+ std::unique_ptr<OUString[]> pLocalNames(new OUString[ nAttribs ]);
+ std::unique_ptr<OUString[]> pQNames(new OUString[ nAttribs ]);
// first recognize all xmlns attributes
sal_Int16 nPos;
@@ -511,7 +512,7 @@ void DocumentHandlerImpl::startElement(
// ownership of arrays belongs to attribute list
xAttributes = static_cast< xml::input::XAttributes * >(
new ExtendedAttributes(
- nAttribs, pUids, pLocalNames, pQNames,
+ nAttribs, std::move(pUids), std::move(pLocalNames), std::move(pQNames),
xAttribs ) );
getElementName( rQElementName, &nUid, &aLocalName );
More information about the Libreoffice-commits
mailing list