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 /sc | |
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 'sc')
-rw-r--r-- | sc/source/core/data/table2.cxx | 29 | ||||
-rw-r--r-- | sc/source/filter/excel/xepivotxml.cxx | 6 | ||||
-rw-r--r-- | sc/source/filter/excel/xestream.cxx | 14 | ||||
-rw-r--r-- | sc/source/filter/qpro/qproform.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx | 108 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 11 | ||||
-rw-r--r-- | sc/source/ui/app/transobj.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh2.cxx | 17 |
8 files changed, 85 insertions, 110 deletions
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 41cf8caf0d18..6608876a6ff4 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -2932,30 +2932,19 @@ bool ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNew bSingle = false; // no difference in this range } } - if (bSingle) - { - if (nEndRow-nStartRow < 20) - { - if (!bChanged) - bChanged = lcl_pixelSizeChanged(*mpRowHeights, nStartRow, nEndRow, nNewHeight, nPPTY); - mpRowHeights->setValue(nStartRow, nEndRow, nNewHeight); - } - else - { - SCROW nMid = (nStartRow+nEndRow) / 2; - if (SetRowHeightRange( nStartRow, nMid, nNewHeight, 1.0 )) - bChanged = true; - if (SetRowHeightRange( nMid+1, nEndRow, nNewHeight, 1.0 )) - bChanged = true; - } + if (!bSingle || nEndRow - nStartRow < 20) + { + bChanged = lcl_pixelSizeChanged(*mpRowHeights, nStartRow, nEndRow, nNewHeight, nPPTY); + mpRowHeights->setValue(nStartRow, nEndRow, nNewHeight); } else { - if (!bChanged) - bChanged = lcl_pixelSizeChanged(*mpRowHeights, nStartRow, nEndRow, nNewHeight, nPPTY); - - mpRowHeights->setValue(nStartRow, nEndRow, nNewHeight); + SCROW nMid = (nStartRow + nEndRow) / 2; + if (SetRowHeightRange(nStartRow, nMid, nNewHeight, 1.0)) + bChanged = true; + if (SetRowHeightRange(nMid + 1, nEndRow, nNewHeight, 1.0)) + bChanged = true; } if (bChanged) diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx index 9a3953ae0ab3..b7e790eca6da 100644 --- a/sc/source/filter/excel/xepivotxml.cxx +++ b/sc/source/filter/excel/xepivotxml.cxx @@ -286,7 +286,7 @@ void XclExpXmlPivotCaches::SavePivotCacheXml( XclExpXmlStream& rStrm, const Entr auto pAttList = sax_fastparser::FastSerializerHelper::createAttrList(); // TODO In same cases, disable listing of items, as it is done in MS Excel. // Exporting savePivotCacheRecordsXml method needs to be updated accordingly - bool bListItems = true; + //bool bListItems = true; std::set<ScDPItemData::Type> aDPTypesWithoutBlank = aDPTypes; aDPTypesWithoutBlank.erase(ScDPItemData::Empty); @@ -352,7 +352,7 @@ void XclExpXmlPivotCaches::SavePivotCacheXml( XclExpXmlStream& rStrm, const Entr pAttList->add(XML_maxDate, XclXmlUtils::ToOString(GetExcelFormattedDate(fMax, GetFormatter()))); } - if (bListItems) + //if (bListItems) // see TODO above { pAttList->add(XML_count, OString::number(static_cast<long>(rFieldItems.size()))); } @@ -360,7 +360,7 @@ void XclExpXmlPivotCaches::SavePivotCacheXml( XclExpXmlStream& rStrm, const Entr pDefStrm->startElement(XML_sharedItems, xAttributeList); - if (bListItems) + //if (bListItems) // see TODO above { it = rFieldItems.begin(); for (; it != itEnd; ++it) diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx index b70086e9f364..46bf1536ebb6 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -890,15 +890,15 @@ sax_fastparser::FSHelperPtr XclXmlUtils::WriteFontData( sax_fastparser::FSHelper const char* pUnderline = lcl_GetUnderlineStyle( rFontData.GetScUnderline(), bHaveUnderline ); const char* pVertAlign = lcl_ToVerticalAlignmentRun( rFontData.GetScEscapement(), bHaveVertAlign ); - lcl_WriteValue( pStream, XML_b, rFontData.mnWeight > 400 ? ToPsz( rFontData.mnWeight > 400 ) : nullptr ); - lcl_WriteValue( pStream, XML_i, rFontData.mbItalic ? ToPsz( rFontData.mbItalic ) : nullptr ); - lcl_WriteValue( pStream, XML_strike, rFontData.mbStrikeout ? ToPsz( rFontData.mbStrikeout ) : nullptr ); + lcl_WriteValue( pStream, XML_b, rFontData.mnWeight > 400 ? ToPsz( true ) : nullptr ); + lcl_WriteValue( pStream, XML_i, rFontData.mbItalic ? ToPsz( true ) : nullptr ); + lcl_WriteValue( pStream, XML_strike, rFontData.mbStrikeout ? ToPsz( true ) : nullptr ); // OOXTODO: lcl_WriteValue( rStream, XML_condense, ); // mac compatibility setting // OOXTODO: lcl_WriteValue( rStream, XML_extend, ); // compatibility setting - lcl_WriteValue( pStream, XML_outline, rFontData.mbOutline ? ToPsz( rFontData.mbOutline ) : nullptr ); - lcl_WriteValue( pStream, XML_shadow, rFontData.mbShadow ? ToPsz( rFontData.mbShadow ) : nullptr ); - lcl_WriteValue( pStream, XML_u, bHaveUnderline ? pUnderline : nullptr ); - lcl_WriteValue( pStream, XML_vertAlign, bHaveVertAlign ? pVertAlign : nullptr ); + lcl_WriteValue( pStream, XML_outline, rFontData.mbOutline ? ToPsz( true ) : nullptr ); + lcl_WriteValue( pStream, XML_shadow, rFontData.mbShadow ? ToPsz( true ) : nullptr ); + lcl_WriteValue( pStream, XML_u, bHaveUnderline ? pUnderline : nullptr ); + lcl_WriteValue( pStream, XML_vertAlign, bHaveVertAlign ? pVertAlign : nullptr ); lcl_WriteValue( pStream, XML_sz, OString::number( rFontData.mnHeight / 20.0 ).getStr() ); // Twips->Pt if( rFontData.maColor != Color( 0xFF, 0xFF, 0xFF, 0xFF ) ) pStream->singleElement( XML_color, diff --git a/sc/source/filter/qpro/qproform.cxx b/sc/source/filter/qpro/qproform.cxx index 14c84e8510b9..73a51c2db404 100644 --- a/sc/source/filter/qpro/qproform.cxx +++ b/sc/source/filter/qpro/qproform.cxx @@ -158,8 +158,7 @@ void QProToSc::DoFunc( DefTokenId eOc, sal_uInt16 nArgs, const sal_Char* pExtStr aPool << eParam[ nLast ]; for( nCount = nLast - 1 ; nCount >= 0 ; nCount-- ) { - if( nCount != -1 ) - aPool << ocSep << eParam[ nCount ]; + aPool << ocSep << eParam[ nCount ]; } } diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx index c9844926688f..49e7b5850a74 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx @@ -659,73 +659,71 @@ void ScXMLChangeTrackingImportHelper::SetNewCell(const ScMyContentAction* pActio ScChangeAction* pChangeAction = pTrack->GetAction(pAction->nActionNumber); if (pChangeAction) { + assert(dynamic_cast<ScChangeActionContent*>(pChangeAction)); ScChangeActionContent* pChangeActionContent = static_cast<ScChangeActionContent*>(pChangeAction); - if (pChangeActionContent) + if (pChangeActionContent->IsTopContent() && !pChangeActionContent->IsDeletedIn()) { - if (pChangeActionContent->IsTopContent() && !pChangeActionContent->IsDeletedIn()) + sal_Int32 nCol, nRow, nTab, nCol2, nRow2, nTab2; + pAction->aBigRange.GetVars(nCol, nRow, nTab, nCol2, nRow2, nTab2); + if ((nCol >= 0) && (nCol <= MAXCOL) && + (nRow >= 0) && (nRow <= MAXROW) && + (nTab >= 0) && (nTab <= MAXTAB)) { - sal_Int32 nCol, nRow, nTab, nCol2, nRow2, nTab2; - pAction->aBigRange.GetVars(nCol, nRow, nTab, nCol2, nRow2, nTab2); - if ((nCol >= 0) && (nCol <= MAXCOL) && - (nRow >= 0) && (nRow <= MAXROW) && - (nTab >= 0) && (nTab <= MAXTAB)) + ScAddress aAddress (static_cast<SCCOL>(nCol), + static_cast<SCROW>(nRow), + static_cast<SCTAB>(nTab)); + ScCellValue aCell; + aCell.assign(*pDoc, aAddress); + if (!aCell.isEmpty()) { - ScAddress aAddress (static_cast<SCCOL>(nCol), - static_cast<SCROW>(nRow), - static_cast<SCTAB>(nTab)); - ScCellValue aCell; - aCell.assign(*pDoc, aAddress); - if (!aCell.isEmpty()) + ScCellValue aNewCell; + if (aCell.meType != CELLTYPE_FORMULA) + { + aNewCell = aCell; + pChangeActionContent->SetNewCell(aNewCell, pDoc, EMPTY_OUSTRING); + pChangeActionContent->SetNewValue(aCell, pDoc); + } + else { - ScCellValue aNewCell; - if (aCell.meType != CELLTYPE_FORMULA) + ScMatrixMode nMatrixFlag = aCell.mpFormula->GetMatrixFlag(); + OUString sFormula; + // With GRAM_ODFF reference detection is faster on compilation. + /* FIXME: new cell should be created with a clone + * of the token array instead. Any reason why this + * wasn't done? */ + aCell.mpFormula->GetFormula(sFormula, formula::FormulaGrammar::GRAM_ODFF); + + // #i87826# [Collaboration] Rejected move destroys formulas + // FIXME: adjust ScFormulaCell::GetFormula(), so that the right formula string + // is returned and no further string handling is necessary + OUString sFormula2; + if ( nMatrixFlag != ScMatrixMode::NONE ) { - aNewCell = aCell; - pChangeActionContent->SetNewCell(aNewCell, pDoc, EMPTY_OUSTRING); - pChangeActionContent->SetNewValue(aCell, pDoc); + sFormula2 = sFormula.copy( 2, sFormula.getLength() - 3 ); } else { - ScMatrixMode nMatrixFlag = aCell.mpFormula->GetMatrixFlag(); - OUString sFormula; - // With GRAM_ODFF reference detection is faster on compilation. - /* FIXME: new cell should be created with a clone - * of the token array instead. Any reason why this - * wasn't done? */ - aCell.mpFormula->GetFormula(sFormula, formula::FormulaGrammar::GRAM_ODFF); - - // #i87826# [Collaboration] Rejected move destroys formulas - // FIXME: adjust ScFormulaCell::GetFormula(), so that the right formula string - // is returned and no further string handling is necessary - OUString sFormula2; - if ( nMatrixFlag != ScMatrixMode::NONE ) - { - sFormula2 = sFormula.copy( 2, sFormula.getLength() - 3 ); - } - else - { - sFormula2 = sFormula.copy( 1 ); - } - - aNewCell.meType = CELLTYPE_FORMULA; - aNewCell.mpFormula = new ScFormulaCell(pDoc, aAddress, sFormula2,formula::FormulaGrammar::GRAM_ODFF, nMatrixFlag); - if (nMatrixFlag == ScMatrixMode::Formula) - { - SCCOL nCols; - SCROW nRows; - aCell.mpFormula->GetMatColsRows(nCols, nRows); - aNewCell.mpFormula->SetMatColsRows(nCols, nRows); - } - aNewCell.mpFormula->SetInChangeTrack(true); - pChangeActionContent->SetNewCell(aNewCell, pDoc, EMPTY_OUSTRING); - // #i40704# don't overwrite the formula string via SetNewValue() + sFormula2 = sFormula.copy( 1 ); + } + + aNewCell.meType = CELLTYPE_FORMULA; + aNewCell.mpFormula = new ScFormulaCell(pDoc, aAddress, sFormula2,formula::FormulaGrammar::GRAM_ODFF, nMatrixFlag); + if (nMatrixFlag == ScMatrixMode::Formula) + { + SCCOL nCols; + SCROW nRows; + aCell.mpFormula->GetMatColsRows(nCols, nRows); + aNewCell.mpFormula->SetMatColsRows(nCols, nRows); } + aNewCell.mpFormula->SetInChangeTrack(true); + pChangeActionContent->SetNewCell(aNewCell, pDoc, EMPTY_OUSTRING); + // #i40704# don't overwrite the formula string via SetNewValue() } } - else - { - OSL_FAIL("wrong cell position"); - } + } + else + { + OSL_FAIL("wrong cell position"); } } } diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 963401915f0a..f2ce09406dc5 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -1478,14 +1478,9 @@ void ScXMLExport::OpenRow(const sal_Int32 nTable, const sal_Int32 nStartRow, con else { assert(nPrevIndex >= 0 && "coverity#1438402"); - if (nRow < nEndRow) - { - ScRowFormatRanges* pTempRowFormatRanges = new ScRowFormatRanges(pRowFormatRanges.get()); - OpenAndCloseRow(nPrevIndex, nRow - nEqualRows, nEqualRows, bPrevHidden, bPrevFiltered); - pRowFormatRanges.reset(pTempRowFormatRanges); - } - else - OpenAndCloseRow(nPrevIndex, nRow - nEqualRows, nEqualRows, bPrevHidden, bPrevFiltered); + ScRowFormatRanges* pTempRowFormatRanges = new ScRowFormatRanges(pRowFormatRanges.get()); + OpenAndCloseRow(nPrevIndex, nRow - nEqualRows, nEqualRows, bPrevHidden, bPrevFiltered); + pRowFormatRanges.reset(pTempRowFormatRanges); nEqualRows = 1; nPrevIndex = nIndex; bPrevHidden = bHidden; diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index c7807cef178f..583c89c32823 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -495,11 +495,8 @@ bool ScTransferObj::WriteObject( tools::SvRef<SotStorageStream>& rxOStm, void* p case SCTRANS_TYPE_EDIT_ODF_TEXT_FLAT: { ScTabEditEngine* pEngine = static_cast<ScTabEditEngine*>(pUserObject); - if ( nUserObjectId == SCTRANS_TYPE_EDIT_ODF_TEXT_FLAT ) - { - pEngine->Write( *rxOStm, EETextFormat::Xml ); - bRet = ( rxOStm->GetError() == ERRCODE_NONE ); - } + pEngine->Write(*rxOStm, EETextFormat::Xml); + bRet = (rxOStm->GetError() == ERRCODE_NONE); } break; diff --git a/sc/source/ui/view/tabvwsh2.cxx b/sc/source/ui/view/tabvwsh2.cxx index 6b33a0921753..ea962224f9a8 100644 --- a/sc/source/ui/view/tabvwsh2.cxx +++ b/sc/source/ui/view/tabvwsh2.cxx @@ -184,18 +184,15 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq) nDrawSfxId = nNewId; sDrawCustom.clear(); // value is set below for custom shapes - if ( nNewId != SID_DRAW_CHART ) // chart not with DrawShell + if (nNewId == SID_DRAW_TEXT || nNewId == SID_DRAW_TEXT_VERTICAL + || nNewId == SID_DRAW_TEXT_MARQUEE || nNewId == SID_DRAW_NOTEEDIT) + SetDrawTextShell(true); + else { - if ( nNewId == SID_DRAW_TEXT || nNewId == SID_DRAW_TEXT_VERTICAL || - nNewId == SID_DRAW_TEXT_MARQUEE || nNewId == SID_DRAW_NOTEEDIT ) - SetDrawTextShell( true ); + if (bEx || pView->GetMarkedObjectList().GetMarkCount() != 0) + SetDrawShellOrSub(); else - { - if ( bEx || pView->GetMarkedObjectList().GetMarkCount() != 0 ) - SetDrawShellOrSub(); - else - SetDrawShell( false ); - } + SetDrawShell(false); } if (pTabView->GetDrawFuncPtr()) |