diff options
author | Oliver-Rainer Wittmann <orw@apache.org> | 2013-05-29 08:10:49 +0000 |
---|---|---|
committer | Oliver-Rainer Wittmann <orw@apache.org> | 2013-05-29 08:10:49 +0000 |
commit | 8c142809c7e16853d5634487cc9ed4e53caa3f91 (patch) | |
tree | beab81202f97ed1f7f255a7904e030ff482ee595 | |
parent | b3f8a9ea7eeee58bcabedd3c296d0758d1ef5a8b (diff) |
122096: - <OutlinerView::ToggleBullets()> - apply default bullet numbering rule on toggle on, if the current numbering r
ule 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
Notes
merged as: 0ff751efaa49a5b3d22d324a43527bfd21e5a17c
-rw-r--r-- | editeng/inc/editeng/outliner.hxx | 81 | ||||
-rw-r--r-- | editeng/source/outliner/outleeng.cxx | 2 | ||||
-rw-r--r-- | editeng/source/outliner/outlin2.cxx | 2 | ||||
-rw-r--r-- | editeng/source/outliner/outliner.cxx | 87 | ||||
-rw-r--r-- | editeng/source/outliner/outlvw.cxx | 454 | ||||
-rw-r--r-- | sd/source/core/drawdoc4.cxx | 10 | ||||
-rw-r--r-- | sd/source/ui/func/fuolbull.cxx | 358 | ||||
-rw-r--r-- | sd/source/ui/inc/View.hxx | 27 | ||||
-rw-r--r-- | sd/source/ui/inc/fuolbull.hxx | 4 | ||||
-rw-r--r-- | sd/source/ui/view/drtxtob1.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/view/sdview.cxx | 51 | ||||
-rwxr-xr-x | svx/source/sidebar/paragraph/ParaPropertyPanel.cxx | 91 |
12 files changed, 537 insertions, 632 deletions
diff --git a/editeng/inc/editeng/outliner.hxx b/editeng/inc/editeng/outliner.hxx index 2c2d22df437d..5e5277a1b61e 100644 --- a/editeng/inc/editeng/outliner.hxx +++ b/editeng/inc/editeng/outliner.hxx @@ -368,12 +368,44 @@ public: const SvxFieldItem* GetFieldUnderMousePointer( sal_uInt16& nPara, xub_StrLen& nPos ) const; const SvxFieldItem* GetFieldAtSelection() const; - /** enables numbering for the selected paragraphs if the numbering of the first paragraph is off - or disables numbering for the selected paragraphs if the numbering of the first paragraph is on + /** enables bullets for the selected paragraphs if the bullets/numbering of the first paragraph is off + or disables bullets/numbering for the selected paragraphs if the bullets/numbering of the first paragraph is on */ - void ToggleBullets(); - sal_Bool ToggleBullets(sal_Bool bBulletOnOff, sal_Bool bNormalBullet, sal_Bool bMasterView, SvxNumRule* pNumRule = NULL, sal_Bool bForceBulletOnOff = false); - sal_Bool ToggleAllParagraphsBullets(sal_Bool bBulletOnOffMode, sal_Bool bNormalBullet, sal_Bool bToggleOn, sal_Bool bMasterView, SvxNumRule* pNumRule = NULL); + void ToggleBullets(); + + void ToggleBulletsNumbering( + const bool bToggle, + const bool bHandleBullets, + const SvxNumRule* pNumRule = NULL ); + + /** apply bullets/numbering for paragraphs + + @param boolean bHandleBullets + true: handle bullets + false: handle numbering + + @param pNewNumRule + numbering rule which needs to be applied. can be 0. + + @param boolean bAtSelection + true: apply bullets/numbering at selected paragraphs + false: apply bullets/numbering at all paragraphs + */ + void ApplyBulletsNumbering( + const bool bHandleBullets, + const SvxNumRule* pNewNumRule, + const bool bCheckCurrentNumRuleBeforeApplyingNewNumRule, + const bool bAtSelection = false ); + + /** switch off bullets/numbering for paragraphs + + @param boolean bAtSelection + true: switch off bullets/numbering at selected paragraphs + false: switch off bullets/numbering at all paragraphs + */ + void SwitchOffBulletsNumbering( + const bool bAtSelection = false ); + /** enables numbering for the selected paragraphs that are not enabled and ignore all selected paragraphs that already have numbering enabled. */ @@ -648,15 +680,16 @@ class EDITENG_DLLPUBLIC Outliner : public SfxBroadcaster DECL_LINK( BeginPasteOrDropHdl, PasteOrDropInfos* ); DECL_LINK( EndPasteOrDropHdl, PasteOrDropInfos* ); DECL_LINK( EditEngineNotifyHdl, EENotify* ); - void ImplCheckParagraphs( sal_uInt16 nStart, sal_uInt16 nEnd ); - sal_Bool ImplHasBullet( sal_uInt16 nPara ) const; - Size ImplGetBulletSize( sal_uInt16 nPara ); - sal_uInt16 ImplGetNumbering( sal_uInt16 nPara, const SvxNumberFormat* pParaFmt ); - void ImplCalcBulletText( sal_uInt16 nPara, sal_Bool bRecalcLevel, sal_Bool bRecalcChilds ); - String ImplGetBulletText( sal_uInt16 nPara ); - void ImplCheckNumBulletItem( sal_uInt16 nPara ); - void ImplInitDepth( sal_uInt16 nPara, sal_Int16 nDepth, sal_Bool bCreateUndo, sal_Bool bUndoAction = sal_False ); - void ImplSetLevelDependendStyleSheet( sal_uInt16 nPara, SfxStyleSheet* pLevelStyle = NULL ); + + void ImplCheckParagraphs( sal_uInt16 nStart, sal_uInt16 nEnd ); + bool ImplHasNumberFormat( sal_uInt16 nPara ) const; + Size ImplGetBulletSize( sal_uInt16 nPara ); + sal_uInt16 ImplGetNumbering( sal_uInt16 nPara, const SvxNumberFormat* pParaFmt ); + void ImplCalcBulletText( sal_uInt16 nPara, sal_Bool bRecalcLevel, sal_Bool bRecalcChilds ); + String ImplGetBulletText( sal_uInt16 nPara ); + void ImplCheckNumBulletItem( sal_uInt16 nPara ); + void ImplInitDepth( sal_uInt16 nPara, sal_Int16 nDepth, sal_Bool bCreateUndo, sal_Bool bUndoAction = sal_False ); + void ImplSetLevelDependendStyleSheet( sal_uInt16 nPara, SfxStyleSheet* pLevelStyle = NULL ); void ImplBlockInsertionCallbacks( sal_Bool b ); @@ -1051,7 +1084,25 @@ public: virtual sal_Bool IsParaIsNumberingRestart( sal_uInt16 nPara ); virtual void SetParaIsNumberingRestart( sal_uInt16 nPara, sal_Bool bParaIsNumberingRestart ); - sal_Int16 GetBulletsNumberingStatus(); + /** determine the bullets/numbering status of the given paragraphs + + @param nParaStart + index of paragraph at which the check starts + + @param nParaEnd + index of paragraph at which the check ends + + @returns + 0 : all paragraphs have bullets + 1 : all paragraphs have numbering + 2 : otherwise + */ + sal_Int16 GetBulletsNumberingStatus( + const sal_uInt16 nParaStart, + const sal_uInt16 nParaEnd ) const; + + // convenient method to determine the bullets/numbering status for all paragraphs + sal_Int16 GetBulletsNumberingStatus() const; }; #endif diff --git a/editeng/source/outliner/outleeng.cxx b/editeng/source/outliner/outleeng.cxx index 9351cbcbae49..3825c87c2109 100644 --- a/editeng/source/outliner/outleeng.cxx +++ b/editeng/source/outliner/outleeng.cxx @@ -76,7 +76,7 @@ Rectangle OutlinerEditEng::GetBulletArea( sal_uInt16 nPara ) Rectangle aBulletArea = Rectangle( Point(), Point() ); if ( nPara < pOwner->pParaList->GetParagraphCount() ) { - if ( pOwner->ImplHasBullet( nPara ) ) + if ( pOwner->ImplHasNumberFormat( nPara ) ) aBulletArea = pOwner->ImpCalcBulletArea( nPara, sal_False, sal_False ); } return aBulletArea; diff --git a/editeng/source/outliner/outlin2.cxx b/editeng/source/outliner/outlin2.cxx index 9566a2ff128b..3c514d86dc72 100644 --- a/editeng/source/outliner/outlin2.cxx +++ b/editeng/source/outliner/outlin2.cxx @@ -599,7 +599,7 @@ sal_Bool Outliner::IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder, sal_Bo { Point aDocPos = GetDocPos( rPaperPos ); sal_uInt16 nPara = pEditEngine->FindParagraph( aDocPos.Y() ); - if ( ( nPara != EE_PARA_NOT_FOUND ) && ImplHasBullet( nPara ) ) + if ( ( nPara != EE_PARA_NOT_FOUND ) && ImplHasNumberFormat( nPara ) ) { Rectangle aBulArea = ImpCalcBulletArea( nPara, sal_True, sal_True ); if ( aBulArea.IsInside( rPaperPos ) ) diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 6a082ea1923f..6a824dafb188 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -370,51 +370,60 @@ void Outliner::SetParaIsNumberingRestart( sal_uInt16 nPara, sal_Bool bParaIsNumb } } -sal_Int16 Outliner::GetBulletsNumberingStatus() +sal_Int16 Outliner::GetBulletsNumberingStatus( + const sal_uInt16 nParaStart, + const sal_uInt16 nParaEnd ) const { - sal_Bool bHasBulletsNumbering = FALSE; - sal_uInt16 nParaCount = (sal_uInt16)(pParaList->GetParagraphCount()); - for (sal_uInt16 nPara = 0; nPara < nParaCount; nPara++) + if ( nParaStart > nParaEnd + || nParaEnd >= pParaList->GetParagraphCount() ) { - if ((bHasBulletsNumbering = ImplHasBullet(nPara))) - { - break; - } + DBG_ASSERT( false,"<Outliner::GetBulletsNumberingStatus> - unexpected parameter values" ); + return 2; } + sal_uInt16 nBulletsCount = 0; sal_uInt16 nNumberingCount = 0; - if (bHasBulletsNumbering) + for (sal_uInt16 nPara = nParaStart; nPara <= nParaEnd; nPara++) { - // At least have one paragraph that having bullets or numbering. - for (sal_uInt16 nPara = 0; nPara < nParaCount; nPara++) + if ( !pParaList->GetParagraph(nPara) ) { - Paragraph* pPara = pParaList->GetParagraph(nPara); - // const SfxItemSet& rAttrs = GetParaAttribs(nPara); - if (!pPara) - { - continue; - } - const SvxNumberFormat* pFmt = GetNumberFormat(nPara); - if (!pFmt) - { - // At least, exists one paragraph that has no Bullets/Numbering. - break; - } - else if ((pFmt->GetNumberingType() == SVX_NUM_BITMAP) || (pFmt->GetNumberingType() == SVX_NUM_CHAR_SPECIAL)) - { - // Having Bullets in this paragraph. - nBulletsCount++; - } - else - { - // Having Numbering in this paragraph. - nNumberingCount++; - } + break; + } + const SvxNumberFormat* pFmt = GetNumberFormat(nPara); + if (!pFmt) + { + // At least, exists one paragraph that has no Bullets/Numbering. + break; + } + else if ((pFmt->GetNumberingType() == SVX_NUM_BITMAP) || (pFmt->GetNumberingType() == SVX_NUM_CHAR_SPECIAL)) + { + // Having Bullets in this paragraph. + nBulletsCount++; + } + else + { + // Having Numbering in this paragraph. + nNumberingCount++; } } - sal_Int16 nValue = (nBulletsCount == nParaCount) ? 0 : 2; - nValue = (nNumberingCount == nParaCount) ? 1 : nValue; - return nValue; + + const sal_uInt16 nParaCount = nParaEnd - nParaStart + 1; + if ( nBulletsCount == nParaCount ) + { + return 0; + } + else if ( nNumberingCount == nParaCount ) + { + return 1; + } + return 2; +} + +sal_Int16 Outliner::GetBulletsNumberingStatus() const +{ + return pParaList->GetParagraphCount() > 0 + ? GetBulletsNumberingStatus( 0, pParaList->GetParagraphCount()-1 ) + : 2; } OutlinerParaObject* Outliner::CreateParaObject( sal_uInt16 nStartPara, sal_uInt16 nCount ) const @@ -1006,7 +1015,7 @@ void Outliner::PaintBullet( sal_uInt16 nPara, const Point& rStartPos, bDrawBullet = rBulletState.GetValue() ? true : false; } - if ( ImplHasBullet( nPara ) && bDrawBullet) + if ( ImplHasNumberFormat( nPara ) && bDrawBullet) { sal_Bool bVertical = IsVertical(); @@ -1507,7 +1516,7 @@ sal_Bool Outliner::HasChilds( Paragraph* pParagraph ) const return pParaList->HasChilds( pParagraph ); } -sal_Bool Outliner::ImplHasBullet( sal_uInt16 nPara ) const +bool Outliner::ImplHasNumberFormat( sal_uInt16 nPara ) const { return GetNumberFormat(nPara) != 0; } @@ -1756,7 +1765,7 @@ EBulletInfo Outliner::GetBulletInfo( sal_uInt16 nPara ) EBulletInfo aInfo; aInfo.nParagraph = nPara; - aInfo.bVisible = ImplHasBullet( nPara ); + aInfo.bVisible = ImplHasNumberFormat( nPara ) ? sal_True : sal_False; const SvxNumberFormat* pFmt = GetNumberFormat( nPara ); aInfo.nType = pFmt ? pFmt->GetNumberingType() : 0; diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx index 4d24d5a8688a..a64ae6f9b3f5 100644 --- a/editeng/source/outliner/outlvw.cxx +++ b/editeng/source/outliner/outlvw.cxx @@ -188,7 +188,7 @@ sal_Bool OutlinerView::PostKeyEvent( const KeyEvent& rKEvt ) bKeyProcessed = sal_True; } else if ( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) && - !bSelection && !aSel.nEndPos && pOwner->ImplHasBullet( aSel.nEndPara ) ) + !bSelection && !aSel.nEndPos && pOwner->ImplHasNumberFormat( aSel.nEndPara ) ) { Indent( aKeyCode.IsShift() ? (-1) : (+1) ); bKeyProcessed = sal_True; @@ -1193,7 +1193,8 @@ void OutlinerView::ToggleBullets() const bool bUpdate = pOwner->pEditEngine->GetUpdateMode(); pOwner->pEditEngine->SetUpdateMode( sal_False ); - sal_Int16 nDepth = -2; + sal_Int16 nNewDepth = -2; + const SvxNumRule* pDefaultBulletNumRule = 0; for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ ) { @@ -1202,29 +1203,52 @@ void OutlinerView::ToggleBullets() if( pPara ) { - if( nDepth == -2 ) - nDepth = (pOwner->GetDepth(nPara) == -1) ? 0 : -1; + if( nNewDepth == -2 ) + { + nNewDepth = (pOwner->GetDepth(nPara) == -1) ? 0 : -1; + if ( nNewDepth == 0 ) + { + // determine default numbering rule for bullets + const ESelection aSelection(nPara, 0); + 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() : 0; + } + } - pOwner->SetDepth( pPara, nDepth ); + pOwner->SetDepth( pPara, nNewDepth ); - if( nDepth == -1 ) + if( nNewDepth == -1 ) { const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara ); - if(rAttrs.GetItemState( EE_PARA_BULLETSTATE ) == SFX_ITEM_SET) + if ( rAttrs.GetItemState( EE_PARA_BULLETSTATE ) == SFX_ITEM_SET ) { SfxItemSet aAttrs(rAttrs); aAttrs.ClearItem( EE_PARA_BULLETSTATE ); pOwner->SetParaAttribs( nPara, aAttrs ); } } + else + { + if ( pDefaultBulletNumRule ) + { + const SvxNumberFormat* pFmt = pOwner ->GetNumberFormat( nPara ); + if ( !pFmt + || ( pFmt->GetNumberingType() != SVX_NUM_BITMAP + && pFmt->GetNumberingType() != SVX_NUM_CHAR_SPECIAL ) ) + { + SfxItemSet aAttrs( pOwner->GetParaAttribs( nPara ) ); + SvxNumRule aNewNumRule( *pDefaultBulletNumRule ); + aAttrs.Put( SvxNumBulletItem( aNewNumRule ), EE_PARA_NUMBULLET ); + pOwner->SetParaAttribs( nPara, aAttrs ); + } + } + } } } - // --> OD 2009-03-10 #i100014# - // It is not a good idea to substract 1 from a count and cast the result - // to sal_uInt16 without check, if the count is 0. - sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount()); - // <-- + const sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount()); pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount ); pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nParaCount, 0 ) ); @@ -1233,205 +1257,46 @@ void OutlinerView::ToggleBullets() pOwner->UndoActionEnd( OLUNDO_DEPTH ); } -sal_Bool OutlinerView::ToggleBullets(sal_Bool bBulletOnOff, sal_Bool bNormalBullet, sal_Bool bMasterView, SvxNumRule* pNumRule, sal_Bool bForceBulletOnOff) -{ - pOwner->UndoActionStart( OLUNDO_DEPTH ); +void OutlinerView::ToggleBulletsNumbering( + const bool bToggle, + const bool bHandleBullets, + const SvxNumRule* pNumRule ) +{ ESelection aSel( pEditView->GetSelection() ); aSel.Adjust(); - const bool bUpdate = pOwner->pEditEngine->GetUpdateMode(); - pOwner->pEditEngine->SetUpdateMode( sal_False ); - - sal_Int16 nDepth = -2; - sal_Bool bRet = sal_False; - - //Modified by xuezhiy for bullet enhancement - bool bBulletOn = sal_True; - - if( bBulletOnOff ) + bool bToggleOn = true; + if ( bToggle ) { - bool bHasBullet = sal_False; - for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ ) + bToggleOn = false; + const sal_Int16 nBulletNumberingStatus( pOwner->GetBulletsNumberingStatus( aSel.nStartPara, aSel.nEndPara ) ); + if ( nBulletNumberingStatus != 0 && bHandleBullets ) { - bHasBullet = pOwner->ImplHasBullet(nPara); - if(bHasBullet) - break; + // not all paragraphs have bullets and method called to toggle bullets --> bullets on + bToggleOn = true; } - - if( bHasBullet ) + else if ( nBulletNumberingStatus != 1 && !bHandleBullets ) { - bBulletOn = sal_False; - - for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ ) - { - Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara ); - DBG_ASSERT(pPara, "OutlinerView::ToggleBullets(), illegal selection?"); - - // const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara ); - if( pPara ) - { - const SvxNumberFormat* pFmt = pOwner ->GetNumberFormat(nPara); - - if( !pFmt ) - { - // Has no Bullet paragraph - bBulletOn = sal_True; - break; - } - else if( ( pFmt->GetNumberingType() == SVX_NUM_BITMAP ) || ( pFmt->GetNumberingType() == SVX_NUM_CHAR_SPECIAL ) ) - { - // Normal ==>> Numbering - if( !bNormalBullet ) - { - bBulletOn = sal_True; - break; - } - } - else - { - // Numbering ==>> Normal - if( bNormalBullet ) - { - bBulletOn = sal_True; - break; - } - } - } - } + // not all paragraphs have numbering and method called to toggle numberings --> numberings on + bToggleOn = true; } - } - if (bForceBulletOnOff) { - bBulletOn = bBulletOnOff; + if ( bToggleOn ) + { + // apply bullets/numbering for selected paragraphs + ApplyBulletsNumbering( bHandleBullets, pNumRule, bToggle, true ); } - for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ ) + else { - Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara ); - DBG_ASSERT(pPara, "OutlinerView::ToggleBullets(), illegal selection?"); - - if( pPara ) - { - bRet = sal_True; - - nDepth = pOwner->GetDepth(nPara); - - if( bBulletOn && nDepth == -1 ) - { - // Off ==>> On - nDepth = 0; - } - else if( !bBulletOn && nDepth == 0 ) - { - // On ==>> Off - nDepth = -1; - } - pOwner->SetDepth( pPara, nDepth ); - - const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara ); -// bool bBulletState = ((const SfxBoolItem&) rAttrs.Get( EE_PARA_BULLETSTATE ) ).GetValue(); - - SfxItemSet aAttrs(rAttrs); - aAttrs.Put( SfxBoolItem( EE_PARA_BULLETSTATE, bBulletOn ) ); - - // Change bullet types - if( bBulletOn && pNumRule) - { - bool bSetBulletType = false; - if( !bBulletOnOff ) - { - // Not bullet on/off button - bSetBulletType = true; - } - else - { - const SvxNumberFormat* pFmt = pOwner ->GetNumberFormat(nPara); - - if( !pFmt ) - { - // Has no bullet - bSetBulletType = true; - } - else - { - sal_Int16 nNumType = pFmt->GetNumberingType(); - if( bNormalBullet && nNumType != SVX_NUM_BITMAP && nNumType != SVX_NUM_CHAR_SPECIAL ) - { - // Set to Normal bullet, old bullet type is Numbering bullet - bSetBulletType = true; - } - else if( !bNormalBullet && (nNumType == SVX_NUM_BITMAP || nNumType == SVX_NUM_CHAR_SPECIAL) ) - { - // Set to Numbering bullet, old bullet type is Normal bullet - bSetBulletType = true; - } - } - } - - // Get old bullet space - SvxNumRule aNewRule( *pNumRule ); - - const SfxPoolItem* pPoolItem=NULL; - SfxItemState eState = rAttrs.GetItemState(EE_PARA_NUMBULLET, sal_False, &pPoolItem); - if (eState != SFX_ITEM_SET) - { - // Use default value when has not contain bullet item - ESelection aSelection(nPara, 0); - SfxItemSet aTmpSet( pOwner->pEditEngine->GetAttribs( aSelection ) ); - pPoolItem = aTmpSet.GetItem( EE_PARA_NUMBULLET ); - } - - const SvxNumBulletItem* pNumBulletItem = dynamic_cast< const SvxNumBulletItem* >( pPoolItem ); - //const SvxNumBulletItem& rNumBullet = (const SvxNumBulletItem&) rAttrs.Get( EE_PARA_NUMBULLET ); - if( pNumBulletItem ) - { - sal_uInt16 nLevelCnt = pNumBulletItem->GetNumRule()->GetLevelCount(); - nLevelCnt = Min( nLevelCnt, pNumRule->GetLevelCount() ); - - for( sal_uInt16 nLevel = 0; nLevel < nLevelCnt; ++nLevel ) - { - const SvxNumberFormat* pOldFmt = pNumBulletItem->GetNumRule()->Get( nLevel ); - const SvxNumberFormat* pNewFmt = pNumRule->Get( nLevel ); - - if( pOldFmt && pNewFmt && (pOldFmt->GetFirstLineOffset() != pNewFmt->GetFirstLineOffset() - || pOldFmt->GetAbsLSpace() != pNewFmt->GetAbsLSpace() ) ) - { - SvxNumberFormat* pNewFmtClone = new SvxNumberFormat( *pNewFmt ); - pNewFmtClone->SetFirstLineOffset( pOldFmt->GetFirstLineOffset() ); - pNewFmtClone->SetAbsLSpace( pOldFmt->GetAbsLSpace() ); - - aNewRule.SetLevel( nLevel, pNewFmtClone ); - delete pNewFmtClone; - } - } - } - - // Don't set bullet attribute to paragraph in Master view - // Because it will be set into style sheet - if( bSetBulletType && !bMasterView ) - aAttrs.Put(SvxNumBulletItem( aNewRule ), EE_PARA_NUMBULLET); - } - - pOwner->SetParaAttribs( nPara, aAttrs ); - - } + // switch off bullets/numbering for selected paragraphs + SwitchOffBulletsNumbering( true ); } - // --> OD 2009-03-10 #i100014# - // It is not a good idea to substract 1 from a count and cast the result - // to sal_uInt16 without check, if the count is 0. - sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount()); - // <-- - pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount ); - pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nParaCount, 0 ) ); - - pOwner->pEditEngine->SetUpdateMode( bUpdate ); - - pOwner->UndoActionEnd( OLUNDO_DEPTH ); - - return bRet; + return; } + void OutlinerView::EnableBullets() { pOwner->UndoActionStart( OLUNDO_DEPTH ); @@ -1445,7 +1310,7 @@ void OutlinerView::EnableBullets() for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ ) { Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara ); - DBG_ASSERT(pPara, "OutlinerView::ToggleBullets(), illegal selection?"); + DBG_ASSERT(pPara, "OutlinerView::EnableBullets(), illegal selection?"); if( pPara && (pOwner->GetDepth(nPara) == -1) ) { @@ -1453,11 +1318,7 @@ void OutlinerView::EnableBullets() } } - // --> OD 2009-03-10 #i100014# - // It is not a good idea to substract 1 from a count and cast the result - // to sal_uInt16 without check, if the count is 0. sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount()); - // <-- pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount ); pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nParaCount, 0 ) ); @@ -1466,127 +1327,192 @@ void OutlinerView::EnableBullets() pOwner->UndoActionEnd( OLUNDO_DEPTH ); } -sal_Bool OutlinerView::ToggleAllParagraphsBullets(sal_Bool bBulletOnOffMode, sal_Bool bNormalBullet, sal_Bool bToggleOn, sal_Bool bMasterView, SvxNumRule* pNumRule) + +void OutlinerView::ApplyBulletsNumbering( + const bool bHandleBullets, + const SvxNumRule* pNewNumRule, + const bool bCheckCurrentNumRuleBeforeApplyingNewNumRule, + const bool bAtSelection ) { if (!pOwner || !pOwner->pEditEngine || !pOwner->pParaList) { - return sal_False; + return; } - sal_Bool bReturn = sal_False; pOwner->UndoActionStart(OLUNDO_DEPTH); const sal_Bool bUpdate = pOwner->pEditEngine->GetUpdateMode(); pOwner->pEditEngine->SetUpdateMode(sal_False); - sal_Int16 nDepth = -2; - sal_uInt16 nParaCount = (sal_uInt16)(pOwner->pParaList->GetParagraphCount()); - for (sal_uInt16 nPara = 0; nPara < nParaCount; nPara++) + sal_uInt16 nStartPara = 0; + sal_uInt16 nEndPara = 0; + if ( bAtSelection ) + { + ESelection aSel( pEditView->GetSelection() ); + aSel.Adjust(); + nStartPara = aSel.nStartPara; + nEndPara = aSel.nEndPara; + } + else + { + nStartPara = 0; + nEndPara = pOwner->pParaList->GetParagraphCount() - 1; + } + + for (sal_uInt16 nPara = nStartPara; nPara <= nEndPara; nPara++) { Paragraph* pPara = pOwner->pParaList->GetParagraph(nPara); - DBG_ASSERT(pPara, "OutlinerView::ToggleAllParagraphsBullets(), illegal selection?"); + DBG_ASSERT(pPara, "OutlinerView::ApplyBulletsNumbering(..), illegal selection?"); if (pPara) { - bReturn = sal_True; - nDepth = pOwner->GetDepth(nPara); - if (bToggleOn && nDepth == -1) - { - // Off ==>> On - nDepth = 0; - } - else if (!bToggleOn && nDepth == 0) + const sal_Int16 nDepth = pOwner->GetDepth(nPara); + if ( nDepth == -1 ) { - // On ==>> Off - nDepth = -1; + pOwner->SetDepth( pPara, 0 ); } - pOwner->SetDepth(pPara, nDepth); const SfxItemSet& rAttrs = pOwner->GetParaAttribs(nPara); SfxItemSet aAttrs(rAttrs); - aAttrs.Put(SfxBoolItem(EE_PARA_BULLETSTATE, bToggleOn)); + aAttrs.Put(SfxBoolItem(EE_PARA_BULLETSTATE, true)); - // Change bullet types. - if (bToggleOn && pNumRule) + // apply new numbering rule + if ( pNewNumRule ) { - sal_Bool bSetBulletType = sal_False; - if (!bBulletOnOffMode) + bool bApplyNumRule = false; + if ( !bCheckCurrentNumRuleBeforeApplyingNewNumRule ) { - // Not bullet on/off button. - bSetBulletType = sal_True; + bApplyNumRule = true; } else { const SvxNumberFormat* pFmt = pOwner ->GetNumberFormat(nPara); if (!pFmt) { - // Has no bullet. - bSetBulletType = sal_True; + bApplyNumRule = true; } else { sal_Int16 nNumType = pFmt->GetNumberingType(); - if (bNormalBullet && nNumType != SVX_NUM_BITMAP && nNumType != SVX_NUM_CHAR_SPECIAL) + if ( bHandleBullets + && nNumType != SVX_NUM_BITMAP && nNumType != SVX_NUM_CHAR_SPECIAL) { // Set to Normal bullet, old bullet type is Numbering bullet. - bSetBulletType = sal_True; + bApplyNumRule = true; } - else if (!bNormalBullet && (nNumType == SVX_NUM_BITMAP || nNumType == SVX_NUM_CHAR_SPECIAL)) + else if ( !bHandleBullets + && (nNumType == SVX_NUM_BITMAP || nNumType == SVX_NUM_CHAR_SPECIAL)) { // Set to Numbering bullet, old bullet type is Normal bullet. - bSetBulletType = sal_True; + bApplyNumRule = true; } } } - // Get old bullet space. - SvxNumRule aNewRule(*pNumRule); - const SfxPoolItem* pPoolItem=NULL; - SfxItemState eState = rAttrs.GetItemState(EE_PARA_NUMBULLET, sal_False, &pPoolItem); - ESelection aSelection(nPara, 0); - SfxItemSet aTmpSet(pOwner->pEditEngine->GetAttribs(aSelection)); - if (eState != SFX_ITEM_SET) + if ( bApplyNumRule ) { - // Use default value when has not contain bullet item. - pPoolItem = aTmpSet.GetItem(EE_PARA_NUMBULLET); - } - - const SvxNumBulletItem* pNumBulletItem = dynamic_cast< const SvxNumBulletItem* >(pPoolItem); - if (pNumBulletItem) - { - sal_uInt16 nLevelCnt = pNumBulletItem->GetNumRule()->GetLevelCount(); - nLevelCnt = Min(nLevelCnt, pNumRule->GetLevelCount()); + SvxNumRule aNewRule(*pNewNumRule); - for (sal_uInt16 nLevel = 0; nLevel < nLevelCnt; nLevel++) + // Get old bullet space. { - const SvxNumberFormat* pOldFmt = pNumBulletItem->GetNumRule()->Get(nLevel); - const SvxNumberFormat* pNewFmt = pNumRule->Get(nLevel); - if (pOldFmt && pNewFmt && (pOldFmt->GetFirstLineOffset() != pNewFmt->GetFirstLineOffset() || pOldFmt->GetAbsLSpace() != pNewFmt->GetAbsLSpace())) + const SfxPoolItem* pPoolItem=NULL; + SfxItemState eState = rAttrs.GetItemState(EE_PARA_NUMBULLET, sal_False, &pPoolItem); + if (eState != SFX_ITEM_SET) { - SvxNumberFormat* pNewFmtClone = new SvxNumberFormat(*pNewFmt); - pNewFmtClone->SetFirstLineOffset(pOldFmt->GetFirstLineOffset()); - pNewFmtClone->SetAbsLSpace(pOldFmt->GetAbsLSpace()); - aNewRule.SetLevel(nLevel, pNewFmtClone); - delete pNewFmtClone; + // Use default value when has not contain bullet item. + ESelection aSelection(nPara, 0); + SfxItemSet aTmpSet(pOwner->pEditEngine->GetAttribs(aSelection)); + pPoolItem = aTmpSet.GetItem(EE_PARA_NUMBULLET); + } + + const SvxNumBulletItem* pNumBulletItem = dynamic_cast< const SvxNumBulletItem* >(pPoolItem); + if (pNumBulletItem) + { + const sal_uInt16 nLevelCnt = Min(pNumBulletItem->GetNumRule()->GetLevelCount(), aNewRule.GetLevelCount()); + for ( sal_uInt16 nLevel = 0; nLevel < nLevelCnt; ++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())) + { + SvxNumberFormat* pNewFmtClone = new SvxNumberFormat(*pNewFmt); + pNewFmtClone->SetFirstLineOffset(pOldFmt->GetFirstLineOffset()); + pNewFmtClone->SetAbsLSpace(pOldFmt->GetAbsLSpace()); + aNewRule.SetLevel(nLevel, pNewFmtClone); + delete pNewFmtClone; + } + } } } - } - // Don't set bullet attribute to paragraph in Master view, because it will be set into style sheet. - if (bSetBulletType && !bMasterView) aAttrs.Put(SvxNumBulletItem(aNewRule), EE_PARA_NUMBULLET); + } } pOwner->SetParaAttribs(nPara, aAttrs); } } - pOwner->ImplCheckParagraphs(0, nParaCount); - pOwner->pEditEngine->QuickMarkInvalid(ESelection(0, 0, nParaCount, 0)); - pOwner->pEditEngine->SetUpdateMode(bUpdate); - pOwner->UndoActionEnd(OLUNDO_DEPTH); + const sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount()); + pOwner->ImplCheckParagraphs( nStartPara, nParaCount ); + pOwner->pEditEngine->QuickMarkInvalid( ESelection( nStartPara, 0, nParaCount, 0 ) ); - return bReturn; + pOwner->pEditEngine->SetUpdateMode( bUpdate ); + + pOwner->UndoActionEnd( OLUNDO_DEPTH ); + + return; } + +void OutlinerView::SwitchOffBulletsNumbering( + const bool bAtSelection ) +{ + sal_uInt16 nStartPara = 0; + sal_uInt16 nEndPara = 0; + if ( bAtSelection ) + { + ESelection aSel( pEditView->GetSelection() ); + aSel.Adjust(); + nStartPara = aSel.nStartPara; + nEndPara = aSel.nEndPara; + } + else + { + nStartPara = 0; + nEndPara = pOwner->pParaList->GetParagraphCount() - 1; + } + + pOwner->UndoActionStart( OLUNDO_DEPTH ); + const bool bUpdate = pOwner->pEditEngine->GetUpdateMode(); + pOwner->pEditEngine->SetUpdateMode( sal_False ); + + for ( sal_uInt16 nPara = nStartPara; nPara <= nEndPara; ++nPara ) + { + Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara ); + DBG_ASSERT(pPara, "OutlinerView::SwitchOffBulletsNumbering(...), illegal paragraph index?"); + + if( pPara ) + { + pOwner->SetDepth( pPara, -1 ); + + const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara ); + if (rAttrs.GetItemState( EE_PARA_BULLETSTATE ) == SFX_ITEM_SET) + { + SfxItemSet aAttrs(rAttrs); + aAttrs.ClearItem( EE_PARA_BULLETSTATE ); + pOwner->SetParaAttribs( nPara, aAttrs ); + } + } + } + + const sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount()); + pOwner->ImplCheckParagraphs( nStartPara, nParaCount ); + pOwner->pEditEngine->QuickMarkInvalid( ESelection( nStartPara, 0, nParaCount, 0 ) ); + + pOwner->pEditEngine->SetUpdateMode( bUpdate ); + pOwner->UndoActionEnd( OLUNDO_DEPTH ); +} + + void OutlinerView::RemoveAttribsKeepLanguages( sal_Bool bRemoveParaAttribs ) { RemoveAttribs( bRemoveParaAttribs, 0, sal_True /*keep language attribs*/ ); diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx index 7fa94b40d142..d9cafeb2f7a4 100644 --- a/sd/source/core/drawdoc4.cxx +++ b/sd/source/core/drawdoc4.cxx @@ -1370,12 +1370,12 @@ void SdDrawDocument::SetTextDefaults() const SvxNumRule aNumRule( NUM_BULLET_REL_SIZE|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE, 10, 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 e8b31a725382..ccecfbe581cc 100644 --- a/sd/source/ui/func/fuolbull.cxx +++ b/sd/source/ui/func/fuolbull.cxx @@ -76,13 +76,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; } @@ -153,32 +150,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 @@ -189,204 +198,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(); - - std::auto_ptr< OutlineViewModelChangeGuard > aGuard; - - if (mpView->ISA(OutlineView)) - { - pOLV = static_cast<OutlineView*>(mpView) - ->GetViewByWindow(mpViewShell->GetActiveWindow()); - - aGuard.reset( new OutlineViewModelChangeGuard( static_cast<OutlineView&>(*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 ) - { - nIdx = 1; - bBulletSwitch = true; - } - if (nIdx == DEFAULT_NONE) + // get numbering rule corresponding to <nIdx> and apply the needed number formats to <pNumRule> + NBOTypeMgrBase* pNumRuleMgr = + NBOutlineTypeMgrFact::CreateInstance( + nSId == FN_SVX_SET_BULLET ? eNBOType::MIXBULLETS : eNBOType::NUMBERING ); + if ( pNumRuleMgr ) { - bBulletSwitch = false; - isRemoveNum = true; - } + 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(); - nIdx--; - //Modified for Numbering&Bullets Dialog UX Enh(Story 992) by chengjh,2011.8.7 - - 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++) { @@ -397,59 +254,66 @@ void FuOutlineBullet::SetCurrentBullet(SfxRequest& rReq) } nMask <<= 1; } - aSetAttr.Put(SvxNumBulletItem( *pNumRule ), nNumItemId); - - OutlinerView* pOLV = mpView->GetTextEditOutlinerView(); - - std::auto_ptr< OutlineViewModelChangeGuard > aGuard; - - if (mpView->ISA(OutlineView)) - { - pOLV = static_cast<OutlineView*>(mpView) - ->GetViewByWindow(mpViewShell->GetActiveWindow()); + } + } - aGuard.reset( new OutlineViewModelChangeGuard( static_cast<OutlineView&>(*mpView) ) ); - } + OutlinerView* pOLV = mpView->GetTextEditOutlinerView(); + std::auto_ptr< OutlineViewModelChangeGuard > aGuard; + { + if (mpView->ISA(OutlineView)) + { + pOLV = static_cast<OutlineView*>(mpView) + ->GetViewByWindow(mpViewShell->GetActiveWindow()); - SdrOutliner* pOwner = mpView->GetTextEditOutliner(); - bool bMasterView = false; + aGuard.reset( new OutlineViewModelChangeGuard( static_cast<OutlineView&>(*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 c541fbbadd05..02886e5a96d7 100644 --- a/sd/source/ui/inc/View.hxx +++ b/sd/source/ui/inc/View.hxx @@ -191,8 +191,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 9b7deb15dcd6..58cbabc06dba 100644 --- a/sd/source/ui/inc/fuolbull.hxx +++ b/sd/source/ui/inc/fuolbull.hxx @@ -51,8 +51,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 ( @@ -62,6 +60,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 8366b5edbd29..e39f6e48e287 100644 --- a/sd/source/ui/view/drtxtob1.cxx +++ b/sd/source/ui/view/drtxtob1.cxx @@ -331,7 +331,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 269f5286d949..c515f51bfd4a 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -1336,7 +1336,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) @@ -1400,23 +1402,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)); @@ -1454,7 +1462,14 @@ void View::ToggleMarkedObjectsBullets(sal_Bool bBulletOnOffMode, sal_Bool bNorma SdrUndoObjSetText* pTxtUndo = dynamic_cast< SdrUndoObjSetText* >(pSdrModel->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, nIndex)); 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(); @@ -1478,23 +1493,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; } diff --git a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx index 6c0dfc5452e0..5dc14b0dde4c 100755 --- a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx +++ b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx @@ -1035,52 +1035,71 @@ void ParaPropertyPanel::NotifyItemUpdate( { (void)bIsEnabled; - if( nSID == SID_ATTR_METRIC ) + switch (nSID) { - m_eMetricUnit = GetCurrentUnit(eState,pState); - if( m_eMetricUnit!=m_last_eMetricUnit ) + case SID_ATTR_METRIC: { - SetFieldUnit( *maLeftIndent.get(), m_eMetricUnit ); - SetFieldUnit( *maRightIndent.get(), m_eMetricUnit ); - SetFieldUnit( *maFLineIndent.get(), m_eMetricUnit ); - SetFieldUnit( *maTopDist.get(), m_eMetricUnit ); - SetFieldUnit( *maBottomDist.get(), m_eMetricUnit ); + m_eMetricUnit = GetCurrentUnit(eState,pState); + if( m_eMetricUnit!=m_last_eMetricUnit ) + { + SetFieldUnit( *maLeftIndent.get(), m_eMetricUnit ); + SetFieldUnit( *maRightIndent.get(), m_eMetricUnit ); + SetFieldUnit( *maFLineIndent.get(), m_eMetricUnit ); + SetFieldUnit( *maTopDist.get(), m_eMetricUnit ); + SetFieldUnit( *maBottomDist.get(), m_eMetricUnit ); + } + m_last_eMetricUnit = m_eMetricUnit; } - m_last_eMetricUnit = m_eMetricUnit; - } + break; - if( nSID == SID_ATTR_PARA_LRSPACE ) + case SID_ATTR_PARA_LRSPACE: StateChangedIndentImpl( nSID, eState, pState ); + break; - if( nSID == SID_ATTR_PARA_LINESPACE ) + case SID_ATTR_PARA_LINESPACE: StateChangedLnSPImpl( nSID, eState, pState ); + break; - if( nSID == SID_ATTR_PARA_ULSPACE) + case SID_ATTR_PARA_ULSPACE: StateChangedULImpl( nSID, eState, pState ); + break; - if (nSID==SID_ATTR_PARA_ADJUST_LEFT || nSID==SID_ATTR_PARA_ADJUST_CENTER || nSID==SID_ATTR_PARA_ADJUST_RIGHT || nSID==SID_ATTR_PARA_ADJUST_BLOCK) + case SID_ATTR_PARA_ADJUST_LEFT: + case SID_ATTR_PARA_ADJUST_CENTER: + case SID_ATTR_PARA_ADJUST_RIGHT: + case SID_ATTR_PARA_ADJUST_BLOCK: StateChangedAlignmentImpl( nSID, eState, pState ); + break; - if (nSID==SID_OUTLINE_LEFT || nSID==SID_OUTLINE_RIGHT) + case SID_OUTLINE_LEFT: + case SID_OUTLINE_RIGHT: StateChangeOutLineImpl( nSID, eState, pState ); + break; - if (nSID==SID_INC_INDENT || nSID==SID_DEC_INDENT) + case SID_INC_INDENT: + case SID_DEC_INDENT: StateChangeIncDecImpl( nSID, eState, pState ); - // Add toggle state for numbering and bullet icons - if (nSID==FN_NUM_NUMBERING_ON || nSID==FN_NUM_BULLET_ON) + break; + + case FN_NUM_NUMBERING_ON: + case FN_NUM_BULLET_ON: StateChangeBulletNumImpl( nSID, eState, pState ); + break; - //Get the num rule index data of the current selection - if ( nSID == FN_BUL_NUM_RULE_INDEX ||nSID == FN_NUM_NUM_RULE_INDEX) + case FN_BUL_NUM_RULE_INDEX: + case FN_NUM_NUM_RULE_INDEX: StateChangeBulletNumRuleImpl( nSID, eState, pState ); + break; - if ((nSID == SID_TABLE_VERT_NONE)||(nSID == SID_TABLE_VERT_CENTER)||(nSID == SID_TABLE_VERT_BOTTOM)) - { + case SID_TABLE_VERT_NONE: + case SID_TABLE_VERT_CENTER: + case SID_TABLE_VERT_BOTTOM: VertStateChanged( nSID, eState, pState); - } - else if (nSID == SID_BACKGROUND_COLOR) - { + break; + + case SID_BACKGROUND_COLOR: ParaBKGStateChanged(nSID, eState, pState); + break; } } @@ -1417,25 +1436,19 @@ void ParaPropertyPanel::StateChangeBulletNumImpl( sal_uInt16 nSID, SfxItemState { if ( (eState >= SFX_ITEM_DEFAULT) && (pState->ISA(SfxBoolItem)) ) { + const SfxBoolItem* pItem= (const SfxBoolItem*)pState; + const sal_Bool aBool = (sal_Bool)pItem->GetValue(); if (nSID==FN_NUM_NUMBERING_ON) { - const SfxBoolItem* pItem= (const SfxBoolItem*)pState; - sal_Bool aBool = (sal_Bool)pItem->GetValue(); - if (aBool) { - maTBxNumBullet->SetItemState(IID_NUMBER, STATE_CHECK); - } else { - maTBxNumBullet->SetItemState(IID_NUMBER, STATE_NOCHECK); - } + maTBxNumBullet->SetItemState( + IID_NUMBER, + aBool ? STATE_CHECK : STATE_NOCHECK ); } else if (nSID==FN_NUM_BULLET_ON) { - const SfxBoolItem* pItem= (const SfxBoolItem*)pState; - sal_Bool aBool = (sal_Bool)pItem->GetValue(); - if (aBool) { - maTBxNumBullet->SetItemState(IID_BULLET, STATE_CHECK); - } else { - maTBxNumBullet->SetItemState(IID_BULLET, STATE_NOCHECK); - } + maTBxNumBullet->SetItemState( + IID_BULLET, + aBool ? STATE_CHECK : STATE_NOCHECK ); } } } |