diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-10-28 03:09:02 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-10-28 08:23:32 +0100 |
commit | 36880d76299e913761f03bbde1b6ca6bea393b5a (patch) | |
tree | 05a880ec60124a405a2d817b2598f23a2bbba423 /sc | |
parent | 85985a6ad85ebd3debf63e286dacbe5945178796 (diff) |
tdf#120703 PVS: V547 Expression is always true/false
Change-Id: I1e5098e11f1e5e2f7c5518ea05c57512f58b585b
Reviewed-on: https://gerrit.libreoffice.org/62464
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/global.cxx | 15 | ||||
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 200 |
2 files changed, 103 insertions, 112 deletions
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 1bb038b4d437..441c95ef8412 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -523,18 +523,13 @@ void ScGlobal::InitTextHeight(const SfxItemPool* pPool) return; } - const ScPatternAttr* pPattern = &pPool->GetDefaultItem(ATTR_PATTERN); - if (!pPattern) - { - OSL_FAIL("ScGlobal::InitTextHeight: No default pattern"); - return; - } + const ScPatternAttr& rPattern = pPool->GetDefaultItem(ATTR_PATTERN); OutputDevice* pDefaultDev = Application::GetDefaultDevice(); ScopedVclPtrInstance< VirtualDevice > pVirtWindow( *pDefaultDev ); pVirtWindow->SetMapMode(MapMode(MapUnit::MapPixel)); vcl::Font aDefFont; - pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, pVirtWindow); // Font color doesn't matter here + rPattern.GetFont(aDefFont, SC_AUTOCOL_BLACK, pVirtWindow); // Font color doesn't matter here pVirtWindow->SetFont(aDefFont); sal_uInt16 nTest = static_cast<sal_uInt16>( pVirtWindow->PixelToLogic(Size(0, pVirtWindow->GetTextHeight()), MapMode(MapUnit::MapTwip)).Height()); @@ -542,10 +537,10 @@ void ScGlobal::InitTextHeight(const SfxItemPool* pPool) if (nTest > nDefFontHeight) nDefFontHeight = nTest; - const SvxMarginItem* pMargin = &pPattern->GetItem(ATTR_MARGIN); + const SvxMarginItem& rMargin = rPattern.GetItem(ATTR_MARGIN); - nTest = static_cast<sal_uInt16>( - nDefFontHeight + pMargin->GetTopMargin() + pMargin->GetBottomMargin() - STD_ROWHEIGHT_DIFF); + nTest = static_cast<sal_uInt16>(nDefFontHeight + rMargin.GetTopMargin() + + rMargin.GetBottomMargin() - STD_ROWHEIGHT_DIFF); if (nTest > nStdRowHeight) nStdRowHeight = nTest; diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 4706b8f21e22..36af4bd5979c 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -3633,131 +3633,127 @@ void ScInputHandler::NotifyChange( const ScInputHdlState* pState, { ScModule* pScMod = SC_MOD(); - if ( pState ) + // Also take foreign reference input into account here (e.g. FunctionsAutoPilot), + // FormEditData, if we're switching from Help to Calc: + if ( !bFormulaMode && !pScMod->IsFormulaMode() && !pScMod->GetFormEditData() ) { + bool bIgnore = false; + if ( bModified ) + { + if (pState->GetPos() != aCursorPos) + { + if (!bProtected) + EnterHandler(); + } + else + bIgnore = true; + } - // Also take foreign reference input into account here (e.g. FunctionsAutoPilot), - // FormEditData, if we're switching from Help to Calc: - if ( !bFormulaMode && !pScMod->IsFormulaMode() && !pScMod->GetFormEditData() ) + if ( !bIgnore ) { - bool bIgnore = false; - if ( bModified ) + const ScAddress& rSPos = pState->GetStartPos(); + const ScAddress& rEPos = pState->GetEndPos(); + const EditTextObject* pData = pState->GetEditData(); + OUString aString = pState->GetString(); + bool bTxtMod = false; + ScDocShell* pDocSh = pActiveViewSh->GetViewData().GetDocShell(); + ScDocument& rDoc = pDocSh->GetDocument(); + + aCursorPos = pState->GetPos(); + + if ( pData ) + bTxtMod = true; + else if ( bHadObject ) + bTxtMod = true; + else if ( bTextValid ) + bTxtMod = ( aString != aCurrentText ); + else + bTxtMod = ( aString != GetEditText(mpEditEngine.get()) ); + + if ( bTxtMod || bForce ) { - if (pState->GetPos() != aCursorPos) + if (pData) { - if (!bProtected) - EnterHandler(); + mpEditEngine->SetText( *pData ); + if (pInputWin) + aString = ScEditUtil::GetMultilineString(*mpEditEngine); + else + aString = GetEditText(mpEditEngine.get()); + lcl_RemoveTabs(aString); + bTextValid = false; + aCurrentText.clear(); } else - bIgnore = true; + { + aCurrentText = aString; + bTextValid = true; //! To begin with remember as a string + } + + if ( pInputWin ) + pInputWin->SetTextString(aString); + else if (comphelper::LibreOfficeKit::isActive()) + { + if (pActiveViewSh) + pActiveViewSh->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_FORMULA, aString.toUtf8().getStr()); + } } - if ( !bIgnore ) + if ( pInputWin || comphelper::LibreOfficeKit::isActive()) // Named range input { - const ScAddress& rSPos = pState->GetStartPos(); - const ScAddress& rEPos = pState->GetEndPos(); - const EditTextObject* pData = pState->GetEditData(); - OUString aString = pState->GetString(); - bool bTxtMod = false; - ScDocShell* pDocSh = pActiveViewSh->GetViewData().GetDocShell(); - ScDocument& rDoc = pDocSh->GetDocument(); - - aCursorPos = pState->GetPos(); - - if ( pData ) - bTxtMod = true; - else if ( bHadObject ) - bTxtMod = true; - else if ( bTextValid ) - bTxtMod = ( aString != aCurrentText ); - else - bTxtMod = ( aString != GetEditText(mpEditEngine.get()) ); + OUString aPosStr; + const ScAddress::Details aAddrDetails( &rDoc, aCursorPos ); - if ( bTxtMod || bForce ) + // Is the range a name? + //! Find by Timer? + if ( pActiveViewSh ) + pActiveViewSh->GetViewData().GetDocument()-> + GetRangeAtBlock( ScRange( rSPos, rEPos ), &aPosStr ); + + if ( aPosStr.isEmpty() ) // Not a name -> format { - if (pData) + ScRefFlags nFlags = ScRefFlags::ZERO; + if( aAddrDetails.eConv == formula::FormulaGrammar::CONV_XL_R1C1 ) + nFlags |= ScRefFlags::COL_ABS | ScRefFlags::ROW_ABS; + if ( rSPos != rEPos ) { - mpEditEngine->SetText( *pData ); - if (pInputWin) - aString = ScEditUtil::GetMultilineString(*mpEditEngine); - else - aString = GetEditText(mpEditEngine.get()); - lcl_RemoveTabs(aString); - bTextValid = false; - aCurrentText.clear(); + ScRange r(rSPos, rEPos); + applyStartToEndFlags(nFlags); + aPosStr = r.Format(ScRefFlags::VALID | nFlags, &rDoc, aAddrDetails); } else - { - aCurrentText = aString; - bTextValid = true; //! To begin with remember as a string - } - - if ( pInputWin ) - pInputWin->SetTextString(aString); - else if (comphelper::LibreOfficeKit::isActive()) - { - if (pActiveViewSh) - pActiveViewSh->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_FORMULA, aString.toUtf8().getStr()); - } + aPosStr = aCursorPos.Format(ScRefFlags::VALID | nFlags, &rDoc, aAddrDetails); } - if ( pInputWin || comphelper::LibreOfficeKit::isActive()) // Named range input + if (pInputWin) { - OUString aPosStr; - const ScAddress::Details aAddrDetails( &rDoc, aCursorPos ); - - // Is the range a name? - //! Find by Timer? - if ( pActiveViewSh ) - pActiveViewSh->GetViewData().GetDocument()-> - GetRangeAtBlock( ScRange( rSPos, rEPos ), &aPosStr ); - - if ( aPosStr.isEmpty() ) // Not a name -> format - { - ScRefFlags nFlags = ScRefFlags::ZERO; - if( aAddrDetails.eConv == formula::FormulaGrammar::CONV_XL_R1C1 ) - nFlags |= ScRefFlags::COL_ABS | ScRefFlags::ROW_ABS; - if ( rSPos != rEPos ) - { - ScRange r(rSPos, rEPos); - applyStartToEndFlags(nFlags); - aPosStr = r.Format(ScRefFlags::VALID | nFlags, &rDoc, aAddrDetails); - } - else - aPosStr = aCursorPos.Format(ScRefFlags::VALID | nFlags, &rDoc, aAddrDetails); - } - - if (pInputWin) - { - // Disable the accessible VALUE_CHANGE event - bool bIsSuppressed = pInputWin->IsAccessibilityEventsSuppressed(false); - pInputWin->SetAccessibilityEventsSuppressed(true); - pInputWin->SetPosString(aPosStr); - pInputWin->SetAccessibilityEventsSuppressed(bIsSuppressed); - pInputWin->SetSumAssignMode(); - } - else if (pActiveViewSh) - { - pActiveViewSh->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_ADDRESS, aPosStr.toUtf8().getStr()); - } + // Disable the accessible VALUE_CHANGE event + bool bIsSuppressed = pInputWin->IsAccessibilityEventsSuppressed(false); + pInputWin->SetAccessibilityEventsSuppressed(true); + pInputWin->SetPosString(aPosStr); + pInputWin->SetAccessibilityEventsSuppressed(bIsSuppressed); + pInputWin->SetSumAssignMode(); } + else if (pActiveViewSh) + { + pActiveViewSh->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_ADDRESS, aPosStr.toUtf8().getStr()); + } + } - if (bStopEditing) - SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScKillEditView ) ); + if (bStopEditing) + SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScKillEditView ) ); - // As long as the content is not edited, turn off online spelling. - // Online spelling is turned back on in StartTable, after setting - // the right language from cell attributes. + // As long as the content is not edited, turn off online spelling. + // Online spelling is turned back on in StartTable, after setting + // the right language from cell attributes. - EEControlBits nCntrl = mpEditEngine->GetControlWord(); - if ( nCntrl & EEControlBits::ONLINESPELLING ) - mpEditEngine->SetControlWord( nCntrl & ~EEControlBits::ONLINESPELLING ); + EEControlBits nCntrl = mpEditEngine->GetControlWord(); + if ( nCntrl & EEControlBits::ONLINESPELLING ) + mpEditEngine->SetControlWord( nCntrl & ~EEControlBits::ONLINESPELLING ); - bModified = false; - bSelIsRef = false; - bProtected = false; - bCommandErrorShown = false; - } + bModified = false; + bSelIsRef = false; + bProtected = false; + bCommandErrorShown = false; } } |