diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-12-21 15:21:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-12-21 17:13:30 +0100 |
commit | f19599c929ac6ae2708b19b9eff62ff70b44ee75 (patch) | |
tree | 6ed489ee28db5b89c6f26ddc068197bf0fd94b6d /editeng/source/uno | |
parent | e519d7465f38367205b37bc80f0244029e352306 (diff) |
loplugin:flatten in editeng..extensions
Change-Id: Ica8f0a6e3d30dba3b5a083e3c04522073de8303f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127233
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng/source/uno')
-rw-r--r-- | editeng/source/uno/unoedprx.cxx | 36 | ||||
-rw-r--r-- | editeng/source/uno/unonrule.cxx | 49 | ||||
-rw-r--r-- | editeng/source/uno/unotext.cxx | 238 |
3 files changed, 159 insertions, 164 deletions
diff --git a/editeng/source/uno/unoedprx.cxx b/editeng/source/uno/unoedprx.cxx index a0eb64a93224..91a4ac15b600 100644 --- a/editeng/source/uno/unoedprx.cxx +++ b/editeng/source/uno/unoedprx.cxx @@ -815,32 +815,30 @@ bool SvxAccessibleTextAdapter::GetIndexAtPoint( const Point& rPoint, sal_Int32& } } - if( aIndex.InField() ) - { - OutputDevice* pOutDev = GetRefDevice(); + if( !aIndex.InField() ) + return true; - DBG_ASSERT(pOutDev!=nullptr, "SvxAccessibleTextAdapter::GetIndexAtPoint: No ref device"); + OutputDevice* pOutDev = GetRefDevice(); - if( !pOutDev ) - return false; + DBG_ASSERT(pOutDev!=nullptr, "SvxAccessibleTextAdapter::GetIndexAtPoint: No ref device"); - ESelection aSelection = MakeEESelection( aIndex ); - SvxFont aFont = EditEngine::CreateSvxFontFromItemSet( mpTextForwarder->GetAttribs( aSelection ) ); - AccessibleStringWrap aStringWrap( *pOutDev, - aFont, - mpTextForwarder->GetText( aSelection ) ); + if( !pOutDev ) + return false; - tools::Rectangle aRect = mpTextForwarder->GetCharBounds( nPara, aIndex.GetEEIndex() ); - Point aPoint = rPoint; - aPoint.Move( -aRect.Left(), -aRect.Top() ); + ESelection aSelection = MakeEESelection( aIndex ); + SvxFont aFont = EditEngine::CreateSvxFontFromItemSet( mpTextForwarder->GetAttribs( aSelection ) ); + AccessibleStringWrap aStringWrap( *pOutDev, + aFont, + mpTextForwarder->GetText( aSelection ) ); - DBG_ASSERT(aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( rPoint ) >= 0, - "SvxAccessibleTextIndex::SetIndex: index value overflow"); + tools::Rectangle aRect = mpTextForwarder->GetCharBounds( nPara, aIndex.GetEEIndex() ); + Point aPoint = rPoint; + aPoint.Move( -aRect.Left(), -aRect.Top() ); - nIndex = (aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( aPoint )); - return true; - } + DBG_ASSERT(aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( rPoint ) >= 0, + "SvxAccessibleTextIndex::SetIndex: index value overflow"); + nIndex = (aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( aPoint )); return true; } diff --git a/editeng/source/uno/unonrule.cxx b/editeng/source/uno/unonrule.cxx index 5ac7c4c1ba41..d850f70265f6 100644 --- a/editeng/source/uno/unonrule.cxx +++ b/editeng/source/uno/unonrule.cxx @@ -504,37 +504,34 @@ sal_Int16 SAL_CALL SvxUnoNumberingRulesCompare::compare( const Any& Any1, const sal_Int16 SvxUnoNumberingRules::Compare( const Any& Any1, const Any& Any2 ) { Reference< XIndexReplace > x1( Any1, UNO_QUERY ), x2( Any2, UNO_QUERY ); - if( x1.is() && x2.is() ) - { - if( x1.get() == x2.get() ) - return 0; + if( !x1 || !x2 ) + return -1; - SvxUnoNumberingRules* pRule1 = comphelper::getFromUnoTunnel<SvxUnoNumberingRules>( x1 ); - if( pRule1 ) - { - SvxUnoNumberingRules* pRule2 = comphelper::getFromUnoTunnel<SvxUnoNumberingRules>( x2 ); - if( pRule2 ) - { - const SvxNumRule& rRule1 = pRule1->getNumRule(); - const SvxNumRule& rRule2 = pRule2->getNumRule(); + if( x1.get() == x2.get() ) + return 0; - const sal_uInt16 nLevelCount1 = rRule1.GetLevelCount(); - const sal_uInt16 nLevelCount2 = rRule2.GetLevelCount(); + SvxUnoNumberingRules* pRule1 = comphelper::getFromUnoTunnel<SvxUnoNumberingRules>( x1 ); + if( !pRule1 ) + return -1; + SvxUnoNumberingRules* pRule2 = comphelper::getFromUnoTunnel<SvxUnoNumberingRules>( x2 ); + if( !pRule2 ) + return -1; - if( nLevelCount1 == 0 || nLevelCount2 == 0 ) - return -1; + const SvxNumRule& rRule1 = pRule1->getNumRule(); + const SvxNumRule& rRule2 = pRule2->getNumRule(); - for( sal_uInt16 i = 0; (i < nLevelCount1) && (i < nLevelCount2); i++ ) - { - if( rRule1.GetLevel(i) != rRule2.GetLevel(i) ) - return -1; - } - return 0; - } - } - } + const sal_uInt16 nLevelCount1 = rRule1.GetLevelCount(); + const sal_uInt16 nLevelCount2 = rRule2.GetLevelCount(); + + if( nLevelCount1 == 0 || nLevelCount2 == 0 ) + return -1; - return -1; + for( sal_uInt16 i = 0; (i < nLevelCount1) && (i < nLevelCount2); i++ ) + { + if( rRule1.GetLevel(i) != rRule2.GetLevel(i) ) + return -1; + } + return 0; } Reference< XAnyCompare > SvxCreateNumRuleCompare() noexcept diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index 16ffaaa8bbfa..b8ad3d09e9ed 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -1064,122 +1064,121 @@ uno::Sequence< beans::PropertyState > SvxUnoTextRangeBase::_getPropertyStates(co bool SvxUnoTextRangeBase::_getOnePropertyStates(const SfxItemSet* pSet, const SfxItemPropertyMapEntry* pMap, beans::PropertyState& rState) { + if(!pSet || !pMap) + return true; + SfxItemState eItemState = SfxItemState::DEFAULT; + bool bItemStateSet(false); + bool bUnknownPropertyFound = false; - if(pSet && pMap) + switch( pMap->nWID ) { - SfxItemState eItemState = SfxItemState::DEFAULT; - bool bItemStateSet(false); - - switch( pMap->nWID ) - { - case WID_FONTDESC: + case WID_FONTDESC: + { + const sal_uInt16* pWhichId = aSvxUnoFontDescriptorWhichMap; + while( *pWhichId ) { - const sal_uInt16* pWhichId = aSvxUnoFontDescriptorWhichMap; - while( *pWhichId ) + const SfxItemState eTempItemState(pSet->GetItemState( *pWhichId )); + + switch( eTempItemState ) { - const SfxItemState eTempItemState(pSet->GetItemState( *pWhichId )); + case SfxItemState::DISABLED: + case SfxItemState::DONTCARE: + eItemState = SfxItemState::DONTCARE; + bItemStateSet = true; + break; - switch( eTempItemState ) + case SfxItemState::DEFAULT: + if( !bItemStateSet ) { - case SfxItemState::DISABLED: - case SfxItemState::DONTCARE: - eItemState = SfxItemState::DONTCARE; + eItemState = SfxItemState::DEFAULT; bItemStateSet = true; - break; - - case SfxItemState::DEFAULT: - if( !bItemStateSet ) - { - eItemState = SfxItemState::DEFAULT; - bItemStateSet = true; - } - break; - - case SfxItemState::SET: - if( !bItemStateSet ) - { - eItemState = SfxItemState::SET; - bItemStateSet = true; - } - break; - default: - bUnknownPropertyFound = true; - break; } + break; - pWhichId++; + case SfxItemState::SET: + if( !bItemStateSet ) + { + eItemState = SfxItemState::SET; + bItemStateSet = true; + } + break; + default: + bUnknownPropertyFound = true; + break; } - } - break; - case WID_NUMLEVEL: - case WID_NUMBERINGSTARTVALUE: - case WID_PARAISNUMBERINGRESTART: - eItemState = SfxItemState::SET; - bItemStateSet = true; - break; - - default: - if(0 != pMap->nWID) - { - eItemState = pSet->GetItemState( pMap->nWID, false ); - bItemStateSet = true; + pWhichId++; } - break; - } + } + break; - if( bUnknownPropertyFound ) - return false; + case WID_NUMLEVEL: + case WID_NUMBERINGSTARTVALUE: + case WID_PARAISNUMBERINGRESTART: + eItemState = SfxItemState::SET; + bItemStateSet = true; + break; - if(bItemStateSet) - { - if (pMap->nWID == EE_CHAR_COLOR) + default: + if(0 != pMap->nWID) { - // Theme & effects can be DEFAULT_VALUE, even if the same pool item has a color - // which is a DIRECT_VALUE. - const SvxColorItem* pColor = pSet->GetItem<SvxColorItem>(EE_CHAR_COLOR); - switch (pMap->nMemberId) - { - case MID_COLOR_THEME_INDEX: - if (pColor->GetThemeIndex() == -1) - { - eItemState = SfxItemState::DEFAULT; - } - break; - case MID_COLOR_LUM_MOD: - if (pColor->GetLumMod() == 10000) - { - eItemState = SfxItemState::DEFAULT; - } - break; - case MID_COLOR_LUM_OFF: - if (pColor->GetLumOff() == 0) - { - eItemState = SfxItemState::DEFAULT; - } - break; - } + eItemState = pSet->GetItemState( pMap->nWID, false ); + bItemStateSet = true; } + break; + } + + if( bUnknownPropertyFound ) + return false; - switch( eItemState ) + if(bItemStateSet) + { + if (pMap->nWID == EE_CHAR_COLOR) + { + // Theme & effects can be DEFAULT_VALUE, even if the same pool item has a color + // which is a DIRECT_VALUE. + const SvxColorItem* pColor = pSet->GetItem<SvxColorItem>(EE_CHAR_COLOR); + switch (pMap->nMemberId) { - case SfxItemState::SET: - rState = beans::PropertyState_DIRECT_VALUE; + case MID_COLOR_THEME_INDEX: + if (pColor->GetThemeIndex() == -1) + { + eItemState = SfxItemState::DEFAULT; + } break; - case SfxItemState::DEFAULT: - rState = beans::PropertyState_DEFAULT_VALUE; + case MID_COLOR_LUM_MOD: + if (pColor->GetLumMod() == 10000) + { + eItemState = SfxItemState::DEFAULT; + } + break; + case MID_COLOR_LUM_OFF: + if (pColor->GetLumOff() == 0) + { + eItemState = SfxItemState::DEFAULT; + } break; -// case SfxItemState::DONTCARE: -// case SfxItemState::DISABLED: - default: - rState = beans::PropertyState_AMBIGUOUS_VALUE; } } - else + + switch( eItemState ) { - rState = beans::PropertyState_AMBIGUOUS_VALUE; + case SfxItemState::SET: + rState = beans::PropertyState_DIRECT_VALUE; + break; + case SfxItemState::DEFAULT: + rState = beans::PropertyState_DEFAULT_VALUE; + break; +// case SfxItemState::DONTCARE: +// case SfxItemState::DISABLED: + default: + rState = beans::PropertyState_AMBIGUOUS_VALUE; } } + else + { + rState = beans::PropertyState_AMBIGUOUS_VALUE; + } return true; } @@ -1396,41 +1395,42 @@ bool SvxUnoTextRangeBase::GoLeft(sal_Int32 nCount, bool Expand) noexcept bool SvxUnoTextRangeBase::GoRight(sal_Int32 nCount, bool Expand) noexcept { - SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; - if( pForwarder ) - { - CheckSelection( maSelection, pForwarder ); + if (!mpEditSource) + return false; + SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder(); + if( !pForwarder ) + return false; - sal_Int32 nNewPos = maSelection.nEndPos + nCount; - sal_Int32 nNewPar = maSelection.nEndPara; + CheckSelection( maSelection, pForwarder ); - bool bOk = true; - sal_Int32 nParCount = pForwarder->GetParagraphCount(); - sal_Int32 nThisLen = pForwarder->GetTextLen( nNewPar ); - while ( nNewPos > nThisLen && bOk ) - { - if ( nNewPar + 1 >= nParCount ) - bOk = false; - else - { - nNewPos -= nThisLen+1; - ++nNewPar; - nThisLen = pForwarder->GetTextLen( nNewPar ); - } - } + sal_Int32 nNewPos = maSelection.nEndPos + nCount; + sal_Int32 nNewPar = maSelection.nEndPara; - if (bOk) + bool bOk = true; + sal_Int32 nParCount = pForwarder->GetParagraphCount(); + sal_Int32 nThisLen = pForwarder->GetTextLen( nNewPar ); + while ( nNewPos > nThisLen && bOk ) + { + if ( nNewPar + 1 >= nParCount ) + bOk = false; + else { - maSelection.nEndPara = nNewPar; - maSelection.nEndPos = nNewPos; + nNewPos -= nThisLen+1; + ++nNewPar; + nThisLen = pForwarder->GetTextLen( nNewPar ); } + } - if (!Expand) - CollapseToEnd(); - - return bOk; + if (bOk) + { + maSelection.nEndPara = nNewPar; + maSelection.nEndPos = nNewPos; } - return false; + + if (!Expand) + CollapseToEnd(); + + return bOk; } void SvxUnoTextRangeBase::GotoStart(bool Expand) noexcept |