loplugin:constantparam (1)

Change-Id: I25077e391ecca1b678062d261a83d88daadf0a58
Reviewed-on: https://gerrit.libreoffice.org/59701
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2018-08-29 09:00:52 +02:00
parent dc06c8f498
commit 6dbae37b8d
15 changed files with 74 additions and 128 deletions
@@ -136,20 +136,8 @@ struct StaticScatterChartTypeInfo : public rtl::StaticAggregate< uno::Reference<
namespace chart
{
ScatterChartType::ScatterChartType(
chart2::CurveStyle eCurveStyle /* chart2::CurveStyle_LINES */ ,
sal_Int32 nResolution /* = 20 */,
sal_Int32 nOrder /* = 3 */ )
ScatterChartType::ScatterChartType()
{
if( eCurveStyle != chart2::CurveStyle_LINES )
setFastPropertyValue_NoBroadcast( PROP_SCATTERCHARTTYPE_CURVE_STYLE,
uno::Any( eCurveStyle ));
if( nResolution != 20 )
setFastPropertyValue_NoBroadcast( PROP_SCATTERCHARTTYPE_CURVE_RESOLUTION,
uno::Any( nResolution ));
if( nOrder != 3 )
setFastPropertyValue_NoBroadcast( PROP_SCATTERCHARTTYPE_SPLINE_ORDER,
uno::Any( nOrder ));
}
ScatterChartType::ScatterChartType( const ScatterChartType & rOther ) :
@@ -28,10 +28,7 @@ namespace chart
class ScatterChartType final : public ChartType
{
public:
ScatterChartType(
css::chart2::CurveStyle eCurveStyle = css::chart2::CurveStyle_LINES,
sal_Int32 nResolution = 20,
sal_Int32 nOrder = 3 );
ScatterChartType();
virtual ~ScatterChartType() override;
virtual OUString SAL_CALL
+7 -42
View File
@@ -21,56 +21,21 @@
namespace comphelper
{
css::uno::Sequence<sal_Int16> findValue(const css::uno::Sequence< OUString >& _rList, const OUString& _rValue, bool _bOnlyFirst)
sal_Int32 findValue(const css::uno::Sequence< OUString >& _rList, const OUString& _rValue)
{
sal_Int32 nLength = _rList.getLength();
if( _bOnlyFirst )
// at which position do I find the value?
const OUString* pTArray = _rList.getConstArray();
for (sal_Int32 i = 0; i < nLength; ++i, ++pTArray)
{
// at which position do I find the value?
sal_Int32 nPos = -1;
const OUString* pTArray = _rList.getConstArray();
for (sal_Int32 i = 0; i < nLength; ++i, ++pTArray)
if( *pTArray == _rValue )
{
if( *pTArray == _rValue )
{
nPos = i;
break;
}
return i;
}
// fill sequence
if( nPos>-1 )
{
css::uno::Sequence<sal_Int16> aRetSeq( 1 );
aRetSeq.getArray()[0] = static_cast<sal_Int16>(nPos);
return aRetSeq;
}
return css::uno::Sequence<sal_Int16>();
}
else
{
css::uno::Sequence<sal_Int16> aRetSeq( nLength );
sal_Int16* pReturn = aRetSeq.getArray();
// how often does the value occur?
const OUString* pTArray = _rList.getConstArray();
for (sal_Int32 i = 0; i < nLength; ++i, ++pTArray)
{
if( *pTArray == _rValue )
{
*pReturn = static_cast<sal_Int16>(i);
++pReturn;
}
}
aRetSeq.realloc(pReturn - aRetSeq.getArray());
return aRetSeq;
}
return -1;
}
} // namespace comphelper
@@ -120,7 +120,7 @@ css::uno::Sequence< OUString > SAL_CALL OConnectionWrapper::getSupportedServiceN
// append our own service, if necessary
OUString sConnectionService( "com.sun.star.sdbc.Connection" );
if ( 0 == ::comphelper::findValue( aSupported, sConnectionService, true ).getLength() )
if ( ::comphelper::findValue( aSupported, sConnectionService ) == -1 )
{
sal_Int32 nLen = aSupported.getLength();
aSupported.realloc( nLen + 1 );
+3 -3
View File
@@ -997,10 +997,10 @@ bool isAggregateColumn(const Reference< XSingleSelectQueryComposer > &_xParser,
if (xColumnsSupplier.is())
xCols = xColumnsSupplier->getColumns();
return isAggregateColumn(xCols, sName, false/*whenNotFound*/);
return isAggregateColumn(xCols, sName);
}
bool isAggregateColumn(const Reference< XNameAccess > &_xColumns, const OUString &_sName, bool whenNotFound)
bool isAggregateColumn(const Reference< XNameAccess > &_xColumns, const OUString &_sName)
{
if ( _xColumns.is() && _xColumns->hasByName(_sName) )
{
@@ -1008,7 +1008,7 @@ bool isAggregateColumn(const Reference< XNameAccess > &_xColumns, const OUString
assert(xProp.is());
return isAggregateColumn( xProp );
}
return whenNotFound;
return false;
}
bool isAggregateColumn( const Reference< XPropertySet > &_xColumn )
+39 -39
View File
@@ -313,7 +313,7 @@ static inline bool idefaultConstructElements(
static inline bool icopyConstructFromElements(
uno_Sequence ** ppSeq, void * pSourceElements,
typelib_TypeDescriptionReference * pElementType,
sal_Int32 nStartIndex, sal_Int32 nStopIndex,
sal_Int32 nStopIndex,
uno_AcquireFunc acquire,
sal_Int32 nAlloc )
{
@@ -325,9 +325,9 @@ static inline bool icopyConstructFromElements(
if (pSeq != nullptr)
{
memcpy(
pSeq->elements + (sizeof(sal_Unicode) * nStartIndex),
static_cast<char *>(pSourceElements) + (sizeof(sal_Unicode) * nStartIndex),
sizeof(sal_Unicode) * (nStopIndex - nStartIndex) );
pSeq->elements,
pSourceElements,
sizeof(sal_Unicode) * nStopIndex );
}
break;
case typelib_TypeClass_BOOLEAN:
@@ -335,9 +335,9 @@ static inline bool icopyConstructFromElements(
if (pSeq != nullptr)
{
memcpy(
pSeq->elements + (sizeof(sal_Bool) * nStartIndex),
static_cast<char *>(pSourceElements) + (sizeof(sal_Bool) * nStartIndex),
sizeof(sal_Bool) * (nStopIndex - nStartIndex) );
pSeq->elements,
pSourceElements,
sizeof(sal_Bool) * nStopIndex );
}
break;
case typelib_TypeClass_BYTE:
@@ -345,9 +345,9 @@ static inline bool icopyConstructFromElements(
if (pSeq != nullptr)
{
memcpy(
pSeq->elements + (sizeof(sal_Int8) * nStartIndex),
static_cast<char *>(pSourceElements) + (sizeof(sal_Int8) * nStartIndex),
sizeof(sal_Int8) * (nStopIndex - nStartIndex) );
pSeq->elements,
pSourceElements,
sizeof(sal_Int8) * nStopIndex );
}
break;
case typelib_TypeClass_SHORT:
@@ -356,9 +356,9 @@ static inline bool icopyConstructFromElements(
if (pSeq != nullptr)
{
memcpy(
pSeq->elements + (sizeof(sal_Int16) * nStartIndex),
static_cast<char *>(pSourceElements) + (sizeof(sal_Int16) * nStartIndex),
sizeof(sal_Int16) * (nStopIndex - nStartIndex) );
pSeq->elements,
pSourceElements,
sizeof(sal_Int16) * nStopIndex );
}
break;
case typelib_TypeClass_LONG:
@@ -367,9 +367,9 @@ static inline bool icopyConstructFromElements(
if (pSeq != nullptr)
{
memcpy(
pSeq->elements + (sizeof(sal_Int32) * nStartIndex),
static_cast<char *>(pSourceElements) + (sizeof(sal_Int32) * nStartIndex),
sizeof(sal_Int32) * (nStopIndex - nStartIndex) );
pSeq->elements,
pSourceElements,
sizeof(sal_Int32) * nStopIndex );
}
break;
case typelib_TypeClass_HYPER:
@@ -378,9 +378,9 @@ static inline bool icopyConstructFromElements(
if (pSeq != nullptr)
{
memcpy(
pSeq->elements + (sizeof(sal_Int64) * nStartIndex),
static_cast<char *>(pSourceElements) + (sizeof(sal_Int64) * nStartIndex),
sizeof(sal_Int64) * (nStopIndex - nStartIndex) );
pSeq->elements,
pSourceElements,
sizeof(sal_Int64) * nStopIndex );
}
break;
case typelib_TypeClass_FLOAT:
@@ -388,9 +388,9 @@ static inline bool icopyConstructFromElements(
if (pSeq != nullptr)
{
memcpy(
pSeq->elements + (sizeof(float) * nStartIndex),
static_cast<char *>(pSourceElements) + (sizeof(float) * nStartIndex),
sizeof(float) * (nStopIndex - nStartIndex) );
pSeq->elements,
pSourceElements,
sizeof(float) * nStopIndex );
}
break;
case typelib_TypeClass_DOUBLE:
@@ -398,9 +398,9 @@ static inline bool icopyConstructFromElements(
if (pSeq != nullptr)
{
memcpy(
pSeq->elements + (sizeof(double) * nStartIndex),
static_cast<char *>(pSourceElements) + (sizeof(double) * nStartIndex),
sizeof(double) * (nStopIndex - nStartIndex) );
pSeq->elements,
pSourceElements,
sizeof(double) * nStopIndex );
}
break;
case typelib_TypeClass_ENUM:
@@ -408,9 +408,9 @@ static inline bool icopyConstructFromElements(
if (pSeq != nullptr)
{
memcpy(
pSeq->elements + (sizeof(sal_Int32) * nStartIndex),
static_cast<char *>(pSourceElements) + (sizeof(sal_Int32) * nStartIndex),
sizeof(sal_Int32) * (nStopIndex - nStartIndex) );
pSeq->elements,
pSourceElements,
sizeof(sal_Int32) * nStopIndex );
}
break;
case typelib_TypeClass_STRING:
@@ -419,7 +419,7 @@ static inline bool icopyConstructFromElements(
if (pSeq != nullptr)
{
rtl_uString ** pDestElements = reinterpret_cast<rtl_uString **>(pSeq->elements);
for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
for ( sal_Int32 nPos = 0; nPos < nStopIndex; ++nPos )
{
// This code tends to trigger coverity's overrun-buffer-arg warning
// coverity[index_parm_via_loop_bound] - https://communities.coverity.com/thread/2993
@@ -438,7 +438,7 @@ static inline bool icopyConstructFromElements(
{
typelib_TypeDescriptionReference ** pDestElements =
reinterpret_cast<typelib_TypeDescriptionReference **>(pSeq->elements);
for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
for ( sal_Int32 nPos = 0; nPos < nStopIndex; ++nPos )
{
TYPE_ACQUIRE(
static_cast<typelib_TypeDescriptionReference **>(
@@ -456,7 +456,7 @@ static inline bool icopyConstructFromElements(
if (pSeq != nullptr)
{
uno_Any * pDestElements = reinterpret_cast<uno_Any *>(pSeq->elements);
for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
for ( sal_Int32 nPos = 0; nPos < nStopIndex; ++nPos )
{
uno_Any * pSource = static_cast<uno_Any *>(pSourceElements) + nPos;
_copyConstructAny(
@@ -482,7 +482,7 @@ static inline bool icopyConstructFromElements(
typelib_CompoundTypeDescription * pTypeDescr =
reinterpret_cast<typelib_CompoundTypeDescription *>(pElementTypeDescr);
for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
for ( sal_Int32 nPos = 0; nPos < nStopIndex; ++nPos )
{
char * pDest =
pDestElements + (nElementSize * nPos);
@@ -527,7 +527,7 @@ static inline bool icopyConstructFromElements(
typelib_TypeDescriptionReference * pSeqElementType =
reinterpret_cast<typelib_IndirectTypeDescription *>(pElementTypeDescr)->pType;
uno_Sequence ** pDestElements = reinterpret_cast<uno_Sequence **>(pSeq->elements);
for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
for ( sal_Int32 nPos = 0; nPos < nStopIndex; ++nPos )
{
uno_Sequence * pNew = icopyConstructSequence(
static_cast<uno_Sequence **>(pSourceElements)[nPos],
@@ -547,7 +547,7 @@ static inline bool icopyConstructFromElements(
if (pSeq != nullptr)
{
void ** pDestElements = reinterpret_cast<void **>(pSeq->elements);
for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos )
for ( sal_Int32 nPos = 0; nPos < nStopIndex; ++nPos )
{
_acquire( pDestElements[nPos] =
static_cast<void **>(pSourceElements)[nPos], acquire );
@@ -596,7 +596,7 @@ static inline bool ireallocSequence(
{
ret = icopyConstructFromElements(
&pNew, pSeq->elements, pElementType,
0, nCopy, acquire,
nCopy, acquire,
nSize ); // alloc to nSize
}
if (ret && nRest > 0)
@@ -683,7 +683,7 @@ sal_Bool SAL_CALL uno_type_sequence_construct(
{
ret = icopyConstructFromElements(
ppSequence, pElements, pElementType,
0, len, acquire,
len, acquire,
len ); // alloc to len
}
@@ -724,7 +724,7 @@ sal_Bool SAL_CALL uno_sequence_construct(
{
ret = icopyConstructFromElements(
ppSequence, pElements, pElementType,
0, len, acquire,
len, acquire,
len ); // alloc to len
}
}
@@ -800,7 +800,7 @@ sal_Bool SAL_CALL uno_type_sequence_reference2One(
ret = icopyConstructFromElements(
&pNew, pSequence->elements,
reinterpret_cast<typelib_IndirectTypeDescription *>(pTypeDescr)->pType,
0, pSequence->nElements, acquire,
pSequence->nElements, acquire,
pSequence->nElements ); // alloc nElements
if (ret)
{
@@ -844,7 +844,7 @@ sal_Bool SAL_CALL uno_sequence_reference2One(
ret = icopyConstructFromElements(
&pNew, pSequence->elements,
reinterpret_cast<typelib_IndirectTypeDescription *>(pTypeDescr)->pType,
0, pSequence->nElements, acquire,
pSequence->nElements, acquire,
pSequence->nElements ); // alloc nElements
if (ret)
{
@@ -89,7 +89,7 @@ Sequence< OUString > OConnection::getSupportedServiceNames( )
{
Sequence< OUString > aSupported = OConnectionWrapper::getSupportedServiceNames();
if ( 0 == findValue( aSupported, SERVICE_SDB_CONNECTION, true ).getLength() )
if ( comphelper::findValue( aSupported, SERVICE_SDB_CONNECTION ) == -1 )
{
sal_Int32 nLen = aSupported.getLength();
aSupported.realloc( nLen + 1 );
@@ -150,9 +150,9 @@ namespace
xColumn->getPropertyValue(PROPERTY_RELATEDCOLUMN) >>= sRelatedColumn;
{
Sequence< sal_Int16> aFind(::comphelper::findValue(_rSource.GetOriginalColumns()->getElementNames(),rElement,true));
if(aFind.getLength())
pNewConnData->SetFieldIndex(JTCS_FROM,aFind[0]+1);
sal_Int32 nFindIndex = ::comphelper::findValue(_rSource.GetOriginalColumns()->getElementNames(),rElement);
if(nFindIndex != -1)
pNewConnData->SetFieldIndex(JTCS_FROM,nFindIndex+1);
else
OSL_FAIL("Column not found!");
}
@@ -160,9 +160,9 @@ namespace
Reference<XNameAccess> xRefColumns = _rDest.GetOriginalColumns();
if(xRefColumns.is())
{
Sequence< sal_Int16> aFind(::comphelper::findValue(xRefColumns->getElementNames(),sRelatedColumn,true));
if(aFind.getLength())
pNewConnData->SetFieldIndex(JTCS_TO,aFind[0]+1);
sal_Int32 nFindIndex = ::comphelper::findValue(xRefColumns->getElementNames(),sRelatedColumn);
if(nFindIndex != -1)
pNewConnData->SetFieldIndex(JTCS_TO,nFindIndex+1);
else
OSL_FAIL("Column not found!");
}
+2 -2
View File
@@ -2160,8 +2160,8 @@ bool SvxLanguageItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
// class SvxNoHyphenItem -------------------------------------------------
SvxNoHyphenItem::SvxNoHyphenItem( const bool bHyphen, const sal_uInt16 nId ) :
SfxBoolItem( nId , bHyphen )
SvxNoHyphenItem::SvxNoHyphenItem( const sal_uInt16 nId ) :
SfxBoolItem( nId , true )
{
}
+3 -3
View File
@@ -29,10 +29,10 @@
namespace comphelper
{
/** search the given string within the given sequence, return the positions where it was found.
if _bOnlyFirst is sal_True, only the first occurrence will be returned.
/** Search the given string within the given sequence, return the position of the first occurence.
Returns -1 if nothing found.
*/
COMPHELPER_DLLPUBLIC css::uno::Sequence<sal_Int16> findValue(const css::uno::Sequence< OUString >& _rList, const OUString& _rValue, bool _bOnlyFirst);
COMPHELPER_DLLPUBLIC sal_Int32 findValue(const css::uno::Sequence< OUString >& _rList, const OUString& _rValue);
namespace internal
{
+1 -4
View File
@@ -796,13 +796,10 @@ namespace dbtools
look for column sName in there
@param _sName
name of the column
@param whenNotFound
value returned when _sName is not in _xColumns
*/
OOO_DLLPUBLIC_DBTOOLS bool isAggregateColumn(
const css::uno::Reference< css::container::XNameAccess > &_xColumns,
const OUString &_sName,
bool whenNotFound
const OUString &_sName
);
/** is this column an aggregate?
+1 -2
View File
@@ -26,8 +26,7 @@
class EDITENG_DLLPUBLIC SvxNoHyphenItem : public SfxBoolItem
{
public:
SvxNoHyphenItem( const bool bHyphen /*= true*/,
const sal_uInt16 nId );
SvxNoHyphenItem( const sal_uInt16 nId );
// "pure virtual Methods" from SfxPoolItem
virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
@@ -703,7 +703,7 @@ uno::Sequence< OUString > SAL_CALL OReportDefinition::getSupportedServiceNames(
aSupported = m_aProps->m_xServiceInfo->getSupportedServiceNames();
// append our own service, if necessary
if ( 0 == ::comphelper::findValue( aSupported, SERVICE_REPORTDEFINITION, true ).getLength() )
if ( ::comphelper::findValue( aSupported, SERVICE_REPORTDEFINITION ) == -1 )
{
sal_Int32 nLen = aSupported.getLength();
aSupported.realloc( nLen + 1 );
+6 -6
View File
@@ -2602,9 +2602,9 @@ OUString DbListBox::GetFormatText(const Reference< css::sdb::XColumn >& _rxField
sText = _rxField->getString();
if ( m_bBound )
{
Sequence< sal_Int16 > aPosSeq = ::comphelper::findValue( m_aValueList, sText, true );
if ( aPosSeq.getLength() )
sText = static_cast<ListBox*>(m_pWindow.get())->GetEntry(aPosSeq.getConstArray()[0]);
sal_Int32 nPos = ::comphelper::findValue( m_aValueList, sText );
if ( nPos != -1 )
sText = static_cast<ListBox*>(m_pWindow.get())->GetEntry(nPos);
else
sText.clear();
}
@@ -2952,9 +2952,9 @@ void DbFilterField::SetText(const OUString& rText)
} break;
case css::form::FormComponentType::LISTBOX:
{
Sequence<sal_Int16> aPosSeq = ::comphelper::findValue(m_aValueList, m_aText, true);
if (aPosSeq.getLength())
static_cast<ListBox*>(m_pWindow.get())->SelectEntryPos(aPosSeq.getConstArray()[0]);
sal_Int32 nPos = ::comphelper::findValue(m_aValueList, m_aText);
if (nPos != -1)
static_cast<ListBox*>(m_pWindow.get())->SelectEntryPos(nPos);
else
static_cast<ListBox*>(m_pWindow.get())->SetNoSelection();
} break;
+1 -1
View File
@@ -470,7 +470,7 @@ void InitCore()
aAttrTab[ RES_CHRATR_WORDLINEMODE- POOLATTR_BEGIN ] = new SvxWordLineModeItem( false, RES_CHRATR_WORDLINEMODE );
aAttrTab[ RES_CHRATR_AUTOKERN- POOLATTR_BEGIN ] = new SvxAutoKernItem( false, RES_CHRATR_AUTOKERN );
aAttrTab[ RES_CHRATR_BLINK - POOLATTR_BEGIN ] = new SvxBlinkItem( false, RES_CHRATR_BLINK );
aAttrTab[ RES_CHRATR_NOHYPHEN - POOLATTR_BEGIN ] = new SvxNoHyphenItem( true, RES_CHRATR_NOHYPHEN );
aAttrTab[ RES_CHRATR_NOHYPHEN - POOLATTR_BEGIN ] = new SvxNoHyphenItem( RES_CHRATR_NOHYPHEN );
aAttrTab[ RES_CHRATR_UNUSED2- POOLATTR_BEGIN ] = new SfxVoidItem( RES_CHRATR_UNUSED2 );
aAttrTab[ RES_CHRATR_BACKGROUND - POOLATTR_BEGIN ] = new SvxBrushItem( RES_CHRATR_BACKGROUND );