diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-06 10:12:29 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-10 12:23:42 +0100 |
commit | 065edb4c8e91170017df482843d0c3eb8d4db114 (patch) | |
tree | 1d030ec9868a56b375a563c9d6e6d81c6115d717 /sw/source/filter | |
parent | 0b34a5dd39e177ba99cd21b639d67ac8123b8458 (diff) |
tdf#120703 PVS: V547 Expression is always true/false
Change-Id: I0b3c407331bfa1fa0c5003250d327d4f26de3643
Reviewed-on: https://gerrit.libreoffice.org/63235
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/source/filter')
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 84 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8sty.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8gr.cxx | 14 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 73 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par2.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par3.cxx | 51 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8scan.cxx | 28 |
8 files changed, 112 insertions, 153 deletions
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 2b59e5ec84e2..1fd3f828696a 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -1460,13 +1460,7 @@ const SwRedlineData* SwWW8AttrIter::GetRunLevelRedline( sal_Int32 nPos ) if( pCurRedline ) { const SwPosition* pEnd = pCurRedline->End(); - if( pEnd->nNode == rNd && - pEnd->nContent.GetIndex() <= nPos ) - { - pCurRedline = nullptr; - ++nCurRedlinePos; - } - else + if (!(pEnd->nNode == rNd && pEnd->nContent.GetIndex() <= nPos)) { switch( pCurRedline->GetType() ) { @@ -1479,57 +1473,55 @@ const SwRedlineData* SwWW8AttrIter::GetRunLevelRedline( sal_Int32 nPos ) default: break; } - pCurRedline = nullptr; - ++nCurRedlinePos; } + pCurRedline = nullptr; + ++nCurRedlinePos; } - if( !pCurRedline ) + assert(!pCurRedline); + // search next Redline + for( ; nCurRedlinePos < m_rExport.m_pDoc->getIDocumentRedlineAccess().GetRedlineTable().size(); + ++nCurRedlinePos ) { - // search next Redline - for( ; nCurRedlinePos < m_rExport.m_pDoc->getIDocumentRedlineAccess().GetRedlineTable().size(); - ++nCurRedlinePos ) - { - const SwRangeRedline* pRedl = m_rExport.m_pDoc->getIDocumentRedlineAccess().GetRedlineTable()[ nCurRedlinePos ]; + const SwRangeRedline* pRedl = m_rExport.m_pDoc->getIDocumentRedlineAccess().GetRedlineTable()[ nCurRedlinePos ]; - const SwPosition* pStt = pRedl->Start(); - const SwPosition* pEnd = pStt == pRedl->GetPoint() - ? pRedl->GetMark() - : pRedl->GetPoint(); + const SwPosition* pStt = pRedl->Start(); + const SwPosition* pEnd = pStt == pRedl->GetPoint() + ? pRedl->GetMark() + : pRedl->GetPoint(); - if( pStt->nNode == rNd ) + if( pStt->nNode == rNd ) + { + if( pStt->nContent.GetIndex() >= nPos ) { - if( pStt->nContent.GetIndex() >= nPos ) + if( pStt->nContent.GetIndex() == nPos ) { - if( pStt->nContent.GetIndex() == nPos ) - { - switch( pRedl->GetType() ) - { - case nsRedlineType_t::REDLINE_INSERT: - case nsRedlineType_t::REDLINE_DELETE: - case nsRedlineType_t::REDLINE_FORMAT: - // write data of this redline - pCurRedline = pRedl; - return &( pCurRedline->GetRedlineData() ); - break; - default: - break; - } - } - break; + switch( pRedl->GetType() ) + { + case nsRedlineType_t::REDLINE_INSERT: + case nsRedlineType_t::REDLINE_DELETE: + case nsRedlineType_t::REDLINE_FORMAT: + // write data of this redline + pCurRedline = pRedl; + return &( pCurRedline->GetRedlineData() ); + break; + default: + break; + } } - } - else - { break; } + } + else + { + break; + } - if( pEnd->nNode == rNd && - pEnd->nContent.GetIndex() < nPos ) - { - pCurRedline = pRedl; - break; - } + if( pEnd->nNode == rNd && + pEnd->nContent.GetIndex() < nPos ) + { + pCurRedline = pRedl; + break; } } return nullptr; diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 09740c9eb718..e674c23e6041 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -1057,12 +1057,6 @@ sal_uInt16 MSWordSections::NumberOfColumns( const SwDoc &rDoc, const WW8_SepInfo if ( !pPd ) pPd = &rDoc.GetPageDesc( 0 ); - if ( !pPd ) - { - OSL_ENSURE( pPd, "totally impossible" ); - return 1; - } - const SfxItemSet &rSet = pPd->GetMaster().GetAttrSet(); SfxItemSet aSet( *rSet.GetPool(), svl::Items<RES_COL, RES_COL>{} ); aSet.SetParent( &rSet ); diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx index 251588a83837..c5c2b0316a3a 100644 --- a/sw/source/filter/ww8/wrtww8gr.cxx +++ b/sw/source/filter/ww8/wrtww8gr.cxx @@ -390,17 +390,9 @@ void WW8Export::OutGrf(const ww8::Frame &rFrame) ? rFrame.GetContent()->GetGrfNode() : nullptr; if ( pGrfNd && pGrfNd->IsLinkedFile() ) { - OUString sStr( FieldString(ww::eINCLUDEPICTURE) ); - sStr += " \""; - { - if ( pGrfNd ) - { - OUString aFileURL; - pGrfNd->GetFileFilterNms( &aFileURL, nullptr ); - sStr += aFileURL; - } - } - sStr += "\" \\d"; + OUString sStr; + pGrfNd->GetFileFilterNms(&sStr, nullptr); + sStr = FieldString(ww::eINCLUDEPICTURE) + " \"" + sStr + "\" \\d"; OutputField( nullptr, ww::eINCLUDEPICTURE, sStr, FieldFlags::Start | FieldFlags::CmdStart | FieldFlags::CmdEnd ); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 317a4efc9bcf..9fba22da4f5e 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -4709,8 +4709,8 @@ void AttributeOutputBase::ParaLineSpacing( const SvxLineSpacingItem& rSpacing ) void WW8AttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust ) { // sprmPJc - sal_uInt8 nAdj = 255; - sal_uInt8 nAdjBiDi = 255; + sal_uInt8 nAdj; + sal_uInt8 nAdjBiDi; switch ( rAdjust.GetAdjust() ) { case SvxAdjust::Left: @@ -4732,46 +4732,43 @@ void WW8AttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust ) return; // not a supported Attribute } - if ( 255 != nAdj ) // supported Attribute? - { - m_rWW8Export.InsUInt16( NS_sprm::sprmPJc80 ); - m_rWW8Export.pO->push_back( nAdj ); + m_rWW8Export.InsUInt16(NS_sprm::sprmPJc80); + m_rWW8Export.pO->push_back(nAdj); - /* - Sadly for left to right paragraphs both these values are the same, - for right to left paragraphs the bidi one is the reverse of the - normal one. - */ - m_rWW8Export.InsUInt16( NS_sprm::sprmPJc ); //bidi version ? - bool bBiDiSwap = false; - if ( m_rWW8Export.m_pOutFormatNode ) + /* + Sadly for left to right paragraphs both these values are the same, + for right to left paragraphs the bidi one is the reverse of the + normal one. + */ + m_rWW8Export.InsUInt16(NS_sprm::sprmPJc); //bidi version ? + bool bBiDiSwap = false; + if (m_rWW8Export.m_pOutFormatNode) + { + SvxFrameDirection nDirection = SvxFrameDirection::Horizontal_LR_TB; + if (dynamic_cast<const SwTextNode*>(m_rWW8Export.m_pOutFormatNode) != nullptr) { - SvxFrameDirection nDirection = SvxFrameDirection::Horizontal_LR_TB; - if ( dynamic_cast< const SwTextNode *>( m_rWW8Export.m_pOutFormatNode ) != nullptr ) - { - SwPosition aPos(*static_cast<const SwContentNode*>(m_rWW8Export.m_pOutFormatNode)); - nDirection = m_rWW8Export.m_pDoc->GetTextDirection(aPos); - } - else if ( dynamic_cast< const SwTextFormatColl *>( m_rWW8Export.m_pOutFormatNode ) != nullptr ) - { - const SwTextFormatColl* pC = - static_cast<const SwTextFormatColl*>(m_rWW8Export.m_pOutFormatNode); - const SvxFrameDirectionItem &rItem = - ItemGet<SvxFrameDirectionItem>(*pC, RES_FRAMEDIR); - nDirection = rItem.GetValue(); - } - if ( ( nDirection == SvxFrameDirection::Horizontal_RL_TB ) || - ( nDirection == SvxFrameDirection::Environment && AllSettings::GetLayoutRTL() ) ) - { - bBiDiSwap = true; - } + SwPosition aPos(*static_cast<const SwContentNode*>(m_rWW8Export.m_pOutFormatNode)); + nDirection = m_rWW8Export.m_pDoc->GetTextDirection(aPos); + } + else if (dynamic_cast<const SwTextFormatColl*>(m_rWW8Export.m_pOutFormatNode) != nullptr) + { + const SwTextFormatColl* pC = + static_cast<const SwTextFormatColl*>(m_rWW8Export.m_pOutFormatNode); + const SvxFrameDirectionItem &rItem = + ItemGet<SvxFrameDirectionItem>(*pC, RES_FRAMEDIR); + nDirection = rItem.GetValue(); + } + if ( ( nDirection == SvxFrameDirection::Horizontal_RL_TB ) || + ( nDirection == SvxFrameDirection::Environment && AllSettings::GetLayoutRTL() ) ) + { + bBiDiSwap = true; } - - if ( bBiDiSwap ) - m_rWW8Export.pO->push_back( nAdjBiDi ); - else - m_rWW8Export.pO->push_back( nAdj ); } + + if (bBiDiSwap) + m_rWW8Export.pO->push_back(nAdjBiDi); + else + m_rWW8Export.pO->push_back(nAdj); } void WW8AttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDirection ) diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 20be4b7357ec..2bb992ac8d95 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -3201,8 +3201,8 @@ void WW8TabDesc::AdjustNewBand() m_pTabLine->GetFrameFormat()->SetFormatAttr(SwFormatRowSplit(!bSetCantSplit)); // if table is only a single row, and row is set as don't split, set the same value for the whole table. - if( bSetCantSplit && m_pTabLines->size() == 1 ) - m_pTable->GetFrameFormat()->SetFormatAttr(SwFormatLayoutSplit( !bSetCantSplit )); + if (bSetCantSplit && m_pTabLines->size() == 1) + m_pTable->GetFrameFormat()->SetFormatAttr(SwFormatLayoutSplit(false)); short i; // SW-Index short j; // WW-Index diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index 34bca3e5ac85..53d5016661ef 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -870,14 +870,12 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet lcl_CopyGreaterEight(sPrefix, sNumString, 0, nFirstNoIndex); //Next number appears at - if (nUpperLevel) - { - sal_uInt8 nOneBasedNextNoIndex = aOfsNumsXCH[nUpperLevel-1]; - const sal_Int32 nNextNoIndex = - nOneBasedNextNoIndex > 0 ? nOneBasedNextNoIndex : SAL_MAX_INT32; - if (sNumString.getLength() > nNextNoIndex) - lcl_CopyGreaterEight(sPostfix, sNumString, nNextNoIndex); - } + assert(nUpperLevel > 0); + sal_uInt8 nOneBasedNextNoIndex = aOfsNumsXCH[nUpperLevel-1]; + const sal_Int32 nNextNoIndex = + nOneBasedNextNoIndex > 0 ? nOneBasedNextNoIndex : SAL_MAX_INT32; + if (sNumString.getLength() > nNextNoIndex) + lcl_CopyGreaterEight(sPostfix, sNumString, nNextNoIndex); /* We use lcl_CopyGreaterEight because once if we have removed unused @@ -2014,9 +2012,9 @@ void SwWW8ImplReader::Read_LFOPosition(sal_uInt16, const sal_uInt8* pData, m_nLFOPosition = USHRT_MAX; } - else + else // nData in (0..0x7FFF] { - m_nLFOPosition = static_cast<sal_uInt16>(nData)-1; + m_nLFOPosition = static_cast<sal_uInt16>(nData)-1; // m_nLFOPosition in [0..0x7FFF) /* If we are a ww8+ style with ww7- style lists then there is a bizarre broken word bug where when the list is removed from a para @@ -2028,28 +2026,25 @@ void SwWW8ImplReader::Read_LFOPosition(sal_uInt16, const sal_uInt8* pData, m_vColl[m_nCurrentColl].m_bHasBrokenWW6List = true; // here the stream data is 1-based, we subtract ONE - if (USHRT_MAX > m_nLFOPosition) + if (m_nLFOPosition != 2047-1) //Normal ww8+ list behaviour { - if (m_nLFOPosition != 2047-1) //Normal ww8+ list behaviour + if (WW8ListManager::nMaxLevel == m_nListLevel) + m_nListLevel = 0; + if (WW8ListManager::nMaxLevel > m_nListLevel) { - if (WW8ListManager::nMaxLevel == m_nListLevel) - m_nListLevel = 0; - if (WW8ListManager::nMaxLevel > m_nListLevel) - { - RegisterNumFormat(m_nLFOPosition, m_nListLevel); - m_nLFOPosition = USHRT_MAX; - m_nListLevel = WW8ListManager::nMaxLevel; - } - } - else if (m_xPlcxMan && m_xPlcxMan->HasParaSprm(NS_sprm::LN_PAnld).pSprm) - { - /* - #i8114# Horrific backwards compatible ww7- lists in ww8+ - docs - */ - Read_ANLevelNo(13 /*equiv ww7- sprm no*/, &m_nListLevel, 1); + RegisterNumFormat(m_nLFOPosition, m_nListLevel); + m_nLFOPosition = USHRT_MAX; + m_nListLevel = WW8ListManager::nMaxLevel; } } + else if (m_xPlcxMan && m_xPlcxMan->HasParaSprm(NS_sprm::LN_PAnld).pSprm) + { + /* + #i8114# Horrific backwards compatible ww7- lists in ww8+ + docs + */ + Read_ANLevelNo(13 /*equiv ww7- sprm no*/, &m_nListLevel, 1); + } } } } diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index b422202e14e3..671bbb944786 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -673,9 +673,6 @@ SwSectionFormat *wwSectionManager::InsertSection( if (!pPage) pPage = &mrReader.m_rDoc.GetPageDesc(0); - if (!pPage) - return nullptr; - SwSectionFormat *pFormat = rSection.mpSection->GetFormat(); OSL_ENSURE(pFormat, "impossible"); if (!pFormat) @@ -4261,7 +4258,7 @@ void SwWW8ImplReader::Read_LineSpace( sal_uInt16, const sal_uInt8* pData, short { long n = nSpace * 10 / 24; // WW: 240 = 100%, SW: 100 = 100% - if( n>SAL_MAX_UINT16 ) n = SAL_MAX_UINT16; + // here n is in [0..13653] aLSpc.SetPropLineSpace( static_cast<sal_uInt16>(n) ); const SvxFontHeightItem* pH = static_cast<const SvxFontHeightItem*>( GetFormatAttr( RES_CHRATR_FONTSIZE )); diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 5354cbbb1c56..643601e144e3 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -2174,10 +2174,10 @@ bool WW8PLCFspecial::SeekPos(long nP) } // Search from beginning? - if( (1 > nIdx) || (nP < pPLCF_PosArray[ nIdx-1 ]) ) + if ((nIdx < 1) || (nP < pPLCF_PosArray[nIdx - 1])) nIdx = 1; - long nI = nIdx ? nIdx : 1; + long nI = nIdx; long nEnd = nIMax; for(int n = (1==nIdx ? 1 : 2); n; --n ) @@ -2447,10 +2447,10 @@ bool WW8PLCF::SeekPos(WW8_CP nPos) } // Search from beginning? - if( (1 > nIdx) || (nP < pPLCF_PosArray[ nIdx-1 ]) ) + if ((nIdx < 1) || (nP < pPLCF_PosArray[nIdx - 1])) nIdx = 1; - sal_Int32 nI = nIdx ? nIdx : 1; + sal_Int32 nI = nIdx; sal_Int32 nEnd = nIMax; for(int n = (1==nIdx ? 1 : 2); n; --n ) @@ -2542,10 +2542,10 @@ bool WW8PLCFpcd_Iter::SeekPos(long nPos) return false; // not found: nPos less than smallest entry } // Search from beginning? - if( (1 > nIdx) || (nP < rPLCF.pPLCF_PosArray[ nIdx-1 ]) ) + if ((nIdx < 1) || (nP < rPLCF.pPLCF_PosArray[nIdx - 1])) nIdx = 1; - long nI = nIdx ? nIdx : 1; + long nI = nIdx; long nEnd = rPLCF.nIMax; for(int n = (1==nIdx ? 1 : 2); n; --n ) @@ -2654,13 +2654,7 @@ WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(const WW8Fib& rFib, SvStream* pSt, } unsigned int nOfs = maRawData[nRawDataOffset] * 2; - - //clip to available data, corrupt fkp - if (nOfs >= 511) - { - mnIMax = mnIdx; - break; - } + // nOfs in [0..0xff*2=510] Entry aEntry(Get_Long(pStart)); @@ -2894,10 +2888,10 @@ bool WW8PLCFx_Fc_FKP::WW8Fkp::SeekPos(WW8_FC nFc) } // Search from beginning? - if ((1 > mnIdx) || (nFc < maEntries[mnIdx-1].mnFC)) + if ((mnIdx < 1) || (nFc < maEntries[mnIdx - 1].mnFC)) mnIdx = 1; - sal_uInt8 nI = mnIdx ? mnIdx : 1; + sal_uInt8 nI = mnIdx; sal_uInt8 nEnd = mnIMax; for(sal_uInt8 n = (1==mnIdx ? 1 : 2); n; --n ) @@ -8314,9 +8308,7 @@ sal_uInt16 wwSprmParser::GetSprmId(const sal_uInt8* pSp) const if (ww::IsSevenMinus(meVersion)) { - nId = *pSp; - if (0x0100 < nId) - nId = 0; + nId = *pSp; // [0..0xff] } else { |