diff options
28 files changed, 160 insertions, 149 deletions
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx index df227f53346d..fbeb40aa4b3d 100644 --- a/cui/source/tabpages/numpages.cxx +++ b/cui/source/tabpages/numpages.cxx @@ -239,7 +239,7 @@ void SvxSingleNumPickTabPage::ActivatePage(const SfxItemSet& rSet) } if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) { - pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); } if(pActNum && *pSaveNum != *pActNum) { @@ -283,7 +283,7 @@ void SvxSingleNumPickTabPage::Reset( const SfxItemSet* rSet ) } } DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); if(!pActNum) pActNum.reset( new SvxNumRule(*pSaveNum) ); @@ -390,7 +390,7 @@ void SvxBulletPickTabPage::ActivatePage(const SfxItemSet& rSet) } if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) { - pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); } if(pActNum && *pSaveNum != *pActNum) { @@ -433,7 +433,7 @@ void SvxBulletPickTabPage::Reset( const SfxItemSet* rSet ) } DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); if(!pActNum) pActNum.reset( new SvxNumRule(*pSaveNum) ); @@ -573,7 +573,7 @@ void SvxNumPickTabPage::ActivatePage(const SfxItemSet& rSet) } if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) { - pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); } if(pActNum && *pSaveNum != *pActNum) { @@ -616,7 +616,7 @@ void SvxNumPickTabPage::Reset( const SfxItemSet* rSet ) } DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); if(!pActNum) pActNum.reset( new SvxNumRule(*pSaveNum) ); @@ -801,7 +801,7 @@ void SvxBitmapPickTabPage::ActivatePage(const SfxItemSet& rSet) } if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) { - pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); } if(pActNum && *pSaveNum != *pActNum) { @@ -861,7 +861,7 @@ void SvxBitmapPickTabPage::Reset( const SfxItemSet* rSet ) } DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); if(!pActNum) pActNum.reset( new SvxNumRule(*pSaveNum) ); @@ -1148,7 +1148,7 @@ void SvxNumOptionsTabPage::ActivatePage(const SfxItemSet& rSet) } if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) { - pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); } bModified = (!pActNum->Get( 0 ) || bPreset); @@ -1211,7 +1211,7 @@ void SvxNumOptionsTabPage::Reset( const SfxItemSet* rSet ) } DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); // insert levels if (!m_xLevelLB->n_children()) @@ -2758,7 +2758,7 @@ void SvxNumPositionTabPage::ActivatePage(const SfxItemSet& rSet) } if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) { - pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); } bModified = (!pActNum->Get( 0 ) || bPreset); if(*pSaveNum != *pActNum || @@ -2831,7 +2831,7 @@ void SvxNumPositionTabPage::Reset( const SfxItemSet* rSet ) } DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); // insert levels if (!m_xLevelLB->count_selected_rows()) diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx index fa7c00b85a99..624227a5f64e 100644 --- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx +++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx @@ -1528,7 +1528,7 @@ namespace accessibility if (rRes.Name == "NumberingLevel") { const SvxNumBulletItem& rNumBullet = rCacheTF.GetParaAttribs(GetParagraphIndex()).Get(EE_PARA_NUMBULLET); - if(rNumBullet.GetNumRule()->GetLevelCount()==0) + if(rNumBullet.GetNumRule().GetLevelCount()==0) { rRes.Value <<= sal_Int16(-1); rRes.Handle = -1; diff --git a/editeng/source/editeng/editdbg.cxx b/editeng/source/editeng/editdbg.cxx index 18b5747bb5bf..d2a97cdb0efa 100644 --- a/editeng/source/editeng/editdbg.cxx +++ b/editeng/source/editeng/editdbg.cxx @@ -83,7 +83,7 @@ static OString DbgOutItem(const SfxItemPool& rPool, const SfxPoolItem& rItem) aDebStr.append("Level"); aDebStr.append(static_cast<sal_Int32>(nLevel)); aDebStr.append('='); - const SvxNumberFormat* pFmt = static_cast<const SvxNumBulletItem&>(rItem).GetNumRule()->Get( nLevel ); + const SvxNumberFormat* pFmt = static_cast<const SvxNumBulletItem&>(rItem).GetNumRule().Get( nLevel ); if ( pFmt ) { aDebStr.append('('); diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx index 66e7824d278a..ba935384eb31 100644 --- a/editeng/source/items/numitem.cxx +++ b/editeng/source/items/numitem.cxx @@ -638,6 +638,21 @@ SvxNumRule::SvxNumRule(const SvxNumRule& rCopy) } } +SvxNumRule::SvxNumRule(SvxNumRule&& rCopy) +{ + ++nRefCount; + nLevelCount = rCopy.nLevelCount ; + nFeatureFlags = rCopy.nFeatureFlags ; + bContinuousNumbering = rCopy.bContinuousNumbering; + eNumberingType = rCopy.eNumberingType; + for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++) + { + if(rCopy.aFmts[i]) + aFmts[i] = std::move(rCopy.aFmts[i]); + aFmtsSet[i] = rCopy.aFmtsSet[i]; + } +} + SvxNumRule::SvxNumRule( SvStream &rStream ) : nLevelCount(0) { @@ -759,6 +774,24 @@ SvxNumRule& SvxNumRule::operator=( const SvxNumRule& rCopy ) return *this; } +SvxNumRule& SvxNumRule::operator=( SvxNumRule&& rCopy ) +{ + if (this != &rCopy) + { + nLevelCount = rCopy.nLevelCount; + nFeatureFlags = rCopy.nFeatureFlags; + bContinuousNumbering = rCopy.bContinuousNumbering; + eNumberingType = rCopy.eNumberingType; + for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++) + { + if(rCopy.aFmts[i]) + aFmts[i] = std::move(rCopy.aFmts[i]); + aFmtsSet[i] = rCopy.aFmtsSet[i]; + } + } + return *this; +} + bool SvxNumRule::operator==( const SvxNumRule& rCopy) const { if(nLevelCount != rCopy.nLevelCount || @@ -927,19 +960,19 @@ void SvxNumRule::UnLinkGraphics() SvxNumBulletItem::SvxNumBulletItem(SvxNumRule const & rRule) : SfxPoolItem(SID_ATTR_NUMBERING_RULE), - pNumRule(new SvxNumRule(rRule)) + maNumRule(rRule) { } SvxNumBulletItem::SvxNumBulletItem(SvxNumRule const & rRule, sal_uInt16 _nWhich ) : SfxPoolItem(_nWhich), - pNumRule(new SvxNumRule(rRule)) + maNumRule(rRule) { } SvxNumBulletItem::SvxNumBulletItem(const SvxNumBulletItem& rCopy) : SfxPoolItem(rCopy), - pNumRule(new SvxNumRule(*rCopy.pNumRule)) + maNumRule(rCopy.maNumRule) { } @@ -950,7 +983,7 @@ SvxNumBulletItem::~SvxNumBulletItem() bool SvxNumBulletItem::operator==( const SfxPoolItem& rCopy) const { return SfxPoolItem::operator==(rCopy) && - *pNumRule == *static_cast<const SvxNumBulletItem&>(rCopy).pNumRule; + maNumRule == static_cast<const SvxNumBulletItem&>(rCopy).maNumRule; } SvxNumBulletItem* SvxNumBulletItem::Clone( SfxItemPool * ) const @@ -960,7 +993,7 @@ SvxNumBulletItem* SvxNumBulletItem::Clone( SfxItemPool * ) const bool SvxNumBulletItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const { - rVal <<= SvxCreateNumRule( pNumRule.get() ); + rVal <<= SvxCreateNumRule( maNumRule ); return true; } @@ -971,14 +1004,13 @@ bool SvxNumBulletItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberI { try { - std::unique_ptr<SvxNumRule> pNewRule(new SvxNumRule( SvxGetNumRule( xRule ) )); - if( pNewRule->GetLevelCount() != pNumRule->GetLevelCount() || - pNewRule->GetNumRuleType() != pNumRule->GetNumRuleType() ) + SvxNumRule aNewRule( SvxGetNumRule( xRule ) ); + if( aNewRule.GetLevelCount() != maNumRule.GetLevelCount() || + aNewRule.GetNumRuleType() != maNumRule.GetNumRuleType() ) { - std::unique_ptr<SvxNumRule> pConverted = SvxConvertNumRule( pNewRule.get(), pNumRule->GetLevelCount(), pNumRule->GetNumRuleType() ); - pNewRule = std::move(pConverted); + aNewRule = SvxConvertNumRule( aNewRule, maNumRule.GetLevelCount(), maNumRule.GetNumRuleType() ); } - pNumRule = std::move( pNewRule ); + maNumRule = std::move( aNewRule ); return true; } catch(const lang::IllegalArgumentException&) @@ -992,19 +1024,19 @@ void SvxNumBulletItem::dumpAsXml(xmlTextWriterPtr pWriter) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxNumBulletItem")); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); - pNumRule->dumpAsXml(pWriter); + maNumRule.dumpAsXml(pWriter); (void)xmlTextWriterEndElement(pWriter); } -std::unique_ptr<SvxNumRule> SvxConvertNumRule( const SvxNumRule* pRule, sal_uInt16 nLevels, SvxNumRuleType eType ) +SvxNumRule SvxConvertNumRule( const SvxNumRule& rRule, sal_uInt16 nLevels, SvxNumRuleType eType ) { - const sal_uInt16 nSrcLevels = pRule->GetLevelCount(); - std::unique_ptr<SvxNumRule> pNewRule(new SvxNumRule( pRule->GetFeatureFlags(), nLevels, pRule->IsContinuousNumbering(), eType )); + const sal_uInt16 nSrcLevels = rRule.GetLevelCount(); + SvxNumRule aNewRule(rRule.GetFeatureFlags(), nLevels, rRule.IsContinuousNumbering(), eType ); for( sal_uInt16 nLevel = 0; (nLevel < nLevels) && (nLevel < nSrcLevels); nLevel++ ) - pNewRule->SetLevel( nLevel, pRule->GetLevel( nLevel ) ); + aNewRule.SetLevel( nLevel, rRule.GetLevel( nLevel ) ); - return pNewRule; + return aNewRule; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 8c74fe883345..9c474131352c 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -1389,8 +1389,8 @@ const SvxNumberFormat* Outliner::GetNumberFormat( sal_Int32 nPara ) const if( nDepth >= 0 ) { const SvxNumBulletItem& rNumBullet = pEditEngine->GetParaAttrib( nPara, EE_PARA_NUMBULLET ); - if ( rNumBullet.GetNumRule()->GetLevelCount() > nDepth ) - pFmt = rNumBullet.GetNumRule()->Get( nDepth ); + if ( rNumBullet.GetNumRule().GetLevelCount() > nDepth ) + pFmt = rNumBullet.GetNumRule().Get( nDepth ); } return pFmt; diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx index da1b2f6d51ec..aabe51c9efd8 100644 --- a/editeng/source/outliner/outlvw.cxx +++ b/editeng/source/outliner/outlvw.cxx @@ -851,7 +851,7 @@ void OutlinerView::ToggleBullets() const SfxItemSet aTmpSet(pOwner->pEditEngine->GetAttribs(aSelection)); const SfxPoolItem& rPoolItem = aTmpSet.GetPool()->GetDefaultItem( EE_PARA_NUMBULLET ); const SvxNumBulletItem* pNumBulletItem = dynamic_cast< const SvxNumBulletItem* >(&rPoolItem); - pDefaultBulletNumRule = pNumBulletItem ? pNumBulletItem->GetNumRule() : nullptr; + pDefaultBulletNumRule = pNumBulletItem ? &pNumBulletItem->GetNumRule() : nullptr; } } @@ -1034,17 +1034,17 @@ void OutlinerView::ApplyBulletsNumbering( const SvxNumBulletItem* pNumBulletItem = dynamic_cast< const SvxNumBulletItem* >(pPoolItem); if (pNumBulletItem) { - const sal_uInt16 nLevelCnt = std::min(pNumBulletItem->GetNumRule()->GetLevelCount(), aNewRule.GetLevelCount()); + const sal_uInt16 nLevelCnt = std::min(pNumBulletItem->GetNumRule().GetLevelCount(), aNewRule.GetLevelCount()); for ( sal_uInt16 nLevel = 0; nLevel < nLevelCnt; ++nLevel ) { - const SvxNumberFormat* pOldFmt = pNumBulletItem->GetNumRule()->Get(nLevel); + const SvxNumberFormat* pOldFmt = pNumBulletItem->GetNumRule().Get(nLevel); const SvxNumberFormat* pNewFmt = aNewRule.Get(nLevel); if (pOldFmt && pNewFmt && (pOldFmt->GetFirstLineOffset() != pNewFmt->GetFirstLineOffset() || pOldFmt->GetAbsLSpace() != pNewFmt->GetAbsLSpace())) { - std::unique_ptr<SvxNumberFormat> pNewFmtClone(new SvxNumberFormat(*pNewFmt)); - pNewFmtClone->SetFirstLineOffset(pOldFmt->GetFirstLineOffset()); - pNewFmtClone->SetAbsLSpace(pOldFmt->GetAbsLSpace()); - aNewRule.SetLevel(nLevel, pNewFmtClone.get()); + SvxNumberFormat aNewFmtClone(*pNewFmt); + aNewFmtClone.SetFirstLineOffset(pOldFmt->GetFirstLineOffset()); + aNewFmtClone.SetAbsLSpace(pOldFmt->GetAbsLSpace()); + aNewRule.SetLevel(nLevel, &aNewFmtClone); } } } diff --git a/editeng/source/uno/unonrule.cxx b/editeng/source/uno/unonrule.cxx index 5180f9d60fdf..9f861b7f9c2a 100644 --- a/editeng/source/uno/unonrule.cxx +++ b/editeng/source/uno/unonrule.cxx @@ -481,18 +481,9 @@ const SvxNumRule& SvxGetNumRule( Reference< XIndexReplace > const & xRule ) return pRule->getNumRule(); } -css::uno::Reference< css::container::XIndexReplace > SvxCreateNumRule(const SvxNumRule* pRule) +css::uno::Reference< css::container::XIndexReplace > SvxCreateNumRule(const SvxNumRule& rRule) { - DBG_ASSERT( pRule, "No default SvxNumRule!" ); - if( pRule ) - { - return new SvxUnoNumberingRules( *pRule ); - } - else - { - SvxNumRule aDefaultRule( SvxNumRuleFlags::BULLET_REL_SIZE | SvxNumRuleFlags::BULLET_COLOR, SVX_MAX_NUM, false); - return new SvxUnoNumberingRules( aDefaultRule ); - } + return new SvxUnoNumberingRules( rRule ); } namespace { @@ -554,7 +545,7 @@ Reference< XAnyCompare > SvxCreateNumRuleCompare() noexcept css::uno::Reference< css::container::XIndexReplace > SvxCreateNumRule() { SvxNumRule aTempRule( SvxNumRuleFlags::NONE, 10, false ); - return SvxCreateNumRule( &aTempRule ); + return SvxCreateNumRule( aTempRule ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index 341198369bac..c1bab48ffac8 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -6176,30 +6176,27 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet, std::optional< sal_Int16 >& rS aNumberFormat.SetIndentAt( 0 ); } SvxNumBulletItem aNewNumBulletItem( *pNumBulletItem ); - SvxNumRule* pRule = aNewNumBulletItem.GetNumRule(); - if ( pRule ) + SvxNumRule& rRule = aNewNumBulletItem.GetNumRule(); + rRule.SetLevel( mxParaSet->mnDepth, aNumberFormat ); + for (sal_uInt16 i = 0; i < rRule.GetLevelCount(); ++i) { - pRule->SetLevel( mxParaSet->mnDepth, aNumberFormat ); - for (sal_uInt16 i = 0; i < pRule->GetLevelCount(); ++i) + if ( i != mxParaSet->mnDepth ) { - if ( i != mxParaSet->mnDepth ) - { - sal_uInt16 n = sanitizeForMaxPPTLevels(i); - - SvxNumberFormat aNumberFormat2( pRule->GetLevel( i ) ); - const PPTParaLevel& rParaLevel = mrStyleSheet.mpParaSheet[ nInstance ]->maParaLevel[ n ]; - const PPTCharLevel& rCharLevel = mrStyleSheet.mpCharSheet[ nInstance ]->maCharLevel[ n ]; - sal_uInt32 nColor; - if ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BuHardColor ) ) - nColor = rParaLevel.mnBulletColor; - else - nColor = rCharLevel.mnFontColor; - aNumberFormat2.SetBulletColor( rManager.MSO_TEXT_CLR_ToColor( nColor ) ); - pRule->SetLevel( i, aNumberFormat2 ); - } + sal_uInt16 n = sanitizeForMaxPPTLevels(i); + + SvxNumberFormat aNumberFormat2( rRule.GetLevel( i ) ); + const PPTParaLevel& rParaLevel = mrStyleSheet.mpParaSheet[ nInstance ]->maParaLevel[ n ]; + const PPTCharLevel& rCharLevel = mrStyleSheet.mpCharSheet[ nInstance ]->maCharLevel[ n ]; + sal_uInt32 nColor; + if ( rParaLevel.mnBuFlags & ( 1 << PPT_ParaAttr_BuHardColor ) ) + nColor = rParaLevel.mnBulletColor; + else + nColor = rCharLevel.mnFontColor; + aNumberFormat2.SetBulletColor( rManager.MSO_TEXT_CLR_ToColor( nColor ) ); + rRule.SetLevel( i, aNumberFormat2 ); } - rSet.Put( aNewNumBulletItem ); } + rSet.Put( aNewNumBulletItem ); } } } diff --git a/include/editeng/numitem.hxx b/include/editeng/numitem.hxx index 52ca43b256f7..8b27c76c7dd1 100644 --- a/include/editeng/numitem.hxx +++ b/include/editeng/numitem.hxx @@ -266,6 +266,7 @@ public: eDefaultNumberFormatPositionAndSpaceMode = SvxNumberFormat::LABEL_WIDTH_AND_POSITION ); SvxNumRule(const SvxNumRule& rCopy); + SvxNumRule(SvxNumRule&&); SvxNumRule(SvStream &rStream); ~SvxNumRule(); @@ -273,6 +274,7 @@ public: bool operator!=( const SvxNumRule& rRule ) const {return !(*this == rRule);} SvxNumRule& operator=( const SvxNumRule& ); + SvxNumRule& operator=( SvxNumRule&& ); void Store(SvStream &rStream); void dumpAsXml(xmlTextWriterPtr pWriter) const; @@ -301,7 +303,7 @@ public: class EDITENG_DLLPUBLIC SvxNumBulletItem final : public SfxPoolItem { - std::unique_ptr<SvxNumRule> pNumRule; + SvxNumRule maNumRule; public: explicit SvxNumBulletItem(SvxNumRule const & rRule); SvxNumBulletItem(SvxNumRule const & rRule, sal_uInt16 nWhich ); @@ -311,7 +313,8 @@ public: virtual SvxNumBulletItem* Clone( SfxItemPool *pPool = nullptr ) const override; virtual bool operator==( const SfxPoolItem& ) const override; - SvxNumRule* GetNumRule() const {return pNumRule.get();} + const SvxNumRule& GetNumRule() const { return maNumRule; } + SvxNumRule& GetNumRule() { return maNumRule; } virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; @@ -345,7 +348,7 @@ inline SvxNodeNum& SvxNodeNum::operator=( const SvxNodeNum& rCpy ) return *this; } -std::unique_ptr<SvxNumRule> SvxConvertNumRule( const SvxNumRule* pRule, sal_uInt16 nLevel, SvxNumRuleType eType ); +SvxNumRule SvxConvertNumRule( const SvxNumRule& rRule, sal_uInt16 nLevel, SvxNumRuleType eType ); #endif diff --git a/include/editeng/unonrule.hxx b/include/editeng/unonrule.hxx index 5b84f31c980f..350a61939cc8 100644 --- a/include/editeng/unonrule.hxx +++ b/include/editeng/unonrule.hxx @@ -32,7 +32,7 @@ namespace com::sun::star::beans { struct PropertyValue; } -EDITENG_DLLPUBLIC css::uno::Reference< css::container::XIndexReplace > SvxCreateNumRule(const SvxNumRule* pRule); +EDITENG_DLLPUBLIC css::uno::Reference< css::container::XIndexReplace > SvxCreateNumRule(const SvxNumRule& rRule); css::uno::Reference< css::container::XIndexReplace > SvxCreateNumRule(); /// @throws css::lang::IllegalArgumentException const SvxNumRule& SvxGetNumRule( css::uno::Reference< css::container::XIndexReplace > const & xRule ); diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx index 46933ed8ab97..5af2c60edfde 100644 --- a/sc/source/ui/unoobj/styleuno.cxx +++ b/sc/source/ui/unoobj/styleuno.cxx @@ -1114,7 +1114,7 @@ void SAL_CALL ScStyleObj::setName( const OUString& aNewName ) uno::Reference<container::XIndexReplace> ScStyleObj::CreateEmptyNumberingRules() { SvxNumRule aRule( SvxNumRuleFlags::NONE, 0, true ); // nothing supported - return SvxCreateNumRule( &aRule ); + return SvxCreateNumRule( aRule ); } // beans::XPropertyState diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx index b5222c40f913..d30c204192d8 100644 --- a/sd/qa/unit/export-tests-ooxml1.cxx +++ b/sd/qa/unit/export-tests-ooxml1.cxx @@ -407,7 +407,7 @@ void SdOOXMLExportTest1::testN828390_5() CPPUNIT_ASSERT( pTxtObj ); const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); const SvxNumBulletItem& rNumFmt = aEdit.GetParaAttribs(3).Get(EE_PARA_NUMBULLET); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's relative size is wrong!", sal_uInt16(75), rNumFmt.GetNumRule()->GetLevel(1).GetBulletRelSize() ); // != 25 + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's relative size is wrong!", sal_uInt16(75), rNumFmt.GetNumRule().GetLevel(1).GetBulletRelSize() ); // != 25 } xDocShRef->DoClose(); @@ -724,7 +724,7 @@ void SdOOXMLExportTest1::testBulletStartNumber() const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's start number is wrong!", sal_Int16(3), sal_Int16(pNumFmt->GetNumRule()->GetLevel(0).GetStart()) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's start number is wrong!", sal_Int16(3), sal_Int16(pNumFmt->GetNumRule().GetLevel(0).GetStart()) ); xDocShRef->DoClose(); } @@ -828,7 +828,7 @@ void SdOOXMLExportTest1::testBulletColor() const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's color is wrong!", Color(0xff0000),pNumFmt->GetNumRule()->GetLevel(0).GetBulletColor()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's color is wrong!", Color(0xff0000),pNumFmt->GetNumRule().GetLevel(0).GetBulletColor()); xDocShRef->DoClose(); } @@ -874,8 +874,8 @@ void SdOOXMLExportTest1::testBulletMarginAndIndentation() const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's left margin is wrong!", sal_Int32(1000),pNumFmt->GetNumRule()->GetLevel(0).GetAbsLSpace() ); // left margin is 0.79 cm - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's indentation is wrong!", sal_Int32(-1000),pNumFmt->GetNumRule()->GetLevel(0). GetFirstLineOffset()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's left margin is wrong!", sal_Int32(1000),pNumFmt->GetNumRule().GetLevel(0).GetAbsLSpace() ); // left margin is 0.79 cm + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's indentation is wrong!", sal_Int32(-1000),pNumFmt->GetNumRule().GetLevel(0). GetFirstLineOffset()); xDocShRef->DoClose(); } diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 973503cc3b80..af1fb0e7d99a 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -2831,7 +2831,7 @@ void SdOOXMLExportTest2::testTdf126234() const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(400), pNumFmt->GetNumRule()->GetLevel(0).GetBulletRelSize()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(400), pNumFmt->GetNumRule().GetLevel(0).GetBulletRelSize()); xDocShRef->DoClose(); } diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 862f7e80c001..866542c717db 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -1563,7 +1563,7 @@ void SdImportTest::testBulletSuffix() const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(1).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's suffix is wrong!", pNumFmt->GetNumRule()->GetLevel(0).GetSuffix(), OUString() ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's suffix is wrong!", pNumFmt->GetNumRule().GetLevel(0).GetSuffix(), OUString() ); xDocShRef->DoClose(); } @@ -2255,7 +2255,7 @@ void SdImportTest::testTdf103477() const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's color is wrong!", Color(0x000000), pNumFmt->GetNumRule()->GetLevel(1).GetBulletColor()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's color is wrong!", Color(0x000000), pNumFmt->GetNumRule().GetLevel(1).GetBulletColor()); xDocShRef->DoClose(); } @@ -2729,7 +2729,7 @@ void SdImportTest::testTdf108925() const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(25), pNumFmt->GetNumRule()->GetLevel(0).GetBulletRelSize()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(25), pNumFmt->GetNumRule().GetLevel(0).GetBulletRelSize()); xDocShRef->DoClose(); } @@ -2807,7 +2807,7 @@ void SdImportTest::testTdf90626() { const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(i).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); - CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(372), pNumFmt->GetNumRule()->GetLevel(0).GetGraphicSize().getHeight(), tools::Long(1)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(372), pNumFmt->GetNumRule().GetLevel(0).GetGraphicSize().getHeight(), tools::Long(1)); } xDocShRef->DoClose(); @@ -2824,12 +2824,12 @@ void SdImportTest::testTdf138148() { const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(i).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); - CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(444), pNumFmt->GetNumRule()->GetLevel(0).GetGraphicSize().getHeight(), tools::Long(1)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(444), pNumFmt->GetNumRule().GetLevel(0).GetGraphicSize().getHeight(), tools::Long(1)); // Without the fix in place, this test would have failed with // - Expected: 148 // - Actual : 444 - CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(148), pNumFmt->GetNumRule()->GetLevel(0).GetGraphicSize().getWidth(), tools::Long(1)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(148), pNumFmt->GetNumRule().GetLevel(0).GetGraphicSize().getWidth(), tools::Long(1)); } xDocShRef->DoClose(); @@ -2891,7 +2891,7 @@ void SdImportTest::testTdf114913() CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj != nullptr); const SvxNumBulletItem *pItem = pTxtObj->GetOutlinerParaObject()->GetTextObject().GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pItem); - CPPUNIT_ASSERT_EQUAL(tools::Long(692), pItem->GetNumRule()->GetLevel(0).GetGraphicSize().getHeight()); + CPPUNIT_ASSERT_EQUAL(tools::Long(692), pItem->GetNumRule().GetLevel(0).GetGraphicSize().getHeight()); xDocShRef->DoClose(); } @@ -3069,9 +3069,9 @@ void SdImportTest::testTdf77747() CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj != nullptr); const SvxNumBulletItem *pNumFmt = pTxtObj->GetOutlinerParaObject()->GetTextObject().GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's suffix is wrong!", OUString("-"), pNumFmt->GetNumRule()->GetLevel(0).GetSuffix() ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's suffix is wrong!", OUString("-"), pNumFmt->GetNumRule().GetLevel(0).GetSuffix() ); CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's numbering type is wrong!", SVX_NUM_NUMBER_HEBREW, - pNumFmt->GetNumRule()->GetLevel(0).GetNumberingType()); + pNumFmt->GetNumRule().GetLevel(0).GetNumberingType()); xDocShRef->DoClose(); } @@ -3381,7 +3381,7 @@ void SdImportTest::testTdf49856() const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(2).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); - const sal_UCS4 aBullet = pNumFmt->GetNumRule()->GetLevel(0).GetBulletChar(); + const sal_UCS4 aBullet = pNumFmt->GetNumRule().GetLevel(0).GetBulletChar(); CPPUNIT_ASSERT_EQUAL(OUString("More level 2"), aEdit.GetText(2)); CPPUNIT_ASSERT_EQUAL(sal_UCS4(0x2022), aBullet); diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 0814abb2515d..de5e8d9133d9 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -1534,7 +1534,7 @@ void SdTiledRenderingTest::testTdf103083() pOutliner->GetStyleSheet(2)->GetName()); const EditTextObject& aEdit = pTextObject->GetOutlinerParaObject()->GetTextObject(); const SvxNumBulletItem* pNumFmt = aEdit.GetParaAttribs(2).GetItem(EE_PARA_NUMBULLET); - SvxNumberFormat aNumFmt(pNumFmt->GetNumRule()->GetLevel(2)); + SvxNumberFormat aNumFmt(pNumFmt->GetNumRule().GetLevel(2)); // cut contents of bullet item comphelper::dispatchCommand(".uno:Cut", uno::Sequence<beans::PropertyValue>()); @@ -1563,7 +1563,7 @@ void SdTiledRenderingTest::testTdf103083() const EditTextObject& aEdit2 = pTextObject->GetOutlinerParaObject()->GetTextObject(); const SvxNumBulletItem* pNumFmt2 = aEdit2.GetParaAttribs(2).GetItem(EE_PARA_NUMBULLET); - SvxNumberFormat aNumFmt2(pNumFmt2->GetNumRule()->GetLevel(2)); + SvxNumberFormat aNumFmt2(pNumFmt2->GetNumRule().GetLevel(2)); bool bEqual(aNumFmt2 == aNumFmt); CPPUNIT_ASSERT_MESSAGE("Bullet properties changed after paste", bEqual); diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx index f7744e353b40..d6256bd6f9ae 100644 --- a/sd/source/core/stlpool.cxx +++ b/sd/source/core/stlpool.cxx @@ -1107,7 +1107,7 @@ void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet, // Subtitle template SvxNumBulletItem const*const pItem( rSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET)); - SvxNumRule *const pDefaultRule = pItem ? pItem->GetNumRule() : nullptr; + const SvxNumRule *const pDefaultRule = pItem ? &pItem->GetNumRule() : nullptr; DBG_ASSERT( pDefaultRule, "Where is my default template? [CL]" ); if(pDefaultRule) diff --git a/sd/source/ui/dlg/BulletAndPositionDlg.cxx b/sd/source/ui/dlg/BulletAndPositionDlg.cxx index d298ec829a66..6ef27fd7de9a 100644 --- a/sd/source/ui/dlg/BulletAndPositionDlg.cxx +++ b/sd/source/ui/dlg/BulletAndPositionDlg.cxx @@ -229,7 +229,7 @@ SvxBulletAndPositionDlg::SvxBulletAndPositionDlg(weld::Window* pWindow, const Sf } if (SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) { - pSaveNum.reset(new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule())); + pSaveNum.reset(new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule())); } bModified = (!pActNum->Get(0) || bPreset); @@ -311,7 +311,7 @@ void SvxBulletAndPositionDlg::Reset(const SfxItemSet* rSet) } } DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset(new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule())); + pSaveNum.reset(new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule())); // insert levels if (!m_xLevelLB->n_children()) diff --git a/sd/source/ui/dlg/dlgolbul.cxx b/sd/source/ui/dlg/dlgolbul.cxx index 3943b050bb17..e82768d7dfa4 100644 --- a/sd/source/ui/dlg/dlgolbul.cxx +++ b/sd/source/ui/dlg/dlgolbul.cxx @@ -104,15 +104,12 @@ OutlineBulletDlg::OutlineBulletDlg(weld::Window* pParent, const SfxItemSet* pAtt if (m_bTitle && m_aInputSet.GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET ) { const SvxNumBulletItem* pItem = m_aInputSet.GetItem<SvxNumBulletItem>(EE_PARA_NUMBULLET); - SvxNumRule* pRule = pItem->GetNumRule(); - if(pRule) - { - SvxNumRule aNewRule( *pRule ); - aNewRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS ); + const SvxNumRule& rRule = pItem->GetNumRule(); + SvxNumRule aNewRule( rRule ); + aNewRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS ); - SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET ); - m_aInputSet.Put(aNewItem); - } + SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET ); + m_aInputSet.Put(aNewItem); } SetInputSet(&m_aInputSet); @@ -156,16 +153,15 @@ const SfxItemSet* OutlineBulletDlg::GetBulletOutputItemSet() const const SfxPoolItem *pItem = nullptr; if( SfxItemState::SET == m_xOutputSet->GetItemState(m_xOutputSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE), false, &pItem )) { - SdBulletMapper::MapFontsInNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule(), *m_xOutputSet); + SdBulletMapper::MapFontsInNumRule(const_cast<SvxNumRule&>(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()), *m_xOutputSet); // #i35937 - removed EE_PARA_BULLETSTATE setting } if (m_bTitle && m_xOutputSet->GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET) { const SvxNumBulletItem* pBulletItem = m_xOutputSet->GetItem<SvxNumBulletItem>(EE_PARA_NUMBULLET); - SvxNumRule* pRule = pBulletItem->GetNumRule(); - if(pRule) - pRule->SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS, false ); + SvxNumRule& rRule = const_cast<SvxNumRule&>(pBulletItem->GetNumRule()); + rRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS, false ); } return m_xOutputSet.get(); diff --git a/sd/source/ui/dlg/prltempl.cxx b/sd/source/ui/dlg/prltempl.cxx index 5b8ff1dab8d7..a741d9ba39c4 100644 --- a/sd/source/ui/dlg/prltempl.cxx +++ b/sd/source/ui/dlg/prltempl.cxx @@ -278,7 +278,7 @@ const SfxItemSet* SdPresLayoutTemplateDlg::GetOutputItemSet() const const SvxNumBulletItem *pSvxNumBulletItem = nullptr; if (SfxItemState::SET == pOutSet->GetItemState(EE_PARA_NUMBULLET, false, reinterpret_cast<const SfxPoolItem**>(&pSvxNumBulletItem))) - SdBulletMapper::MapFontsInNumRule( *pSvxNumBulletItem->GetNumRule(), *pOutSet ); + SdBulletMapper::MapFontsInNumRule( const_cast<SvxNumRule&>(pSvxNumBulletItem->GetNumRule()), *pOutSet ); return pOutSet.get(); } else diff --git a/sd/source/ui/func/fuolbull.cxx b/sd/source/ui/func/fuolbull.cxx index b8e141daad5d..13db35c73079 100644 --- a/sd/source/ui/func/fuolbull.cxx +++ b/sd/source/ui/func/fuolbull.cxx @@ -169,7 +169,7 @@ void FuBulletAndPosition::SetCurrentBulletsNumbering(SfxRequest& rReq) std::unique_ptr<SvxNumRule> pNumRule; if ( pTmpItem ) { - pNumRule.reset(new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pTmpItem)->GetNumRule())); + pNumRule.reset(new SvxNumRule(static_cast<const SvxNumBulletItem*>(pTmpItem)->GetNumRule())); // get numbering rule corresponding to <nIdx> and apply the needed number formats to <pNumRule> NBOTypeMgrBase* pNumRuleMgr = @@ -323,15 +323,12 @@ const SfxPoolItem* FuBulletAndPosition::GetNumBulletItem(SfxItemSet& aNewAttr, s if(bTitle && aNewAttr.GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET ) { const SvxNumBulletItem* pBulletItem = aNewAttr.GetItem(EE_PARA_NUMBULLET); - SvxNumRule* pLclRule = pBulletItem->GetNumRule(); - if(pLclRule) - { - SvxNumRule aNewRule( *pLclRule ); - aNewRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS ); + const SvxNumRule& rLclRule = pBulletItem->GetNumRule(); + SvxNumRule aNewRule( rLclRule ); + aNewRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS ); - SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET ); - aNewAttr.Put(aNewItem); - } + SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET ); + aNewAttr.Put(aNewItem); } SfxItemState eItemState = aNewAttr.GetItemState(nNumItemId, false, &pTmpItem); diff --git a/sd/source/ui/func/futempl.cxx b/sd/source/ui/func/futempl.cxx index e75a18b74782..a29fb21ab35c 100644 --- a/sd/source/ui/func/futempl.cxx +++ b/sd/source/ui/func/futempl.cxx @@ -407,7 +407,7 @@ void FuTemplate::DoExecute( SfxRequest& rReq ) { if (aTempSet.GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET) { - SvxNumRule aRule(*aTempSet.GetItem<SvxNumBulletItem>(EE_PARA_NUMBULLET)->GetNumRule()); + SvxNumRule aRule(aTempSet.GetItem<SvxNumBulletItem>(EE_PARA_NUMBULLET)->GetNumRule()); OUString sStyleName(SdResId(STR_PSEUDOSHEET_OUTLINE) + " 1"); SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( sStyleName, SfxStyleFamily::Pseudo); diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx index 4292978d85cf..09f37d6a2872 100644 --- a/sd/source/ui/view/drtxtob1.cxx +++ b/sd/source/ui/view/drtxtob1.cxx @@ -463,7 +463,7 @@ void TextObjectBar::Execute( SfxRequest &rReq ) if (pItem ) { - SvxNumRule aNewRule(*pItem->GetNumRule()); + SvxNumRule aNewRule(pItem->GetNumRule()); ESelection aSel = pOLV->GetSelection(); aSel.Adjust(); sal_Int32 nStartPara = aSel.nStartPara; diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx index fd5ecd53e008..08868977b473 100644 --- a/sd/source/ui/view/drviews3.cxx +++ b/sd/source/ui/view/drviews3.cxx @@ -838,10 +838,9 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) const SvxLRSpaceItem& rOrigLRSpaceItem = aEditAttr.Get( EE_PARA_LRSPACE ); const SvxNumBulletItem& rNumBulletItem = aEditAttr.Get( EE_PARA_NUMBULLET ); if( nOutlineLevel != -1 && - rNumBulletItem.GetNumRule() && - rNumBulletItem.GetNumRule()->GetLevelCount() > nOutlineLevel ) + rNumBulletItem.GetNumRule().GetLevelCount() > nOutlineLevel ) { - const SvxNumberFormat& rFormat = rNumBulletItem.GetNumRule()->GetLevel(nOutlineLevel); + const SvxNumberFormat& rFormat = rNumBulletItem.GetNumRule().GetLevel(nOutlineLevel); SvxNumberFormat aFormat(rFormat); // left margin gets distributed onto LRSpace item @@ -879,7 +878,7 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) if( rFormat != aFormat ) { // put all items - rNumBulletItem.GetNumRule()->SetLevel(nOutlineLevel,aFormat); + const_cast<SvxNumRule&>(rNumBulletItem.GetNumRule()).SetLevel(nOutlineLevel,aFormat); aEditAttr.Put( rNumBulletItem ); aEditAttr.Put( aLRSpaceItem ); mpDrawView->SetAttributes( aEditAttr ); @@ -968,10 +967,9 @@ void DrawViewShell::GetRulerState(SfxItemSet& rSet) const sal_Int16 nOutlineLevel = aEditAttr.Get( EE_PARA_OUTLLEVEL ).GetValue(); const SvxNumBulletItem& rNumBulletItem = aEditAttr.Get( EE_PARA_NUMBULLET ); if( nOutlineLevel != -1 && - rNumBulletItem.GetNumRule() && - rNumBulletItem.GetNumRule()->GetLevelCount() > nOutlineLevel ) + rNumBulletItem.GetNumRule().GetLevelCount() > nOutlineLevel ) { - const SvxNumberFormat& rFormat = rNumBulletItem.GetNumRule()->GetLevel(nOutlineLevel); + const SvxNumberFormat& rFormat = rNumBulletItem.GetNumRule().GetLevel(nOutlineLevel); aLRSpaceItem.SetTextLeft(rFormat.GetAbsLSpace() + rLRSpaceItem.GetTextLeft()); aLRSpaceItem.SetTextFirstLineOffset( rLRSpaceItem.GetTextFirstLineOffset() + rFormat.GetFirstLineOffset() diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx index 52955fc247cf..23bdffa57239 100644 --- a/sd/source/ui/view/drviewsf.cxx +++ b/sd/source/ui/view/drviewsf.cxx @@ -611,7 +611,7 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet ) pTmpItem=GetNumBulletItem(aNewAttr, nNumItemId); if (pTmpItem) - pNumRule.reset(new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pTmpItem)->GetNumRule())); + pNumRule.reset(new SvxNumRule(static_cast<const SvxNumBulletItem*>(pTmpItem)->GetNumRule())); if ( pNumRule ) { diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx index 890b9ddde1b2..7f481d9677bc 100644 --- a/sd/source/ui/view/viewshel.cxx +++ b/sd/source/ui/view/viewshel.cxx @@ -853,15 +853,12 @@ const SfxPoolItem* ViewShell::GetNumBulletItem(SfxItemSet& aNewAttr, sal_uInt16& if(bTitle && aNewAttr.GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET ) { const SvxNumBulletItem* pBulletItem = aNewAttr.GetItem(EE_PARA_NUMBULLET); - SvxNumRule* pRule = pBulletItem->GetNumRule(); - if(pRule) - { - SvxNumRule aNewRule( *pRule ); - aNewRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS ); + const SvxNumRule& rRule = pBulletItem->GetNumRule(); + SvxNumRule aNewRule( rRule ); + aNewRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS ); - SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET ); - aNewAttr.Put(aNewItem); - } + SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET ); + aNewAttr.Put(aNewItem); } SfxItemState eNumState = aNewAttr.GetItemState(nNumItemId, false, &pTmpItem); diff --git a/svx/source/unodraw/unomod.cxx b/svx/source/unodraw/unomod.cxx index 784fc59d2e83..5980da82d73d 100644 --- a/svx/source/unodraw/unomod.cxx +++ b/svx/source/unodraw/unomod.cxx @@ -663,18 +663,18 @@ css::uno::Reference< css::container::XIndexReplace > SvxCreateNumRule(SdrModel* const SvxNumBulletItem* pItem = pModel->GetItemPool().GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET); if( pItem ) { - pDefaultRule = pItem->GetNumRule(); + pDefaultRule = &pItem->GetNumRule(); } } if( pDefaultRule ) { - return SvxCreateNumRule( pDefaultRule ); + return SvxCreateNumRule( *pDefaultRule ); } else { SvxNumRule aTempRule( SvxNumRuleFlags::NONE, 10, false ); - return SvxCreateNumRule( &aTempRule ); + return SvxCreateNumRule( aTempRule ); } } diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx index 015812df184e..8b8d6bb3f63e 100644 --- a/sw/source/uibase/app/docstyle.cxx +++ b/sw/source/uibase/app/docstyle.cxx @@ -1640,10 +1640,10 @@ void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet, { case SfxItemState::SET: { - SvxNumRule* pSetRule = static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule(); - pSetRule->UnLinkGraphics(); + SvxNumRule& rSetRule = const_cast<SvxNumRule&>(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()); + rSetRule.UnLinkGraphics(); SwNumRule aSetRule(*m_pNumRule); - aSetRule.SetSvxRule(*pSetRule, &m_rDoc); + aSetRule.SetSvxRule(rSetRule, &m_rDoc); m_rDoc.ChgNumRuleFormats( aSetRule ); } break; diff --git a/sw/source/uibase/shells/txtnum.cxx b/sw/source/uibase/shells/txtnum.cxx index b75cc1c7dcbd..e1890bbd6f34 100644 --- a/sw/source/uibase/shells/txtnum.cxx +++ b/sw/source/uibase/shells/txtnum.cxx @@ -209,13 +209,13 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq) { pRequest->AppendItem(*pItem); pRequest->Done(); - SvxNumRule* pSetRule = static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule(); - pSetRule->UnLinkGraphics(); + SvxNumRule& rSetRule = const_cast<SvxNumRule&>(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()); + rSetRule.UnLinkGraphics(); SwNumRule aSetRule(pNumRuleAtCurrentSelection != nullptr ? pNumRuleAtCurrentSelection->GetName() : GetShell().GetUniqueNumRuleName(), numfunc::GetDefaultPositionAndSpaceMode()); - aSetRule.SetSvxRule(*pSetRule, GetShell().GetDoc()); + aSetRule.SetSvxRule(rSetRule, GetShell().GetDoc()); aSetRule.SetAutoRule(true); // No start of new list, if an existing list style is edited. // Otherwise start a new list. @@ -229,11 +229,11 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq) { pRequest->AppendItem(*pItem); pRequest->Done(); - SvxNumRule* pSetRule = static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule(); + const SvxNumRule& rSetRule = static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule(); SwNumRule aSetRule( GetShell().GetUniqueNumRuleName(), numfunc::GetDefaultPositionAndSpaceMode()); - aSetRule.SetSvxRule(*pSetRule, GetShell().GetDoc()); + aSetRule.SetSvxRule(rSetRule, GetShell().GetDoc()); aSetRule.SetAutoRule(true); // start new list GetShell().SetCurNumRule(aSetRule, true); |