Kaydet (Commit) 7a1c21e5 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:simplifybool for negation of comparison operator

Change-Id: Ie56daf560185274754afbc7a09c432b5c2793791
Reviewed-on: https://gerrit.libreoffice.org/45068Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst c24c32bf
......@@ -222,7 +222,7 @@ IMPL_LINK( BreakPointDialog, ButtonHdl, Button *, pButton, void )
{
delete m_aModifiedBreakPointList.remove( pBrk );
m_pComboBox->RemoveEntryAt(nEntry);
if ( nEntry && !( nEntry < m_pComboBox->GetEntryCount() ) )
if ( nEntry && nEntry >= m_pComboBox->GetEntryCount() )
nEntry--;
m_pComboBox->SetText( m_pComboBox->GetEntry( nEntry ) );
if (SfxDispatcher* pDispatcher = GetDispatcher())
......
......@@ -137,7 +137,7 @@ Type getSequenceElementType(const Type& _rSequenceType)
OSL_ENSURE(_rSequenceType.getTypeClass() == TypeClass_SEQUENCE,
"getSequenceElementType: must be called with a sequence type!");
if (!(_rSequenceType.getTypeClass() == TypeClass_SEQUENCE))
if (_rSequenceType.getTypeClass() != TypeClass_SEQUENCE)
return Type();
TypeDescription aTD(_rSequenceType);
......
......@@ -87,25 +87,43 @@ bool SimplifyBool::VisitUnaryLNot(UnaryOperator const * expr) {
return true;
}
auto e = getSubExprOfLogicalNegation(expr->getSubExpr());
if (e == nullptr) {
if (e) {
// Ignore macros, otherwise
// OSL_ENSURE(!b, ...);
// triggers.
if (e->getLocStart().isMacroID())
return true;
// double logical not of an int is an idiom to convert to bool
if (!e->IgnoreImpCasts()->getType()->isBooleanType())
return true;
report(
DiagnosticsEngine::Warning,
("double logical negation expression of the form '!!A' (with A of type"
" %0) can %select{logically|literally}1 be simplified as 'A'"),
expr->getLocStart())
<< e->IgnoreImpCasts()->getType()
<< e->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
return true;
}
// Ignore macros, otherwise
// OSL_ENSURE(!b, ...);
// triggers.
if (e->getLocStart().isMacroID())
return true;
// double logical not of an int is an idiom to convert to bool
if (!e->IgnoreImpCasts()->getType()->isBooleanType())
return true;
report(
DiagnosticsEngine::Warning,
("double logical negation expression of the form '!!A' (with A of type"
" %0) can %select{logically|literally}1 be simplified as 'A'"),
expr->getLocStart())
<< e->IgnoreImpCasts()->getType()
<< e->IgnoreImpCasts()->getType()->isBooleanType()
<< expr->getSourceRange();
if (auto binaryOp = dyn_cast<BinaryOperator>(expr->getSubExpr()->IgnoreParenImpCasts())) {
// Ignore macros, otherwise
// OSL_ENSURE(!b, ...);
// triggers.
if (binaryOp->getLocStart().isMacroID())
return true;
auto t = binaryOp->getLHS()->IgnoreImpCasts()->getType()->getUnqualifiedDesugaredType();
// RecordType would require more smarts - we'd need to verify that an inverted operator actually existed
if (t->isTemplateTypeParmType() || t->isRecordType() || t->isDependentType())
return true;
if (!binaryOp->isComparisonOp())
return true;
report(
DiagnosticsEngine::Warning,
("logical negation of comparison operator, can be simplified by inverting operator"),
expr->getLocStart())
<< expr->getSourceRange();
}
return true;
}
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
void f1(int a, int b)
{
if (!(a < b))
{ // expected-error@-1 {{logical negation of comparison operator, can be simplified by inverting operator [loplugin:simplifybool]}}
a = b;
}
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -136,7 +136,7 @@ OResultSet::OResultSet(SQLHANDLE _pStatementHandle ,OStatement_Base* pStmt) :
// In other words, isolate them from ODBC restrictions.
// TODO: we assume SQL_GD_BLOCK, unless fetchSize is 1
OTools::GetInfo(m_pStatement->getOwnConnection(),m_aConnectionHandle,SQL_GETDATA_EXTENSIONS,nValueLen,nullptr);
m_bFetchDataInOrder = !((SQL_GD_ANY_ORDER & nValueLen) == SQL_GD_ANY_ORDER);
m_bFetchDataInOrder = ((SQL_GD_ANY_ORDER & nValueLen) != SQL_GD_ANY_ORDER);
}
catch(const Exception&)
{
......
......@@ -1831,7 +1831,7 @@ sal_uInt16 SvxSwPosSizeTabPage::FillPosLB(FrmMap const *_pMap,
// #i22341# - add condition to handle map <aVCharMap>
// that is ambiguous in the alignment.
if ( _pMap[i].nAlign == _nAlign &&
( !(_pMap == aVCharMap) || _pMap[i].nLBRelations & nLBRelations ) )
( _pMap != aVCharMap || _pMap[i].nLBRelations & nLBRelations ) )
{
sSelEntry = sEntry;
}
......
......@@ -227,7 +227,7 @@ public:
OSL_ASSERT( m_xNodeList.is() );
OSL_ASSERT( m_xUpdateInformationProvider.is() );
if( !(m_nCount < m_nNodes ) )
if( m_nCount >= m_nNodes )
throw container::NoSuchElementException(OUString::number(m_nCount), *this);
try
......
......@@ -395,7 +395,7 @@ void CGM::ImplDoClass4()
fStartAngle = fEndAngle;
fEndAngle = fG;
}
if ( ! ( fInterAngle > fStartAngle ) && ( fInterAngle < fEndAngle ) )
if ( ( fInterAngle <= fStartAngle ) && ( fInterAngle < fEndAngle ) )
{
nSwitch ^=1;
aIntermediatePoint = aEndingPoint;
......@@ -465,7 +465,7 @@ void CGM::ImplDoClass4()
fStartAngle = fEndAngle;
fEndAngle = fG;
}
if ( ! ( fInterAngle > fStartAngle ) && ( fInterAngle < fEndAngle ) )
if ( ( fInterAngle <= fStartAngle ) && ( fInterAngle < fEndAngle ) )
{
aIntermediatePoint = aEndingPoint;
aEndingPoint = aStartingPoint;
......
......@@ -105,7 +105,7 @@ void SAL_CALL PropertySetContainer::removeByIndex( sal_Int32 nIndex )
{
SolarMutexGuard g;
if ( !((sal_Int32)m_aPropertySetVector.size() > nIndex) )
if ( (sal_Int32)m_aPropertySetVector.size() <= nIndex )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
m_aPropertySetVector.erase(m_aPropertySetVector.begin() + nIndex);
......@@ -114,7 +114,7 @@ void SAL_CALL PropertySetContainer::removeByIndex( sal_Int32 nIndex )
// XIndexReplace
void SAL_CALL PropertySetContainer::replaceByIndex( sal_Int32 Index, const css::uno::Any& Element )
{
if ( !((sal_Int32)m_aPropertySetVector.size() > Index) )
if ( (sal_Int32)m_aPropertySetVector.size() <= Index )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
Reference< XPropertySet > aPropertySetElement;
......
......@@ -210,7 +210,7 @@ void SAL_CALL ItemContainer::replaceByIndex( sal_Int32 Index, const Any& aItem )
static_cast<OWeakObject *>(this), 2 );
ShareGuard aLock( m_aShareMutex );
if ( !(sal_Int32( m_aItemVector.size()) > Index) )
if ( sal_Int32( m_aItemVector.size()) <= Index )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
m_aItemVector[Index] = aSeq;
......
......@@ -224,7 +224,7 @@ void SAL_CALL RootItemContainer::replaceByIndex( sal_Int32 Index, const Any& aIt
throw IllegalArgumentException( WRONG_TYPE_EXCEPTION, static_cast<OWeakObject *>(this), 2 );
ShareGuard aLock( m_aShareMutex );
if ( !(sal_Int32( m_aItemVector.size()) > Index) )
if ( sal_Int32( m_aItemVector.size()) <= Index )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
m_aItemVector[Index] = aSeq;
......
......@@ -61,7 +61,7 @@ namespace framework
if ( m_aDockedData.m_nDockedArea == ui::DockingArea_DOCKINGAREA_TOP ||
m_aDockedData.m_nDockedArea == ui::DockingArea_DOCKINGAREA_BOTTOM )
{
if ( !( m_aDockedData.m_aPos.Y == aUIElement.m_aDockedData.m_aPos.Y ) )
if ( m_aDockedData.m_aPos.Y != aUIElement.m_aDockedData.m_aPos.Y )
return ( m_aDockedData.m_aPos.Y < aUIElement.m_aDockedData.m_aPos.Y );
else
{
......@@ -76,7 +76,7 @@ namespace framework
}
else
{
if ( !( m_aDockedData.m_aPos.X == aUIElement.m_aDockedData.m_aPos.X ) )
if ( m_aDockedData.m_aPos.X != aUIElement.m_aDockedData.m_aPos.X )
return ( m_aDockedData.m_aPos.X < aUIElement.m_aDockedData.m_aPos.X );
else
{
......
......@@ -123,7 +123,7 @@ bool Bookmark::Read(HWPFile & hwpf)
if (!hwpf.Read2b(dummy))
return false;
if (!(len == 34))// 2 * (BMK_COMMENT_LEN + 1) + 2
if (len != 34)// 2 * (BMK_COMMENT_LEN + 1) + 2
{
return hwpf.SetState(HWP_InvalidFileFormat);
}
......@@ -282,7 +282,7 @@ bool TxtBox::Read(HWPFile & hwpf)
UpdateBBox(this);
ncell = nCell;
if (!(ncell > 0)){
if (ncell <= 0){
return hwpf.SetState(HWP_InvalidFileFormat);
}
......@@ -656,7 +656,7 @@ bool AutoNum::Read(HWPFile & hwpf)
hwpf.Read2b(&number, 1);
hwpf.Read2b(&dummy, 1);
if (!(hh == dummy)){
if (hh != dummy){
return hwpf.SetState(HWP_InvalidFileFormat);
}
return !hwpf.State();
......@@ -679,7 +679,7 @@ bool NewNum::Read(HWPFile & hwpf)
hwpf.Read2b(&number, 1);
hwpf.Read2b(&dummy, 1);
if (!(hh == dummy)){
if (hh != dummy){
return hwpf.SetState(HWP_InvalidFileFormat);
}
return !hwpf.State();
......@@ -701,7 +701,7 @@ bool ShowPageNum::Read(HWPFile & hwpf)
hwpf.Read2b(&shape, 1);
hwpf.Read2b(&dummy, 1);
if (!(hh == dummy)){
if (hh != dummy){
return hwpf.SetState(HWP_InvalidFileFormat);
}
m_nPageNumber = hwpf.getCurrentPage();
......@@ -725,7 +725,7 @@ bool PageNumCtrl::Read(HWPFile & hwpf)
hwpf.Read2b(&what, 1);
hwpf.Read2b(&dummy, 1);
if (!(hh == dummy)){
if (hh != dummy){
return hwpf.SetState(HWP_InvalidFileFormat);
}
return !hwpf.State();
......@@ -744,7 +744,7 @@ bool MailMerge::Read(HWPFile & hwpf)
hwpf.Read1b(field_name, 20);
hwpf.Read2b(&dummy, 1);
if (!(hh == dummy)){
if (hh != dummy){
return hwpf.SetState(HWP_InvalidFileFormat);
}
return !hwpf.State();
......@@ -762,7 +762,7 @@ bool Compose::Read(HWPFile & hwpf)
hwpf.Read2b(compose, 3);
hwpf.Read2b(&dummy, 1);
if (!(hh == dummy)){
if (hh != dummy){
return hwpf.SetState(HWP_InvalidFileFormat);
}
return !hwpf.State();
......@@ -781,7 +781,7 @@ bool Hyphen::Read(HWPFile & hwpf)
hwpf.Read2b(&width, 1);
hwpf.Read2b(&dummy, 1);
if (!(hh == dummy)){
if (hh != dummy){
return hwpf.SetState(HWP_InvalidFileFormat);
}
return !hwpf.State();
......@@ -802,7 +802,7 @@ bool TocMark::Read(HWPFile & hwpf)
hwpf.Read2b(&kind, 1);
hwpf.Read2b(&dummy, 1);
if (!(hh == dummy)){
if (hh != dummy){
return hwpf.SetState(HWP_InvalidFileFormat);
}
return !hwpf.State();
......@@ -825,7 +825,7 @@ bool IndexMark::Read(HWPFile & hwpf)
hwpf.Read2b(&pgno, 1);
hwpf.Read2b(&dummy, 1);
if (!(hh == dummy)){
if (hh != dummy){
return hwpf.SetState(HWP_InvalidFileFormat);
}
return !hwpf.State();
......@@ -851,7 +851,7 @@ bool Outline::Read(HWPFile & hwpf)
hwpf.Read2b(deco, 14);
hwpf.Read2b(&dummy, 1);
if (!(hh == dummy)){
if (hh != dummy){
return hwpf.SetState(HWP_InvalidFileFormat);
}
return !hwpf.State();
......@@ -870,7 +870,7 @@ bool KeepSpace::Read(HWPFile & hwpf)
{
hwpf.Read2b(&dummy, 1);
if (!(hh == dummy)){
if (hh != dummy){
return hwpf.SetState(HWP_InvalidFileFormat);
}
return !hwpf.State();
......@@ -889,7 +889,7 @@ bool FixedSpace::Read(HWPFile & hwpf)
{
hwpf.Read2b(&dummy, 1);
if (!(hh == dummy)){
if (hh != dummy){
return hwpf.SetState(HWP_InvalidFileFormat);
}
return !hwpf.State();
......
......@@ -284,13 +284,13 @@ OUString ODataInputStream::readUTF()
case 12: case 13:
// 110x xxxx 10xx xxxx
nCount += 2;
if( ! ( nCount <= nUTFLen ) )
if( nCount > nUTFLen )
{
throw WrongFormatException( );
}
char2 = (sal_uInt8)readByte();
if( ! ( (char2 & 0xC0) == 0x80 ) )
if( (char2 & 0xC0) != 0x80 )
{
throw WrongFormatException( );
}
......@@ -301,7 +301,7 @@ OUString ODataInputStream::readUTF()
case 14:
// 1110 xxxx 10xx xxxx 10xx xxxx
nCount += 3;
if( !( nCount <= nUTFLen) )
if( nCount > nUTFLen )
{
throw WrongFormatException( );
}
......
......@@ -85,7 +85,7 @@ bool SunVersion::init(const char *szVersion)
}
//if correct separator then form integer
else if (
! (nPartPos == 0) // prevents: ".4.1", "..1", part must start with digit
(nPartPos != 0) // prevents: ".4.1", "..1", part must start with digit
&& (
//separators after maintenance (1.4.1_01, 1.4.1-beta, or 1.4.1)
(pCur == pEnd || *pCur == '_' || *pCur == '-')
......
......@@ -122,7 +122,7 @@ bool VbaInputStream::updateChunk()
if( mbEof ) return false;
// check header signature
bool bIgnoreBrokenSig = !( (nHeader & VBACHUNK_SIGMASK) == VBACHUNK_SIG );
bool bIgnoreBrokenSig = ( (nHeader & VBACHUNK_SIGMASK) != VBACHUNK_SIG );
// decode length of chunk data and compression flag
bool bCompressed = getFlag( nHeader, VBACHUNK_COMPRESSED );
......
......@@ -789,7 +789,7 @@ Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) con
}
else if( PyObject_IsInstance( o, getAnyClass( runtime ).get() ) )
{
if( !(ACCEPT_UNO_ANY == mode) )
if( ACCEPT_UNO_ANY != mode )
{
throw RuntimeException(
"uno.Any instance not accepted during method call, "
......
......@@ -713,7 +713,7 @@ RegError ORegistry::closeKey(RegKeyHandle hKey)
REG_GUARD(m_mutex);
OUString const aKeyName (pKey->getName());
if (!(m_openKeyTable.count(aKeyName) > 0))
if (m_openKeyTable.count(aKeyName) <= 0)
return RegError::KEY_NOT_OPEN;
if (pKey->isModified())
......
......@@ -441,7 +441,7 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
/* set close-on-exec flag */
int flags;
if (!((flags = fcntl(s, F_GETFD, 0)) < 0))
if ((flags = fcntl(s, F_GETFD, 0)) >= 0)
{
flags |= FD_CLOEXEC;
if (fcntl(s, F_SETFD, flags) < 0)
......
......@@ -347,7 +347,7 @@ rtlDigestError SAL_CALL rtl_digest_updateMD2(
if (!pImpl || !pData)
return rtl_Digest_E_Argument;
if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD2))
if (pImpl->m_digest.m_algorithm != rtl_Digest_AlgorithmMD2)
return rtl_Digest_E_Algorithm;
if (nDatLen == 0)
......@@ -406,7 +406,7 @@ rtlDigestError SAL_CALL rtl_digest_getMD2(
if (pImpl->m_digest.m_algorithm != rtl_Digest_AlgorithmMD2)
return rtl_Digest_E_Algorithm;
if (!(pImpl->m_digest.m_length <= nBufLen))
if (pImpl->m_digest.m_length > nBufLen)
return rtl_Digest_E_BufferSize;
ctx = &(pImpl->m_context);
......@@ -686,7 +686,7 @@ rtlDigestError SAL_CALL rtl_digest_updateMD5(
if (!pImpl || !pData)
return rtl_Digest_E_Argument;
if (!(pImpl->m_digest.m_algorithm == rtl_Digest_AlgorithmMD5))
if (pImpl->m_digest.m_algorithm != rtl_Digest_AlgorithmMD5)
return rtl_Digest_E_Algorithm;
if (nDatLen == 0)
......@@ -760,7 +760,7 @@ rtlDigestError SAL_CALL rtl_digest_getMD5(
if (pImpl->m_digest.m_algorithm != rtl_Digest_AlgorithmMD5)
return rtl_Digest_E_Algorithm;
if (!(pImpl->m_digest.m_length <= nBufLen))
if (pImpl->m_digest.m_length > nBufLen)
return rtl_Digest_E_BufferSize;
ctx = &(pImpl->m_context);
......@@ -790,7 +790,7 @@ rtlDigestError SAL_CALL rtl_digest_rawMD5(
if (pImpl->m_digest.m_algorithm != rtl_Digest_AlgorithmMD5)
return rtl_Digest_E_Algorithm;
if (!(pImpl->m_digest.m_length <= nBufLen))
if (pImpl->m_digest.m_length > nBufLen)
return rtl_Digest_E_BufferSize;
ctx = &(pImpl->m_context);
......@@ -1201,7 +1201,7 @@ rtlDigestError SAL_CALL rtl_digest_getSHA(
if (pImpl->m_digest.m_algorithm != rtl_Digest_AlgorithmSHA)
return rtl_Digest_E_Algorithm;
if (!(pImpl->m_digest.m_length <= nBufLen))
if (pImpl->m_digest.m_length > nBufLen)
return rtl_Digest_E_BufferSize;
ctx = &(pImpl->m_context);
......@@ -1361,7 +1361,7 @@ rtlDigestError SAL_CALL rtl_digest_getSHA1 (
if (pImpl->m_digest.m_algorithm != rtl_Digest_AlgorithmSHA1)
return rtl_Digest_E_Algorithm;
if (!(pImpl->m_digest.m_length <= nBufLen))
if (pImpl->m_digest.m_length > nBufLen)
return rtl_Digest_E_BufferSize;
ctx = &(pImpl->m_context);
......@@ -1555,7 +1555,7 @@ rtlDigestError SAL_CALL rtl_digest_getHMAC_MD5(
if (pImpl->m_digest.m_algorithm != rtl_Digest_AlgorithmHMAC_MD5)
return rtl_Digest_E_Algorithm;
if (!(pImpl->m_digest.m_length <= nBufLen))
if (pImpl->m_digest.m_length > nBufLen)
return rtl_Digest_E_BufferSize;
nBufLen = pImpl->m_digest.m_length;
......@@ -1751,7 +1751,7 @@ rtlDigestError SAL_CALL rtl_digest_getHMAC_SHA1(
if (pImpl->m_digest.m_algorithm != rtl_Digest_AlgorithmHMAC_SHA1)
return rtl_Digest_E_Algorithm;
if (!(pImpl->m_digest.m_length <= nBufLen))
if (pImpl->m_digest.m_length > nBufLen)
return rtl_Digest_E_BufferSize;
nBufLen = pImpl->m_digest.m_length;
......
......@@ -170,7 +170,7 @@ bool isRepresentableInteger(double fAbsValue)
// this here.
double fInt;
return (nInt <= kMaxInt &&
(!((fInt = static_cast< double >(nInt)) < fAbsValue) && !(fInt > fAbsValue)));
(((fInt = static_cast< double >(nInt)) >= fAbsValue) && (fInt <= fAbsValue)));
}
return false;
}
......
......@@ -611,7 +611,7 @@ inline SaxInvalidCharacterError SaxWriterHelper::startElement(const OUString& rN
nCurrentPos = writeSequence();
if (!writeString(xAttribs->getValueByIndex( i ), true, true) &&
!(eRet == SAX_ERROR))
eRet != SAX_ERROR)
eRet = SAX_WARNING;
mp_Sequence[nCurrentPos] = '"';
......
......@@ -4803,7 +4803,7 @@ void ScDocument::ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
void ScDocument::AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex )
{
if(!(static_cast<size_t>(nTab) < maTabs.size()))
if(static_cast<size_t>(nTab) >= maTabs.size())
return;
if(!maTabs[nTab])
......@@ -4814,7 +4814,7 @@ void ScDocument::AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_u
void ScDocument::RemoveCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex )
{
if(!(static_cast<size_t>(nTab) < maTabs.size()))
if(static_cast<size_t>(nTab) >= maTabs.size())
return;
if(!maTabs[nTab])
......
......@@ -1533,8 +1533,8 @@ void OpDcount2::GenSlidingWindowFunction(std::stringstream &ss,
GenTmpVariables(ss,vSubArguments);
int dataCol = 0;
int dataRow = 0;
if(!(vSubArguments[0]->GetFormulaToken()->GetType() ==
formula::svDoubleVectorRef))
if(vSubArguments[0]->GetFormulaToken()->GetType() !=
formula::svDoubleVectorRef)
throw Unhandled(__FILE__, __LINE__);
formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
......
......@@ -258,7 +258,7 @@ void ScChartHelper::SetChartRanges( const uno::Reference< chart2::XChartDocument
xLabeledSequence->setLabel( xNewSeq );
}
if( !(nRange<rRanges.getLength()) )
if( nRange >= rRanges.getLength() )
break;
if( xValues.is())
......
......@@ -2300,7 +2300,7 @@ void XclImpOptionButtonObj::DoProcessControl( ScfPropertySet& rPropSet ) const
}
else
pTbxObj = nullptr;
} while ( pTbxObj && !( pTbxObj->mnFirstInGroup == 1 ) );
} while ( pTbxObj && ( pTbxObj->mnFirstInGroup != 1 ) );
}
else
{
......
......@@ -1069,7 +1069,7 @@ void ScHTMLLayoutParser::TableOn( HtmlImportInfo* pInfo )
}
}
bInCell = false;
if ( bTabInTabCell && !(nTableWidth < nLastWidth) )
if ( bTabInTabCell && (nTableWidth >= nLastWidth) )
{ // Multiple tables in one cell, underneath each other
bTabInTabCell = false;
NextRow( pInfo );
......
......@@ -75,7 +75,7 @@ OUString OrcusFormatDetect::detect(css::uno::Sequence<css::beans::PropertyValue>
while(!bEnd)
{
sal_Int32 nReadBytes = xInputStream->readBytes(aSeq, nBytes);
bEnd = !(nReadBytes == nBytes);
bEnd = (nReadBytes != nBytes);
aContent.append(reinterpret_cast<const char*>(aSeq.getConstArray()), nReadBytes);
}
......
......@@ -815,7 +815,7 @@ sal_Int32 ScFormatRangeStyles::GetStyleNameIndex(const sal_Int32 nTable,
const sal_Int32 nColumn, const sal_Int32 nRow, bool& bIsAutoStyle) const
{
OSL_ENSURE(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
if (!(static_cast<size_t>(nTable) < aTables.size()))
if (static_cast<size_t>(nTable) >= aTables.size())
return -1;
ScMyFormatRangeAddresses* pFormatRanges(aTables[nTable]);
ScMyFormatRangeAddresses::iterator aItr(pFormatRanges->begin());
......@@ -840,7 +840,7 @@ sal_Int32 ScFormatRangeStyles::GetStyleNameIndex(const sal_Int32 nTable, const s
bool& bIsAutoStyle, sal_Int32& nValidationIndex, sal_Int32& nNumberFormat, const sal_Int32 nRemoveBeforeRow)
{
OSL_ENSURE(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
if (!(static_cast<size_t>(nTable) < aTables.size()))
if (static_cast<size_t>(nTable) >= aTables.size())
return -1;
ScMyFormatRangeAddresses* pFormatRanges(aTables[nTable]);
ScMyFormatRangeAddresses::iterator aItr(pFormatRanges->begin());
......@@ -1107,7 +1107,7 @@ void ScRowStyles::AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields)
sal_Int32 ScRowStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField)
{
OSL_ENSURE(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
if (!(static_cast<size_t>(nTable) < aTables.size()))
if (static_cast<size_t>(nTable) >= aTables.size())
return -1;
if (maCache.hasCache(nTable, nField))
......
......@@ -2436,7 +2436,7 @@ void BoundsProvider<IndexType>::Compute(
SAL_INFO("sc.lok.header", "BoundsProvider: rBottomNearest: index: " << aSecondNearest.first
<< ", pos: " << aSecondNearest.second << ", diff: " << nSecondDiff);
bool bReverse = !(std::abs(nFirstDiff) < std::abs(nSecondDiff));
bool bReverse = (std::abs(nFirstDiff) >= std::abs(nSecondDiff));
if(bReverse)
{
......
......@@ -1120,7 +1120,7 @@ void ScViewData::ResetOldCursor()
SCCOL ScViewData::GetCurXForTab( SCTAB nTabIndex ) const
{
if (!ValidTab(nTabIndex) || !(nTabIndex < static_cast<SCTAB>(maTabData.size())))
if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())))
return -1;
return maTabData[nTabIndex]->nCurX;
......@@ -1128,7 +1128,7 @@ SCCOL ScViewData::GetCurXForTab( SCTAB nTabIndex ) const
SCROW ScViewData::GetCurYForTab( SCTAB nTabIndex ) const
{
if (!ValidTab(nTabIndex) || !(nTabIndex < static_cast<SCTAB>(maTabData.size())))
if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())))
return -1;
return maTabData[nTabIndex]->nCurY;
......@@ -1136,7 +1136,7 @@ SCROW ScViewData::GetCurYForTab( SCTAB nTabIndex ) const
void ScViewData::SetCurXForTab( SCCOL nNewCurX, SCTAB nTabIndex )
{
if (!ValidTab(nTabIndex) || !(nTabIndex < static_cast<SCTAB>(maTabData.size())))
if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())))
return;
maTabData[nTabIndex]->nCurX = nNewCurX;
......@@ -1144,7 +1144,7 @@ void ScViewData::SetCurXForTab( SCCOL nNewCurX, SCTAB nTabIndex )
void ScViewData::SetCurYForTab( SCCOL nNewCurY, SCTAB nTabIndex )
{
if (!ValidTab(nTabIndex) || !(nTabIndex < static_cast<SCTAB>(maTabData.size())))
if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())))
return;
maTabData[nTabIndex]->nCurY = nNewCurY;
......@@ -1853,7 +1853,7 @@ void ScViewData::SetTabNo( SCTAB nNewTab )
ScPositionHelper* ScViewData::GetLOKWidthHelper(SCTAB nTabIndex)
{
if (!ValidTab(nTabIndex) || !(nTabIndex < static_cast<SCTAB>(maTabData.size())))
if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())))
{
return nullptr;
}
......@@ -1862,7 +1862,7 @@ ScPositionHelper* ScViewData::GetLOKWidthHelper(SCTAB nTabIndex)
ScPositionHelper* ScViewData::GetLOKHeightHelper(SCTAB nTabIndex)
{
if (!ValidTab(nTabIndex) || !(nTabIndex < static_cast<SCTAB>(maTabData.size())))
if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())))