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 | |
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>
68 files changed, 1026 insertions, 1394 deletions
diff --git a/accessibility/source/standard/vclxaccessiblebox.cxx b/accessibility/source/standard/vclxaccessiblebox.cxx index c43245428253..df87e4d7e350 100644 --- a/accessibility/source/standard/vclxaccessiblebox.cxx +++ b/accessibility/source/standard/vclxaccessiblebox.cxx @@ -411,10 +411,7 @@ OUString SAL_CALL VCLXAccessibleBox::getAccessibleActionDescription (sal_Int32 n if (nIndex!=0 || !m_bIsDropDownBox) throw css::lang::IndexOutOfBoundsException(); - if (m_bIsDropDownBox) - return OUString(RID_STR_ACC_ACTION_TOGGLEPOPUP); - - return OUString(); + return OUString(RID_STR_ACC_ACTION_TOGGLEPOPUP); } Reference< XAccessibleKeyBinding > VCLXAccessibleBox::getAccessibleActionKeyBinding( sal_Int32 nIndex ) diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 69dae820aad8..c8131460accf 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -3219,12 +3219,9 @@ bool SbiRuntime::checkClass_Impl( const SbxVariableRef& refVal, } else { - if ( !bVBAEnabled ) - { - if( bRaiseErrors ) - Error( ERRCODE_BASIC_NEEDS_OBJECT ); - bOk = false; - } + if( bRaiseErrors ) + Error( ERRCODE_BASIC_NEEDS_OBJECT ); + bOk = false; } return bOk; } diff --git a/chart2/source/view/axes/Tickmarks_Equidistant.cxx b/chart2/source/view/axes/Tickmarks_Equidistant.cxx index 7b319974bbb5..85a6a4915a3c 100644 --- a/chart2/source/view/axes/Tickmarks_Equidistant.cxx +++ b/chart2/source/view/axes/Tickmarks_Equidistant.cxx @@ -311,8 +311,8 @@ bool EquidistantTickFactory::isVisible( double fScaledValue ) const void EquidistantTickFactory::getAllTicks( TickInfoArraysType& rAllTickInfos ) const { //create point sequences for each tick depth - sal_Int32 nDepthCount = getTickDepth(); - sal_Int32 nMaxMajorTickCount = getMaxTickCount(0); + const sal_Int32 nDepthCount = getTickDepth(); + const sal_Int32 nMaxMajorTickCount = getMaxTickCount(0); if (nDepthCount <= 0 || nMaxMajorTickCount <= 0) return; @@ -333,8 +333,7 @@ void EquidistantTickFactory::getAllTicks( TickInfoArraysType& rAllTickInfos ) co return; aAllTicks[0].realloc(nRealMajorTickCount); - if(nDepthCount>0) - addSubTicks( 1, aAllTicks ); + addSubTicks(1, aAllTicks); //so far we have added all ticks between the outer major tick marks //this was necessary to create sub ticks correctly diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 85da43f53daf..0b488abaa5e1 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -1589,10 +1589,8 @@ void VCartesianAxis::createLabels() if (!m_aAxisProperties.m_bDisplayLabels) return; - std::unique_ptr< TickFactory2D > apTickFactory2D( createTickFactory2D() ); + std::unique_ptr<TickFactory2D> apTickFactory2D(createTickFactory2D()); // throws on failure TickFactory2D* pTickFactory2D = apTickFactory2D.get(); - if( !pTickFactory2D ) - return; //get the transformed screen values for all tickmarks in aAllTickInfos pTickFactory2D->updateScreenValues( m_aAllTickInfos ); @@ -1644,10 +1642,8 @@ void VCartesianAxis::createMaximumLabels() if (!m_aAxisProperties.m_bDisplayLabels) return; - std::unique_ptr< TickFactory2D > apTickFactory2D( createTickFactory2D() ); + std::unique_ptr<TickFactory2D> apTickFactory2D(createTickFactory2D()); // throws on failure TickFactory2D* pTickFactory2D = apTickFactory2D.get(); - if( !pTickFactory2D ) - return; //get the transformed screen values for all tickmarks in aAllTickInfos pTickFactory2D->updateScreenValues( m_aAllTickInfos ); @@ -1682,10 +1678,8 @@ void VCartesianAxis::updatePositions() if (!m_aAxisProperties.m_bDisplayLabels) return; - std::unique_ptr< TickFactory2D > apTickFactory2D( createTickFactory2D() ); + std::unique_ptr<TickFactory2D> apTickFactory2D(createTickFactory2D()); // throws on failure TickFactory2D* pTickFactory2D = apTickFactory2D.get(); - if( !pTickFactory2D ) - return; //update positions of all existing text shapes pTickFactory2D->updateScreenValues( m_aAllTickInfos ); @@ -1778,10 +1772,8 @@ void VCartesianAxis::createShapes() if( !prepareShapeCreation() ) return; - std::unique_ptr< TickFactory2D > apTickFactory2D( createTickFactory2D() ); + std::unique_ptr<TickFactory2D> apTickFactory2D(createTickFactory2D()); // throws on failure TickFactory2D* pTickFactory2D = apTickFactory2D.get(); - if( !pTickFactory2D ) - return; //create line shapes if(m_nDimension==2) diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index e9a9e6d5df11..548ecef28ccf 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -2517,14 +2517,7 @@ uno::Reference< drawing::XShape > ShapeFactory* ShapeFactory::getOrCreateShapeFactory(const uno::Reference< lang::XMultiServiceFactory>& xFactory) { - static ShapeFactory* pShapeFactory = nullptr; - - if (pShapeFactory) - return pShapeFactory; - - if (!pShapeFactory) - pShapeFactory = new ShapeFactory(xFactory); - + static ShapeFactory* pShapeFactory = new ShapeFactory(xFactory); return pShapeFactory; } diff --git a/cui/source/dialogs/srchxtra.cxx b/cui/source/dialogs/srchxtra.cxx index 08a403dd063d..a63691256f19 100644 --- a/cui/source/dialogs/srchxtra.cxx +++ b/cui/source/dialogs/srchxtra.cxx @@ -82,8 +82,7 @@ void SvxSearchFormatDialog::PageCreated(const OString& rId, SfxTabPage& rPage) pList = m_pFontList.get(); } - if ( pList ) - static_cast<SvxCharNamePage&>(rPage). + static_cast<SvxCharNamePage&>(rPage). SetFontList( SvxFontListItem( pList, SID_ATTR_CHAR_FONTLIST ) ); static_cast<SvxCharNamePage&>(rPage).EnableSearchMode(); } diff --git a/cui/source/tabpages/textanim.cxx b/cui/source/tabpages/textanim.cxx index d5e27cfc2113..7a73a7d91ead 100644 --- a/cui/source/tabpages/textanim.cxx +++ b/cui/source/tabpages/textanim.cxx @@ -143,31 +143,17 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) if( !pItem ) pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANIKIND ); - if( pItem ) - { - eAniKind = static_cast<const SdrTextAniKindItem*>(pItem)->GetValue(); - m_xLbEffect->set_active( sal::static_int_cast< sal_Int32 >(eAniKind) ); - } - else - m_xLbEffect->set_active(-1); + + eAniKind = static_cast<const SdrTextAniKindItem*>(pItem)->GetValue(); + m_xLbEffect->set_active(sal::static_int_cast<sal_Int32>(eAniKind)); m_xLbEffect->save_value(); // animation direction pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANIDIRECTION ); if( !pItem ) pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANIDIRECTION ); - if( pItem ) - { - SdrTextAniDirection eValue = static_cast<const SdrTextAniDirectionItem*>(pItem)->GetValue(); - SelectDirection( eValue ); - } - else - { - m_xBtnUp->set_active( false ); - m_xBtnLeft->set_active( false ); - m_xBtnRight->set_active( false ); - m_xBtnDown->set_active( false ); - } + + SelectDirection(static_cast<const SdrTextAniDirectionItem*>(pItem)->GetValue()); m_aUpState = m_xBtnUp->get_state(); m_aLeftState = m_xBtnLeft->get_state(); m_aRightState = m_xBtnRight->get_state(); @@ -177,66 +163,46 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANISTARTINSIDE ); if( !pItem ) pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANISTARTINSIDE ); - if( pItem ) - { - m_xTsbStartInside->set_inconsistent(false); - bool bValue = static_cast<const SdrTextAniStartInsideItem*>(pItem)->GetValue(); - if( bValue ) - m_xTsbStartInside->set_state( TRISTATE_TRUE ); - else - m_xTsbStartInside->set_state( TRISTATE_FALSE ); - } + + if (static_cast<const SdrTextAniStartInsideItem*>(pItem)->GetValue()) + m_xTsbStartInside->set_state(TRISTATE_TRUE); else - m_xTsbStartInside->set_state( TRISTATE_INDET ); + m_xTsbStartInside->set_state(TRISTATE_FALSE); m_xTsbStartInside->save_state(); // Stop inside pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANISTOPINSIDE ); if( !pItem ) pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANISTOPINSIDE ); - if( pItem ) - { - m_xTsbStopInside->set_inconsistent(false); - bool bValue = static_cast<const SdrTextAniStopInsideItem*>(pItem)->GetValue(); - if( bValue ) - m_xTsbStopInside->set_state( TRISTATE_TRUE ); - else - m_xTsbStopInside->set_state( TRISTATE_FALSE ); - } + + if (static_cast<const SdrTextAniStopInsideItem*>(pItem)->GetValue()) + m_xTsbStopInside->set_state(TRISTATE_TRUE); else - m_xTsbStopInside->set_state( TRISTATE_INDET ); + m_xTsbStopInside->set_state(TRISTATE_FALSE); m_xTsbStopInside->save_state(); // quantity pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANICOUNT ); if( !pItem ) pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANICOUNT ); - if( pItem ) + + long nValue = static_cast<long>(static_cast<const SdrTextAniCountItem*>(pItem)->GetValue()); + m_xNumFldCount->set_value(nValue); + if (nValue == 0) { - m_xTsbEndless->set_inconsistent(false); - long nValue = static_cast<long>(static_cast<const SdrTextAniCountItem*>(pItem)->GetValue()); - m_xNumFldCount->set_value(nValue); - if( nValue == 0 ) + if (eAniKind == SdrTextAniKind::Slide) { - if( eAniKind == SdrTextAniKind::Slide ) - { - m_xTsbEndless->set_state( TRISTATE_FALSE ); - m_xTsbEndless->set_sensitive(false); - } - else - { - m_xTsbEndless->set_state( TRISTATE_TRUE ); - m_xNumFldCount->set_text(""); - } + m_xTsbEndless->set_state(TRISTATE_FALSE); + m_xTsbEndless->set_sensitive(false); } else - m_xTsbEndless->set_state( TRISTATE_FALSE ); + { + m_xTsbEndless->set_state(TRISTATE_TRUE); + m_xNumFldCount->set_text(""); + } } else - { - m_xNumFldCount->set_text(""); - m_xTsbEndless->set_state( TRISTATE_INDET ); - } + m_xTsbEndless->set_state(TRISTATE_FALSE); m_xTsbEndless->save_state(); m_xNumFldCount->save_value(); @@ -244,24 +210,16 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANIDELAY ); if( !pItem ) pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANIDELAY ); - if( pItem ) - { - m_xTsbAuto->set_inconsistent(false); - long nValue = static_cast<long>(static_cast<const SdrTextAniDelayItem*>(pItem)->GetValue()); - m_xMtrFldDelay->set_value(nValue, FieldUnit::NONE); - if( nValue == 0 ) - { - m_xTsbAuto->set_state( TRISTATE_TRUE ); - m_xMtrFldDelay->set_text(""); - } - else - m_xTsbAuto->set_state( TRISTATE_FALSE ); - } - else + + nValue = static_cast<long>(static_cast<const SdrTextAniDelayItem*>(pItem)->GetValue()); + m_xMtrFldDelay->set_value(nValue, FieldUnit::NONE); + if (nValue == 0) { + m_xTsbAuto->set_state(TRISTATE_TRUE); m_xMtrFldDelay->set_text(""); - m_xTsbAuto->set_state( TRISTATE_INDET ); } + else + m_xTsbAuto->set_state(TRISTATE_FALSE); m_xTsbAuto->save_state(); m_xMtrFldDelay->save_value(); @@ -269,40 +227,31 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANIAMOUNT ); if( !pItem ) pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANIAMOUNT ); - if( pItem ) - { - m_xTsbPixel->set_inconsistent(false); - long nValue = static_cast<long>(static_cast<const SdrTextAniAmountItem*>(pItem)->GetValue()); - if( nValue <= 0 ) - { - m_xTsbPixel->set_state( TRISTATE_TRUE ); - nValue = -nValue; - if( nValue == 0 ) - nValue++; - m_xMtrFldAmount->set_unit( FieldUnit::CUSTOM ); - m_xMtrFldAmount->set_digits(0); - - m_xMtrFldAmount->set_increments(1, 10, FieldUnit::NONE); - m_xMtrFldAmount->set_range(1, 100, FieldUnit::NONE); - m_xMtrFldAmount->set_value(nValue, FieldUnit::NONE); - } - else - { - m_xTsbPixel->set_state( TRISTATE_FALSE ); - m_xMtrFldAmount->set_unit( eFUnit ); - m_xMtrFldAmount->set_digits(2); - m_xMtrFldAmount->set_increments(10, 100, FieldUnit::NONE); - m_xMtrFldAmount->set_range(1, 10000, FieldUnit::NONE); + nValue = static_cast<long>(static_cast<const SdrTextAniAmountItem*>(pItem)->GetValue()); + if (nValue <= 0) + { + m_xTsbPixel->set_state(TRISTATE_TRUE); + nValue = -nValue; + if (nValue == 0) + nValue++; + m_xMtrFldAmount->set_unit(FieldUnit::CUSTOM); + m_xMtrFldAmount->set_digits(0); - SetMetricValue( *m_xMtrFldAmount, nValue, eUnit ); - } + m_xMtrFldAmount->set_increments(1, 10, FieldUnit::NONE); + m_xMtrFldAmount->set_range(1, 100, FieldUnit::NONE); + m_xMtrFldAmount->set_value(nValue, FieldUnit::NONE); } else { - m_xMtrFldAmount->set_sensitive(false); - m_xMtrFldAmount->set_text(""); - m_xTsbPixel->set_state( TRISTATE_INDET ); + m_xTsbPixel->set_state(TRISTATE_FALSE); + m_xMtrFldAmount->set_unit(eFUnit); + m_xMtrFldAmount->set_digits(2); + + m_xMtrFldAmount->set_increments(10, 100, FieldUnit::NONE); + m_xMtrFldAmount->set_range(1, 10000, FieldUnit::NONE); + + SetMetricValue(*m_xMtrFldAmount, nValue, eUnit); } m_xTsbPixel->save_state(); m_xMtrFldAmount->save_value(); diff --git a/cui/source/tabpages/textattr.cxx b/cui/source/tabpages/textattr.cxx index b80cfd38fd7c..0a6d3696ebc0 100644 --- a/cui/source/tabpages/textattr.cxx +++ b/cui/source/tabpages/textattr.cxx @@ -116,52 +116,31 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs ) MapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST ); const SfxPoolItem* pItem = GetItem( *rAttrs, SDRATTR_TEXT_LEFTDIST ); - if( !pItem ) pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LEFTDIST ); - if( pItem ) - { - long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue(); - SetMetricValue( *m_xMtrFldLeft, nValue, eUnit ); - } - else - m_xMtrFldLeft->set_text(""); + + SetMetricValue(*m_xMtrFldLeft, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); m_xMtrFldLeft->save_value(); pItem = GetItem( *rAttrs, SDRATTR_TEXT_RIGHTDIST ); if( !pItem ) pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_RIGHTDIST ); - if( pItem ) - { - long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue(); - SetMetricValue( *m_xMtrFldRight, nValue, eUnit ); - } - else - m_xMtrFldRight->set_text(""); + + SetMetricValue(*m_xMtrFldRight, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); m_xMtrFldRight->save_value(); pItem = GetItem( *rAttrs, SDRATTR_TEXT_UPPERDIST ); if( !pItem ) pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_UPPERDIST ); - if( pItem ) - { - long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue(); - SetMetricValue( *m_xMtrFldTop, nValue, eUnit ); - } - else - m_xMtrFldTop->set_text(""); + + SetMetricValue(*m_xMtrFldTop, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); m_xMtrFldTop->save_value(); pItem = GetItem( *rAttrs, SDRATTR_TEXT_LOWERDIST ); if( !pItem ) pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LOWERDIST ); - if( pItem ) - { - long nValue = static_cast<const SdrMetricItem*>(pItem)->GetValue(); - SetMetricValue( *m_xMtrFldBottom, nValue, eUnit ); - } - else - m_xMtrFldBottom->set_text(""); + + SetMetricValue(*m_xMtrFldBottom, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); m_xMtrFldBottom->save_value(); // adjust to height and autogrowsize diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index ab2ba01378db..f84fba00dfff 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -932,65 +932,63 @@ void SvxAutoCorrect::FnCapitalStartSentence( SvxAutoCorrDoc& rDoc, // Found [ \t]+[A-Z0-9]+ until here. Test now on the paragraph separator. // all three can happen, but not more than once! const sal_Unicode* pExceptStt = nullptr; - if( !bAtStart ) + bool bContinue = true; + Flags nFlag = Flags::NONE; + do { - bool bContinue = true; - Flags nFlag = Flags::NONE; - do { - switch( *pStr ) - { + switch (*pStr) + { // Western and Asian full stop case '.': - case 0x3002 : - case 0xFF0E : + case 0x3002: + case 0xFF0E: + { + if (pStr >= pStart + 2 && *(pStr - 2) == '.') { - if (pStr >= pStart + 2 && *(pStr-2) == '.') - { - //e.g. text "f.o.o. word": Now currently considering - //capitalizing word but second last character of - //previous word is a . So probably last word is an - //anagram that ends in . and not truly the end of a - //previous sentence, so don't autocapitalize this word - return; - } - if( nFlag & Flags::FullStop ) - return; // no valid separator -> no replacement - nFlag |= Flags::FullStop; - pExceptStt = pStr; + //e.g. text "f.o.o. word": Now currently considering + //capitalizing word but second last character of + //previous word is a . So probably last word is an + //anagram that ends in . and not truly the end of a + //previous sentence, so don't autocapitalize this word + return; } - break; + if (nFlag & Flags::FullStop) + return; // no valid separator -> no replacement + nFlag |= Flags::FullStop; + pExceptStt = pStr; + } + break; case '!': - case 0xFF01 : - { - if( nFlag & Flags::ExclamationMark ) - return; // no valid separator -> no replacement - nFlag |= Flags::ExclamationMark; - } - break; + case 0xFF01: + { + if (nFlag & Flags::ExclamationMark) + return; // no valid separator -> no replacement + nFlag |= Flags::ExclamationMark; + } + break; case '?': - case 0xFF1F : - { - if( nFlag & Flags::QuestionMark) - return; // no valid separator -> no replacement - nFlag |= Flags::QuestionMark; - } - break; + case 0xFF1F: + { + if (nFlag & Flags::QuestionMark) + return; // no valid separator -> no replacement + nFlag |= Flags::QuestionMark; + } + break; default: - if( nFlag == Flags::NONE ) - return; // no valid separator -> no replacement + if (nFlag == Flags::NONE) + return; // no valid separator -> no replacement else bContinue = false; break; - } + } - if( bContinue && pStr-- == pStart ) - { - return; // no valid separator -> no replacement - } - } while( bContinue ); - if( Flags::FullStop != nFlag ) - pExceptStt = nullptr; - } + if (bContinue && pStr-- == pStart) + { + return; // no valid separator -> no replacement + } + } while (bContinue); + if (Flags::FullStop != nFlag) + pExceptStt = nullptr; if( 2 > ( pStr - pStart ) ) return; diff --git a/editeng/source/uno/unoipset.cxx b/editeng/source/uno/unoipset.cxx index 71afb18871e3..27281c3ade9b 100644 --- a/editeng/source/uno/unoipset.cxx +++ b/editeng/source/uno/unoipset.cxx @@ -157,32 +157,28 @@ void SvxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry* pMa pItem = &pPool->GetDefaultItem( pMap->nWID ); } - DBG_ASSERT( pItem, "Got no default for item!" ); - if( pItem ) - { - uno::Any aValue( rVal ); + uno::Any aValue(rVal); - const MapUnit eMapUnit = pPool ? pPool->GetMetric(pMap->nWID) : MapUnit::Map100thMM; + const MapUnit eMapUnit = pPool ? pPool->GetMetric(pMap->nWID) : MapUnit::Map100thMM; - // check for needed metric translation - if( (pMap->nMoreFlags & PropertyMoreFlags::METRIC_ITEM) && eMapUnit != MapUnit::Map100thMM ) - { - if ( !bDontConvertNegativeValues || SvxUnoCheckForPositiveValue( aValue ) ) - SvxUnoConvertFromMM( eMapUnit, aValue ); - } + // check for needed metric translation + if ((pMap->nMoreFlags & PropertyMoreFlags::METRIC_ITEM) && eMapUnit != MapUnit::Map100thMM) + { + if (!bDontConvertNegativeValues || SvxUnoCheckForPositiveValue(aValue)) + SvxUnoConvertFromMM(eMapUnit, aValue); + } - std::unique_ptr<SfxPoolItem> pNewItem( pItem->Clone() ); + std::unique_ptr<SfxPoolItem> pNewItem(pItem->Clone()); - sal_uInt8 nMemberId = pMap->nMemberId; - if( eMapUnit == MapUnit::Map100thMM ) - nMemberId &= (~CONVERT_TWIPS); + sal_uInt8 nMemberId = pMap->nMemberId; + if (eMapUnit == MapUnit::Map100thMM) + nMemberId &= (~CONVERT_TWIPS); - if( pNewItem->PutValue( aValue, nMemberId ) ) - { - // Set new item in item set - pNewItem->SetWhich( pMap->nWID ); - rSet.Put( *pNewItem ); - } + if (pNewItem->PutValue(aValue, nMemberId)) + { + // Set new item in item set + pNewItem->SetWhich(pMap->nWID); + rSet.Put(*pNewItem); } } diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index f1b48747669b..68858043cca3 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -1124,7 +1124,7 @@ bool SvxUnoTextRangeBase::_getOnePropertyStates(const SfxItemSet* pSet, const Sf } if( bUnknownPropertyFound ) - return !bUnknownPropertyFound; + return false; if( nWID != 0 ) eItemState = pSet->GetItemState( nWID, false ); @@ -1145,7 +1145,7 @@ bool SvxUnoTextRangeBase::_getOnePropertyStates(const SfxItemSet* pSet, const Sf rState = beans::PropertyState_AMBIGUOUS_VALUE; } } - return !bUnknownPropertyFound; + return true; } void SAL_CALL SvxUnoTextRangeBase::setPropertyToDefault( const OUString& PropertyName ) diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx index f04466efe73c..ec8c46d80016 100644 --- a/extensions/source/ole/unoconversionutilities.hxx +++ b/extensions/source/ole/unoconversionutilities.hxx @@ -1927,7 +1927,6 @@ void UnoConversionUtilities<T>::dispatchExObject2Sequence( const VARIANTARG* pva { try { - bool bFail = false; if( pvar->vt != VT_DISPATCH) throw BridgeRuntimeError("[automation bridge] UnoConversionUtilities<T>::dispatchExObject2Sequence \n" "Conversion of dispatch object to Sequence failed!"); @@ -2038,10 +2037,6 @@ void UnoConversionUtilities<T>::dispatchExObject2Sequence( const VARIANTARG* pva anySeq.setValue( &p_uno_Seq, pDesc); uno_destructData( &p_uno_Seq, pDesc, cpp_release); typelib_typedescription_release( pDesc); - - if (bFail) - throw BridgeRuntimeError( - "[automation bridge] Conversion of ValueObject failed "); } catch (const BridgeRuntimeError &) { diff --git a/extensions/source/propctrlr/stringrepresentation.cxx b/extensions/source/propctrlr/stringrepresentation.cxx index bdca73fe13fc..b28df28c0e0e 100644 --- a/extensions/source/propctrlr/stringrepresentation.cxx +++ b/extensions/source/propctrlr/stringrepresentation.cxx @@ -338,14 +338,12 @@ namespace // loop through the elements and concatenate the string representations of the integers // (separated by a line break) - const ElementType* pElements = _rElements.getConstArray(); - const ElementType* pElementsEnd = pElements + _rElements.getLength(); - for ( ; pElements != pElementsEnd; ++pElements ) + for (const auto& rElement : _rElements) { - sCompose.append( OUString( _rTransformer( *pElements ) ) ); - if ( pElements != pElementsEnd ) - sCompose.append("\n"); + sCompose.append(OUString(_rTransformer(rElement))); + sCompose.append("\n"); } + sCompose.stripEnd('\n'); return sCompose.makeStringAndClear(); } diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx index 7617eafeef1f..fb91a7b09d17 100644 --- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx +++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx @@ -650,33 +650,30 @@ bool XMLFilterSettingsDialog::insertOrEdit( filter_info_impl* pNewInfo, const fi bOk = false; } } - else + else // bOk { - if( bOk ) + try + { + Reference< XFlushable > xFlushable( mxFilterContainer, UNO_QUERY ); + if( xFlushable.is() ) + xFlushable->flush(); + } + catch( const Exception& ) + { + OSL_FAIL( "XMLFilterSettingsDialog::insertOrEdit exception caught!" ); + bOk = false; + } + + if( !bOk ) { + // we failed to add the filter, so lets remove the type try { - Reference< XFlushable > xFlushable( mxFilterContainer, UNO_QUERY ); - if( xFlushable.is() ) - xFlushable->flush(); + mxTypeDetection->removeByName( pFilterEntry->maType ); } catch( const Exception& ) { OSL_FAIL( "XMLFilterSettingsDialog::insertOrEdit exception caught!" ); - bOk = false; - } - - if( !bOk ) - { - // we failed to add the filter, so lets remove the type - try - { - mxTypeDetection->removeByName( pFilterEntry->maType ); - } - catch( const Exception& ) - { - OSL_FAIL( "XMLFilterSettingsDialog::insertOrEdit exception caught!" ); - } } } diff --git a/i18npool/source/textconversion/textconversion_ko.cxx b/i18npool/source/textconversion/textconversion_ko.cxx index f09aa509e909..0e0a9bdcd6fa 100644 --- a/i18npool/source/textconversion/textconversion_ko.cxx +++ b/i18npool/source/textconversion/textconversion_ko.cxx @@ -325,8 +325,7 @@ TextConversion_ko::getConversion( const OUString& aText, sal_Int32 nStartPos, sa aBuf.append(str + start, result.Boundary.startPos - start); // append skip portion aBuf.append(result.Candidates[0]); // append converted portion } else { - if (length + nStartPos > start) - aBuf.append(str + start, length + nStartPos - start); // append last portion + aBuf.append(str + start, length + nStartPos - start); // append last portion break; } } diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx index a9d84556e158..7711a9e79907 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx @@ -79,8 +79,7 @@ bool SunVersion::init(const char *szVersion) { if (pCur < pEnd && rtl::isAsciiDigit(static_cast<unsigned char>(*pCur))) { - if (pCur < pEnd) - pCur ++; + pCur ++; nPartPos ++; } //if correct separator then form integer diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index 3469fda997fa..c048d2ecb8b4 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -1299,8 +1299,6 @@ void SAL_CALL OReportDefinition::storeToStorage( const uno::Reference< embed::XS uno::Sequence < beans::PropertyValue > aProps; // export sub streams for package, else full stream into a file - bool bErr = false; - uno::Reference< beans::XPropertySet> xProp(_xStorageToSaveTo,uno::UNO_QUERY); if ( xProp.is() ) { @@ -1349,44 +1347,23 @@ void SAL_CALL OReportDefinition::storeToStorage( const uno::Reference< embed::XS aDelegatorArguments[nArgsLen++] <<= xObjectResolver; uno::Reference<XComponent> xCom(static_cast<OWeakObject*>(this),uno::UNO_QUERY); - if( !bErr ) - { - xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("settings.xml"))); - WriteThroughComponent( - xCom, "settings.xml", - "com.sun.star.comp.report.XMLSettingsExporter", - aDelegatorArguments, aProps, _xStorageToSaveTo ); - } + // Try to write to settings.xml, meta.xml, and styles.xml; only really care about success of + // write to content.xml (keeping logic of commit 94ccba3eebc83b58e74e18f0e028c6a995ce6aa6) + xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("settings.xml"))); + WriteThroughComponent(xCom, "settings.xml", "com.sun.star.comp.report.XMLSettingsExporter", + aDelegatorArguments, aProps, _xStorageToSaveTo); - if( !bErr ) - { - xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("meta.xml"))); - WriteThroughComponent( - xCom, "meta.xml", - "com.sun.star.comp.report.XMLMetaExporter", - aDelegatorArguments, aProps, _xStorageToSaveTo ); - } + xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("meta.xml"))); + WriteThroughComponent(xCom, "meta.xml", "com.sun.star.comp.report.XMLMetaExporter", + aDelegatorArguments, aProps, _xStorageToSaveTo); - if( !bErr ) - { - xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("styles.xml"))); - WriteThroughComponent( - xCom, "styles.xml", - "com.sun.star.comp.report.XMLStylesExporter", - aDelegatorArguments, aProps, _xStorageToSaveTo ); - } + xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("styles.xml"))); + WriteThroughComponent(xCom, "styles.xml", "com.sun.star.comp.report.XMLStylesExporter", + aDelegatorArguments, aProps, _xStorageToSaveTo); - if ( !bErr ) - { - xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("content.xml"))); - if( !WriteThroughComponent( - xCom, "content.xml", - "com.sun.star.comp.report.ExportFilter", - aDelegatorArguments, aProps, _xStorageToSaveTo ) ) - { - bErr = true; - } - } + xInfoSet->setPropertyValue("StreamName", uno::makeAny(OUString("content.xml"))); + bool bOk = WriteThroughComponent(xCom, "content.xml", "com.sun.star.comp.report.ExportFilter", + aDelegatorArguments, aProps, _xStorageToSaveTo); uno::Any aImage; uno::Reference< embed::XVisualObject > xCurrentController(getCurrentController(),uno::UNO_QUERY); @@ -1403,7 +1380,7 @@ void SAL_CALL OReportDefinition::storeToStorage( const uno::Reference< embed::XS m_pImpl->m_pObjectContainer->InsertGraphicStreamDirectly(xStream, "report", "image/png"); } - if ( !bErr ) + if (bOk) { bool bPersist = false; if ( _xStorageToSaveTo == m_pImpl->m_xStorage ) diff --git a/reportdesign/source/ui/report/propbrw.cxx b/reportdesign/source/ui/report/propbrw.cxx index 008792b2cb3f..a50d13d7a8db 100644 --- a/reportdesign/source/ui/report/propbrw.cxx +++ b/reportdesign/source/ui/report/propbrw.cxx @@ -340,7 +340,7 @@ OUString PropBrw::GetHeadlineName( const uno::Sequence< Reference<uno::XInterfac Reference< lang::XServiceInfo > xServiceInfo( xNameCont->getByName("ReportComponent"), UNO_QUERY ); if ( xServiceInfo.is() ) { - const char* pResId = nullptr; + const char* pResId; if ( xServiceInfo->supportsService( SERVICE_FIXEDTEXT ) ) { pResId = RID_STR_PROPTITLE_FIXEDTEXT; @@ -384,10 +384,7 @@ OUString PropBrw::GetHeadlineName( const uno::Sequence< Reference<uno::XInterfac return aName; } - if (pResId) - { - aName += RptResId(pResId); - } + aName += RptResId(pResId); } } else // multiselection 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()) diff --git a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx index 207d288c29f3..6d9bf0bd1de3 100644 --- a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx +++ b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx @@ -368,22 +368,18 @@ bool SlideSorterController::Command ( } } - if (pViewShell != nullptr) + if (SfxDispatcher* pDispatcher = pViewShell->GetDispatcher()) { - SfxDispatcher* pDispatcher = pViewShell->GetDispatcher(); - if (pDispatcher != nullptr) - { - mbContextMenuOpen = true; - if (!rEvent.IsMouseEvent()) - pDispatcher->ExecutePopup(aPopupId, pWindow, &aMenuLocation); - else - pDispatcher->ExecutePopup(aPopupId); - mbContextMenuOpen = false; - mrSlideSorter.GetView().UpdatePageUnderMouse(); - ::rtl::Reference<SelectionFunction> pFunction(GetCurrentSelectionFunction()); - if (pFunction.is()) - pFunction->ResetMouseAnchor(); - } + mbContextMenuOpen = true; + if (!rEvent.IsMouseEvent()) + pDispatcher->ExecutePopup(aPopupId, pWindow, &aMenuLocation); + else + pDispatcher->ExecutePopup(aPopupId); + mbContextMenuOpen = false; + mrSlideSorter.GetView().UpdatePageUnderMouse(); + ::rtl::Reference<SelectionFunction> pFunction(GetCurrentSelectionFunction()); + if (pFunction.is()) + pFunction->ResetMouseAnchor(); } if (pPage == nullptr) { diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index bdd61533eb38..c7b8b6b4950a 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -797,13 +797,10 @@ uno::Reference< drawing::XDrawPage > SAL_CALL SdXImpressDocument::getHandoutMast uno::Reference< drawing::XDrawPage > xPage; - if( mpDoc ) - { - initializeDocument(); - SdPage* pPage = mpDoc->GetMasterSdPage( 0, PageKind::Handout ); - if( pPage ) - xPage.set( pPage->getUnoPage(), uno::UNO_QUERY ); - } + initializeDocument(); + SdPage* pPage = mpDoc->GetMasterSdPage(0, PageKind::Handout); + if (pPage) + xPage.set(pPage->getUnoPage(), uno::UNO_QUERY); return xPage; } @@ -956,7 +953,7 @@ css::uno::Reference<css::uno::XInterface> SdXImpressDocument::create( if( aServiceSpecifier == "com.sun.star.document.ExportEmbeddedObjectResolver" ) { - ::comphelper::IEmbeddedHelper *pPersist = mpDoc ? mpDoc->GetPersist() : nullptr; + comphelper::IEmbeddedHelper* pPersist = mpDoc->GetPersist(); if( nullptr == pPersist ) throw lang::DisposedException(); @@ -965,7 +962,7 @@ css::uno::Reference<css::uno::XInterface> SdXImpressDocument::create( if( aServiceSpecifier == "com.sun.star.document.ImportEmbeddedObjectResolver" ) { - ::comphelper::IEmbeddedHelper *pPersist = mpDoc ? mpDoc->GetPersist() : nullptr; + comphelper::IEmbeddedHelper* pPersist = mpDoc->GetPersist(); if( nullptr == pPersist ) throw lang::DisposedException(); diff --git a/sd/source/ui/unoidl/unopback.cxx b/sd/source/ui/unoidl/unopback.cxx index 1f0a1a0cb16e..aed0fb2eec6b 100644 --- a/sd/source/ui/unoidl/unopback.cxx +++ b/sd/source/ui/unoidl/unopback.cxx @@ -402,20 +402,17 @@ uno::Any SAL_CALL SdUnoPageBackground::getPropertyDefault( const OUString& aProp throw beans::UnknownPropertyException( aPropertyName, static_cast<cppu::OWeakObject*>(this)); uno::Any aAny; - if( mpSet ) + if (pEntry->nWID == OWN_ATTR_FILLBMP_MODE) { - if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE ) - { - aAny <<= drawing::BitmapMode_REPEAT; - } - else - { - SfxItemPool& rPool = *mpSet->GetPool(); - SfxItemSet aSet( rPool, {{pEntry->nWID, pEntry->nWID}}); - aSet.Put( rPool.GetDefaultItem( pEntry->nWID ) ); + aAny <<= drawing::BitmapMode_REPEAT; + } + else + { + SfxItemPool& rPool = *mpSet->GetPool(); + SfxItemSet aSet(rPool, { { pEntry->nWID, pEntry->nWID } }); + aSet.Put(rPool.GetDefaultItem(pEntry->nWID)); - aAny = SvxItemPropertySet_getPropertyValue( pEntry, aSet ); - } + aAny = SvxItemPropertySet_getPropertyValue(pEntry, aSet); } return aAny; } diff --git a/sd/source/ui/unoidl/unosrch.cxx b/sd/source/ui/unoidl/unosrch.cxx index d4c65435fd1a..7be7281816bf 100644 --- a/sd/source/ui/unoidl/unosrch.cxx +++ b/sd/source/ui/unoidl/unosrch.cxx @@ -789,14 +789,11 @@ sal_Int32 SAL_CALL SdUnoFindAllAccess::getCount() uno::Any SAL_CALL SdUnoFindAllAccess::getByIndex( sal_Int32 Index ) { - uno::Any aAny; - if( Index < 0 || Index >= getCount() ) throw lang::IndexOutOfBoundsException(); - const uno::Reference< uno::XInterface > *pRefs = maSequence.getConstArray(); - if(pRefs) - aAny <<= pRefs[ Index ]; + uno::Any aAny; + aAny <<= maSequence[Index]; return aAny; } diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx index ccf09ff1db67..d9fe8fb46367 100644 --- a/sd/source/ui/view/sdview3.cxx +++ b/sd/source/ui/view/sdview3.cxx @@ -935,18 +935,6 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper, { svt::EmbeddedObjectRef aObjRef( xObj, aObjDesc.mnViewAspect ); - // try to get the replacement image from the clipboard - Graphic aGraphic; - SotClipboardFormatId nGrFormat = SotClipboardFormatId::NONE; - - // insert replacement image ( if there is one ) into the object helper - if ( nGrFormat != SotClipboardFormatId::NONE ) - { - datatransfer::DataFlavor aDataFlavor; - SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor ); - aObjRef.SetGraphic( aGraphic, aDataFlavor.MimeType ); - } - Size aSize; if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON ) { diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx index 0398ff0488f5..5b4bc878393a 100644 --- a/sd/source/ui/view/viewshel.cxx +++ b/sd/source/ui/view/viewshel.cxx @@ -399,13 +399,10 @@ bool ViewShell::KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin) if(pWin) SetActiveWindow(pWin); - if(!bReturn) - { - // give key input first to SfxViewShell to give CTRL+Key - // (e.g. CTRL+SHIFT+'+', to front) priority. - OSL_ASSERT (GetViewShell()!=nullptr); - bReturn = GetViewShell()->KeyInput(rKEvt); - } + // give key input first to SfxViewShell to give CTRL+Key + // (e.g. CTRL+SHIFT+'+', to front) priority. + OSL_ASSERT(GetViewShell() != nullptr); + bReturn = GetViewShell()->KeyInput(rKEvt); const size_t OriCount = GetView()->GetMarkedObjectList().GetMarkCount(); if(!bReturn) diff --git a/svgio/source/svgreader/svgsvgnode.cxx b/svgio/source/svgreader/svgsvgnode.cxx index c588b2c37038..0d42099eff3b 100644 --- a/svgio/source/svgreader/svgsvgnode.cxx +++ b/svgio/source/svgreader/svgsvgnode.cxx @@ -501,12 +501,12 @@ namespace svgio basegfx::B2DRange aSvgCanvasRange; // viewport double fW = 0.0; // dummy values double fH = 0.0; - if(getViewBox()) + if (const basegfx::B2DRange* pBox = getViewBox()) { // SVG 1.1 defines in section 7.7 that a negative value for width or height // in viewBox is an error and that 0.0 disables rendering - const double fViewBoxWidth = getViewBox()->getWidth(); - const double fViewBoxHeight = getViewBox()->getHeight(); + const double fViewBoxWidth = pBox->getWidth(); + const double fViewBoxHeight = pBox->getHeight(); if(basegfx::fTools::more(fViewBoxWidth,0.0) && basegfx::fTools::more(fViewBoxHeight,0.0)) { // The intrinsic aspect ratio of the svg element is given by absolute values of svg width and svg height @@ -542,14 +542,10 @@ namespace svgio // We get viewport >= content, therefore no clipping. bNeedsMapping = false; - const basegfx::B2DRange aChildRange( - aSequence.getB2DRange( - drawinglayer::geometry::ViewInformation2D())); - - const double fChildWidth(getViewBox() ? getViewBox()->getWidth() : aChildRange.getWidth()); - const double fChildHeight(getViewBox() ? getViewBox()->getHeight() : aChildRange.getHeight()); - const double fLeft(getViewBox() ? getViewBox()->getMinX() : aChildRange.getMinX()); - const double fTop (getViewBox() ? getViewBox()->getMinY() : aChildRange.getMinY()); + const double fChildWidth(pBox->getWidth()); + const double fChildHeight(pBox->getHeight()); + const double fLeft(pBox->getMinX()); + const double fTop(pBox->getMinY()); if ( fChildWidth / fViewBoxWidth > fChildHeight / fViewBoxHeight ) { // expand y fW = fChildWidth; @@ -572,7 +568,7 @@ namespace svgio const SvgAspectRatio& rRatio = getSvgAspectRatio().isSet()? getSvgAspectRatio() : aRatioDefault; basegfx::B2DHomMatrix aViewBoxMapping; - aViewBoxMapping = rRatio.createMapping(aSvgCanvasRange, *getViewBox()); + aViewBoxMapping = rRatio.createMapping(aSvgCanvasRange, *pBox); // no need to check ratio here for slice, the outermost Svg will // be clipped anyways (see below) diff --git a/svx/source/accessibility/ShapeTypeHandler.cxx b/svx/source/accessibility/ShapeTypeHandler.cxx index c569700ed0bc..e6454389c30f 100644 --- a/svx/source/accessibility/ShapeTypeHandler.cxx +++ b/svx/source/accessibility/ShapeTypeHandler.cxx @@ -269,33 +269,22 @@ OUString ShapeTypeHandler::CreateAccessibleBaseName (const uno::Reference<drawin pResourceId = STR_ObjNameSingulRECT; break; case DRAWING_CUSTOM: - { - pResourceId = STR_ObjNameSingulCUSTOMSHAPE; + pResourceId = STR_ObjNameSingulCUSTOMSHAPE; - SvxShape* pShape = SvxShape::getImplementation( rxShape ); - if (pShape) + if (SvxShape* pShape = SvxShape::getImplementation(rxShape)) + { + if (auto pCustomShape = dynamic_cast<SdrObjCustomShape*>(pShape->GetSdrObject())) { - SdrObject *pSdrObj = pShape->GetSdrObject(); - if (pSdrObj) + if (pCustomShape->IsTextPath()) + pResourceId = STR_ObjNameSingulFONTWORK; + else { - if(dynamic_cast<const SdrObjCustomShape*>( pSdrObj) != nullptr) - { - SdrObjCustomShape* pCustomShape = static_cast<SdrObjCustomShape*>(pSdrObj); - if(pCustomShape) - { - if (pCustomShape->IsTextPath()) - pResourceId = STR_ObjNameSingulFONTWORK; - else - { - pResourceId = nullptr; - sName = pCustomShape->GetCustomShapeName(); - } - } - } + pResourceId = nullptr; + sName = pCustomShape->GetCustomShapeName(); } } - break; } + break; case DRAWING_TEXT: pResourceId = STR_ObjNameSingulTEXT; break; diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index 6d099d6efb77..cb0c3d1fa2c5 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -168,10 +168,7 @@ void SdrDragEntrySdrObject::prepareCurrentState(SdrDragMethod& rDragMethod) if(mbModify) { - if(!mpClone) - { - mpClone = maOriginal.getFullDragClone(); - } + mpClone = maOriginal.getFullDragClone(); // apply original transformation, implemented at the DragMethods rDragMethod.applyCurrentTransformationToSdrObject(*mpClone); diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx index 7dc05bc1a086..a53725c6ee1e 100644 --- a/svx/source/svdraw/svdhdl.cxx +++ b/svx/source/svdraw/svdhdl.cxx @@ -2098,11 +2098,7 @@ void SdrHdlList::SetFocusHdl(SdrHdl* pNew) pActual->Touch(); } - if(pNew) - { - pNew->Touch(); - } - + pNew->Touch(); } } } diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx index 41158c70c2e5..6f2720601d77 100644 --- a/svx/source/svdraw/svdpagv.cxx +++ b/svx/source/svdraw/svdpagv.cxx @@ -788,7 +788,8 @@ bool SdrPageView::EnterGroup(SdrObject* pObj) void SdrPageView::LeaveOneGroup() { - if(!GetCurrentGroup()) + SdrObject* pLastGroup = GetCurrentGroup(); + if (!pLastGroup) return; bool bGlueInvalidate = GetView().ImpIsGlueVisible(); @@ -796,8 +797,7 @@ void SdrPageView::LeaveOneGroup() if(bGlueInvalidate) GetView().GlueInvalidate(); - SdrObject* pLastGroup = GetCurrentGroup(); - SdrObject* pParentGroup = GetCurrentGroup()->getParentSdrObjectFromSdrObject(); + SdrObject* pParentGroup = pLastGroup->getParentSdrObjectFromSdrObject(); SdrObjList* pParentList = GetPage(); if(pParentGroup) @@ -810,9 +810,8 @@ void SdrPageView::LeaveOneGroup() SetCurrentGroupAndList(pParentGroup, pParentList); // select the group we just left - if(pLastGroup) - if(GetView().GetSdrPageView()) - GetView().MarkObj(pLastGroup, GetView().GetSdrPageView()); + if (GetView().GetSdrPageView()) + GetView().MarkObj(pLastGroup, GetView().GetSdrPageView()); GetView().AdjustMarkHdl(); @@ -825,15 +824,13 @@ void SdrPageView::LeaveOneGroup() void SdrPageView::LeaveAllGroup() { - if(GetCurrentGroup()) + if (SdrObject* pLastGroup = GetCurrentGroup()) { bool bGlueInvalidate = GetView().ImpIsGlueVisible(); if(bGlueInvalidate) GetView().GlueInvalidate(); - SdrObject* pLastGroup = GetCurrentGroup(); - // deselect everything GetView().UnmarkAll(); @@ -841,14 +838,11 @@ void SdrPageView::LeaveAllGroup() SetCurrentGroupAndList(nullptr, GetPage()); // find and select uppermost group - if(pLastGroup) - { - while(pLastGroup->getParentSdrObjectFromSdrObject()) - pLastGroup = pLastGroup->getParentSdrObjectFromSdrObject(); + while (pLastGroup->getParentSdrObjectFromSdrObject()) + pLastGroup = pLastGroup->getParentSdrObjectFromSdrObject(); - if(GetView().GetSdrPageView()) - GetView().MarkObj(pLastGroup, GetView().GetSdrPageView()); - } + if (GetView().GetSdrPageView()) + GetView().MarkObj(pLastGroup, GetView().GetSdrPageView()); GetView().AdjustMarkHdl(); diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index 187f52af7a69..b800c7a06181 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -1169,46 +1169,43 @@ TableHitKind SdrTableObj::CheckTableHit( const Point& rPos, sal_Int32& rnX, sal_ // get vertical edge number and check for a hit const bool bRTL = (GetWritingMode() == WritingMode_RL_TB); bool bVrtHit = false; - if( nX >= 0 ) + if( !bRTL ) { - if( !bRTL ) + while( rnX <= nColCount ) { - while( rnX <= nColCount ) + if( nX - aTol <= 0 ) { - if( nX - aTol <= 0 ) - { - bVrtHit = true; - break; - } + bVrtHit = true; + break; + } - if( rnX == nColCount ) - break; + if( rnX == nColCount ) + break; - nX -= mpImpl->mpLayouter->getColumnWidth( rnX ); - if( nX < 0 ) - break; - rnX++; - } + nX -= mpImpl->mpLayouter->getColumnWidth( rnX ); + if( nX < 0 ) + break; + rnX++; } - else + } + else + { + rnX = nColCount; + while( rnX >= 0 ) { - rnX = nColCount; - while( rnX >= 0 ) + if( nX - aTol <= 0 ) { - if( nX - aTol <= 0 ) - { - bVrtHit = true; - break; - } + bVrtHit = true; + break; + } - if( rnX == 0 ) - break; + if( rnX == 0 ) + break; - rnX--; - nX -= mpImpl->mpLayouter->getColumnWidth( rnX ); - if( nX < 0 ) - break; - } + rnX--; + nX -= mpImpl->mpLayouter->getColumnWidth( rnX ); + if( nX < 0 ) + break; } } @@ -1216,24 +1213,21 @@ TableHitKind SdrTableObj::CheckTableHit( const Point& rPos, sal_Int32& rnX, sal_ // get vertical edge number and check for a hit bool bHrzHit = false; - if( nY >= 0 ) + while( rnY <= nRowCount ) { - while( rnY <= nRowCount ) + if( nY - aTol <= 0 ) { - if( nY - aTol <= 0 ) - { - bHrzHit = true; - break; - } + bHrzHit = true; + break; + } - if( rnY == nRowCount ) - break; + if( rnY == nRowCount ) + break; - nY -= mpImpl->mpLayouter->getRowHeight(rnY); - if( nY < 0 ) - break; - rnY++; - } + nY -= mpImpl->mpLayouter->getRowHeight(rnY); + if( nY < 0 ) + break; + rnY++; } // rnY is now the edge number above the pointer, if it was hit bVrtHit is also true diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx index c35463b0c297..1b934d7731b1 100644 --- a/svx/source/table/tablemodel.cxx +++ b/svx/source/table/tablemodel.cxx @@ -979,7 +979,7 @@ void TableModel::optimize() if( bEmpty ) { - if( nCol > 0 ) try + try { const OUString sWidth("Width"); sal_Int32 nWidth1 = 0, nWidth2 = 0; @@ -1016,7 +1016,7 @@ void TableModel::optimize() if( bEmpty ) { - if( nRow > 0 ) try + try { const OUString sHeight("Height"); sal_Int32 nHeight1 = 0, nHeight2 = 0; diff --git a/svx/source/unodraw/unoshap3.cxx b/svx/source/unodraw/unoshap3.cxx index 2d5871e00c1f..571a1d74ffb5 100644 --- a/svx/source/unodraw/unoshap3.cxx +++ b/svx/source/unodraw/unoshap3.cxx @@ -126,9 +126,7 @@ void SAL_CALL Svx3DSceneObject::add( const Reference< drawing::XShape >& xShape if( dynamic_cast<const E3dObject* >(pSdrShape) != nullptr ) { GetSdrObject()->GetSubList()->NbcInsertObject( pSdrShape ); - - if(pShape) - pShape->Create( pSdrShape, mxPage.get() ); + pShape->Create(pSdrShape, mxPage.get()); } else { diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx index 4dffab0d5906..287d2bd18b42 100644 --- a/svx/source/unodraw/unoshtxt.cxx +++ b/svx/source/unodraw/unoshtxt.cxx @@ -206,12 +206,9 @@ SvxTextEditSourceImpl::SvxTextEditSourceImpl( SdrObject& rObject, SdrText* pText mpText = pTextObj->getText( 0 ); } - if( mpModel ) - StartListening( *mpModel ); - if( mpView ) - StartListening( *mpView ); - if( mpObject ) - mpObject->AddObjectUser( *this ); + StartListening( *mpModel ); + StartListening( *mpView ); + mpObject->AddObjectUser( *this ); // Init edit mode state from shape info (IsTextEditActive()) mbShapeIsEditMode = IsEditMode(); diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx index 74912a9ded57..cafbe882ff37 100644 --- a/svx/source/xoutdev/xattr.cxx +++ b/svx/source/xoutdev/xattr.cxx @@ -1099,14 +1099,14 @@ XLineStartItem* XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const sal_uInt32 nCount, nSurrogate; - const SfxItemPool* pPool1 = &pModel->GetItemPool(); - if( !aUniqueName.isEmpty() && pPool1 ) + const SfxItemPool& rPool1 = pModel->GetItemPool(); + if (!aUniqueName.isEmpty()) { - nCount = pPool1->GetItemCount2( XATTR_LINESTART ); + nCount = rPool1.GetItemCount2(XATTR_LINESTART); for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) { - const XLineStartItem* pItem = pPool1->GetItem2( XATTR_LINESTART, nSurrogate ); + const XLineStartItem* pItem = rPool1.GetItem2(XATTR_LINESTART, nSurrogate); if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) ) { @@ -1124,11 +1124,11 @@ XLineStartItem* XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const if( !bForceNew ) { - nCount = pPool1->GetItemCount2( XATTR_LINEEND ); + nCount = rPool1.GetItemCount2(XATTR_LINEEND); for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) { - const XLineEndItem* pItem = pPool1->GetItem2( XATTR_LINEEND, nSurrogate ); + const XLineEndItem* pItem = rPool1.GetItem2(XATTR_LINEEND, nSurrogate); if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) ) { @@ -1200,53 +1200,50 @@ XLineStartItem* XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const sal_Int32 nUserIndex = 1; const OUString aUser(SvxResId(RID_SVXSTR_LINEEND)); - if( pPool1 ) + nCount = rPool1.GetItemCount2(XATTR_LINESTART); + sal_uInt32 nSurrogate2; + + for (nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++) { - nCount = pPool1->GetItemCount2( XATTR_LINESTART ); - sal_uInt32 nSurrogate2; + const XLineStartItem* pItem = rPool1.GetItem2(XATTR_LINESTART, nSurrogate2); - for( nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++ ) + if (pItem && !pItem->GetName().isEmpty()) { - const XLineStartItem* pItem = pPool1->GetItem2( XATTR_LINESTART, nSurrogate2 ); - - if( pItem && !pItem->GetName().isEmpty() ) + if (!bForceNew && pItem->GetLineStartValue() == pLineStartItem->GetLineStartValue()) { - if( !bForceNew && pItem->GetLineStartValue() == pLineStartItem->GetLineStartValue() ) - { - aUniqueName = pItem->GetName(); - bFoundExisting = true; - break; - } + aUniqueName = pItem->GetName(); + bFoundExisting = true; + break; + } - if( pItem->GetName().startsWith( aUser ) ) - { - sal_Int32 nThisIndex = pItem->GetName().copy( aUser.getLength() ).toInt32(); - if( nThisIndex >= nUserIndex ) - nUserIndex = nThisIndex + 1; - } + if (pItem->GetName().startsWith(aUser)) + { + sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32(); + if (nThisIndex >= nUserIndex) + nUserIndex = nThisIndex + 1; } } + } - nCount = pPool1->GetItemCount2( XATTR_LINEEND ); - for( nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++ ) - { - const XLineEndItem* pItem = pPool1->GetItem2( XATTR_LINEEND, nSurrogate2 ); + nCount = rPool1.GetItemCount2(XATTR_LINEEND); + for (nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++) + { + const XLineEndItem* pItem = rPool1.GetItem2(XATTR_LINEEND, nSurrogate2); - if( pItem && !pItem->GetName().isEmpty() ) + if (pItem && !pItem->GetName().isEmpty()) + { + if (!bForceNew && pItem->GetLineEndValue() == pLineStartItem->GetLineStartValue()) { - if( !bForceNew && pItem->GetLineEndValue() == pLineStartItem->GetLineStartValue() ) - { - aUniqueName = pItem->GetName(); - bFoundExisting = true; - break; - } + aUniqueName = pItem->GetName(); + bFoundExisting = true; + break; + } - if( pItem->GetName().startsWith( aUser ) ) - { - sal_Int32 nThisIndex = pItem->GetName().copy( aUser.getLength() ).toInt32(); - if( nThisIndex >= nUserIndex ) - nUserIndex = nThisIndex + 1; - } + if (pItem->GetName().startsWith(aUser)) + { + sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32(); + if (nThisIndex >= nUserIndex) + nUserIndex = nThisIndex + 1; } } } @@ -1353,14 +1350,14 @@ XLineEndItem* XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const sal_uInt16 nCount, nSurrogate; - const SfxItemPool* pPool1 = &pModel->GetItemPool(); - if( !aUniqueName.isEmpty() && pPool1 ) + const SfxItemPool& rPool1 = pModel->GetItemPool(); + if (!aUniqueName.isEmpty()) { - nCount = pPool1->GetItemCount2( XATTR_LINESTART ); + nCount = rPool1.GetItemCount2(XATTR_LINESTART); for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) { - const XLineStartItem* pItem = pPool1->GetItem2( XATTR_LINESTART, nSurrogate ); + const XLineStartItem* pItem = rPool1.GetItem2(XATTR_LINESTART, nSurrogate); if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) ) { @@ -1378,11 +1375,11 @@ XLineEndItem* XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const if( !bForceNew ) { - nCount = pPool1->GetItemCount2( XATTR_LINEEND ); + nCount = rPool1.GetItemCount2(XATTR_LINEEND); for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) { - const XLineEndItem* pItem = pPool1->GetItem2( XATTR_LINEEND, nSurrogate ); + const XLineEndItem* pItem = rPool1.GetItem2(XATTR_LINEEND, nSurrogate); if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) ) { @@ -1454,53 +1451,50 @@ XLineEndItem* XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const sal_Int32 nUserIndex = 1; const OUString aUser(SvxResId(RID_SVXSTR_LINEEND)); - if( pPool1 ) + nCount = rPool1.GetItemCount2(XATTR_LINESTART); + sal_uInt32 nSurrogate2; + + for (nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++) { - nCount = pPool1->GetItemCount2( XATTR_LINESTART ); - sal_uInt32 nSurrogate2; + const XLineStartItem* pItem = rPool1.GetItem2(XATTR_LINESTART, nSurrogate2); - for( nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++ ) + if (pItem && !pItem->GetName().isEmpty()) { - const XLineStartItem* pItem = pPool1->GetItem2( XATTR_LINESTART, nSurrogate2 ); - - if( pItem && !pItem->GetName().isEmpty() ) + if (!bForceNew && pItem->GetLineStartValue() == pLineEndItem->GetLineEndValue()) { - if( !bForceNew && pItem->GetLineStartValue() == pLineEndItem->GetLineEndValue() ) - { - aUniqueName = pItem->GetName(); - bFoundExisting = true; - break; - } + aUniqueName = pItem->GetName(); + bFoundExisting = true; + break; + } - if( pItem->GetName().startsWith( aUser ) ) - { - sal_Int32 nThisIndex = pItem->GetName().copy( aUser.getLength() ).toInt32(); - if( nThisIndex >= nUserIndex ) - nUserIndex = nThisIndex + 1; - } + if (pItem->GetName().startsWith(aUser)) + { + sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32(); + if (nThisIndex >= nUserIndex) + nUserIndex = nThisIndex + 1; } } + } - nCount = pPool1->GetItemCount2( XATTR_LINEEND ); - for( nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++ ) - { - const XLineEndItem* pItem = pPool1->GetItem2( XATTR_LINEEND, nSurrogate2 ); + nCount = rPool1.GetItemCount2(XATTR_LINEEND); + for (nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++) + { + const XLineEndItem* pItem = rPool1.GetItem2(XATTR_LINEEND, nSurrogate2); - if( pItem && !pItem->GetName().isEmpty() ) + if (pItem && !pItem->GetName().isEmpty()) + { + if (!bForceNew && pItem->GetLineEndValue() == pLineEndItem->GetLineEndValue()) { - if( !bForceNew && pItem->GetLineEndValue() == pLineEndItem->GetLineEndValue() ) - { - aUniqueName = pItem->GetName(); - bFoundExisting = true; - break; - } + aUniqueName = pItem->GetName(); + bFoundExisting = true; + break; + } - if( pItem->GetName().startsWith( aUser ) ) - { - sal_Int32 nThisIndex = pItem->GetName().copy( aUser.getLength() ).toInt32(); - if( nThisIndex >= nUserIndex ) - nUserIndex = nThisIndex + 1; - } + if (pItem->GetName().startsWith(aUser)) + { + sal_Int32 nThisIndex = pItem->GetName().copy(aUser.getLength()).toInt32(); + if (nThisIndex >= nUserIndex) + nUserIndex = nThisIndex + 1; } } } diff --git a/svx/source/xoutdev/xattr2.cxx b/svx/source/xoutdev/xattr2.cxx index c8dc42be2a1c..3bf103d9469e 100644 --- a/svx/source/xoutdev/xattr2.cxx +++ b/svx/source/xoutdev/xattr2.cxx @@ -252,9 +252,7 @@ SfxPoolItem* XLineCapItem::Clone(SfxItemPool* /*pPool*/) const bool XLineCapItem::GetPresentation( SfxItemPresentation /*ePres*/, MapUnit /*eCoreUnit*/, MapUnit /*ePresUnit*/, OUString& rText, const IntlWrapper&) const { - rText.clear(); - - const char* pId = nullptr; + const char* pId; switch( GetValue() ) { @@ -271,8 +269,7 @@ bool XLineCapItem::GetPresentation( SfxItemPresentation /*ePres*/, MapUnit /*eCo break; } - if (pId) - rText = SvxResId(pId); + rText = SvxResId(pId); return true; } diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx index ae0ff382b9e7..865907a172a9 100644 --- a/sw/source/core/attr/swatrset.cxx +++ b/sw/source/core/attr/swatrset.cxx @@ -377,8 +377,7 @@ void SwAttrSet::CopyToModify( SwModify& rMod ) const RES_PAGEDESC, false, &pItem ) && nullptr != ( pPgDesc = static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc()) ) { - if( !tmpSet ) - tmpSet.reset( new SfxItemSet( *this )); + tmpSet.reset(new SfxItemSet(*this)); SwPageDesc* pDstPgDesc = pDstDoc->FindPageDesc(pPgDesc->GetName()); if( !pDstPgDesc ) diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx index 4b7fef996f36..1103e507d8c4 100644 --- a/sw/source/core/undo/unins.cxx +++ b/sw/source/core/undo/unins.cxx @@ -843,7 +843,7 @@ void SwUndoReRead::SaveGraphicData( const SwGrfNode& rGrfNd ) { maNm = OUString(); maFltr = OUString(); - rGrfNd.GetFileFilterNms( maNm ? &*maNm : nullptr, maFltr ? &*maFltr : nullptr ); + rGrfNd.GetFileFilterNms(&*maNm, &*maFltr); pGrf.reset(); } else diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index 87584578da2c..0b2064cfa53b 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -652,274 +652,264 @@ uno::Reference< chart2::data::XDataSource > SwChartDataProvider::Impl_createData if (!pTableFormat || !pUnoCursor) throw lang::IllegalArgumentException(); - if(pTableFormat) + SwTable* pTable = SwTable::FindTable(pTableFormat); + if (pTable->IsTableComplex()) + return xRes; // we can't handle this thus returning an empty references + + // get a character map in the size of the table to mark + // all the ranges to use in + sal_Int32 nRows = pTable->GetTabLines().size(); + sal_Int32 nCols = pTable->GetTabLines().front()->GetTabBoxes().size(); + std::vector<std::vector<sal_Char>> aMap(nRows); + for (sal_Int32 i = 0; i < nRows; ++i) + aMap[i].resize(nCols); + + // iterate over subranges and mark used cells in above map + //!! by proceeding this way we automatically get rid of + //!! multiple listed or overlapping cell ranges which should + //!! just be ignored silently + sal_Int32 nSubRanges = aSubRanges.getLength(); + for (sal_Int32 i = 0; i < nSubRanges; ++i) { - SwTable* pTable = SwTable::FindTable( pTableFormat ); - if(pTable->IsTableComplex()) - return xRes; // we can't handle this thus returning an empty references - else + OUString aTableName, aStartCell, aEndCell; + bool bOk2 = GetTableAndCellsFromRangeRep( + pSubRanges[i], aTableName, aStartCell, aEndCell ); + OSL_ENSURE(bOk2, "failed to get table and start/end cells"); + + sal_Int32 nStartRow, nStartCol, nEndRow, nEndCol; + SwXTextTable::GetCellPosition(aStartCell, nStartCol, nStartRow); + SwXTextTable::GetCellPosition(aEndCell, nEndCol, nEndRow); + OSL_ENSURE( nStartRow <= nEndRow && nStartCol <= nEndCol, + "cell range not normalized"); + + // test if the ranges span more than the available cells + if( nStartRow < 0 || nEndRow >= nRows || + nStartCol < 0 || nEndCol >= nCols ) { - // get a character map in the size of the table to mark - // all the ranges to use in - sal_Int32 nRows = pTable->GetTabLines().size(); - sal_Int32 nCols = pTable->GetTabLines().front()->GetTabBoxes().size(); - std::vector< std::vector< sal_Char > > aMap( nRows ); - for (sal_Int32 i = 0; i < nRows; ++i) - aMap[i].resize( nCols ); - - // iterate over subranges and mark used cells in above map - //!! by proceeding this way we automatically get rid of - //!! multiple listed or overlapping cell ranges which should - //!! just be ignored silently - sal_Int32 nSubRanges = aSubRanges.getLength(); - for (sal_Int32 i = 0; i < nSubRanges; ++i) - { - OUString aTableName, aStartCell, aEndCell; - bool bOk2 = GetTableAndCellsFromRangeRep( - pSubRanges[i], aTableName, aStartCell, aEndCell ); - OSL_ENSURE( bOk2, "failed to get table and start/end cells" ); - - sal_Int32 nStartRow, nStartCol, nEndRow, nEndCol; - SwXTextTable::GetCellPosition( aStartCell, nStartCol, nStartRow ); - SwXTextTable::GetCellPosition( aEndCell, nEndCol, nEndRow ); - OSL_ENSURE( nStartRow <= nEndRow && nStartCol <= nEndCol, - "cell range not normalized"); - - // test if the ranges span more than the available cells - if( nStartRow < 0 || nEndRow >= nRows || - nStartCol < 0 || nEndCol >= nCols ) - { - throw lang::IllegalArgumentException(); - } - for (sal_Int32 k1 = nStartRow; k1 <= nEndRow; ++k1) - { - for (sal_Int32 k2 = nStartCol; k2 <= nEndCol; ++k2) - aMap[k1][k2] = 'x'; - } - } + throw lang::IllegalArgumentException(); + } + for (sal_Int32 k1 = nStartRow; k1 <= nEndRow; ++k1) + { + for (sal_Int32 k2 = nStartCol; k2 <= nEndCol; ++k2) + aMap[k1][k2] = 'x'; + } + } + + // find label and data sequences to use - // find label and data sequences to use + sal_Int32 oi; // outer index (slower changing index) + sal_Int32 ii; // inner index (faster changing index) + sal_Int32 oiEnd = bDtaSrcIsColumns ? nCols : nRows; + sal_Int32 iiEnd = bDtaSrcIsColumns ? nRows : nCols; + std::vector<sal_Int32> aLabelIdx(oiEnd); + std::vector<sal_Int32> aDataStartIdx(oiEnd); + std::vector<sal_Int32> aDataLen(oiEnd); + for (oi = 0; oi < oiEnd; ++oi) + { + aLabelIdx[oi] = -1; + aDataStartIdx[oi] = -1; + aDataLen[oi] = 0; + } + + for (oi = 0; oi < oiEnd; ++oi) + { + ii = 0; + while (ii < iiEnd) + { + sal_Char &rChar = bDtaSrcIsColumns ? aMap[ii][oi] : aMap[oi][ii]; - sal_Int32 oi; // outer index (slower changing index) - sal_Int32 ii; // inner index (faster changing index) - sal_Int32 oiEnd = bDtaSrcIsColumns ? nCols : nRows; - sal_Int32 iiEnd = bDtaSrcIsColumns ? nRows : nCols; - std::vector< sal_Int32 > aLabelIdx( oiEnd ); - std::vector< sal_Int32 > aDataStartIdx( oiEnd ); - std::vector< sal_Int32 > aDataLen( oiEnd ); - for (oi = 0; oi < oiEnd; ++oi) + // label should be used but is not yet found? + if (rChar == 'x' && bFirstIsLabel && aLabelIdx[oi] == -1) { - aLabelIdx[oi] = -1; - aDataStartIdx[oi] = -1; - aDataLen[oi] = 0; + aLabelIdx[oi] = ii; + rChar = 'L'; // setting a different char for labels here + // makes the test for the data sequence below + // easier } - for (oi = 0; oi < oiEnd; ++oi) + // find data sequence + if (rChar == 'x' && aDataStartIdx[oi] == -1) { - ii = 0; - while (ii < iiEnd) - { - sal_Char &rChar = bDtaSrcIsColumns ? aMap[ii][oi] : aMap[oi][ii]; - - // label should be used but is not yet found? - if (rChar == 'x' && bFirstIsLabel && aLabelIdx[oi] == -1) - { - aLabelIdx[oi] = ii; - rChar = 'L'; // setting a different char for labels here - // makes the test for the data sequence below - // easier - } - - // find data sequence - if (rChar == 'x' && aDataStartIdx[oi] == -1) - { - aDataStartIdx[oi] = ii; + aDataStartIdx[oi] = ii; - // get length of data sequence - sal_Int32 nL = 0; - sal_Char c; - while (ii< iiEnd && 'x' == (c = bDtaSrcIsColumns ? aMap[ii][oi] : aMap[oi][ii])) - { - ++nL; ++ii; - } - aDataLen[oi] = nL; - - // check that there is no other separate sequence of data - // to be found because that is not supported - while (ii < iiEnd) - { - if ('x' == (c = bDtaSrcIsColumns ? aMap[ii][oi] : aMap[oi][ii])) - throw lang::IllegalArgumentException(); - ++ii; - } - } - else - ++ii; + // get length of data sequence + sal_Int32 nL = 0; + sal_Char c; + while (ii< iiEnd && 'x' == (c = bDtaSrcIsColumns ? aMap[ii][oi] : aMap[oi][ii])) + { + ++nL; ++ii; } - } + aDataLen[oi] = nL; - // make some other consistency checks while calculating - // the number of XLabeledDataSequence to build: - // - labels should always be used or not at all - // - the data sequences should have equal non-zero length - sal_Int32 nNumLDS = 0; - if (oiEnd > 0) - { - sal_Int32 nFirstSeqLen = 0; - sal_Int32 nFirstSeqLabelIdx = -1; - bool bFirstFound = false; - for (oi = 0; oi < oiEnd; ++oi) + // check that there is no other separate sequence of data + // to be found because that is not supported + while (ii < iiEnd) { - // row/col used at all? - if (aDataStartIdx[oi] != -1 && - (!bFirstIsLabel || aLabelIdx[oi] != -1)) - { - ++nNumLDS; - if (!bFirstFound) - { - nFirstSeqLen = aDataLen[oi]; - nFirstSeqLabelIdx = aLabelIdx[oi]; - bFirstFound = true; - } - else - { - if (nFirstSeqLen != aDataLen[oi] || - nFirstSeqLabelIdx != aLabelIdx[oi]) - throw lang::IllegalArgumentException(); - } - } + if ('x' == (c = bDtaSrcIsColumns ? aMap[ii][oi] : aMap[oi][ii])) + throw lang::IllegalArgumentException(); + ++ii; } } - if (nNumLDS == 0) - throw lang::IllegalArgumentException(); + else + ++ii; + } + } - // now we should have all necessary data to build a proper DataSource - // thus if we came this far there should be no further problem - if (bTestOnly) - return xRes; // have createDataSourcePossible return true - - // create data source from found label and data sequences - uno::Sequence< uno::Reference< chart2::data::XDataSequence > > aLabelSeqs( nNumLDS ); - uno::Reference< chart2::data::XDataSequence > *pLabelSeqs = aLabelSeqs.getArray(); - uno::Sequence< uno::Reference< chart2::data::XDataSequence > > aDataSeqs( nNumLDS ); - uno::Reference< chart2::data::XDataSequence > *pDataSeqs = aDataSeqs.getArray(); - sal_Int32 nSeqsIdx = 0; - for (oi = 0; oi < oiEnd; ++oi) + // make some other consistency checks while calculating + // the number of XLabeledDataSequence to build: + // - labels should always be used or not at all + // - the data sequences should have equal non-zero length + sal_Int32 nNumLDS = 0; + if (oiEnd > 0) + { + sal_Int32 nFirstSeqLen = 0; + sal_Int32 nFirstSeqLabelIdx = -1; + bool bFirstFound = false; + for (oi = 0; oi < oiEnd; ++oi) + { + // row/col used at all? + if (aDataStartIdx[oi] != -1 && + (!bFirstIsLabel || aLabelIdx[oi] != -1)) { - // row/col not used? (see if-statement above where nNumLDS was counted) - if (!(aDataStartIdx[oi] != -1 && - (!bFirstIsLabel || aLabelIdx[oi] != -1))) - continue; - - // get cell ranges for label and data - - SwRangeDescriptor aLabelDesc; - SwRangeDescriptor aDataDesc; - if (bDtaSrcIsColumns) // use columns + ++nNumLDS; + if (!bFirstFound) { - aLabelDesc.nTop = aLabelIdx[oi]; - aLabelDesc.nLeft = oi; - aLabelDesc.nBottom = aLabelDesc.nTop; - aLabelDesc.nRight = oi; - - aDataDesc.nTop = aDataStartIdx[oi]; - aDataDesc.nLeft = oi; - aDataDesc.nBottom = aDataDesc.nTop + aDataLen[oi] - 1; - aDataDesc.nRight = oi; + nFirstSeqLen = aDataLen[oi]; + nFirstSeqLabelIdx = aLabelIdx[oi]; + bFirstFound = true; } - else // use rows + else { - aLabelDesc.nTop = oi; - aLabelDesc.nLeft = aLabelIdx[oi]; - aLabelDesc.nBottom = oi; - aLabelDesc.nRight = aLabelDesc.nLeft; - - aDataDesc.nTop = oi; - aDataDesc.nLeft = aDataStartIdx[oi]; - aDataDesc.nBottom = oi; - aDataDesc.nRight = aDataDesc.nLeft + aDataLen[oi] - 1; + if (nFirstSeqLen != aDataLen[oi] || + nFirstSeqLabelIdx != aLabelIdx[oi]) + throw lang::IllegalArgumentException(); } - const OUString aBaseName = pTableFormat->GetName() + "."; + } + } + } + if (nNumLDS == 0) + throw lang::IllegalArgumentException(); - OUString aLabelRange; - if (aLabelIdx[oi] != -1) - { - aLabelRange = aBaseName - + sw_GetCellName( aLabelDesc.nLeft, aLabelDesc.nTop ) - + ":" + sw_GetCellName( aLabelDesc.nRight, aLabelDesc.nBottom ); - } + // now we should have all necessary data to build a proper DataSource + // thus if we came this far there should be no further problem + if (bTestOnly) + return xRes; // have createDataSourcePossible return true + + // create data source from found label and data sequences + uno::Sequence<uno::Reference<chart2::data::XDataSequence>> aLabelSeqs(nNumLDS); + uno::Reference<chart2::data::XDataSequence>* pLabelSeqs = aLabelSeqs.getArray(); + uno::Sequence<uno::Reference<chart2::data::XDataSequence>> aDataSeqs(nNumLDS); + uno::Reference<chart2::data::XDataSequence>* pDataSeqs = aDataSeqs.getArray(); + sal_Int32 nSeqsIdx = 0; + for (oi = 0; oi < oiEnd; ++oi) + { + // row/col not used? (see if-statement above where nNumLDS was counted) + if (!(aDataStartIdx[oi] != -1 && + (!bFirstIsLabel || aLabelIdx[oi] != -1))) + continue; - OUString aDataRange; - if (aDataStartIdx[oi] != -1) - { - aDataRange = aBaseName - + sw_GetCellName( aDataDesc.nLeft, aDataDesc.nTop ) - + ":" + sw_GetCellName( aDataDesc.nRight, aDataDesc.nBottom ); - } + // get cell ranges for label and data - // get cursors spanning the cell ranges for label and data - std::shared_ptr<SwUnoCursor> pLabelUnoCursor; - std::shared_ptr<SwUnoCursor> pDataUnoCursor; - GetFormatAndCreateCursorFromRangeRep( pDoc, aLabelRange, &pTableFormat, pLabelUnoCursor); - GetFormatAndCreateCursorFromRangeRep( pDoc, aDataRange, &pTableFormat, pDataUnoCursor); - - // create XDataSequence's from cursors - if (pLabelUnoCursor) - pLabelSeqs[ nSeqsIdx ] = new SwChartDataSequence( *this, *pTableFormat, pLabelUnoCursor ); - OSL_ENSURE( pDataUnoCursor, "pointer to data sequence missing" ); - if (pDataUnoCursor) - pDataSeqs [ nSeqsIdx ] = new SwChartDataSequence( *this, *pTableFormat, pDataUnoCursor ); - if (pLabelUnoCursor || pDataUnoCursor) - ++nSeqsIdx; - } - OSL_ENSURE( nSeqsIdx == nNumLDS, "mismatch between sequence size and num,ber of entries" ); + SwRangeDescriptor aLabelDesc; + SwRangeDescriptor aDataDesc; + if (bDtaSrcIsColumns) // use columns + { + aLabelDesc.nTop = aLabelIdx[oi]; + aLabelDesc.nLeft = oi; + aLabelDesc.nBottom = aLabelDesc.nTop; + aLabelDesc.nRight = oi; + + aDataDesc.nTop = aDataStartIdx[oi]; + aDataDesc.nLeft = oi; + aDataDesc.nBottom = aDataDesc.nTop + aDataLen[oi] - 1; + aDataDesc.nRight = oi; + } + else // use rows + { + aLabelDesc.nTop = oi; + aLabelDesc.nLeft = aLabelIdx[oi]; + aLabelDesc.nBottom = oi; + aLabelDesc.nRight = aLabelDesc.nLeft; + + aDataDesc.nTop = oi; + aDataDesc.nLeft = aDataStartIdx[oi]; + aDataDesc.nBottom = oi; + aDataDesc.nRight = aDataDesc.nLeft + aDataLen[oi] - 1; + } + const OUString aBaseName = pTableFormat->GetName() + "."; - // build data source from data and label sequences - uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aLDS( nNumLDS ); - uno::Reference< chart2::data::XLabeledDataSequence > *pLDS = aLDS.getArray(); - for (sal_Int32 i = 0; i < nNumLDS; ++i) - { - SwChartLabeledDataSequence *pLabeledDtaSeq = new SwChartLabeledDataSequence; - pLabeledDtaSeq->setLabel( pLabelSeqs[i] ); - pLabeledDtaSeq->setValues( pDataSeqs[i] ); - pLDS[i] = pLabeledDtaSeq; - } + OUString aLabelRange; + if (aLabelIdx[oi] != -1) + { + aLabelRange = aBaseName + + sw_GetCellName( aLabelDesc.nLeft, aLabelDesc.nTop ) + + ":" + sw_GetCellName( aLabelDesc.nRight, aLabelDesc.nBottom ); + } - // apply 'SequenceMapping' if it was provided - sal_Int32 nSequenceMappingLen = aSequenceMapping.getLength(); - if (nSequenceMappingLen) - { - sal_Int32 *pSequenceMapping = aSequenceMapping.getArray(); - uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aOld_LDS( aLDS ); - uno::Reference< chart2::data::XLabeledDataSequence > *pOld_LDS = aOld_LDS.getArray(); + OUString aDataRange = aBaseName + + sw_GetCellName( aDataDesc.nLeft, aDataDesc.nTop ) + + ":" + sw_GetCellName( aDataDesc.nRight, aDataDesc.nBottom ); - sal_Int32 nNewCnt = 0; - for (sal_Int32 i = 0; i < nSequenceMappingLen; ++i) - { - // check that index to be used is valid - // and has not yet been used - sal_Int32 nIdx = pSequenceMapping[i]; - if (0 <= nIdx && nIdx < nNumLDS && pOld_LDS[nIdx].is()) - { - pLDS[nNewCnt++] = pOld_LDS[nIdx]; + // get cursors spanning the cell ranges for label and data + std::shared_ptr<SwUnoCursor> pLabelUnoCursor; + std::shared_ptr<SwUnoCursor> pDataUnoCursor; + GetFormatAndCreateCursorFromRangeRep(pDoc, aLabelRange, &pTableFormat, pLabelUnoCursor); + GetFormatAndCreateCursorFromRangeRep(pDoc, aDataRange, &pTableFormat, pDataUnoCursor); - // mark index as being used already (avoids duplicate entries) - pOld_LDS[nIdx].clear(); - } - } - // add not yet used 'old' sequences to new one - for (sal_Int32 i = 0; i < nNumLDS; ++i) - { - if (pOld_LDS[i].is()) - pLDS[nNewCnt++] = pOld_LDS[i]; - } - OSL_ENSURE( nNewCnt == nNumLDS, "unexpected size of resulting sequence" ); - } + // create XDataSequence's from cursors + if (pLabelUnoCursor) + pLabelSeqs[nSeqsIdx] = new SwChartDataSequence(*this, *pTableFormat, pLabelUnoCursor); + OSL_ENSURE(pDataUnoCursor, "pointer to data sequence missing"); + if (pDataUnoCursor) + pDataSeqs[nSeqsIdx] = new SwChartDataSequence(*this, *pTableFormat, pDataUnoCursor); + if (pLabelUnoCursor || pDataUnoCursor) + ++nSeqsIdx; + } + OSL_ENSURE(nSeqsIdx == nNumLDS, "mismatch between sequence size and num,ber of entries"); - xRes = new SwChartDataSource( aLDS ); + // build data source from data and label sequences + uno::Sequence<uno::Reference<chart2::data::XLabeledDataSequence>> aLDS(nNumLDS); + uno::Reference<chart2::data::XLabeledDataSequence>* pLDS = aLDS.getArray(); + for (sal_Int32 i = 0; i < nNumLDS; ++i) + { + SwChartLabeledDataSequence* pLabeledDtaSeq = new SwChartLabeledDataSequence; + pLabeledDtaSeq->setLabel(pLabelSeqs[i]); + pLabeledDtaSeq->setValues(pDataSeqs[i]); + pLDS[i] = pLabeledDtaSeq; + } + + // apply 'SequenceMapping' if it was provided + sal_Int32 nSequenceMappingLen = aSequenceMapping.getLength(); + if (nSequenceMappingLen) + { + sal_Int32 *pSequenceMapping = aSequenceMapping.getArray(); + uno::Sequence<uno::Reference<chart2::data::XLabeledDataSequence>> aOld_LDS(aLDS); + uno::Reference<chart2::data::XLabeledDataSequence>* pOld_LDS = aOld_LDS.getArray(); + + sal_Int32 nNewCnt = 0; + for (sal_Int32 i = 0; i < nSequenceMappingLen; ++i) + { + // check that index to be used is valid + // and has not yet been used + sal_Int32 nIdx = pSequenceMapping[i]; + if (0 <= nIdx && nIdx < nNumLDS && pOld_LDS[nIdx].is()) + { + pLDS[nNewCnt++] = pOld_LDS[nIdx]; + + // mark index as being used already (avoids duplicate entries) + pOld_LDS[nIdx].clear(); + } + } + // add not yet used 'old' sequences to new one + for (sal_Int32 i = 0; i < nNumLDS; ++i) + { + if (pOld_LDS[i].is()) + pLDS[nNewCnt++] = pOld_LDS[i]; } + OSL_ENSURE(nNewCnt == nNumLDS, "unexpected size of resulting sequence"); } + xRes = new SwChartDataSource(aLDS); return xRes; } diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index fa903d7bf703..e2d61dc8abe1 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -760,37 +760,32 @@ uno::Reference< drawing::XShapeGroup > SwXDrawPage::group(const uno::Reference< const SdrMarkList& rMarkList = pPage->PreGroup(xShapes); if ( rMarkList.GetMarkCount() > 1 ) { - bool bFlyInCnt = false; - for ( size_t i = 0; !bFlyInCnt && i < rMarkList.GetMarkCount(); ++i ) + for (size_t i = 0; i < rMarkList.GetMarkCount(); ++i) { const SdrObject *pObj = rMarkList.GetMark( i )->GetMarkedSdrObj(); if (RndStdIds::FLY_AS_CHAR == ::FindFrameFormat(const_cast<SdrObject*>( pObj))->GetAnchor().GetAnchorId()) { - bFlyInCnt = true; + throw uno::RuntimeException(); // FlyInCnt! } } - if( bFlyInCnt ) - throw uno::RuntimeException(); - if( !bFlyInCnt ) - { - UnoActionContext aContext(pDoc); - pDoc->GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr ); - SwDrawContact* pContact = pDoc->GroupSelection( *pPage->GetDrawView() ); - pDoc->ChgAnchor( - pPage->GetDrawView()->GetMarkedObjectList(), - RndStdIds::FLY_AT_PARA, - true, false ); + UnoActionContext aContext(pDoc); + pDoc->GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr ); - pPage->GetDrawView()->UnmarkAll(); - if(pContact) - { - uno::Reference< uno::XInterface > xInt = SwFmDrawPage::GetInterface( pContact->GetMaster() ); - xRet.set(xInt, uno::UNO_QUERY); - } - pDoc->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr ); + SwDrawContact* pContact = pDoc->GroupSelection( *pPage->GetDrawView() ); + pDoc->ChgAnchor( + pPage->GetDrawView()->GetMarkedObjectList(), + RndStdIds::FLY_AT_PARA, + true, false ); + + pPage->GetDrawView()->UnmarkAll(); + if(pContact) + { + uno::Reference< uno::XInterface > xInt = SwFmDrawPage::GetInterface( pContact->GetMaster() ); + xRet.set(xInt, uno::UNO_QUERY); } + pDoc->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr ); } pPage->RemovePageView(); } diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index 6275e317caf9..86f9ead27693 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -222,155 +222,152 @@ void SwXTextPortion::GetPropertyValue( OSL_ENSURE( pUnoCursor, "UNO cursor missing" ); if (!pUnoCursor) return; - if(pUnoCursor) + switch(rEntry.nWID) { - switch(rEntry.nWID) + case FN_UNO_TEXT_PORTION_TYPE: { - case FN_UNO_TEXT_PORTION_TYPE: + const char* pRet; + switch (m_ePortionType) + { + case PORTION_TEXT: pRet = "Text";break; + case PORTION_FIELD: pRet = "TextField";break; + case PORTION_FRAME: pRet = "Frame";break; + case PORTION_FOOTNOTE: pRet = "Footnote";break; + case PORTION_REFMARK_START: + case PORTION_REFMARK_END: pRet = UNO_NAME_REFERENCE_MARK;break; + case PORTION_TOXMARK_START: + case PORTION_TOXMARK_END: pRet = UNO_NAME_DOCUMENT_INDEX_MARK;break; + case PORTION_BOOKMARK_START : + case PORTION_BOOKMARK_END : pRet = UNO_NAME_BOOKMARK;break; + case PORTION_REDLINE_START: + case PORTION_REDLINE_END: pRet = "Redline";break; + case PORTION_RUBY_START: + case PORTION_RUBY_END: pRet = "Ruby";break; + case PORTION_SOFT_PAGEBREAK:pRet = "SoftPageBreak";break; + case PORTION_META: pRet = UNO_NAME_META; break; + case PORTION_FIELD_START:pRet = "TextFieldStart";break; + case PORTION_FIELD_END:pRet = "TextFieldEnd";break; + case PORTION_FIELD_START_END:pRet = "TextFieldStartEnd";break; + case PORTION_ANNOTATION: + pRet = "Annotation"; + break; + case PORTION_ANNOTATION_END: + pRet = "AnnotationEnd"; + break; + default: + pRet = nullptr; + } + + OUString sRet; + if( pRet ) + sRet = OUString::createFromAscii( pRet ); + rVal <<= sRet; + } + break; + case FN_UNO_CONTROL_CHARACTER: // obsolete! + break; + case FN_UNO_DOCUMENT_INDEX_MARK: + rVal <<= m_xTOXMark; + break; + case FN_UNO_REFERENCE_MARK: + rVal <<= m_xRefMark; + break; + case FN_UNO_BOOKMARK: + rVal <<= m_xBookmark; + break; + case FN_UNO_FOOTNOTE: + rVal <<= m_xFootnote; + break; + case FN_UNO_TEXT_FIELD: + rVal <<= m_xTextField; + break; + case FN_UNO_META: + rVal <<= m_xMeta; + break; + case FN_UNO_IS_COLLAPSED: + { + switch (m_ePortionType) { - const char* pRet; - switch (m_ePortionType) - { - case PORTION_TEXT: pRet = "Text";break; - case PORTION_FIELD: pRet = "TextField";break; - case PORTION_FRAME: pRet = "Frame";break; - case PORTION_FOOTNOTE: pRet = "Footnote";break; case PORTION_REFMARK_START: - case PORTION_REFMARK_END: pRet = UNO_NAME_REFERENCE_MARK;break; - case PORTION_TOXMARK_START: - case PORTION_TOXMARK_END: pRet = UNO_NAME_DOCUMENT_INDEX_MARK;break; case PORTION_BOOKMARK_START : - case PORTION_BOOKMARK_END : pRet = UNO_NAME_BOOKMARK;break; - case PORTION_REDLINE_START: - case PORTION_REDLINE_END: pRet = "Redline";break; + case PORTION_TOXMARK_START: + case PORTION_REFMARK_END: + case PORTION_TOXMARK_END: + case PORTION_BOOKMARK_END : + case PORTION_REDLINE_START : + case PORTION_REDLINE_END : case PORTION_RUBY_START: - case PORTION_RUBY_END: pRet = "Ruby";break; - case PORTION_SOFT_PAGEBREAK:pRet = "SoftPageBreak";break; - case PORTION_META: pRet = UNO_NAME_META; break; - case PORTION_FIELD_START:pRet = "TextFieldStart";break; - case PORTION_FIELD_END:pRet = "TextFieldEnd";break; - case PORTION_FIELD_START_END:pRet = "TextFieldStartEnd";break; - case PORTION_ANNOTATION: - pRet = "Annotation"; - break; - case PORTION_ANNOTATION_END: - pRet = "AnnotationEnd"; - break; + case PORTION_RUBY_END: + case PORTION_FIELD_START: + case PORTION_FIELD_END: + rVal <<= m_bIsCollapsed; + break; default: - pRet = nullptr; - } - - OUString sRet; - if( pRet ) - sRet = OUString::createFromAscii( pRet ); - rVal <<= sRet; + break; } - break; - case FN_UNO_CONTROL_CHARACTER: // obsolete! - break; - case FN_UNO_DOCUMENT_INDEX_MARK: - rVal <<= m_xTOXMark; - break; - case FN_UNO_REFERENCE_MARK: - rVal <<= m_xRefMark; - break; - case FN_UNO_BOOKMARK: - rVal <<= m_xBookmark; - break; - case FN_UNO_FOOTNOTE: - rVal <<= m_xFootnote; - break; - case FN_UNO_TEXT_FIELD: - rVal <<= m_xTextField; - break; - case FN_UNO_META: - rVal <<= m_xMeta; - break; - case FN_UNO_IS_COLLAPSED: + } + break; + case FN_UNO_IS_START: + { + bool bStart = true, bPut = true; + switch (m_ePortionType) { - switch (m_ePortionType) - { - case PORTION_REFMARK_START: - case PORTION_BOOKMARK_START : - case PORTION_TOXMARK_START: - case PORTION_REFMARK_END: - case PORTION_TOXMARK_END: - case PORTION_BOOKMARK_END : - case PORTION_REDLINE_START : - case PORTION_REDLINE_END : - case PORTION_RUBY_START: - case PORTION_RUBY_END: - case PORTION_FIELD_START: - case PORTION_FIELD_END: - rVal <<= m_bIsCollapsed; - break; - default: - break; - } + case PORTION_REFMARK_START: + case PORTION_BOOKMARK_START: + case PORTION_TOXMARK_START: + case PORTION_REDLINE_START: + case PORTION_RUBY_START: + case PORTION_FIELD_START: + break; + + case PORTION_REFMARK_END: + case PORTION_TOXMARK_END: + case PORTION_BOOKMARK_END: + case PORTION_REDLINE_END: + case PORTION_RUBY_END: + case PORTION_FIELD_END: + bStart = false; + break; + default: + bPut = false; } - break; - case FN_UNO_IS_START: + if(bPut) + rVal <<= bStart; + } + break; + case RES_TXTATR_CJK_RUBY: + { + const uno::Any* pToSet = nullptr; + switch(rEntry.nMemberId) { - bool bStart = true, bPut = true; - switch (m_ePortionType) - { - case PORTION_REFMARK_START: - case PORTION_BOOKMARK_START: - case PORTION_TOXMARK_START: - case PORTION_REDLINE_START: - case PORTION_RUBY_START: - case PORTION_FIELD_START: - break; - - case PORTION_REFMARK_END: - case PORTION_TOXMARK_END: - case PORTION_BOOKMARK_END: - case PORTION_REDLINE_END: - case PORTION_RUBY_END: - case PORTION_FIELD_END: - bStart = false; - break; - default: - bPut = false; - } - if(bPut) - rVal <<= bStart; + case MID_RUBY_TEXT : pToSet = m_pRubyText.get(); break; + case MID_RUBY_ADJUST : pToSet = m_pRubyAdjust.get(); break; + case MID_RUBY_CHARSTYLE:pToSet = m_pRubyStyle.get(); break; + case MID_RUBY_ABOVE : pToSet = m_pRubyIsAbove.get();break; + case MID_RUBY_POSITION: pToSet = m_pRubyPosition.get();break; } - break; - case RES_TXTATR_CJK_RUBY: + if(pToSet) + rVal = *pToSet; + } + break; + default: + beans::PropertyState eTemp; + bool bDone = SwUnoCursorHelper::getCursorPropertyValue( + rEntry, *pUnoCursor, &rVal, eTemp ); + if(!bDone) { - const uno::Any* pToSet = nullptr; - switch(rEntry.nMemberId) + if(!pSet) { - case MID_RUBY_TEXT : pToSet = m_pRubyText.get(); break; - case MID_RUBY_ADJUST : pToSet = m_pRubyAdjust.get(); break; - case MID_RUBY_CHARSTYLE:pToSet = m_pRubyStyle.get(); break; - case MID_RUBY_ABOVE : pToSet = m_pRubyIsAbove.get();break; - case MID_RUBY_POSITION: pToSet = m_pRubyPosition.get();break; + pSet = o3tl::make_unique<SfxItemSet>( + pUnoCursor->GetDoc()->GetAttrPool(), + svl::Items< + RES_CHRATR_BEGIN, RES_FRMATR_END - 1, + RES_UNKNOWNATR_CONTAINER, + RES_UNKNOWNATR_CONTAINER>{}); + SwUnoCursorHelper::GetCursorAttr(*pUnoCursor, *pSet); } - if(pToSet) - rVal = *pToSet; + m_pPropSet->getPropertyValue(rEntry, *pSet, rVal); } - break; - default: - beans::PropertyState eTemp; - bool bDone = SwUnoCursorHelper::getCursorPropertyValue( - rEntry, *pUnoCursor, &rVal, eTemp ); - if(!bDone) - { - if(!pSet) - { - pSet = o3tl::make_unique<SfxItemSet>( - pUnoCursor->GetDoc()->GetAttrPool(), - svl::Items< - RES_CHRATR_BEGIN, RES_FRMATR_END - 1, - RES_UNKNOWNATR_CONTAINER, - RES_UNKNOWNATR_CONTAINER>{}); - SwUnoCursorHelper::GetCursorAttr(*pUnoCursor, *pSet); - } - m_pPropSet->getPropertyValue(rEntry, *pSet, rVal); - } - } } } diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 55500a7eab90..1fc47bd59ce7 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -723,9 +723,9 @@ sal_Int32 lcl_GetCountOrName<SfxStyleFamily::Cell>(const SwDoc& rDoc, OUString* { const sal_Int32 nAutoFormat = nIndex / rTableTemplateMap.size(); const sal_Int32 nBoxFormat = rTableTemplateMap[nIndex % rTableTemplateMap.size()]; - const SwTableAutoFormat* pTableFormat = &rAutoFormats[nAutoFormat]; - if (pTableFormat) - *pString = pTableFormat->GetName() + pTableFormat->GetTableTemplateCellSubName(pTableFormat->GetBoxFormat(nBoxFormat)); + const SwTableAutoFormat& rTableFormat = rAutoFormats[nAutoFormat]; + *pString = rTableFormat.GetName() + + rTableFormat.GetTableTemplateCellSubName(rTableFormat.GetBoxFormat(nBoxFormat)); } else *pString = rDoc.GetCellStyles()[nIndex-nUsedCellStylesCount].GetName(); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index e27630e16445..0657f7bc361d 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -2462,8 +2462,7 @@ class SwXHeadFootText::Impl : m_pHeadFootFormat(&rHeadFootFormat) , m_bIsHeader(bIsHeader) { - if(m_pHeadFootFormat) - StartListening(m_pHeadFootFormat->GetNotifier()); + StartListening(m_pHeadFootFormat->GetNotifier()); } SwFrameFormat* GetHeadFootFormat() const { 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 { diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx index 5fa4446755b4..2a42029afd2c 100644 --- a/sw/source/uibase/uiview/viewtab.cxx +++ b/sw/source/uibase/uiview/viewtab.cxx @@ -1329,18 +1329,9 @@ void SwView::StateTabWin(SfxItemSet& rSet) aLongLR.SetRight(rPageRect.Right() - aRect.Right()); } } - if( nWhich == SID_ATTR_LONG_LRSPACE ) - rSet.Put( aLongLR ); - else - { - SvxLRSpaceItem aLR( aLongLR.GetLeft(), - aLongLR.GetRight(), - 0, 0, - nWhich); - rSet.Put(aLR); - } - break; + rSet.Put( aLongLR ); } + break; // provide left and right margins of current page style case SID_ATTR_PAGE_LRSPACE: @@ -1387,17 +1378,9 @@ void SwView::StateTabWin(SfxItemSet& rSet) aLongUL.SetUpper(rPagePrtRect.Top()); aLongUL.SetLower(nPageHeight - rPagePrtRect.Bottom()); } - if( nWhich == SID_ATTR_LONG_ULSPACE ) - rSet.Put( aLongUL ); - else - { - SvxULSpaceItem aULTmp(static_cast<sal_uInt16>(aLongUL.GetUpper()), - static_cast<sal_uInt16>(aLongUL.GetLower()), - nWhich); - rSet.Put(aULTmp); - } - break; + rSet.Put( aLongUL ); } + break; // provide top and bottom margins of current page style case SID_ATTR_PAGE_ULSPACE: diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 9324c70999af..4cb1bd3ec1e3 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3007,18 +3007,13 @@ void SAL_CALL SwXTextDocument::render( { // the view shell should be SwView for documents PDF export // or SwPagePreview for PDF export of the page preview - //!! (check for SwView first as in GuessViewShell) !! - OSL_ENSURE( pView, "!! view missing !!" ); SwViewShell* pVwSh = nullptr; - if (pView) - { - // TODO/mba: we really need a generic way to get the SwViewShell! - SwView* pSwView = dynamic_cast<SwView*>( pView ); - if ( pSwView ) - pVwSh = pSwView->GetWrtShellPtr(); - else - pVwSh = static_cast<SwPagePreview*>(pView)->GetViewShell(); - } + // TODO/mba: we really need a generic way to get the SwViewShell! + const SwView* pSwView = dynamic_cast<const SwView*>(pView); + if (pSwView) + pVwSh = pSwView->GetWrtShellPtr(); + else + pVwSh = static_cast<SwPagePreview*>(pView)->GetViewShell(); // get output device to use VclPtr< OutputDevice > pOut = lcl_GetOutputDevice( *m_pPrintUIOptions ); @@ -3029,8 +3024,8 @@ void SAL_CALL SwXTextDocument::render( const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage" ); bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); - OSL_ENSURE(( dynamic_cast< const SwView *>( pView ) != nullptr && m_pRenderData->IsViewOptionAdjust()) - || (dynamic_cast< const SwView *>( pView ) == nullptr && !m_pRenderData->IsViewOptionAdjust()), + OSL_ENSURE((pSwView && m_pRenderData->IsViewOptionAdjust()) + || (!pSwView && !m_pRenderData->IsViewOptionAdjust()), "SwView / SwViewOptionAdjust_Impl availability mismatch" ); // since printing now also use the API for PDF export this option @@ -3043,9 +3038,7 @@ void SAL_CALL SwXTextDocument::render( // During this process, additional information required for tagging // the pdf file are collected, which are evaulated during painting. - SwWrtShell* pWrtShell = dynamic_cast< const SwView *>( pView ) != nullptr ? - static_cast<SwView*>(pView)->GetWrtShellPtr() : - nullptr; + SwWrtShell* pWrtShell = pSwView ? pSwView->GetWrtShellPtr() : nullptr; SwPrintData const& rSwPrtOptions = *m_pRenderData->GetSwPrtOptions(); diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx index 154d9d7f9553..aa679eb392e9 100644 --- a/sw/source/uibase/utlui/uitool.cxx +++ b/sw/source/uibase/utlui/uitool.cxx @@ -230,7 +230,7 @@ static UseOnPage lcl_convertUseFromSvx(SvxPageUsage nUse) void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) { SwFrameFormat& rMaster = rPageDesc.GetMaster(); - int nFirstShare = -1; + bool bFirstShare = false; // Transfer all general frame attributes rMaster.SetFormatAttr(rSet); @@ -278,12 +278,9 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) ::FillHdFt(pHeaderFormat, rHeaderSet); rPageDesc.ChgHeaderShare(rHeaderSet.Get(SID_ATTR_PAGE_SHARED).GetValue()); - if (nFirstShare < 0) - { - rPageDesc.ChgFirstShare(static_cast<const SfxBoolItem&>( + rPageDesc.ChgFirstShare(static_cast<const SfxBoolItem&>( rHeaderSet.Get(SID_ATTR_PAGE_SHARED_FIRST)).GetValue()); - nFirstShare = rPageDesc.IsFirstShared() ? 1 : 0; - } + bFirstShare = true; } else { @@ -317,7 +314,7 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) ::FillHdFt(pFooterFormat, rFooterSet); rPageDesc.ChgFooterShare(rFooterSet.Get(SID_ATTR_PAGE_SHARED).GetValue()); - if (nFirstShare < 0) + if (!bFirstShare) { rPageDesc.ChgFirstShare(static_cast<const SfxBoolItem&>( rFooterSet.Get(SID_ATTR_PAGE_SHARED_FIRST)).GetValue()); diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index fd38f2413c57..a8fe3486be61 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -2000,25 +2000,21 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, tools: break; case PORTIONKIND_TAB: // for HideSelection() only Range, pSelection = 0. - if ( pSelStart ) + if ( pSelStart ) // also implies pSelEnd { const tools::Rectangle aTabArea( aTmpPos, Point( aTmpPos.X()+nTxtWidth, aTmpPos.Y()+mnCharHeight-1 ) ); - bool bDone = false; - if ( pSelStart ) + // is the Tab in the Selection??? + const TextPaM aTextStart(nPara, nIndex); + const TextPaM aTextEnd(nPara, nIndex + 1); + if ((aTextStart < *pSelEnd) && (aTextEnd > *pSelStart)) { - // is the Tab in the Selection??? - const TextPaM aTextStart( nPara, nIndex ); - const TextPaM aTextEnd( nPara, nIndex+1 ); - if ( ( aTextStart < *pSelEnd ) && ( aTextEnd > *pSelStart ) ) - { - const Color aOldColor = pOutDev->GetFillColor(); - pOutDev->SetFillColor( rStyleSettings.GetHighlightColor() ); - pOutDev->DrawRect( aTabArea ); - pOutDev->SetFillColor( aOldColor ); - bDone = true; - } + const Color aOldColor = pOutDev->GetFillColor(); + pOutDev->SetFillColor( + rStyleSettings.GetHighlightColor()); + pOutDev->DrawRect(aTabArea); + pOutDev->SetFillColor(aOldColor); } - if ( !bDone ) + else { pOutDev->Erase( aTabArea ); } diff --git a/vcl/source/treelist/svimpbox.cxx b/vcl/source/treelist/svimpbox.cxx index 5b37c1b6960c..a70b99f4d421 100644 --- a/vcl/source/treelist/svimpbox.cxx +++ b/vcl/source/treelist/svimpbox.cxx @@ -2188,7 +2188,7 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt) if( IsExpandable() && !pView->IsExpanded( pCursor ) ) pView->Expand( pCursor ); } - else if ( bIsCellFocusEnabled && pCursor ) + else if (bIsCellFocusEnabled) { if ( nCurTabPos < ( pView->TabCount() - 1 /*!2*/ ) ) { @@ -2219,7 +2219,7 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt) case KEY_LEFT: { - if ( bIsCellFocusEnabled && pCursor ) + if (bIsCellFocusEnabled) { if ( nCurTabPos > FIRST_ENTRY_TAB ) { @@ -2394,24 +2394,19 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt) break; case KEY_ADD: - if( pCursor ) + if (!pView->IsExpanded(pCursor)) + pView->Expand(pCursor); + if (bMod1) { - if( !pView->IsExpanded(pCursor)) - pView->Expand( pCursor ); - if( bMod1 ) + sal_uInt16 nRefDepth = pTree->GetDepth(pCursor); + SvTreeListEntry* pCur = pTree->Next(pCursor); + while (pCur && pTree->GetDepth(pCur) > nRefDepth) { - sal_uInt16 nRefDepth = pTree->GetDepth( pCursor ); - SvTreeListEntry* pCur = pTree->Next( pCursor ); - while( pCur && pTree->GetDepth(pCur) > nRefDepth ) - { - if( pCur->HasChildren() && !pView->IsExpanded(pCur)) - pView->Expand( pCur ); - pCur = pTree->Next( pCur ); - } + if (pCur->HasChildren() && !pView->IsExpanded(pCur)) + pView->Expand(pCur); + pCur = pTree->Next(pCur); } } - else - bKeyUsed = false; break; case KEY_A: @@ -2422,46 +2417,41 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt) break; case KEY_SUBTRACT: - if( pCursor ) + if (pView->IsExpanded(pCursor)) + pView->Collapse(pCursor); + if (bMod1) { - if( pView->IsExpanded(pCursor)) - pView->Collapse( pCursor ); - if( bMod1 ) + // collapse all parents until we get to the root + SvTreeListEntry* pParentToCollapse = pTree->GetRootLevelParent(pCursor); + if (pParentToCollapse) { - // collapse all parents until we get to the root - SvTreeListEntry* pParentToCollapse = pTree->GetRootLevelParent(pCursor); - if( pParentToCollapse ) + sal_uInt16 nRefDepth; + // special case explorer: if the root only has a single + // entry, don't collapse the root entry + if (pTree->GetChildList(nullptr).size() < 2) { - sal_uInt16 nRefDepth; - // special case explorer: if the root only has a single - // entry, don't collapse the root entry - if (pTree->GetChildList(nullptr).size() < 2) + nRefDepth = 1; + pParentToCollapse = pCursor; + while (pTree->GetParent(pParentToCollapse) + && pTree->GetDepth(pTree->GetParent(pParentToCollapse)) > 0) { - nRefDepth = 1; - pParentToCollapse = pCursor; - while( pTree->GetParent(pParentToCollapse) && - pTree->GetDepth( pTree->GetParent(pParentToCollapse)) > 0) - { - pParentToCollapse = pTree->GetParent(pParentToCollapse); - } + pParentToCollapse = pTree->GetParent(pParentToCollapse); } - else - nRefDepth = 0; + } + else + nRefDepth = 0; - if( pView->IsExpanded(pParentToCollapse) ) - pView->Collapse( pParentToCollapse ); - SvTreeListEntry* pCur = pTree->Next( pParentToCollapse ); - while( pCur && pTree->GetDepth(pCur) > nRefDepth ) - { - if( pCur->HasChildren() && pView->IsExpanded(pCur) ) - pView->Collapse( pCur ); - pCur = pTree->Next( pCur ); - } + if (pView->IsExpanded(pParentToCollapse)) + pView->Collapse(pParentToCollapse); + SvTreeListEntry* pCur = pTree->Next(pParentToCollapse); + while (pCur && pTree->GetDepth(pCur) > nRefDepth) + { + if (pCur->HasChildren() && pView->IsExpanded(pCur)) + pView->Collapse(pCur); + pCur = pTree->Next(pCur); } } } - else - bKeyUsed = false; break; case KEY_DIVIDE : diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx index dccdbda4db2f..667503bb7300 100644 --- a/vcl/source/treelist/treelistbox.cxx +++ b/vcl/source/treelist/treelistbox.cxx @@ -2674,17 +2674,17 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::Render SvViewDataEntry* pViewDataEntry = GetViewDataEntry( &rEntry ); - sal_uInt16 nTabCount = aTabs.size(); - sal_uInt16 nItemCount = rEntry.ItemCount(); - sal_uInt16 nCurTab = 0; - sal_uInt16 nCurItem = 0; + const size_t nTabCount = aTabs.size(); + const size_t nItemCount = rEntry.ItemCount(); + size_t nCurTab = 0; + size_t nCurItem = 0; while (nCurTab < nTabCount && nCurItem < nItemCount) { SvLBoxTab* pTab = aTabs[nCurTab].get(); - sal_uInt16 nNextTab = nCurTab + 1; + const size_t nNextTab = nCurTab + 1; SvLBoxTab* pNextTab = nNextTab < nTabCount ? aTabs[nNextTab].get() : nullptr; - SvLBoxItem* pItem = nCurItem < nItemCount ? &rEntry.GetItem(nCurItem) : nullptr; + SvLBoxItem& rItem = rEntry.GetItem(nCurItem); SvLBoxTabFlags nFlags = pTab->nFlags; Size aSize(SvLBoxItem::GetSize(pViewDataEntry, nCurItem)); @@ -2715,7 +2715,7 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::Render Wallpaper aWallpaper = rRenderContext.GetBackground(); bool bSelTab = bool(nFlags & SvLBoxTabFlags::SHOW_SELECTION); - SvLBoxItemType nItemType = pItem->GetType(); + SvLBoxItemType nItemType = rItem.GetType(); if (pViewDataEntry->IsHighlighted() && bSelTab) { @@ -2811,10 +2811,10 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::Render aEntryPos.AdjustY((nTempEntryHeight - aSize.Height()) / 2 ); pViewDataEntry->SetPaintRectangle(aRect); - pItem->Paint(aEntryPos, *this, rRenderContext, pViewDataEntry, rEntry); + rItem.Paint(aEntryPos, *this, rRenderContext, pViewDataEntry, rEntry); // division line between tabs - if (pNextTab && pItem->GetType() == SvLBoxItemType::String && + if (pNextTab && rItem.GetType() == SvLBoxItemType::String && // not at the right edge of the window! aRect.Right() < nMaxRight) { diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 1567865c4412..46a875a9e8b9 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -1506,9 +1506,8 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) { uno::Reference< beans::XPropertySet > xDocProperties; xDocProperties.set( rDM_Impl.GetTextDocument(), uno::UNO_QUERY_THROW ); - bool bSquaredPageMode = false; - Insert( PROP_GRID_STANDARD_MODE, uno::makeAny( !bSquaredPageMode ) ); - xDocProperties->setPropertyValue( "DefaultPageMode", uno::makeAny( bSquaredPageMode ) ); + Insert(PROP_GRID_STANDARD_MODE, uno::makeAny(true)); + xDocProperties->setPropertyValue("DefaultPageMode", uno::makeAny(false)); } catch ( const uno::Exception& ) { @@ -1592,7 +1591,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) if (0 <= m_nPageNumber) { - sal_Int16 nPageNumber = m_nPageNumber >= 0 ? static_cast< sal_Int16 >(m_nPageNumber) : 1; + sal_Int16 nPageNumber = static_cast< sal_Int16 >(m_nPageNumber); xRangeProperties->setPropertyValue(getPropertyName(PROP_PAGE_NUMBER_OFFSET), uno::makeAny(nPageNumber)); } diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx index 001e22bad455..833b38d16876 100644 --- a/writerfilter/source/rtftok/rtfdispatchflag.cxx +++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx @@ -748,7 +748,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) break; case RTF_SECTUNLOCKED: { - auto pValue = new RTFValue(int(!nParam)); + auto pValue = new RTFValue(0); m_aStates.top().aSectionSprms.set(NS_ooxml::LN_EG_SectPrContents_formProt, pValue); } break; diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 670410023dc2..9a7b980ba09d 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -476,19 +476,11 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap // The coordinates are in an (x,y) form. aToken = aToken.copy(1, aToken.getLength() - 2); sal_Int32 nI = 0; - boost::optional<sal_Int32> oX; - boost::optional<sal_Int32> oY; - do - { - OUString aPoint = aToken.getToken(0, ',', nI); - if (!oX) - oX = aPoint.toInt32(); - else - oY = aPoint.toInt32(); - } while (nI >= 0); + sal_Int32 nX = aToken.getToken(0, ',', nI).toInt32(); + sal_Int32 nY = (nI >= 0) ? aToken.getToken(0, ',', nI).toInt32() : 0; drawing::EnhancedCustomShapeParameterPair aPair; - aPair.First.Value <<= *oX; - aPair.Second.Value <<= *oY; + aPair.First.Value <<= nX; + aPair.Second.Value <<= nY; aCoordinates.push_back(aPair); } } while (nCharIndex >= 0); @@ -829,19 +821,11 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap // The coordinates are in an (x,y) form. aToken = aToken.copy(1, aToken.getLength() - 2); sal_Int32 nI = 0; - boost::optional<sal_Int32> oX; - boost::optional<sal_Int32> oY; - do - { - OUString aPoint = aToken.getToken(0, ',', nI); - if (!oX) - oX = aPoint.toInt32(); - else - oY = aPoint.toInt32(); - } while (nI >= 0); + sal_Int32 nX = aToken.getToken(0, ',', nI).toInt32(); + sal_Int32 nY = (nI >= 0) ? aToken.getToken(0, ',', nI).toInt32() : 0; RTFSprms aPathAttributes; - aPathAttributes.set(NS_ooxml::LN_CT_Point2D_x, new RTFValue(*oX)); - aPathAttributes.set(NS_ooxml::LN_CT_Point2D_y, new RTFValue(*oY)); + aPathAttributes.set(NS_ooxml::LN_CT_Point2D_x, new RTFValue(nX)); + aPathAttributes.set(NS_ooxml::LN_CT_Point2D_y, new RTFValue(nY)); aPolygonSprms.set(NS_ooxml::LN_CT_WrapPath_lineTo, new RTFValue(aPathAttributes), RTFOverwrite::NO_APPEND); } diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx index 14ffebb3c81d..4a4028717490 100644 --- a/xmloff/source/style/xmlnumfe.cxx +++ b/xmloff/source/style/xmlnumfe.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <comphelper/sequence.hxx> #include <comphelper/string.hxx> #include <svl/zforlist.hxx> #include <svl/zformat.hxx> @@ -187,17 +188,7 @@ bool SvXMLNumUsedList_Impl::GetNextUsed(sal_uInt32& nKey) uno::Sequence<sal_Int32> SvXMLNumUsedList_Impl::GetWasUsed() { - uno::Sequence<sal_Int32> ret(nWasUsedCount); - sal_Int32* pWasUsed = ret.getArray(); - if (pWasUsed) - { - for (const auto nWasUsed : aWasUsed) - { - *pWasUsed = nWasUsed; - ++pWasUsed; - } - } - return ret; + return comphelper::containerToSequence<sal_Int32>(aWasUsed); } void SvXMLNumUsedList_Impl::SetWasUsed(const uno::Sequence<sal_Int32>& rWasUsed) |