From e3f402870dd26133b08b76fc77a93ec9e12c1315 Mon Sep 17 00:00:00 2001 From: Oliver-Rainer Wittmann Date: Wed, 29 May 2013 08:10:49 +0000 Subject: Resolves: #i122096# apply default bullet numbering rule on toggle on... if the current numbering rule is not a bullet numbering rule. - improve application default bullet numbering rule by add corresponding spacing to the first list level - refactoring of code introduced for paragraph property panel to handle toggle and set of bullets and numbering (cherry picked from commit 8c142809c7e16853d5634487cc9ed4e53caa3f91) Conflicts: editeng/inc/editeng/outliner.hxx editeng/source/outliner/outlin2.cxx editeng/source/outliner/outliner.cxx editeng/source/outliner/outlvw.cxx sd/source/ui/func/fuolbull.cxx Change-Id: If2807b2b81f8ade1e5b3282aa636cc2c0d8ea76a (cherry picked from commit 0ff751efaa49a5b3d22d324a43527bfd21e5a17c) --- sd/source/core/drawdoc4.cxx | 10 +- sd/source/ui/func/fuolbull.cxx | 358 +++++++++++++---------------------------- sd/source/ui/inc/View.hxx | 27 +++- sd/source/ui/inc/fuolbull.hxx | 4 +- sd/source/ui/view/drtxtob1.cxx | 2 +- sd/source/ui/view/sdview.cxx | 51 ++++-- 6 files changed, 179 insertions(+), 273 deletions(-) (limited to 'sd') diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx index 52dc47109979..040413c20f5b 100644 --- a/sd/source/core/drawdoc4.cxx +++ b/sd/source/core/drawdoc4.cxx @@ -1225,12 +1225,12 @@ void SdDrawDocument::SetTextDefaults() const SvxNumRule aNumRule( NUM_BULLET_REL_SIZE|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE, SVX_MAX_NUM, sal_False); - aNumberFormat.SetLSpace( 0 ); - aNumberFormat.SetAbsLSpace( 0 ); - aNumberFormat.SetFirstLineOffset( 0 ); - aNumRule.SetLevel( 0, aNumberFormat ); + //aNumberFormat.SetLSpace( 0 ); + //aNumberFormat.SetAbsLSpace( 0 ); + //aNumberFormat.SetFirstLineOffset( 0 ); + //aNumRule.SetLevel( 0, aNumberFormat ); - for( sal_uInt16 i = 1; i < aNumRule.GetLevelCount(); i++ ) + for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ ) { const short nLSpace = (i + 1) * 600; aNumberFormat.SetLSpace(nLSpace); diff --git a/sd/source/ui/func/fuolbull.cxx b/sd/source/ui/func/fuolbull.cxx index c029edabac7a..5bbf4e24c226 100644 --- a/sd/source/ui/func/fuolbull.cxx +++ b/sd/source/ui/func/fuolbull.cxx @@ -61,13 +61,10 @@ FunctionReference FuOutlineBullet::Create( ViewShell* pViewSh, ::sd::Window* pWi void FuOutlineBullet::DoExecute( SfxRequest& rReq ) { - sal_uInt16 nSId = rReq.GetSlot(); - if (nSId == FN_SVX_SET_BULLET){ - SetCurrentBullet(rReq); - return; - } - else if (nSId == FN_SVX_SET_NUMBER){ - SetCurrentNumbering(rReq); + const sal_uInt16 nSId = rReq.GetSlot(); + if ( nSId == FN_SVX_SET_BULLET || nSId == FN_SVX_SET_NUMBER ) + { + SetCurrentBulletsNumbering(rReq); return; } @@ -137,32 +134,44 @@ void FuOutlineBullet::DoExecute( SfxRequest& rReq ) */ } -void FuOutlineBullet::SetCurrentNumbering(SfxRequest& rReq) +void FuOutlineBullet::SetCurrentBulletsNumbering(SfxRequest& rReq) { if (!mpDoc || !mpView) return; - SfxItemSet aEditAttr( mpDoc->GetPool() ); - mpView->GetAttributes( aEditAttr ); + const sal_uInt16 nSId = rReq.GetSlot(); + if ( nSId != FN_SVX_SET_BULLET && nSId != FN_SVX_SET_NUMBER ) + { + // unexpected SfxRequest + return; + } - SfxItemSet aNewAttr( mpViewShell->GetPool(), - EE_ITEMS_START, EE_ITEMS_END ); - aNewAttr.Put( aEditAttr, sal_False ); + SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, nSId, sal_False ); + if ( !pItem ) + { + rReq.Done(); + return; + } - SfxItemSet aSetAttr( mpViewShell->GetPool(), - EE_ITEMS_START, EE_ITEMS_END ); + SfxItemSet aNewAttr( mpViewShell->GetPool(), EE_ITEMS_START, EE_ITEMS_END ); + { + SfxItemSet aEditAttr( mpDoc->GetPool() ); + mpView->GetAttributes( aEditAttr ); + aNewAttr.Put( aEditAttr, sal_False ); + } + const DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >(mpViewShell); //Init bullet level in "Customize" tab page in bullet dialog in master page view - if( mpView && mpViewShell && mpViewShell->ISA(DrawViewShell) - && ((DrawViewShell *)mpViewShell)->GetEditMode() == EM_MASTERPAGE ) + const bool bInMasterView = pDrawViewShell && pDrawViewShell->GetEditMode() == EM_MASTERPAGE; + if ( bInMasterView ) { SdrObject* pObj = mpView->GetTextEditObject(); if( pObj && pObj->GetObjIdentifier() == OBJ_OUTLINETEXT ) { - sal_uInt16 nLevel = mpView->GetSelectionLevel(); + const sal_uInt16 nLevel = mpView->GetSelectionLevel(); if( nLevel != 0xFFFF ) { - + //save the itemset value SfxItemSet aStoreSet( aNewAttr ); aNewAttr.ClearItem(); //extend range @@ -173,204 +182,52 @@ void FuOutlineBullet::SetCurrentNumbering(SfxRequest& rReq) } } } - //End of add - - sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF; - SvxNumRule* pNumRule = NULL; - const SfxPoolItem* pTmpItem=NULL; - sal_uInt32 nNumItemId = SID_ATTR_NUMBERING_RULE; - - if(SFX_ITEM_SET == aNewAttr.GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pTmpItem)) - nActNumLvl = ((const SfxUInt16Item*)pTmpItem)->GetValue(); - - pTmpItem=GetNumBulletItem(aNewAttr, nNumItemId); - - if (pTmpItem) - pNumRule = new SvxNumRule(*((SvxNumBulletItem*)pTmpItem)->GetNumRule()); - SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, FN_SVX_SET_NUMBER , sal_False ); - if (pItem && pNumRule) + sal_uInt16 nIdx = pItem->GetValue(); + bool bToggle = false; + bool bSwitchOff = false; + if( nIdx == (sal_uInt16)0xFFFF ) { - sal_uInt16 nIdx = pItem->GetValue(); // If the nIdx is (sal_uInt16)0xFFFF, means set bullet status to on/off - // And the bullet default status is 1. - bool bBulletSwitch = false; - sal_Bool isRemoveNum =false; - if( nIdx == (sal_uInt16)0xFFFF ) - { - nIdx = 1; - bBulletSwitch = true; - } - if (nIdx == DEFAULT_NONE) - { - bBulletSwitch = false; - isRemoveNum = true; - } - nIdx--; - - NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING); - if ( pNumbering ) - { - //Sym3_2508, set unit attribute to NB Manager - pNumbering->SetItems(&aNewAttr); - SvxNumRule aTmpRule( *pNumRule ); - pNumbering->ApplyNumRule(aTmpRule,nIdx,nActNumLvl); - sal_uInt16 nMask = 1; - for(sal_uInt16 i = 0; i < pNumRule->GetLevelCount(); i++) - { - if(nActNumLvl & nMask) - { - SvxNumberFormat aFmt(aTmpRule.GetLevel(i)); - pNumRule->SetLevel(i, aFmt); - } - nMask <<= 1 ; - } - aSetAttr.Put(SvxNumBulletItem( *pNumRule ), nNumItemId); - OutlinerView* pOLV = mpView->GetTextEditOutlinerView(); - - boost::scoped_ptr< OutlineViewModelChangeGuard > aGuard; - - if (mpView->ISA(OutlineView)) - { - pOLV = static_cast(mpView) - ->GetViewByWindow(mpViewShell->GetActiveWindow()); - - aGuard.reset( new OutlineViewModelChangeGuard( static_cast(*mpView) ) ); - } - - SdrOutliner* pOwner = mpView->GetTextEditOutliner(); - bool bMasterView = false; - - DrawViewShell* pDrawViewShell = static_cast< DrawViewShell* >(mpViewShell); - - if ( pOwner && pDrawViewShell && pDrawViewShell->GetEditMode() == EM_MASTERPAGE ) - bMasterView = !pOwner->IsInUndo() && pOwner->IsUndoEnabled(); - - if( bMasterView ) - { - pOwner->UndoActionStart( OLUNDO_ATTR ); - pOLV->ToggleBullets( bBulletSwitch, sal_False, bMasterView, pNumRule,isRemoveNum); - mpView->SetAttributes(aSetAttr); //Modify for Sym2_3151 - pOwner->UndoActionEnd( OLUNDO_ATTR ); - } - else if( pOLV ) - pOLV->ToggleBullets( bBulletSwitch, sal_False, bMasterView, pNumRule ,isRemoveNum); - else - { - sal_Bool bInMasterView = pDrawViewShell && pDrawViewShell->GetEditMode() == EM_MASTERPAGE; - SdrModel* pSdrModel = mpView->GetModel(); - sal_Bool bModelUndoEnabled = pSdrModel ? pSdrModel->IsUndoEnabled() : sal_False; - if (bInMasterView && bModelUndoEnabled) - { - pSdrModel->BegUndo(); - } - mpView->ToggleMarkedObjectsBullets(bBulletSwitch, sal_False, bInMasterView, pNumRule,isRemoveNum); - if (bInMasterView) - { - mpView->SetAttributes(aSetAttr); - } - if (bInMasterView && bModelUndoEnabled) - { - pSdrModel->EndUndo(); - } - } - } - //End + nIdx = 1; + bToggle = true; } - delete pNumRule; - rReq.Done(); -} - -void FuOutlineBullet::SetCurrentBullet(SfxRequest& rReq) -{ - if (!mpDoc || !mpView) - return; - - SfxItemSet aEditAttr( mpDoc->GetPool() ); - mpView->GetAttributes( aEditAttr ); - - SfxItemSet aNewAttr( mpViewShell->GetPool(), - EE_ITEMS_START, EE_ITEMS_END ); - aNewAttr.Put( aEditAttr, sal_False ); - - //Add for Sym2_3151, should add new attributes in an empty item set, then use this item set as parameter in SetAttributes() - SfxItemSet aSetAttr( mpViewShell->GetPool(), - EE_ITEMS_START, EE_ITEMS_END ); - - //Init bullet level in "Customize" tab page in bullet dialog in master page view - if( mpView && mpViewShell && mpViewShell->ISA(DrawViewShell) - && ((DrawViewShell *)mpViewShell)->GetEditMode() == EM_MASTERPAGE ) + else if (nIdx == DEFAULT_NONE) { - SdrObject* pObj = mpView->GetTextEditObject(); - if( pObj && pObj->GetObjIdentifier() == OBJ_OUTLINETEXT ) - { - sal_uInt16 nLevel = mpView->GetSelectionLevel(); - if( nLevel != 0xFFFF ) - { - //aNewAttr.MergeRange( SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL ); - //aNewAttr.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, nLevel ) ); - //save the itemset value - SfxItemSet aStoreSet( aNewAttr ); - aNewAttr.ClearItem(); - //extend range - aNewAttr.MergeRange( SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL ); - aNewAttr.Put( aStoreSet ); - //put current level user selected - aNewAttr.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, nLevel ) ); - } - } + bSwitchOff = true; } - //End of add + nIdx--; - sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF; - SvxNumRule* pNumRule = NULL; - const SfxPoolItem* pTmpItem=NULL; sal_uInt32 nNumItemId = SID_ATTR_NUMBERING_RULE; - - if(SFX_ITEM_SET == aNewAttr.GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pTmpItem)) - nActNumLvl = ((const SfxUInt16Item*)pTmpItem)->GetValue(); - - pTmpItem=GetNumBulletItem(aNewAttr, nNumItemId); - - if (pTmpItem) + const SfxPoolItem* pTmpItem = GetNumBulletItem( aNewAttr, nNumItemId ); + SvxNumRule* pNumRule = NULL; + if ( pTmpItem ) + { pNumRule = new SvxNumRule(*((SvxNumBulletItem*)pTmpItem)->GetNumRule()); - SFX_REQUEST_ARG( rReq, pItem, SfxUInt16Item, FN_SVX_SET_BULLET , sal_False ); - if (pItem && pNumRule) - { - sal_uInt16 nIdx = pItem->GetValue(); - // If the nIdx is (sal_uInt16)0xFFFF, means set bullet status to on/off - // And the bullet default status is 2. - bool bBulletSwitch = false; - sal_Bool isRemoveNum =false; - if( nIdx == (sal_uInt16)0xFFFF ) + // get numbering rule corresponding to and apply the needed number formats to + NBOTypeMgrBase* pNumRuleMgr = + NBOutlineTypeMgrFact::CreateInstance( + nSId == FN_SVX_SET_BULLET ? eNBOType::MIXBULLETS : eNBOType::NUMBERING ); + if ( pNumRuleMgr ) { - nIdx = 1; - bBulletSwitch = true; - } - if (nIdx == DEFAULT_NONE) - { - bBulletSwitch = false; - isRemoveNum = true; - } - - nIdx--; - //Modified for Numbering&Bullets Dialog UX Enh(Story 992) by chengjh,2011.8.7 + sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF; + const SfxPoolItem* pNumLevelItem = NULL; + if(SFX_ITEM_SET == aNewAttr.GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pNumLevelItem)) + nActNumLvl = ((const SfxUInt16Item*)pNumLevelItem)->GetValue(); - NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS); - if ( pBullets ) - { - //Sym3_2508, set unit attribute to NB Manager - pBullets->SetItems(&aNewAttr); + pNumRuleMgr->SetItems(&aNewAttr); SvxNumRule aTmpRule( *pNumRule ); - //Sym3_3423 Always apply the "." if wants a default numbering rule - if (bBulletSwitch==true && nIdx==0) //want to reset bullet + if ( nSId == FN_SVX_SET_BULLET && bToggle && nIdx==0 ) { - pBullets->ApplyNumRule(aTmpRule,nIdx,nActNumLvl,true); + // for toggling bullets get default numbering rule + pNumRuleMgr->ApplyNumRule( aTmpRule, nIdx, nActNumLvl, true ); } - else { - pBullets->ApplyNumRule(aTmpRule,nIdx,nActNumLvl); + else + { + pNumRuleMgr->ApplyNumRule( aTmpRule, nIdx, nActNumLvl ); } + sal_uInt16 nMask = 1; for(sal_uInt16 i = 0; i < pNumRule->GetLevelCount(); i++) { @@ -381,59 +238,66 @@ void FuOutlineBullet::SetCurrentBullet(SfxRequest& rReq) } nMask <<= 1; } - aSetAttr.Put(SvxNumBulletItem( *pNumRule ), nNumItemId); - - OutlinerView* pOLV = mpView->GetTextEditOutlinerView(); - - boost::scoped_ptr< OutlineViewModelChangeGuard > aGuard; - - if (mpView->ISA(OutlineView)) - { - pOLV = static_cast(mpView) - ->GetViewByWindow(mpViewShell->GetActiveWindow()); + } + } - aGuard.reset( new OutlineViewModelChangeGuard( static_cast(*mpView) ) ); - } + OutlinerView* pOLV = mpView->GetTextEditOutlinerView(); + boost::scoped_ptr< OutlineViewModelChangeGuard > aGuard; + { + if (mpView->ISA(OutlineView)) + { + pOLV = static_cast(mpView) + ->GetViewByWindow(mpViewShell->GetActiveWindow()); - SdrOutliner* pOwner = mpView->GetTextEditOutliner(); - bool bMasterView = false; + aGuard.reset( new OutlineViewModelChangeGuard( static_cast(*mpView) ) ); + } + } - DrawViewShell* pDrawViewShell = static_cast< DrawViewShell* >(mpViewShell); + SdrOutliner* pOwner = bInMasterView ? mpView->GetTextEditOutliner() : 0; + const bool bOutlinerUndoEnabled = pOwner && !pOwner->IsInUndo() && pOwner->IsUndoEnabled(); + SdrModel* pSdrModel = bInMasterView ? mpView->GetModel() : 0; + const bool bModelUndoEnabled = pSdrModel && pSdrModel->IsUndoEnabled(); - if ( pOwner && pDrawViewShell && pDrawViewShell->GetEditMode() == EM_MASTERPAGE ) - bMasterView = !pOwner->IsInUndo() && pOwner->IsUndoEnabled(); + if ( bOutlinerUndoEnabled ) + { + pOwner->UndoActionStart( OLUNDO_ATTR ); + } + else if ( bModelUndoEnabled ) + { + pSdrModel->BegUndo(); + } - if( bMasterView ) - { - pOwner->UndoActionStart( OLUNDO_ATTR ); - pOLV->ToggleBullets( bBulletSwitch, sal_True, bMasterView, pNumRule, isRemoveNum ); - mpView->SetAttributes(aSetAttr); //Modify for Sym2_3151 - pOwner->UndoActionEnd( OLUNDO_ATTR ); - } - else if( pOLV ) - pOLV->ToggleBullets( bBulletSwitch, sal_True, bMasterView, pNumRule, isRemoveNum ); - else - { - sal_Bool bInMasterView = pDrawViewShell && pDrawViewShell->GetEditMode() == EM_MASTERPAGE; - SdrModel* pSdrModel = mpView->GetModel(); - sal_Bool bModelUndoEnabled = pSdrModel ? pSdrModel->IsUndoEnabled() : sal_False; - if (bInMasterView && bModelUndoEnabled) - { - pSdrModel->BegUndo(); - } - mpView->ToggleMarkedObjectsBullets(bBulletSwitch, sal_True, bInMasterView, pNumRule, isRemoveNum ); - if (bInMasterView) - { - mpView->SetAttributes(aSetAttr); - } - if (bInMasterView && bModelUndoEnabled) - { - pSdrModel->EndUndo(); - } - } + if ( pOLV ) + { + if ( bSwitchOff ) + { + pOLV->SwitchOffBulletsNumbering( true ); } - //End + else + { + pOLV->ToggleBulletsNumbering( bToggle, nSId == FN_SVX_SET_BULLET, bInMasterView ? 0 : pNumRule ); + } + } + else + { + mpView->ChangeMarkedObjectsBulletsNumbering( bToggle, nSId == FN_SVX_SET_BULLET, bInMasterView ? 0 : pNumRule, bSwitchOff ); + } + if ( bInMasterView ) + { + SfxItemSet aSetAttr( mpViewShell->GetPool(), EE_ITEMS_START, EE_ITEMS_END ); + aSetAttr.Put(SvxNumBulletItem( *pNumRule ), nNumItemId); + mpView->SetAttributes(aSetAttr); } + + if( bOutlinerUndoEnabled ) + { + pOwner->UndoActionEnd( OLUNDO_ATTR ); + } + else if ( bModelUndoEnabled ) + { + pSdrModel->EndUndo(); + } + delete pNumRule; rReq.Done(); } diff --git a/sd/source/ui/inc/View.hxx b/sd/source/ui/inc/View.hxx index 6fc9dd178e09..03e2de29b655 100644 --- a/sd/source/ui/inc/View.hxx +++ b/sd/source/ui/inc/View.hxx @@ -194,8 +194,31 @@ public: virtual void CheckPossibilities(); virtual sal_Bool MarkPoints(const ::Rectangle* pRect, sal_Bool bUnmark); using SdrMarkView::MarkPoints; - sal_Bool ShouldToggleOn(sal_Bool bBulletOnOffMode, sal_Bool bNormalBullet); - void ToggleMarkedObjectsBullets(sal_Bool bBulletOnOffMode, sal_Bool bNormalBullet, sal_Bool bMasterView, SvxNumRule* pNumRule = NULL, sal_Bool bForceBulletOnOff = false); + + bool ShouldToggleOn( + const bool bBulletOnOffMode, + const bool bNormalBullet); + + /** change the bullets/numbering of the marked objects + + @param bToggle + true: just toggle the current bullets/numbering on --> off resp. off --> on + + @param bHandleBullets + true: handle bullets + false: handle numbering + + @param pNumRule + numbering rule which needs to be applied. can be 0. + + @param bSwitchOff + true: switch off bullets/numbering + */ + void ChangeMarkedObjectsBulletsNumbering( + const bool bToggle, + const bool bHandleBullets, + const SvxNumRule* pNumRule, + const bool bSwitchOff); void SetPossibilitiesDirty() { bPossibilitiesDirty = true; } void SetMoveAllowed( bool bSet ) { bMoveAllowed = bSet; } diff --git a/sd/source/ui/inc/fuolbull.hxx b/sd/source/ui/inc/fuolbull.hxx index 995cda6b9e86..96977b96a2eb 100644 --- a/sd/source/ui/inc/fuolbull.hxx +++ b/sd/source/ui/inc/fuolbull.hxx @@ -44,8 +44,6 @@ public: static FunctionReference Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq ); virtual void DoExecute( SfxRequest& rReq ); - void SetCurrentBullet(SfxRequest& rReq); - void SetCurrentNumbering(SfxRequest& rReq); private: FuOutlineBullet ( @@ -55,6 +53,8 @@ private: SdDrawDocument* pDoc, SfxRequest& rReq); + void SetCurrentBulletsNumbering(SfxRequest& rReq); + const SfxPoolItem* GetNumBulletItem(SfxItemSet& aNewAttr, sal_uInt32& nNumItemId); }; diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx index 20fcad0af901..572fbed1b854 100644 --- a/sd/source/ui/view/drtxtob1.cxx +++ b/sd/source/ui/view/drtxtob1.cxx @@ -318,7 +318,7 @@ void TextObjectBar::Execute( SfxRequest &rReq ) case FN_NUM_BULLET_ON: if( pOLV ) pOLV->ToggleBullets(); - break; + break; case SID_GROW_FONT_SIZE: case SID_SHRINK_FONT_SIZE: diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index ae233e96d612..bf342e0ea476 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -1230,7 +1230,9 @@ void View::OnEndPasteOrDrop( PasteOrDropInfos* pInfos ) } } -sal_Bool View::ShouldToggleOn(sal_Bool bBulletOnOffMode, sal_Bool bNormalBullet) +bool View::ShouldToggleOn( + const bool bBulletOnOffMode, + const bool bNormalBullet) { // If setting bullets/numbering by the dialog, always should toggle on. if (!bBulletOnOffMode) @@ -1294,23 +1296,29 @@ sal_Bool View::ShouldToggleOn(sal_Bool bBulletOnOffMode, sal_Bool bNormalBullet) return bToggleOn; } -void View::ToggleMarkedObjectsBullets(sal_Bool bBulletOnOffMode, sal_Bool bNormalBullet, sal_Bool bMasterView, SvxNumRule* pNumRule, sal_Bool bForceBulletOnOff) +void View::ChangeMarkedObjectsBulletsNumbering( + const bool bToggle, + const bool bHandleBullets, + const SvxNumRule* pNumRule, + const bool bSwitchOff ) { SdrModel* pSdrModel = GetModel(); Window* pWindow = dynamic_cast< Window* >(GetFirstOutputDevice()); if (!pSdrModel || !pWindow) return; - sal_Bool bUndoEnabled = pSdrModel->IsUndoEnabled(); - sal_Bool bToggleOn = ShouldToggleOn(bBulletOnOffMode, bNormalBullet); - if ( bForceBulletOnOff ) { - bToggleOn = bBulletOnOffMode; - } - SdrUndoGroup* pUndoGroup = new SdrUndoGroup(*pSdrModel); + const bool bUndoEnabled = pSdrModel->IsUndoEnabled(); + SdrUndoGroup* pUndoGroup = bUndoEnabled ? new SdrUndoGroup(*pSdrModel) : 0; + + const bool bToggleOn = + bSwitchOff + ? false + : ShouldToggleOn( bToggle, bHandleBullets ); + SdrOutliner* pOutliner = SdrMakeOutliner(OUTLINERMODE_TEXTOBJECT, pSdrModel); OutlinerView* pOutlinerView = new OutlinerView(pOutliner, pWindow); - sal_uInt32 nMarkCount = GetMarkedObjectCount(); + const sal_uInt32 nMarkCount = GetMarkedObjectCount(); for (sal_uInt32 nIndex = 0; nIndex < nMarkCount; nIndex++) { SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(GetMarkedObjectByIndex(nIndex)); @@ -1348,7 +1356,14 @@ void View::ToggleMarkedObjectsBullets(sal_Bool bBulletOnOffMode, sal_Bool bNorma SdrUndoObjSetText* pTxtUndo = dynamic_cast< SdrUndoObjSetText* >(pSdrModel->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, nCellIndex)); pUndoGroup->AddAction(pTxtUndo); } - pOutlinerView->ToggleAllParagraphsBullets(bBulletOnOffMode, bNormalBullet, bToggleOn, bMasterView, pNumRule); + if ( !bToggleOn ) + { + pOutlinerView->SwitchOffBulletsNumbering(); + } + else + { + pOutlinerView->ApplyBulletsNumbering( bHandleBullets, pNumRule, bToggle ); + } sal_uInt32 nParaCount = pOutliner->GetParagraphCount(); pText->SetOutlinerParaObject(pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount)); pOutliner->Clear(); @@ -1372,23 +1387,27 @@ void View::ToggleMarkedObjectsBullets(sal_Bool bBulletOnOffMode, sal_Bool bNorma SdrUndoObjSetText* pTxtUndo = dynamic_cast< SdrUndoObjSetText* >(pSdrModel->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, 0)); pUndoGroup->AddAction(pTxtUndo); } - pOutlinerView->ToggleAllParagraphsBullets(bBulletOnOffMode, bNormalBullet, bToggleOn, bMasterView, pNumRule); + if ( !bToggleOn ) + { + pOutlinerView->SwitchOffBulletsNumbering(); + } + else + { + pOutlinerView->ApplyBulletsNumbering( bHandleBullets, pNumRule, bToggle ); + } sal_uInt32 nParaCount = pOutliner->GetParagraphCount(); pTextObj->SetOutlinerParaObject(pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount)); pOutliner->Clear(); } } - if (pUndoGroup->GetActionCount() > 0 && bUndoEnabled) + if ( bUndoEnabled && pUndoGroup->GetActionCount() > 0 ) { pSdrModel->BegUndo(); pSdrModel->AddUndo(pUndoGroup); pSdrModel->EndUndo(); } - else - { - delete pUndoGroup; - } + delete pOutliner; delete pOutlinerView; } -- cgit